This function calculates the Feed Conversion Ratio (FCR) based on average daily gain (ADG) and average daily feed intake (ADFI) results. It also calculates a corrected FCR if stage information is available.

fcr_get(adg_res, adfi_res)

Arguments

adg_res

A list containing ADG results, including 'adg_info' and 'adg_data' from adg_get().

adfi_res

A list containing ADFI results, including 'adfi_info' and 'adfi_data' from adfi_get().

Value

A list containing:

fcr_res

A data.table with FCR results, including 'fcr' and 'cor_fcr' (if applicable)

adg_info

The original ADG info data.table

adg_data

The original ADG data

adfi_info

The original ADFI info data.table

adfi_data

The original ADFI data

Note

  • This function assumes that 'adg_info' and 'adfi_info' are data.tables with columns 'responder' and 'location'.

  • The function expects 'corrected_dfi' and 'lm_slope' columns in the joined data for FCR calculation.

  • The corrected FCR calculation is only performed if a 'stage' column is present in the joined data.

  • The variables 'min_weight_cut' and 'max_weight_cut' should be defined in the global environment or passed as parameters for the corrected FCR calculation.

Examples

nedap_csv_data <- mintyr::nedap
adg_results <- adg_get(data = nedap_csv_data)
#> • There are no duplicate responders in different locations.
#> • The removing of weight < 15kg will not delete responder.
#> • Removing records of missing will delete responders: 1
#> • Deleted responders: 
#>  c("15964")
#> • Running RANSAC Robust Regression:
#> • RANSAC Robust Regression succeeded!
#> • The outliers detected by Robust model will not delete responder.
#> • All responders' begin_test_weight are less than or equal to 60kg.
#> • Removing end_test_weight <85kg records will delete responders: 1
#> • Deleted responders: 
#>  c("15967")
#> • Running Simple Linear Regression
#> • Calculate ADG using Simple Linear Regression succeeded!
adfi_results <- adfi_get(data = nedap_csv_data, adg_res = adg_results)
#> • There are no duplicate responders in different locations.
#> • Successfully generated the following 3 variables:
#>  - FIV:feed intake per visit;
#>  - OTV:occupation time per visit;
#>  - FRV:feeding rate per visit;
#> • Successfully generated 10 error types from 3 variables:
#>  - FIV-lo; FIV-hi; FIV-0; OTV-lo; OTV-hi; FRV-hi-FIV-lo; FRV-hi-strict; FRV-hi; FRV-0; FRV-lo;
#> • Running linear mixed model with equation: 
#>  dfi_right_part ~ otd_2 + otd_6 + otd_9 + otd_10 + otv_hi_p + frv_hi_fiv_lo_p + frv_lo_p + location + lm_slope + weight + (1 | responder)
fcr_results <- fcr_get(adg_res = adg_results, adfi_res = adfi_results)
head(fcr_results$fcr_res)
#> Key: <responder, location>
#>    responder location start_date_origin min_weight_origin end_date_origin
#>       <char>   <char>            <Date>             <num>          <Date>
#> 1:     13913      101        2024-02-19          21866.22      2024-05-25
#> 2:     13918      101        2024-02-19          16529.06      2024-05-25
#> 3:     13935      102        2024-02-19          21414.80      2024-05-25
#> 4:     13954      101        2024-02-20          30876.24      2024-05-25
#> 5:     13996      101        2024-02-19          22753.31      2024-05-25
#> 6:     14260      102        2024-02-19          27757.93      2024-05-25
#>    max_weight_origin r_squared  lm_slope test_days origin_dfi corrected_dfi
#>                <num>     <num>     <num>     <int>      <num>         <num>
#> 1:          132895.4 0.9914949 1180.5834        95   2562.365      2577.739
#> 2:          121102.8 0.9917870 1089.6744        96   2319.814      2305.710
#> 3:          138871.4 0.9976035 1233.5471        96   2703.371      2706.317
#> 4:          118602.7 0.9781564  941.2985        95   2317.260      2308.288
#> 5:          142956.6 0.9957625 1281.2277        96   2909.309      2921.329
#> 6:          142547.7 0.9962627 1221.0429        96   2846.546      2819.889
#>         fcr
#>       <num>
#> 1: 2.183445
#> 2: 2.115962
#> 3: 2.193931
#> 4: 2.452238
#> 5: 2.280101
#> 6: 2.309410
head(fcr_results$fcr_summary)
#>               traits      N     min     max  median    mean     sd     cv
#>               <char> <char>  <char>  <char>  <char>  <char> <char> <char>
#> 1: min_weight_origin     28    7.09   30.88   22.22   21.52   4.87 22.64%
#> 2: max_weight_origin     28  105.51  146.80  135.95  132.66  10.57  7.97%
#> 3:          lm_slope     28  907.51 1321.20 1203.42 1173.66 109.56  9.33%
#> 4:         test_days     28   95.00   96.00   96.00   95.68   0.48  0.50%
#> 5:        origin_dfi     28 1867.24 3361.74 2823.68 2739.91 357.71 13.06%
#> 6:     corrected_dfi     28 1878.89 3336.57 2817.39 2737.01 353.74 12.92%