我有以下线性模型,我想找到最佳线性无偏估计
x<-c(rep(c(1,0,-1,0),4),rep(c(0,1,0,-1),4),rep(c(1,1,0,0),4), rep(c(2,2,-1,-1),4))
x<-matrix(x,ncol=4,byrow=T)
y<-c(2.1,1.9,2,2.2,1.2,0.8,1.1,0.9,5.1,5.2,4.9,4.9,7.9,8,8.2,7.9)
答案 0 :(得分:1)
您的第四个自变量是其他三个的线性组合,因此从拟合中省略。要检查此项,请将第四个变量替换为rnorm
。
x<-c(rep(c(1,0,-1,0),4),rep(c(0,1,0,-1),4),rep(c(1,1,0,0),4), rnorm(16))
x<-matrix(x,ncol=4,byrow=T)
y<-c(2.1,1.9,2,2.2,1.2,0.8,1.1,0.9,5.1,5.2,4.9,4.9,7.9,8,8.2,7.9)
lm( y ~ x )
# Call:
# lm(formula = y ~ x)
# Coefficients:
# (Intercept) x1 x2 x3 x4
# 6.0274 0.4742 -1.6753 4.5236 2.6643