## Set seed for reproductibility
set.seed(123)
## Load "wheat" dataset from BGLR
data("wheat",package = "BGLR")
## Generate a design data frame for all genotypes in 5 environments
Design <- expand.grid(Genotype=rownames(wheat.A),Environment=paste0("Env",1:5))
## Set sparseness by discarding 80% of the combinations
Design <- Design[-sample(nrow(Design),round(nrow(Design)*4/5)),]
## Simulate phenotypic data with default parameter values
DataSim <- Simulate_MET_data(Design=Design,K=wheat.A)
# \donttest{
## Calculate the blup and the conditional variance matrix using simulated variance components
## this step can take several seconds
## note that variance can also be estimated (e.g. using BGLR)
BlupEnvBV <- EnvBV_blup(Pheno=DataSim$Pheno,K=wheat.A,Omega_G=DataSim$Omega_G,
Omega_E=DataSim$Omega_E)
## Display results
head(BlupEnvBV$G_hat)
BlupEnvBV$P[1:5,1:5]
# }
Run the code above in your browser using DataLab