sommer

library(sommer)
data(DT_example)
head(DT_example)
##                   Name     Env Loc Year     Block Yield    Weight
## 33  Manistee(MSL292-A) CA.2013  CA 2013 CA.2013.1     4 -1.904711
## 65          CO02024-9W CA.2013  CA 2013 CA.2013.1     5 -1.446958
## 66  Manistee(MSL292-A) CA.2013  CA 2013 CA.2013.2     5 -1.516271
## 67            MSL007-B CA.2011  CA 2011 CA.2011.2     5 -1.435510
## 68           MSR169-8Y CA.2013  CA 2013 CA.2013.1     5 -1.469051
## 103         AC05153-1W CA.2013  CA 2013 CA.2013.1     6 -1.307167
DT <- DT_example
str(DT)
## 'data.frame':    185 obs. of  7 variables:
##  $ Name  : Factor w/ 41 levels "A01143-3C","AC00206-2W",..: 16 12 16 18 28 6 8 18 25 32 ...
##  $ Env   : Factor w/ 3 levels "CA.2011","CA.2012",..: 3 3 3 1 3 3 2 1 2 2 ...
##  $ Loc   : Factor w/ 1 level "CA": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Year  : Factor w/ 3 levels "2011","2012",..: 3 3 3 1 3 3 2 1 2 2 ...
##  $ Block : Factor w/ 6 levels "CA.2011.1","CA.2011.2",..: 5 5 6 2 5 5 4 1 3 4 ...
##  $ Yield : int  4 5 5 5 5 6 6 6 6 6 ...
##  $ Weight: num  -1.9 -1.45 -1.52 -1.44 -1.47 ...
ans1 <- mmer(Yield~Env,
             random= ~ Name + Env:Name,
             rcov= ~ units,
             data=DT, verbose = FALSE)
summary(ans1)
## ============================================================
##          Multivariate Linear Mixed Model fit by REML         
## **********************  sommer 4.1  ********************** 
## ============================================================
##          logLik      AIC      BIC Method Converge
## Value -20.14538 46.29075 55.95182     NR     TRUE
## ============================================================
## Variance-Covariance components:
##                      VarComp VarCompSE Zratio Constraint
## Name.Yield-Yield       3.682     1.691  2.177   Positive
## Env:Name.Yield-Yield   5.173     1.495  3.460   Positive
## units.Yield-Yield      4.366     0.647  6.748   Positive
## ============================================================
## Fixed effects:
##   Trait      Effect Estimate Std.Error t.value
## 1 Yield (Intercept)   16.496    0.6855  24.065
## 2 Yield  EnvCA.2012   -5.777    0.7558  -7.643
## 3 Yield  EnvCA.2013   -6.380    0.7960  -8.015
## ============================================================
## Groups and observations:
##          Yield
## Name        41
## Env:Name   123
## ============================================================
## Use the '$' sign to access results and parameters
data(DT_example)
DT <- DT_example
ans2 <- mmer(Yield~Env,
             random= ~Name + vs(ds(Env),Name),
             rcov= ~ vs(ds(Env),units),
             data=DT, verbose = FALSE)
summary(ans2)
## ============================================================
##          Multivariate Linear Mixed Model fit by REML         
## **********************  sommer 4.1  ********************** 
## ============================================================
##          logLik      AIC      BIC Method Converge
## Value -15.42983 36.85965 46.52072     NR     TRUE
## ============================================================
## Variance-Covariance components:
##                           VarComp VarCompSE Zratio Constraint
## Name.Yield-Yield            2.963     1.496  1.980   Positive
## CA.2011:Name.Yield-Yield   10.146     4.507  2.251   Positive
## CA.2012:Name.Yield-Yield    1.878     1.870  1.004   Positive
## CA.2013:Name.Yield-Yield    6.629     2.503  2.649   Positive
## CA.2011:units.Yield-Yield   4.942     1.525  3.242   Positive
## CA.2012:units.Yield-Yield   5.725     1.312  4.363   Positive
## CA.2013:units.Yield-Yield   2.560     0.640  4.000   Positive
## ============================================================
## Fixed effects:
##   Trait      Effect Estimate Std.Error t.value
## 1 Yield (Intercept)   16.508    0.8268  19.965
## 2 Yield  EnvCA.2012   -5.817    0.8575  -6.783
## 3 Yield  EnvCA.2013   -6.412    0.9356  -6.854
## ============================================================
## Groups and observations:
##              Yield
## Name            41
## CA.2011:Name    41
## CA.2012:Name    41
## CA.2013:Name    41
## ============================================================
## Use the '$' sign to access results and parameters
data(DT_example)
DT <- DT_example
ans3 <- mmer(Yield~Env,
             random=~ vs(us(Env),Name),
             rcov=~vs(us(Env),units),
             data=DT, verbose = FALSE)
summary(ans3)
## ===================================================================
##              Multivariate Linear Mixed Model fit by REML             
## **************************  sommer 4.1  ************************** 
## ===================================================================
##          logLik      AIC      BIC Method Converge
## Value -11.49971 28.99943 38.66049     NR     TRUE
## ===================================================================
## Variance-Covariance components:
##                                   VarComp VarCompSE Zratio Constraint
## CA.2011:Name.Yield-Yield           15.665    5.4207  2.890   Positive
## CA.2012:CA.2011:Name.Yield-Yield    6.110    2.4851  2.459   Unconstr
## CA.2012:Name.Yield-Yield            4.530    1.8208  2.488   Positive
## CA.2013:CA.2011:Name.Yield-Yield    6.384    3.0659  2.082   Unconstr
## CA.2013:CA.2012:Name.Yield-Yield    0.393    1.5234  0.258   Unconstr
## CA.2013:Name.Yield-Yield            8.597    2.4838  3.461   Positive
## CA.2011:units.Yield-Yield           4.970    1.5323  3.243   Positive
## CA.2012:CA.2011:units.Yield-Yield   4.087    0.0000    Inf   Unconstr
## CA.2012:units.Yield-Yield           5.673    1.3008  4.361   Positive
## CA.2013:CA.2011:units.Yield-Yield   4.087    0.0000    Inf   Unconstr
## CA.2013:CA.2012:units.Yield-Yield   4.087    0.0000    Inf   Unconstr
## CA.2013:units.Yield-Yield           2.557    0.6393  4.000   Positive
## ===================================================================
## Fixed effects:
##   Trait      Effect Estimate Std.Error t.value
## 1 Yield (Intercept)   16.331    0.8137  20.070
## 2 Yield  EnvCA.2012   -5.696    0.7404  -7.693
## 3 Yield  EnvCA.2013   -6.271    0.8191  -7.656
## ===================================================================
## Groups and observations:
##                      Yield
## CA.2011:Name            41
## CA.2012:CA.2011:Name    82
## CA.2012:Name            41
## CA.2013:CA.2011:Name    82
## CA.2013:CA.2012:Name    82
## CA.2013:Name            41
## ===================================================================
## Use the '$' sign to access results and parameters
data(DT_example)
DT <- DT_example
DT$EnvName <- paste(DT$Env,DT$Name)
ans4 <- mmer(cbind(Yield, Weight) ~ Env,
             random= ~ vs(Name, Gtc=unsm(2)) + vs(EnvName, Gtc=unsm(2)),
             rcov= ~ vs(units, Gtc=unsm(2)),
             data=DT, verbose = FALSE)
summary(ans4)
## ============================================================
##          Multivariate Linear Mixed Model fit by REML         
## **********************  sommer 4.1  ********************** 
## ============================================================
##         logLik       AIC       BIC Method Converge
## Value 167.0252 -322.0505 -298.5695     NR     TRUE
## ============================================================
## Variance-Covariance components:
##                         VarComp VarCompSE Zratio Constraint
## u:Name.Yield-Yield       3.7089   1.68117  2.206   Positive
## u:Name.Yield-Weight      0.9071   0.37944  2.391   Unconstr
## u:Name.Weight-Weight     0.2243   0.08775  2.557   Positive
## u:EnvName.Yield-Yield    5.0921   1.47879  3.443   Positive
## u:EnvName.Yield-Weight   1.0269   0.30767  3.338   Unconstr
## u:EnvName.Weight-Weight  0.2101   0.06661  3.154   Positive
## u:units.Yield-Yield      4.3837   0.64941  6.750   Positive
## u:units.Yield-Weight     0.9077   0.14145  6.417   Unconstr
## u:units.Weight-Weight    0.2280   0.03377  6.751   Positive
## ============================================================
## Fixed effects:
##    Trait      Effect Estimate Std.Error t.value
## 1  Yield (Intercept)  16.4093    0.6783  24.191
## 2 Weight (Intercept)   0.9806    0.1497   6.550
## 3  Yield  EnvCA.2012  -5.6844    0.7474  -7.606
## 4 Weight  EnvCA.2012  -1.1846    0.1593  -7.439
## 5  Yield  EnvCA.2013  -6.2952    0.7850  -8.019
## 6 Weight  EnvCA.2013  -1.3559    0.1681  -8.065
## ============================================================
## Groups and observations:
##           Yield Weight
## u:Name       41     41
## u:EnvName    94     94
## ============================================================
## Use the '$' sign to access results and parameters
data(DT_example)
DT <- DT_example
DT$EnvName <- paste(DT$Env,DT$Name)
ans5 <- mmer(cbind(Yield, Weight) ~ Env,
             random= ~ vs(Name, Gtc=unsm(2)) + vs(ds(Env),Name, Gtc=unsm(2)),
             rcov= ~ vs(ds(Env),units, Gtc=unsm(2)),
             data=DT, verbose = FALSE)
summary(ans5)
## =============================================================
##           Multivariate Linear Mixed Model fit by REML          
## **********************  sommer 4.1  ********************** 
## =============================================================
##         logLik       AIC       BIC Method Converge
## Value 177.8154 -343.6308 -320.1497     NR     TRUE
## =============================================================
## Variance-Covariance components:
##                             VarComp VarCompSE Zratio Constraint
## u:Name.Yield-Yield          3.31936   1.45269 2.2850   Positive
## u:Name.Yield-Weight         0.79393   0.32621 2.4338   Unconstr
## u:Name.Weight-Weight        0.19085   0.07503 2.5438   Positive
## CA.2011:Name.Yield-Yield    8.70657   4.01470 2.1687   Positive
## CA.2011:Name.Yield-Weight   1.77892   0.83926 2.1196   Unconstr
## CA.2011:Name.Weight-Weight  0.35966   0.17903 2.0089   Positive
## CA.2012:Name.Yield-Yield    2.57109   1.94951 1.3188   Positive
## CA.2012:Name.Yield-Weight   0.33245   0.39840 0.8345   Unconstr
## CA.2012:Name.Weight-Weight  0.03842   0.08595 0.4470   Positive
## CA.2013:Name.Yield-Yield    5.46908   2.16307 2.5284   Positive
## CA.2013:Name.Yield-Weight   1.34713   0.50479 2.6687   Unconstr
## CA.2013:Name.Weight-Weight  0.32902   0.12208 2.6952   Positive
## CA.2011:units.Yield-Yield   4.93852   1.52318 3.2422   Positive
## CA.2011:units.Yield-Weight  0.99447   0.32150 3.0932   Unconstr
## CA.2011:units.Weight-Weight 0.23982   0.07394 3.2433   Positive
## CA.2012:units.Yield-Yield   5.73887   1.31533 4.3631   Positive
## CA.2012:units.Yield-Weight  1.28009   0.30157 4.2448   Unconstr
## CA.2012:units.Weight-Weight 0.31806   0.07286 4.3652   Positive
## CA.2013:units.Yield-Yield   2.56127   0.63993 4.0024   Positive
## CA.2013:units.Yield-Weight  0.44569   0.12645 3.5246   Unconstr
## CA.2013:units.Weight-Weight 0.12232   0.03057 4.0009   Positive
## =============================================================
## Fixed effects:
##    Trait      Effect Estimate Std.Error t.value
## 1  Yield (Intercept)  16.4243    0.7891  20.815
## 2 Weight (Intercept)   0.9866    0.1683   5.863
## 3  Yield  EnvCA.2012  -5.7339    0.8266  -6.937
## 4 Weight  EnvCA.2012  -1.1998    0.1698  -7.066
## 5  Yield  EnvCA.2013  -6.3128    0.8757  -7.209
## 6 Weight  EnvCA.2013  -1.3621    0.1915  -7.114
## =============================================================
## Groups and observations:
##              Yield Weight
## u:Name          41     41
## CA.2011:Name    41     41
## CA.2012:Name    41     41
## CA.2013:Name    41     41
## =============================================================
## Use the '$' sign to access results and parameters
data(DT_example)
DT <- DT_example
DT$EnvName <- paste(DT$Env,DT$Name)
ans6 <- mmer(cbind(Yield, Weight) ~ Env,
             random= ~ vs(us(Env),Name, Gtc=unsm(2)),
             rcov= ~ vs(ds(Env),units, Gtc=unsm(2)),
             data=DT, verbose = FALSE)
summary(ans6)
## ====================================================================
##              Multivariate Linear Mixed Model fit by REML             
## **************************  sommer 4.1  ************************** 
## ====================================================================
##         logLik       AIC       BIC Method Converge
## Value 181.7945 -351.5889 -328.1079     NR     TRUE
## ====================================================================
## Variance-Covariance components:
##                                    VarComp VarCompSE Zratio Constraint
## CA.2011:Name.Yield-Yield           15.6451   5.35692  2.921   Positive
## CA.2011:Name.Yield-Weight           3.3586   1.14633  2.930   Unconstr
## CA.2011:Name.Weight-Weight          0.7182   0.24871  2.888   Positive
## CA.2012:CA.2011:Name.Yield-Yield    6.5289   2.48615  2.626   Positive
## CA.2012:CA.2011:Name.Yield-Weight   1.3505   0.52388  2.578   Unconstr
## CA.2012:CA.2011:Name.Weight-Weight  0.2842   0.11259  2.524   Positive
## CA.2012:Name.Yield-Yield            4.7893   1.86183  2.572   Positive
## CA.2012:Name.Yield-Weight           0.8640   0.38377  2.251   Unconstr
## CA.2012:Name.Weight-Weight          0.1693   0.08354  2.027   Positive
## CA.2013:CA.2011:Name.Yield-Yield    5.9934   2.93830  2.040   Positive
## CA.2013:CA.2011:Name.Yield-Weight   1.4232   0.64973  2.190   Unconstr
## CA.2013:CA.2011:Name.Weight-Weight  0.3379   0.14680  2.302   Positive
## CA.2013:CA.2012:Name.Yield-Yield    2.0987   1.44034  1.457   Positive
## CA.2013:CA.2012:Name.Yield-Weight   0.5240   0.32356  1.619   Unconstr
## CA.2013:CA.2012:Name.Weight-Weight  0.1342   0.07572  1.772   Positive
## CA.2013:Name.Yield-Yield            8.6257   2.47811  3.481   Positive
## CA.2013:Name.Yield-Weight           2.1048   0.58748  3.583   Unconstr
## CA.2013:Name.Weight-Weight          0.5125   0.14285  3.588   Positive
## CA.2011:units.Yield-Yield           4.9516   1.52694  3.243   Positive
## CA.2011:units.Yield-Weight          0.9993   0.32286  3.095   Unconstr
## CA.2011:units.Weight-Weight         0.2411   0.07432  3.244   Positive
## CA.2012:units.Yield-Yield           5.7790   1.32423  4.364   Positive
## CA.2012:units.Yield-Weight          1.2914   0.30408  4.247   Unconstr
## CA.2012:units.Weight-Weight         0.3212   0.07356  4.366   Positive
## CA.2013:units.Yield-Yield           2.5567   0.63883  4.002   Positive
## CA.2013:units.Yield-Weight          0.4452   0.12631  3.524   Unconstr
## CA.2013:units.Weight-Weight         0.1223   0.03056  4.001   Positive
## ====================================================================
## Fixed effects:
##    Trait      Effect Estimate Std.Error t.value
## 1  Yield (Intercept)  16.3342    0.8254  19.790
## 2 Weight (Intercept)   0.9677    0.1770   5.466
## 3  Yield  EnvCA.2012  -5.6637    0.7449  -7.604
## 4 Weight  EnvCA.2012  -1.1855    0.1604  -7.390
## 5  Yield  EnvCA.2013  -6.2153    0.8340  -7.453
## 6 Weight  EnvCA.2013  -1.3406    0.1806  -7.425
## ====================================================================
## Groups and observations:
##                      Yield Weight
## CA.2011:Name            41     41
## CA.2012:CA.2011:Name    82     82
## CA.2012:Name            41     41
## CA.2013:CA.2011:Name    82     82
## CA.2013:CA.2012:Name    82     82
## CA.2013:Name            41     41
## ====================================================================
## Use the '$' sign to access results and parameters