4.2 Multivariate genetic effects

We can simulate genetic effects affecting multiple phenotypes and the covariance between them, by specifying the number of response variables, and a covariance matrix, instead of only a variance.

squid_data <- simulate_population(
  data_structure = BTped,
  pedigree = list(animal = BTped),
  n_response=2,
  parameters = list(
    animal = list(
      vcov = diag(2)

    ),
    residual = list(
      vcov = diag(2)
    )
  )
)

data <- get_population_data(squid_data)
head(data)
##                 y1         y2 animal_effect1 animal_effect2  residual1
## R187557 -0.8385548  0.1841058      0.6786441     -0.3935136 -1.5171990
## R187559 -0.4701207  1.0400757     -1.4113157      1.0666325  0.9411949
## R187568 -0.1846425  0.3584195      1.0712568      0.3008260 -1.2558993
## R187518 -0.9746306  1.1945939     -2.3299460      0.7226137  1.3553154
## R187528 -0.8318896  0.2290793      0.3754430      0.3256557 -1.2073326
## R187945  1.8103155 -1.2127095      2.1203028     -1.2159118 -0.3099873
##            residual2  animal  dam sire squid_pop
## R187557  0.577619380 R187557 <NA> <NA>         1
## R187559 -0.026556865 R187559 <NA> <NA>         1
## R187568  0.057593543 R187568 <NA> <NA>         1
## R187518  0.471980260 R187518 <NA> <NA>         1
## R187528 -0.096576413 R187528 <NA> <NA>         1
## R187945  0.003202301 R187945 <NA> <NA>         1
# Ainv<-inverseA(BTped)$Ainv
# mod <- MCMCglmm(cbind(y1,y2)~1,random=~us(trait):animal, rcov=~us(trait):units,data=data,family=rep("gaussian",2),verbose=FALSE,ginverse=list(animal=Ainv))
# summary(mod)