\[y=X\beta + Zu + e\] Where, \(y\) is a \(n x 1\) vector of visit length at the feeder (minutes), \(X\beta\) are the fixed effects, \(location-trial \ (14)\), \(hour \ entry \ at \ the \ feeder \ (23)\) and \(animal \ median \ weigth\) as covariate; \(Z\) is a \(n\) x \(q\) desing matrix (\(q\) is the number of pigs) relates records in \(y\) to the random vector of additive genetic effects \(u\) (\(q\) x \(1\)); \(e\) (\(n\) x \(1\)) is the random residuals vector.
\[y=X\beta + Zu + Z_fa_f + e\] Where, \(y\) is a \(n x 1\) vector of visit length at the feeder (minutes), \(X\beta\) are the fixed effects, \(location-trial \ (12)\), \(hour \ entry \ at \ the \ feeder \ (23)\) and \(animal \ median \ weigth\) as covariate; \(Z\) is a \(n\) x \(q\) desing matrix (\(q\) is the number of pigs) relates records in \(y\) to the random vector of additive genetic effects \(u\) (\(q\) x \(1\)); \(Z_f\) is the design matrix of the next individual that visited the feeder, named \(followers\), relating to \(y\) with the random vector effects \(a_f\) (\(q\) x \(1\)) and \(e\) (\(n\) x \(1\)) is the random residuals vector.
ggplot(BlupEF, aes(x=EarBLUP, y=FollBLUP))+
geom_point(aes(color = EarBLUP, size = FollBLUP)) +
geom_smooth(method = "lm",se = FALSE, color = "red")+
scale_color_continuous(low = "black", high = "blue") +
guides(color = FALSE, size = FALSE) +
geom_point(aes(y = FollBLUP), shape = 1) +
labs(title = "Direct BV vs Follower BV",
subtitle = paste("r =",round(cor(BlupEF$EarBLUP,BlupEF$FollBLUP), 5), ";","p-val =",
round(cor.test(BlupEF$EarBLUP,BlupEF$FollBLUP)$p.val,5)))+
theme(plot.subtitle = element_text(size = 8,face = "bold"))+
xlab("Direct Breeding value")+ylab("Follower Breeding value")
The Average daily gain \(ADG\) for each individual was calculated as:
\[ADG_i=\frac{\ median(Wt_{initial}) \ - median(Wt_{end})}{total\ trial \ days}\] Where:
\(ADG_i\) is the Average daily gain in kilograms of an individual \(i\) in any trial, with \(i=1,..,135\)
\(median(Wt_{initial})\) is the median weight in the start day of any trial.
\(median(Wt_{end})\) is the median weight in the end day of any trial.
\(total\ trial \ days\) are the number of total days of each trial.
ggplot(ADG, aes(x=Loc_trial, y=ADG))+geom_boxplot()+
ggtitle("Average Daily Gain (kg) by Trial") +
xlab("Location by Trial")+ ylab("Average Daily Gain (Kg)")+
theme(axis.text.x = element_text(angle = 45, hjust = 1),legend.position="none")
\[y=X\beta + e\] Where:
\(y\) is a \(n x 1\) vector of Average daily gain (\(ADG_i\) kg) of an individual
\(X\beta\) are the fixed effects, \(location-trial \ (14)\)
\(e\) (\(n\) x \(1\)) is the random residuals vector.
and \(y_i-x_i\hat{\beta}=\hat{e_i}\) is the ADG of the animal \(i\)
\(Average\ daily\ gain\ as\ deviation\ of\ group\)
The regression model for quantile level \(\tau\) of the Weight by individual is:
\[Q_{\tau}(y_i)= \beta_{0}(\tau) + \beta_1(\tau)x_{i1}\] \(\tau=0.5\) median quantile
\((y_i)\) is the \(i-th\) observation of the Weight of an animal
\(\beta_{0}\) is the intercept parameter
\(\beta_1\) is the slope
\(x_{i1}\) is the trial day
The goodness of fit for quantile regression by individual, which is analog to \(R^2\), was calculated following to Koenker and Machado (1999), and then
\[R^1(\tau)=1-\frac{\hat{V}(\tau)}{\tilde{V}(\tau)}\] Where:
\(R^1(\tau)\) is a local measure of goodness of fit for a particular quantile
\(\hat{V}(\tau)\) is a model with the intercept parameter only
\(\tilde{V}(\tau)\) is the unrestricted model
The Weight gain (\(weight.gain.qr\))
The random regression model on median weight in each trial in matrix notation is:
\[Y_{j}= X_j\beta + Z_ju_{j} + \ e_{j}\]
Where:
\(Y_{ij}\) is a matrix \(n_j\)x\(1\) with all observation of median weight for each day, in \(jth\) trial
\(X_j\) is the design matrix \(n_j\)x\(2\) of fixed effects for each group
\(\beta\) is the fixed effects vector, with \(\beta=(\beta_{0}, \beta_{1})'\)
\(Z_j\) is the design matrix \(n_j\)x\(2\) of random effects for each group
\(u_j\) is the random effects vector, with \(u=(u_{0j}, u_{1j})'\)
\(e_{ij}\) is the error vector
and the the \(ith\) row (\(i = 1,...n_j\)) of the response vector is:
\[y_{ij}= \beta_0 + \beta_1x_{ij} + u_0 + u_{1j}x_{ij} + e_{ij}\]
$weight.gain.rr_{pig}= group slope + trial.day.rr = (1 + u{1j})x_{ij} $
ggplot(blps.gr, aes(x=ADG, y=Weight.gain.rr))+geom_point() + geom_abline()+
labs(title = bquote( "Weight gain estimated by random regression and" ~ "ADG"[i] ~ "models" ) )+ xlab(bquote("ADG"[i]))+ ylab("Weight gain random regression")
The animal average daily feed intake was calculated as:
\[AFI_{i} = \frac{\sum_{j=1}^n X_j}{total\ days\ trial} \]
Where \(X_{j}\) is the \(jth\) consumed of an individual (\(j=1,..n\))
Feed.intake<-trials.data%>%group_by(Loc_trial,Eartag_trial)%>%
summarize(animal.intake=sum(Consumed),
total.days=(max(trial.day)-min(trial.day)),
Average.daily.intake=animal.intake/total.days)%>%
ungroup()%>%as.data.frame()
rownames(Feed.intake)<-Feed.intake$Eartag_trial
#----------
ggplot(Feed.intake, aes(x=Loc_trial, y=Average.daily.intake))+geom_boxplot()+
ggtitle("Average Daily Feed Intake (kg) by Trial") +
xlab("Location by Trial")+ ylab("Average Daily Feed Intake (Kg)")+
theme(axis.text.x = element_text(angle = 45, hjust = 1),legend.position="none")
#----------
\[y=X\beta + e\] Where:
\(y\) is a \(n x 1\) vector of Average feed intake (\(AFI_i\) kg) of an individual
\(X\beta\) are the fixed effects, \(location-trial \ (14)\)
\(e\) (\(n\) x \(1\)) is the random residuals vector.
and \(y_i-x_i\hat{\beta}=\hat{e_i}\) is the AFI of the animal \(i\)
\(EarBLUP =\ animal\ ramdom\ effect\ of\ visit\ length\ at\ the\ feeder\\ less\ than\ or\ equal\ to\ 60 s\)
\(FollBLUP = animal\ ramdom\ effect\ as\ next\ individual\ that\ visited\ the\ feeder\\ less\ than\ or\ equal\ to\ 60 s\)
\(ADG= ADG_i\)
\(ADG.locmean=ADG_i-\hat{\ loc:trial}\)
\(weight.gain.qr= estimated\ weight\ gain\ by\ median\ regression\ model\)
\(trial.day.rr = trial\ day\ random\ effect\ of\ the\ ith\ animal\ estimated\ by\ random\ regression\)
\(Weight.gain.rr = group\ slope + trial.day.rr,\ estimated\ by\ random\ regression\)
\(Average.daily.intake= AFI_i\)
\(feed.intake.fitloc = AFI_i- \hat{\ loc:trial}\)
ADGs.FI.BLUPs%>%select(EarBLUP,FollBLUP,ADG,ADG.locmean,
weight.gain.qr, trial.day.rr, Weight.gain.rr,
Average.daily.intake, feed.intake.fitloc)%>%cor()%>%
kable()%>%kable_styling(bootstrap_options = c("striped", "hover", "condensed"),full_width = F,
position = "left",font_size = 12)
| EarBLUP | FollBLUP | ADG | ADG.locmean | weight.gain.qr | trial.day.rr | Weight.gain.rr | Average.daily.intake | feed.intake.fitloc | |
|---|---|---|---|---|---|---|---|---|---|
| EarBLUP | 1.0000000 | 0.1231659 | 0.0657784 | 0.1200577 | 0.0245560 | 0.0778275 | 0.0472014 | 0.0586624 | 0.0854993 |
| FollBLUP | 0.1231659 | 1.0000000 | -0.0012882 | -0.0023511 | 0.0006074 | -0.0058356 | -0.0035392 | 0.0019494 | 0.0028412 |
| ADG | 0.0657784 | -0.0012882 | 1.0000000 | 0.5478900 | 0.9250629 | 0.4983372 | 0.9567826 | 0.7109197 | 0.3885109 |
| ADG.locmean | 0.1200577 | -0.0023511 | 0.5478900 | 1.0000000 | 0.5723908 | 0.9095570 | 0.5516344 | 0.4865273 | 0.7091039 |
| weight.gain.qr | 0.0245560 | 0.0006074 | 0.9250629 | 0.5723908 | 1.0000000 | 0.6489043 | 0.9870484 | 0.7318058 | 0.4860840 |
| trial.day.rr | 0.0778275 | -0.0058356 | 0.4983372 | 0.9095570 | 0.6489043 | 1.0000000 | 0.6064868 | 0.5149118 | 0.7504736 |
| Weight.gain.rr | 0.0472014 | -0.0035392 | 0.9567826 | 0.5516344 | 0.9870484 | 0.6064868 | 1.0000000 | 0.7302546 | 0.4551523 |
| Average.daily.intake | 0.0586624 | 0.0019494 | 0.7109197 | 0.4865273 | 0.7318058 | 0.5149118 | 0.7302546 | 1.0000000 | 0.6861158 |
| feed.intake.fitloc | 0.0854993 | 0.0028412 | 0.3885109 | 0.7091039 | 0.4860840 | 0.7504736 | 0.4551523 | 0.6861158 | 1.0000000 |
The sum of visit length total at the feeder for each individual was calculated as:
\[Vl_i= \sum_{j=1}^{n_i}X_j\]
Where:
\(Vl_i\) is the sum of the visit length total time at the feeder from the \(ith\) animal
\(X_j\) is the \(jth\) observation of visit length time at the feeder from the \(ith\) animal
\(n_i\) total number of observations from the \(ith\) animal
The linear model fitted was: \[y=X\beta + e\] Where:
\(y\) is a \(n x 1\) vector of the sum of the visit length total \(Vl_i\) at the feeder from the \(ith\) animal
\(X\beta\) are the fixed effects, \(location-trial \ (12)\)
\(e\) (\(n\) x \(1\)) is the random residuals vector.
and \(y_i-x_i\hat{\beta}=\hat{e_i}\) is the visit length total as deviation of estimated mean of location-trial group of the animal \(i\)
The random regression model on visit length in each trial in matrix notation is:
\[Y_{j}= X_j\beta + Z_ju_{j} + \ e_{j}\]
Where:
\(Y_{ij}\) is a matrix \(n_j\)x\(1\) with all observation of visit length total for each day, in \(jth\) trial
\(X_j\) is the design matrix \(n_j\)x\(2\) of fixed effects for each group (location-trial, trial day)
\(\beta\) is the fixed effects vector, with \(\beta=(\beta_{0}, \beta_{1})'\)
\(Z_j\) is the design matrix \(n_j\)x\(2\) of random effects for each group (Animal, trial day)
\(u_j\) is the random effects vector, with \(u=(u_{0j}, u_{1j})'\)
\(e_{ij}\) is the error vector
and the the \(ith\) row (\(i = 1,...n_j\)) of the response vector is:
\[y_{ij}= \beta_0 + \beta_1x_{ij} + u_0 + u_{1j}x_{ij} + e_{ij}\]
The visit length by animal is
\(Visit.length_{pig}= group\ slope + trial.day.rr = (\beta_1 + u_{1j})x_{ij}\)
The animal Average Feeder Occupation time was calculated as:
\[AFO_{i} = \frac{\sum_{j=1}^n X_j}{total\ days\ trial} \]
Where \(X_{j}\) is the \(jth\) time of occupation event of an individual in minutes (\(j=1,..n\))
AFO<-trials.data%>%group_by(Loc_trial,Eartag_trial)%>%
summarize(animal.AFO=sum(visit.length),
total.days=(max(trial.day)-min(trial.day)),
AFO=animal.AFO/total.days)%>%
ungroup()%>%as.data.frame()
rownames(AFO)<-AFO$Eartag_trial
#----------
ggplot(AFO, aes(x=Loc_trial, y=AFO))+geom_boxplot()+
ggtitle("Average Daily Feeder Occupation Time (min) by Trial") +
xlab("Location by Trial")+ ylab("Average Daily Feeder Occupation Time (min)")+
theme(axis.text.x = element_text(angle = 45, hjust = 1),legend.position="none")
#----------
\[y=X\beta + e\] Where:
\(y\) is a \(n x 1\) vector of Average Daily feeder occupation time (\(AFO_i\) min) of an individual
\(X\beta\) are the fixed effects, \(location-trial \ (14)\)
\(e\) (\(n\) x \(1\)) is the random residuals vector.
and \(\hat{e_i}=y_i-x_i\hat{\beta}\) is the ADFO of the animal \(i\)
\(Estimates\ of\ Pearson,\ Kendall\ and\ Spearman\ coefficients\ correlations\ and\ their\ p-values\)
\(EarBLUP = animal\ ramdom \ effect\ of \ visit \ length \ at \ the \ feeder\)
\(FollBLUP = animal\ ramdom \ effect\ as \ next \ individual \ that \ visited \ the \ feeder\)
\(WG=trial.day.rr = u_{1i},\ trial\ day\ random\ effect\ of\ the\ ith\ animal\ on\ weight\ gain\)
\(AFI=feed.intake.fitloc = AFI_i- \hat{\ loc:trial}\)
\(FOT=visitl.fitloc = Vl_i-\hat{\ loc:trial}\)
\(FOD_1=Visit.length_{pig}= group\ slope + vl.day = (\beta_1 + u_{1j})x_{ij}\)
\(FOD_2=vl.day = trial\ day\ random\ effect\ of\ the\ ith\ animal\ on\ visit\ length\ at\ the\ feeder\)
\(ADFO=AFO.fitloc = AFO_i- \hat{\ loc:trial}\)
kable(outcor, caption = " Estimates correlation between BLUP's of visit length and weight gain and feed intake, feeder occupation time") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"),full_width = F,
position = "center",font_size = 14) %>%
add_header_above(c(" Trait" = 1, "Direct BLUP" = 6, "Follower BLUP" = 6), italic = T,
bold = T)%>%
column_spec(1, bold = T)%>%
column_spec(c(2,3,8,9), background = "#AAEEAA")%>%
column_spec(c(4,5,10,11), background = "#CCEAAA")%>%
row_spec(c(3,6), bold = T)
| Pearson | Pval | Spearman | Pval | Kendall | Pval | Pearson | Pval | Spearman | Pval | Kendall | Pval | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| WG | 0.0778 | 0.3696 | 0.0826 | 0.3409 | 0.0543 | 0.3503 | -0.0058 | 0.9464 | 0.0562 | 0.5174 | 0.0379 | 0.5141 |
| AFI | 0.0855 | 0.3241 | 0.1270 | 0.1422 | 0.0839 | 0.1488 | 0.0028 | 0.9739 | 0.0479 | 0.5810 | 0.0331 | 0.5695 |
| FOT | 0.4532 | 0.0000 | 0.4952 | 0.0000 | 0.3501 | 0.0000 | -0.2150 | 0.0123 | -0.1832 | 0.0334 | -0.1257 | 0.0306 |
| FOD_1 | -0.0332 | 0.7025 | -0.0677 | 0.4350 | -0.0501 | 0.3889 | -0.1464 | 0.0902 | -0.1057 | 0.2225 | -0.0700 | 0.2286 |
| FOD_2 | -0.0462 | 0.5950 | -0.1054 | 0.2239 | -0.0647 | 0.2658 | -0.2037 | 0.0178 | -0.1627 | 0.0593 | -0.1076 | 0.0642 |
| ADFO | 0.5136 | 0.0000 | 0.5125 | 0.0000 | 0.3667 | 0.0000 | -0.2601 | 0.0023 | -0.2186 | 0.0109 | -0.1472 | 0.0113 |