You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A minor, yet useful enhancement would be to allow the user to specify contrasts for the fixed effects.
By looking at the code of mmer, a contrasts argument could be used on line 261 baseX <- model.matrix(newfixed, mf) maybe? But I don't know how it would work with multivariate models...
The text was updated successfully, but these errors were encountered:
Could you elaborate a more complete example using another software like base lm or lmer to understand a bit more what do you mean? With some mock up data if possible.
library(lme4)
library(sommer)
## simulate some data with a LMM y = X beta + Z u + epsilon:
set.seed(12345)
p <- 3
q <- 20
n <- p * q
dat <- expand.grid(geno=paste0("geno", 1:q),
block=LETTERS[1:p],
KEEP.OUT.ATTRS=FALSE)
str(dat)
head(dat)
## listContr <- list("block"="contr.treatment")
listContr <- list("block"="contr.sum")
X <- model.matrix(~ block, dat, contrasts.arg=listContr)
beta <- rnorm(p)
Z <- model.matrix(~ 0 + geno, dat)
u <- rnorm(q)
y <- X %*% beta + Z %*% u + rnorm(n)
dat$yield <- y
## plot the data:
hist(dat$yield)
boxplot(yield ~ block, dat)
## fit with lmer
fit1 <- lmer(yield ~ block + (1|geno), dat, contrasts=listContr)
cbind("truth"=beta, "estim"=fixef(fit1))
## fit with mmer:
fit2 <- mmer(yield ~ block, ~ geno, data=dat)
cbind("truth"=beta, "estim"=fit2$Beta[,"Estimate"])
By default for unordered factor, R chooses the "treatment" contrasts. But I often uses the "sum" contrast instead for my simulations. It would be great if we could give listContr (see above) to mmer.
p.s.: see here for more details about coding and contrast matrices in R
A minor, yet useful enhancement would be to allow the user to specify contrasts for the fixed effects.
By looking at the code of
mmer
, a contrasts argument could be used on line 261baseX <- model.matrix(newfixed, mf)
maybe? But I don't know how it would work with multivariate models...The text was updated successfully, but these errors were encountered: