, 两者一样
3, 构建模型
y = Xb + Zu + e
构建固定因子矩阵
这里使用函数model.matrix构建矩阵, 比较方便
for(i in 1:4) dat[,i] <- as.factor...y <- as.matrix(dat$weight)
y
140
152
135
143
160
混合线性方程组
XpZ <- crossprod(X,Z);XpZ
Chang1 1 1 1 0 0...-2 -2.000000 . 5
可以看到, 里面的LHS左手矩阵和上图结果一致.
RHS <- rbind(Xpy,Zpy)
RHS
?...求解BLUP值
solve(LHS)%*%RHS
7 x 1 Matrix of class "dgeMatrix"
[,1]
[1,] 142.842105
[2,] 151.118421...<- rbind(cbind(XpX,XpZ),cbind(ZpX,ZpZ+Ainv*K))
LHS
RHS <- rbind(Xpy,Zpy)
RHS
solve(LHS)%*%RHS