Compute standardised contribution per unit based on coefficients
Source:R/step2_constraints.R
compute_std_unit_contrib.Rd
Compute standardised contribution per unit for each tag_outcome
, based on standardise coefficients.
Arguments
- uc_raw
A dataframe where contribution per unit for each
tag_outcome
is stored.- std_coef
Standardise coefficients for each
tag_outcome
, stored as a dataframe.
Value
A list of outputs:
uc_raw
stores the original values of contribution per unit for each food and tag_outcomestd_coef
standardise coefficients used to compute the standardized contribution per unituc_std
stores the standardised values of contribution per unit
Examples
cpu_selected <- select_perunit(data_perunit_contrib = contrib_per_unit,
tag_food = c('Bread', 'Vegetables', 'Red meat'),
tag_outcome = c('energy', 'protein', 'ghge'))
coefs <- compute_stdcoef(data_perunit_contrib = cpu_selected)
compute_std_unit_contrib(uc_raw = cpu_selected, std_coef = coefs$std_coef)
#> $uc_raw
#> # A tibble: 3 × 4
#> food_name energy protein ghge
#> <chr> <dbl> <dbl> <dbl>
#> 1 Bread 10.7 0.0912 0.00107
#> 2 Vegetables 1.57 0.0149 0.00103
#> 3 Red meat 8.34 0.173 0.0129
#>
#> $std_coef
#> tag_outcome std_coef
#> 1 energy 0.2109576
#> 2 protein 12.6767653
#> 3 ghge 145.6722840
#>
#> $uc_std
#> food_name energy protein ghge
#> 1 Bread 2.2563085 1.1563754 0.1558693
#> 2 Vegetables 0.3302183 0.1885935 0.1500425
#> 3 Red meat 1.7597741 2.1882512 1.8849994
#>