티스토리 뷰

독립 변수의 범위를 제한함에 따라 생기는 회귀계수의 표집오차 증가

독립 변수의 범위를 제한함에 따라 생기는 회귀계수의 표본오차 증가



그래프 순서

1  3

2  4


그래프 1)

모집단 

                      


그래프 2)

이제 이 모집단에 표본크기 50의 표본을 추출하여 회귀계수를 추정해 봅시다. 표본은 추출할 때마다 달라지겠지만, 회귀선의 95% 신뢰구간은 다음의 그래프와 비슷합니다.


그래프 3)

하지만 표본 추출시 독립변수의 범위를 로 제한한다면(표본크기: 50), 회귀선의 95% 신뢰구간은 다음과 같이 넓어집니다.


그래프 4)

그리고 독립변수의 범위를 더욱 제한하여, 의 범위가 되게 한다면(표본크기: 50), 회귀선의 95% 신뢰구간은 다음과 같이 변화합니다. 이제 회귀선의 기울기에 대해서 양수인지 음수인지도 정확하지 않네요.


다음 R 소스입니다. 모집단과 표본은 실행할 때마다 다르므로, 결과는 실행할 때마다 다르게 나옵니다. 하지만 독립변수의 범위를 제한함에 따라 추정된 회귀선의 기울기의 분포가 넓어짐을 확인할 수 있습니다.


<R source>

Liner regression_sampling range restriction.R



par(mfcol=c(2,2))



x<-rnorm(500, mean=55, sd=10)

y<-.7*x+rnorm(500,sd=5)

plot(x,y,xlim=c(20,90),ylim=c(0,80), main="Population, sd=10")

mylm<-lm(y~x)

abline(mylm,col="red", lwd=3)

newx<-seq(20,90)

prd<-predict(mylm,newdata=data.frame(x=newx),interval = c("confidence"), 

level = 0.90,type="response")


x_pop=x; y_pop=y;


index<-sample(1:500, 50)

x<-x_pop[index]

y<-y_pop[index]


plot(x,y,xlim=c(20,90),ylim=c(0,80), main="Sampling without range restriction")

mylm<-lm(y~x)

abline(mylm,col="red", lwd=3)

newx<-seq(20,90)

prd<-predict(mylm,newdata=data.frame(x=newx),interval = c("confidence"), 

level = 0.90,type="response")

lines(newx,prd[,2],col="red",lty=2)

lines(newx,prd[,3],col="red",lty=2)


index=which(x_pop>55-2*5 & x_pop<55+2*5)


index<-sample(index, 50)

x<-x_pop[index]

y<-y_pop[index]


plot(x,y,xlim=c(20,90),ylim=c(0,80), , main="Sampling, range : mean+-2*5")

mylm<-lm(y~x)

abline(mylm,col="red", lwd=2)

newx<-seq(20,90)

prd<-predict(mylm,newdata=data.frame(x=newx),interval = c("confidence"), 

level = 0.90,type="response")

lines(newx,prd[,2],col="red",lty=2)

lines(newx,prd[,3],col="red",lty=2)


index=which(x_pop>55-2*1 & x_pop<55+2*1)


index<-sample(index, 50)

x<-x_pop[index]

y<-y_pop[index]


plot(x,y,xlim=c(20,90),ylim=c(0,80), , main="Sampling, range : mean+-2*1")

mylm<-lm(y~x)

abline(mylm,col="red", lwd=1)

newx<-seq(20,90)

prd<-predict(mylm,newdata=data.frame(x=newx),interval = c("confidence"), 

level = 0.90,type="response", lwd=3)

lines(newx,prd[,2],col="red",lty=2)

lines(newx,prd[,3],col="red",lty=2)




공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함