• 검색 결과가 없습니다.

R 자기상관

N/A
N/A
Protected

Academic year: 2021

Share "R 자기상관"

Copied!
4
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

R 자기상관 1

I. 자기상관 검정

II. 자기상관 추정

(2)

Ⅰ. 자기상관 검정 2

b2-ch5-1-rev.R

library(stargazer);library(lmtest);library(orcutt)

sample1<-("http://kanggc.iptime.org/book/data/ar.txt") sample1_dat<-read.delim(sample1,header=T)

consume<-ts(sample1_dat$consume, start=c(1995.1), freq uency=4)

gdp<-ts(sample1_dat$gdp, start=c(1995.1), frequency=4) ols.res<-lm(consume~gdp)

summary(ols.res) res<-resid(ols.res)

lres<-append(res[1:24], 0, after=0) res.t<-ts(res)

lres.t<-ts(append(res.t[1:24], 0, after=0))

plot(res,main="Residual plotting(u(t) vs. time)",xlab='time') plot(lres,res,main="Residual plotting(u(t) vs. u(t-1))") abline(h=0, v=0)

다음에 계속

1. 그래프

(3)

3

b2-ch5-1-rev.R

앞에서 계속

#DW test dwtest(ols.res)

#LM test n<-length(res)

lres.t<-ts(append(res.t[1:24], 0 , after=0))

(res.aux<-lm(res.t~gdp+lres.t)) lm<-n*summary(res.aux)$r.squ ared

lm

(pchisq(lm, df=1, lower.tail=F) library(tigerstats)

par(mfrow=c(3,1))

pchisqGC(3.841459, df=1, regio n="above", graph=T)

pchisqGC(2.705543, df=1, regio n="above", graph=T)

pchisqGC(3.122012, df=1, regio n="above", graph=T)

- DW 통계량 1.2273이 𝑫𝑳=1.288보다 작으므로 양(+)의 1차 자기상관이 있 는 것으로 나타남

- DW 통계량 1.2273의 p-value가 0.01178로 0.05보다 작으므로 5% 유의수 준에서 귀무가설 즉, 자기상관이 없다는 귀무가설을 기각하고, 대립가설 즉, 양(+)의 1차 자기상관이 있다는 대립가설을 허용

2. DW 검정 및 LM 검정

- LM 통계량 의 값이 3.122012이고, 𝝌𝟐-분포에서 계산된 LM 통계량의 유의확률이 0.07724137이므로 10% 유의수준에서 1차 자기상관이 있는 것으로 결정

(4)

Ⅱ. 자기상관 추정 4

b2-ch5-2.R

library(stargazer);library(lmtest);library(orcutt)

sample1<-("http://kanggc.iptime.org/book/data/ar.txt") sample1_dat<-read.delim(sample1,header=T)

consume<-ts(sample1_dat$consume, start=c(1995.1), freq uency=4)

gdp<-ts(sample1_dat$gdp, start=c(1995.1), frequency=4)

ols.res<-lm(consume~gdp) summary(ols.res)

res<-resid(ols.res) res.t<-ts(res)

#Cochrane-Orcutt estimation coch.res<-cochrane.orcutt(ols.res) coch.res

#GLS estimation

tconsume<-consume[2:25]-0.357123*consume[1:24]

tgdp<-gdp[2:25]-0.357123*gdp[1:24]

gls.res<-lm(tconsume~tgdp) summary(gls.res)

stargazer(coch.res, gls.res, type="text")

참조

관련 문서

 authors와 books를 authors의 surname 값과 books의 name 값이 같은 자료를 한 행으로 하여 합친다... 사용예를

따라서, X1은 중요한 변수이므로 분석에서 제외하지

 식료품 이분산 Breusch-Pagan test 검정 / Eviews output (1차항 이분산과 관련되는 경우). 8.2 이분산이 OLS

• 이론가설 수립 à 자료 수집à모델 설정 à통계분 석을 통해 모델의 적합성과 타당성 검정 à 회귀계 수 산출 à 모수 추정.. • 모델의

ㅇ 산업수요 맞춤형 고등학교 또는 특성화고등학교 과정 , 해양수산계의 대학 또는 전문대학의 전파전자통신기능사 과정 , 일반계 고등학교의 직업과정 ,

모분산이 알려진 경우와 모르는 경우에 대한 모평균의 구간 추정과 두 모집단의 평균의 차에 대한 구간추정하는 방법에 대하여 알아본다. 모분산이 알려진 경우와

– 데이터 마이닝 기법은 통계학에서 발전한 탐색적자료분석, 가설 검정, 다변량 분석, 시계열 분석, 일반선형모형 등의 방법론과 데이터베이스 측면에서 발전한

정규분포를 이루지만 모집단의 분산을 모르는 경우 표본의 크기 가 작을 때에는 t 검정을 이용하여 두 표본 평균간의 차에 대한 유 의성을 검정.. 서로