if (spaMM.getOption("example_maxtime")>1.5 &&
requireNamespace("agridat", quietly = TRUE)) {
data("onofri.winterwheat", package="agridat")
(constvar <- fitme(
yield ~ gen + (1|year) + (1|block %in% year)+(1|gen %in% year),
data=onofri.winterwheat, method="REML"))
# Diagonal matrix of NA's, represented as vector for its lower triangle:
ranCoefs_for_diag <- function(nlevels) {
## Conceptual version
# diagmat <- matrix(NA, ncol=nlevels,nrow=nlevels)
# diagmat[lower.tri(diagmat,diag=FALSE)] <- 0
# return(diagmat[lower.tri(diagmat,diag=TRUE)])
## which amounts to:
vec <- rep(0,nlevels*(nlevels+1L)/2L)
vec[cumsum(c(1L,rev(seq(nlevels-1L)+1L)))] <- NA
vec
}
(varvar <- fitme(
yield ~ gen + (1|year) + (1|block %in% year)+(0+gen|gen %in% year), method="REML",
data=onofri.winterwheat, fixed=list(ranCoefs=list("3"=ranCoefs_for_diag(8L)))))
}
Run the code above in your browser using DataLab