knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This document describes the background, the introduction and the construction of a carcass value index.

Definition

A carcass value index is the part of the aggregate genotype that combines all traits related to the carcass. At present, these traits consist of

The index is computed as weighted mean from the estimated breeding values and the economic values.

Economic Values

An economic value of a given trait is defined as the change in profit when the population mean changes a small amount. In general profit $P$ is defined as

$$P = R - C$$ where $R$ is the revenue and $C$ stands for costs. From the above equation, profit changes when revenue and or costs change.

Carcass Traits

For the above listed carcass traits, we assume that costs can be kept constant for small changes of the population mean. Hence all changes of profit which account for an economic value would be due to changes in the expected average price accross the whole population. This simplification is used in the design of a function to compute economic values for carcass traits.

When computing the expected average price over a complete population, we need as input a certain empirical distribution and the prices given by the payment system. The payment system is typically represented by a vector of prices. The empirical distribution can either be discrete or continuous. Continuous distributions are specified by mean and standard deviation and discrete distributions are given by a vector of empirical frequencies.

Function To Compute Economic Values

Based on the previous section the input parameters are

tbl_param <- tibble::data_frame(`Input Parameter` = c("pn_mean",
                                                      "pn_sd",
                                                      "pvec_class_freq",
                                                      "pvec_threshold",
                                                      "pvec_price",
                                                      "pn_delta_mean"),
                                Meaning = c("empirical population mean",
                                            "empirical population standard deviation",
                                            "vector of empirical trait frequencies",
                                            "vector of thresholds given by payment system",
                                            "vector of prices given by payment system",
                                            "small change of population mean"))
knitr::kable(tbl_param,
             booktabs = TRUE)

Numerical Example

The computations that lead to the economic value are easiest shown with an example. We start with the trait carcass conformation and we restrict ourselves to look only at adult animals. Hence the trait is called cca. The first computation is done for the LM breed. The following input pararameters are explicitly set.

### # distributional characteristics
n_mean_cca_lm <- 6.56
n_sd_cca_lm <- 0.7
### # copied from Sophie's slack message
vec_count_cca_lm <- c(2,11,57,1041,6652,21092,56227)
vec_freq_cca_lm <- vec_count_cca_lm / sum(vec_count_cca_lm)
vec_freq_cca_lm
### # prices
vec_price_cca <- c(7.526960,7.938872,8.450784,8.800000,9.137304,9.392693,9.642693)

Step 1

Given the prices and the empirical frequencies of the population distribution, we can compute the expected price of a random carcass in the population as

n_exp_av_price <- crossprod(vec_freq_cca_lm, vec_price_cca)
n_exp_av_price

Step 2

The second step is to approximate the population distribution with a normal distribution and to determine the borders of the single price classes.

The class borders can be found with the function qnorm(). To determine the class borders with the function qnorm(), we need the cumulative frequencies which are computed by cumsum().

vec_csum_cca_lm <- cumsum(vec_freq_cca_lm)
vec_csum_cca_lm

The boundaries are defined by the result of qnorm() and noting the fact that the last value in the cumulative frequency vector is $1$ and for this last value the border would be Inf. Hence, we can leave out the last element of the vector of cumulative sums.

vec_bound_cca_lm <- qnorm(vec_csum_cca_lm[1:(length(vec_csum_cca_lm)-1)], mean = n_mean_cca_lm, sd = n_sd_cca_lm, lower.tail = TRUE)
vec_bound_cca_lm

Step 3

Shifting the mean by a small quantity $\delta$ leads to

n_delta_cca_lm <- 0.1
(n_mean_cca_lm_shifted <- n_mean_cca_lm + n_delta_cca_lm)

Compute the frequencies under the shifted distribution leaving the boundaries as they were in step 2. Because the result coming out of pnorm() are also cumulative, we have to split them into individual frequencies using diff(). The last entry of the frequencies usually has to be added to the vector of frequencies.

vec_freq_cca_lm_shifted_cum <- pnorm( vec_bound_cca_lm, mean = n_mean_cca_lm_shifted, sd = n_sd_cca_lm )
vec_freq_cca_lm_shifted <- diff(c(0, vec_freq_cca_lm_shifted_cum))
n_sum_frea_cca_lm_shifted <- vec_freq_cca_lm_shifted_cum[length(vec_freq_cca_lm_shifted_cum)]
if (n_sum_frea_cca_lm_shifted < 1)
(vec_freq_cca_lm_shifted <- c(vec_freq_cca_lm_shifted, 1-n_sum_frea_cca_lm_shifted))
sum(vec_freq_cca_lm_shifted)

The price under the shifted distribution is

(n_exp_price_cca_lm_shifted <- crossprod(vec_freq_cca_lm_shifted, vec_price_cca))

The difference per unit of the trait corresponds to the economic value

(ev_cca_lm <- (n_exp_price_cca_lm_shifted - n_exp_av_price)/n_delta_cca_lm)

Organising Input in a Systematic Way

Input parameters either depend on the trait alone such as the vector of prices of a given pricing system or they depend on both the trait and the breed. This suggests a certain hierarchical data structure as input. The top hierarchy level corresponds to the trait and within each trait, we add a set of lower level fields to specify the breed-specific input parameters.

An Example

The easiest format to specify hierarchical datastructure is JSON. JSON is a data-structure consisting of key-value pairs which allows for recursive and thereby hierarchical structures. One example for a JSON-formatted data structure is

s_cca_input <- '{
"trait":"cca",
"price":[7.526960, 7.938872, 8.450784, 8.800000, 9.137304, 9.392693, 9.642693],
"breeds": [
  {"name":"LM",
   "mean":6.56,
   "sd":0.7,
   "freq":[2.350673e-05, 1.292870e-04, 6.699419e-04, 1.223526e-02, 7.818340e-02, 2.479020e-01, 6.608566e-01]}
  ]
}'
json_input <- jsonlite::fromJSON(s_cca_input)
json_input$trait
json_input$breeds


pvrqualitasag/MeatValueIndex documentation built on May 13, 2019, 4:44 p.m.