Correct daily feed intake for feeder errors with a linear mixed model, impute missing days and compute average daily feed intake (ADFI) over the ADG stage.

calc_adfi(visits, adg, qc = adg$settings, verbose = 1, cores = 1)

Arguments

visits

Visit table from prep_visits(), or already flagged by flag_feed_errors().

adg

Result of calc_adg().

qc

QC settings; by default the ones used for adg. Used here: the feeder error thresholds, dfi_correct, dfi_range, dfi_quantile, impute_method, long_gap_days, loess_span.

verbose

0 (silent), 1 (summary, default) or 2 (details).

cores

Number of CPU cores for the per-pig computations. Default 1.

Value

An object of class ppt_adfi (a list):

  • per_pig: adfi (g/d over the stage), adfi_raw (mean recorded intake of the recorded stage days), adfi_error_free, n_stage_days, n_observed, n_corrected, n_interpolated, n_extrapolated, n_missing, n_extrap_start / n_extrap_end (consecutive extrapolated days at the start / end of the stage), coverage (share of stage days with a recorded or corrected value), adg_type;

  • daily: one row per pig and day: bw (kg), in_stage, n_visits, n_error_visits, dfi_raw, dfi_error_free, dfi_corrected, dfi (final value, g) and state;

  • model: fixed-effect estimates of the correction model;

  • pop_curve: the population curves of impute_method = "loess_pop", one row per group ("all" or a breed): n_pigs, n_days, coefficients b0, b1, b2 of dfi = b0 + b1 bw + b2 bw^2 (g, kg) and the weight range bw_min, bw_max; no rows for other methods;

  • removed, settings.

References

Jiao, S., Maltecca, C., Gray, K. A., & Cassady, J. P. (2014). Feed intake, average daily gain, feed efficiency, and real-time ultrasound traits in Duroc pigs: I. Journal of Animal Science, 92, 2377-2386.

Examples

visits <- prep_visits(nedap, verbose = 0)
w <- clean_weight(visits, verbose = 0)
adg <- calc_adg(w, verbose = 0)
adfi <- calc_adfi(visits, adg)
#> 
#> ── Flagging feeder errors (Casey et al. 2005) ──────────────────────────────────
#> ✔ 1.58% of 31,652 identified visits with at least one error 0.1s
#> 
#> ── ADFI over 30-120 kg ─────────────────────────────────────────────────────────
#> ℹ Correction model: 2575 pig-days, 10 error covariates
#> ℹ Population curve of intake on body weight: all (29 pigs)
#>   Stage pig-days                     2,207
#>   └ recorded without error (org)     1,905   86.3%
#>   └ corrected (corr)                   270   12.2%
#>   └ filled between records (iii)         1   <0.1%
#>   └ filled at the stage ends (elrp)     31    1.4%
#>   └ outside dfi_range                    1   <0.1%
#> ✔ ADFI 2845 ± 360 g/d (mean ± SD) 0.2s
head(adfi$per_pig)
#>    responder location  stage     adfi     adg_type adfi_raw adfi_error_free
#>       <char>   <char> <char>    <num>       <char>    <num>           <num>
#> 1:     13913      101 30-120 2642.654     observed 2624.829        2623.974
#> 2:     13918      101 30-120 2566.372     observed 2540.500        2539.662
#> 3:     13954      101 30-120 2681.418 extrapolated 2622.948        2622.221
#> 4:     13996      101 30-120 2860.245     observed 2839.957        2836.714
#> 5:     14962      101 30-120 2830.550     observed 2816.375        2816.083
#> 6:     15006      101 30-120 3121.544     observed 3107.429        3107.229
#>    n_stage_days n_observed n_corrected n_interpolated n_extrapolated n_missing
#>           <int>      <int>       <int>          <int>          <int>     <int>
#> 1:           76         76          12              0              0         0
#> 2:           80         80          15              0              0         0
#> 3:           80         77          11              0              3         0
#> 4:           70         70           7              0              0         0
#> 5:           72         72           8              0              0         0
#> 6:           70         70           7              0              0         0
#>    n_extrap_start n_extrap_end coverage
#>             <int>        <int>    <num>
#> 1:              0            0   1.0000
#> 2:              0            0   1.0000
#> 3:              0            3   0.9625
#> 4:              0            0   1.0000
#> 5:              0            0   1.0000
#> 6:              0            0   1.0000
table(adfi$daily[in_stage == TRUE, state])
#> 
#> corr elrp  iii  org 
#>  270   31    1 1905 
head(adfi$model)
#>           term      estimate    std_error      p_value
#>         <char>         <num>        <num>        <num>
#> 1: (Intercept)  -1034.723262  306.8930401 7.585135e-04
#> 2: location102     -2.797787   63.2856637 9.650757e-01
#> 3:          bw     23.338374    0.3577956 0.000000e+00
#> 4:         adg      1.725667    0.2444888 1.703038e-07
#> 5:  pte_fiv_hi -11834.326758 5882.7526284 4.435732e-02
#> 6:  pte_otv_hi  -1931.619656 3368.2285196 5.663690e-01