Prediction Theory 1 Introduction 2 General Linear Mixed Model
Prediction Theory 1 Introduction 2 General Linear Mixed Model
Prediction Theory 1 Introduction 2 General Linear Mixed Model
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
MME = function(X,Z,GI,RI,y) {<br />
XX = t(X) %*% RI %*% X<br />
XZ = t(X) %*% RI %*% Z<br />
ZZ = (t(Z) %*% RI %*% Z) + GI<br />
Xy = t(X) %*% RI %*% y<br />
Zy = t(Z) %*% RI %*% y<br />
# Combine the pieces into LHS and RHS<br />
piece1 = cbind(XX,XZ)<br />
piece2 = cbind(t(XZ),ZZ)<br />
LHS = rbind(piece1,piece2)<br />
RHS = rbind(Xy,Zy)<br />
# Invert LHS and solve<br />
C = ginv(LHS)<br />
SOL = C %*% RHS<br />
SSR = t(SOL) %*% RHS<br />
SOLNS = cbind(SOL,sqrt(diag(C)))<br />
return(list(LHS=LHS,RHS=RHS,C=C,SSR=SSR,SOLNS=SOLNS))<br />
}<br />
To use the function,<br />
Exampl = MME(X1,Z1,GI,RI,y)<br />
str(Exampl)<br />
# To view the results<br />
Exampl$LHS<br />
Exampl$RHS<br />
Exampl$C<br />
Exampl$SOLNS<br />
Exampl$SSR<br />
25