Merge pull request #1894 from solgenomics/topic/encode_passwords
[sgn.git] / R / BLUP_modelling.r
blob0f2ee0cb86437425f31c25a008c73ca99b230453
1 rm(list=ls())
2 library(lme4)
4 # Define models
6 #0# fixed effect trait, random effect (genotype)
7 data_i <- data.frame(phenodata_sub=phenodata[,i],genotype = genotype[,1])
8 fmer <- lmer(phenodata~1|genotype, data = data_i, na.action = na.omit)
10 #1# fixed effect: year, random effect (genotype)
11 fmer <- lmer(phenodata[,i]~year + (1|genotype), data = phenodata)
12 fmer <- lmer(v~1|w, data = data_i, na.action = na.omit)
14 #2# fixed effect: block, random effect (genotype)
15 fmer <- lmer(phenodata[,i]~block + (1|genotype), data = phenodata)
17 #3# fixed effects: year and block (additive), random effect (genotype) and covariate response identical for all
18 fmeria <- lmer(phenodata[,i]~year + block + (1|genotype), data = phenodata)
20 #4# fixed effects: (year and block (additive), random effect (genotype), interaction (genotype:year) and covariate response identical for all
21 fmerib <- lmer(phenodata[,i]~year + block + (1|genotype) + (1|genotype:year), data = phenodata)
23 #5# fixed effects: (year and block (additive), , hierarchical random effect (genotype),(response to genotype covariate based on year):
24 fmert <- lmer(phenodata[,i]~year + block + (-1+year|genotype), data = phenodata)
26 # Model comparison (most complex vs less complex)
27 #genotype effect on year+block:
28 model(2) versus model(0)
30 #year effect on year+block:
31 model(1) versus model(0)
33 #block effect on genotype:
34 model(2) versus model(1)
36 #genotype:year interaction on genotype:
37 model(3) versus model(2)
39 #year + block hierachical effect on genotype:
40 model(5) versus model(2)