【发布时间】:2019-09-15 23:33:00
【问题描述】:
模拟线性回归的条件并显示多维线性回归(三个或更多参数)的估计是无偏的。尝试对线性回归的参数进行有偏差的估计,并通过模拟表明您设法实现了偏差。
这是我尝试过的,但我被困在从有偏见的估计中获得无偏见的估计。
b0=2
b1=1.3
b2=5
N=1000
matrica=matrix(rep(0,N*3),ncol=3)
for (i in 1:N) {
x1=rnorm(100) ##expectation and variance is arbitrary
x2=rnorm(100)
err=rnorm(100)
y=b0+b1*x1+b2*x2+err
lm=lm(y~x1+x2)
matrica[i,1]=lm$coefficients[1]
matrica[i,2]=lm$coefficients[2]
matrica[i,3]=lm$coefficients[3]
}
matrica
rez1 <- matrica[1:N ,1]
rez2 <- matrica[1:N ,2]
rez3 <- matrica[1:N ,3]
## now we need to show that the estimates are unbiased (b0~mean(rez1...))
summary(rez1)
summary(rez2)
summary(rez3)
cor(rez1,rez2) #highly connected
cor(rez2,rez3) #highly connected
【问题讨论】:
-
我建议您设置种子以实现可重复性。你的问题是什么?您的问题和期望的结果不清楚。
-
@OTStats 我不知道如何从有偏估计中得到无偏估计
-
将它(以问题的形式)添加到您上面的帖子中。
标签: r statistics