mat.Vpred | R Documentation |
For n
observations, w
effects to be predicted,
f
nuiscance fixed effects and r
nuisance random effects,
the variances of a set of predicted effects is calculated using
the incidence matrix for the effects to be predicted and, optionally,
a variance matrix of the effects, an incidence matrix for the
nuisance fixed factors and covariates, the variance matrix of the nuisance
random effects in the mixed model and the residual variance matrix.
This function has been superseded by mat.Vpredicts
, which
allows the use of both matrices and formula
e.
mat.Vpred(W, Gg = 0, X = matrix(1, nrow = nrow(W), ncol = 1), Vu = 0, R, eliminate)
W |
The |
Gg |
The |
X |
The |
Vu |
The |
R |
The residual variance |
eliminate |
The |
Firstly the information matrix is calculated as
A <- t(W) %*% Vinv %*% W + ginv(Gg) - A%*%ginv(t(X)%*%Vinv%*%X)%*%t(A)
,
where Vinv <- ginv(Vu + R)
, A = t(W) %*% Vinv %*% X
and ginv(B) is the unique Moore-Penrose inverse of B formed using the eigendecomposition of B.
If eliminate
is set and the effects to be predicted are fixed then the reduced information matrix is calculated as A <- (I - eliminate) Vinv (I - eliminate)
.
Finally, the variance of the predicted effects is calculated: Vpred <- ginv(A)
.
A w x w
matrix
containing the variances and covariances of the
predicted effects.
Chris Brien
Smith, A. B., D. G. Butler, C. R. Cavanagh and B. R. Cullis (2015). Multi-phase variety trials using both composite and individual replicate samples: a model-based design approach. Journal of Agricultural Science, 153, 1017-1029.
designAmeasures
, mat.Vpredicts
.
## Reduced example from Smith et al. (2015)
## Generate two-phase design
mill.fac <- fac.gen(list(Mrep = 2, Mday = 2, Mord = 3))
field.lay <- fac.gen(list(Frep = 2, Fplot = 4))
field.lay$Variety <- factor(c("D","E","Y","W","G","D","E","M"),
levels = c("Y","W","G","M","D","E"))
start.design <- cbind(mill.fac, field.lay[c(3,4,5,8,1,7,3,4,5,8,6,2),])
rownames(start.design) <- NULL
## Set up matrices
n <- nrow(start.design)
W <- model.matrix(~ -1+ Variety, start.design)
ng <- ncol(W)
Gg<- diag(1, ng)
Vu <- with(start.design, fac.vcmat(Mrep, 0.3) +
fac.vcmat(fac.combine(list(Mrep, Mday)), 0.2) +
fac.vcmat(Frep, 0.1) +
fac.vcmat(fac.combine(list(Frep, Fplot)), 0.2))
R <- diag(1, n)
## Calculate the variance matrix of the predicted random Variety effects
Vp <- mat.Vpred(W = W, Gg = Gg, Vu = Vu, R = R)
designAmeasures(Vp)
## Calculate the variance matrix of the predicted fixed Variety effects,
## elminating the grand mean
Vp.reduc <- mat.Vpred(W = W, Gg = 0, Vu = Vu, R = R,
eliminate = projector(matrix(1, nrow = n, ncol = n)/n))
designAmeasures(Vp.reduc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.