달력

2

« 2025/2 »

  • 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
2018. 5. 30. 23:12

7.4 공부/통계학2018. 5. 30. 23:12

# Industrial Data, P167 lm1 <- lm(Y ~ X, data=P167) plot(P167$X,P167$Y) residuals <- rstandard(lm1) plot(P167$X, residuals) ty<-P167$Y/P167$X tx<-1/P167$X w<-1/P167$X^2 # Transformation lm2<-lm(ty ~ tx) summary(lm2) anova(lm(ty~1),lm2) residuals(lm2) ## weighted residual fitted(lm2) ## weighted fitted value plot(P167$X, rstandard(lm2)) # WLS lm3<-lm(Y ~ X, data=P167, weight=w) summary(lm3) rm<-lm(Y ~ 1, data=P167, weight=w) anova(rm,lm3) residuals(lm3) ## unweighted residual weighted.residuals(lm3) ## weighted residual fitted(lm3) #y_hat,w plot(P167$X, rstandard(lm3)) #Education Expenditure data ## OLS regression result b1<-lm(Y~X1+X2+X3, data=P189) summary(b1) plot(fitted(b1),rstandard(b1)) identify(fitted(b1),rstandard(b1)) ##check influence and leverage plot(influence(b1)$hat) identify(influence(b1)$hat) plot(cooks.distance(b1)) plot(dffits(b1)) ##check heteroskedasticity plot(P189$Region,rstandard(b1)) plot(P189$X1,rstandard(b1)) plot(P189$X2,rstandard(b1)) ## OLS without AK b2<-lm(b1,subset=-c(49)) summary(b2) residuals<-b2$residuals predicted <- fitted(b2) plot(predicted,rstandard(b2)) plot(P189$Region[-49],rstandard(b2)) ## WLS Result without AK s1 <- sum(residuals[(P189$Region==1)]^2)/(9-1) s2 <- sum(residuals[(P189$Region==2)]^2)/(12-1) s3 <- sum(residuals[(P189$Region==3)]^2)/(16-1) s4 <- sum(residuals[(P189$Region==4)]^2, na.rm=TRUE)/(12-1) P189$w[(P189$Region==1)]<-1/s1 P189$w[(P189$Region==2)]<-1/s2 P189$w[(P189$Region==3)]<-1/s3 P189$w[(P189$Region==4)]<-1/s4 P189new<-P189[-49,] b3<-lm(Y~X1+X2+X3,data=P189new,weights=w) summary(b3) predicted<-fitted(b3) residuals<-rstandard(b3) plot(predicted,residuals) plot(P189new$Region,residuals)

'공부 > 통계학' 카테고리의 다른 글

no matches hat  (0) 2018.09.17
fpp2 backcasting  (0) 2018.09.10
Frequentist's C.I   (0) 2018.04.11
문제풀때 쓰는 수식 및 정보   (0) 2018.03.27
베타분포  (0) 2018.03.22
:
Posted by 시스메