単位根をもつデータで回帰分析を行うと見せかけの回帰が発生することがあるとのことで
前期レポート(可処分所得と牛肉・豚肉消費量の回帰分析)はどうだったんだろう?と。
> zai=read.csv("上級財と下級財.csv")
> zai
year shotoku ushi buta
1 2000 474411 26152 21728
2 2001 466003 21157 22396
3 2002 453716 19982 23434
4 2003 440667 21374 21858
5 2004 446288 20918 23362
6 2005 441156 21324 23191
7 2006 441448 20705 23249
8 2007 442504 20868 23923
9 2008 442749 20885 25555
10 2009 427912 20167 24791
11 2010 429967 18964 23957
> adf.test(zai$ushi)
Augmented Dickey-Fuller Test
data: zai$ushi
Dickey-Fuller = 0.49819, Lag order = 2, p-value = 0.99
alternative hypothesis: stationary
Warning message:
In adf.test(zai$ushi) : p-value greater than printed p-value
> adf.test(zai$buta)
Augmented Dickey-Fuller Test
data: zai$buta
Dickey-Fuller = -2.1133, Lag order = 2, p-value = 0.5292
alternative hypothesis: stationary
> adf.test(zai$shotoku)
Augmented Dickey-Fuller Test
data: zai$shotoku
Dickey-Fuller = -2.9715, Lag order = 2, p-value = 0.2023
alternative hypothesis: stationary
> attach(zai)
> tzai=ts(data.frame(shotoku,ushi),start=c(2000),frequency=1)
> tzai.vecm<-ca.jo(tzai,ecdet="none",type="eigen",K=2,spec="longrun")
> summary(tzai.vecm)
######################
# Johansen-Procedure #
######################
Test type: maximal eigenvalue statistic (lambda max) , with linear trend
Eigenvalues (lambda):
[1] 0.978205232 0.006646841
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 0.06 6.50 8.18 11.65
r = 0 | 34.43 12.91 14.90 19.19
Eigenvectors, normalised to first column:
(These are the cointegration relations)
shotoku.l2 ushi.l2
shotoku.l2 1.00000 1.00000
ushi.l2 -14.70265 14.88364
Weights W:
(This is the loading matrix)
shotoku.l2 ushi.l2
shotoku.d -0.50176474 -0.034212011
ushi.d 0.09580659 -0.002062248
こちらも単位根ありですが、可処分所得と牛肉消費量では共和分ランク1となりました。
> tzai.vec2var<-vec2var(tzai.vecm,r=1)
> print(tzai.vec2var)
Coefficient matrix of lagged endogenous variables:
A1:
shotoku.l1 ushi.l1
shotoku 0.2629252 7.4695378
ushi 0.1215143 0.1326964
A2:
shotoku.l2 ushi.l2
shotoku 0.23531008 -0.09226474
ushi -0.02570774 -0.54130746
Coefficient matrix of deterministic regressor(s).
constant
shotoku 64389.54
ushi -13030.31
> tzai.prd<-predict(tzai.vec2var,n.ahead=5,ci=0.95)
> plot(tzai.prd)

> tzai.irf<-irf(tzai.vec2var,n.ahead=5,ci=0.95)
> plot(tzai.irf)
Hit to see next plot:


一通り結果は出たけど、「可処分所得↑⇒牛肉消費量↑」なのかはわからず・・・
Granger因果性検定をかけようとしたらエラーになりました。変数の型が違うのかも
続きはもう明日にします。
前期レポート(可処分所得と牛肉・豚肉消費量の回帰分析)はどうだったんだろう?と。
> zai=read.csv("上級財と下級財.csv")
> zai
year shotoku ushi buta
1 2000 474411 26152 21728
2 2001 466003 21157 22396
3 2002 453716 19982 23434
4 2003 440667 21374 21858
5 2004 446288 20918 23362
6 2005 441156 21324 23191
7 2006 441448 20705 23249
8 2007 442504 20868 23923
9 2008 442749 20885 25555
10 2009 427912 20167 24791
11 2010 429967 18964 23957
> adf.test(zai$ushi)
Augmented Dickey-Fuller Test
data: zai$ushi
Dickey-Fuller = 0.49819, Lag order = 2, p-value = 0.99
alternative hypothesis: stationary
Warning message:
In adf.test(zai$ushi) : p-value greater than printed p-value
> adf.test(zai$buta)
Augmented Dickey-Fuller Test
data: zai$buta
Dickey-Fuller = -2.1133, Lag order = 2, p-value = 0.5292
alternative hypothesis: stationary
> adf.test(zai$shotoku)
Augmented Dickey-Fuller Test
data: zai$shotoku
Dickey-Fuller = -2.9715, Lag order = 2, p-value = 0.2023
alternative hypothesis: stationary
> attach(zai)
> tzai=ts(data.frame(shotoku,ushi),start=c(2000),frequency=1)
> tzai.vecm<-ca.jo(tzai,ecdet="none",type="eigen",K=2,spec="longrun")
> summary(tzai.vecm)
######################
# Johansen-Procedure #
######################
Test type: maximal eigenvalue statistic (lambda max) , with linear trend
Eigenvalues (lambda):
[1] 0.978205232 0.006646841
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 0.06 6.50 8.18 11.65
r = 0 | 34.43 12.91 14.90 19.19
Eigenvectors, normalised to first column:
(These are the cointegration relations)
shotoku.l2 ushi.l2
shotoku.l2 1.00000 1.00000
ushi.l2 -14.70265 14.88364
Weights W:
(This is the loading matrix)
shotoku.l2 ushi.l2
shotoku.d -0.50176474 -0.034212011
ushi.d 0.09580659 -0.002062248
こちらも単位根ありですが、可処分所得と牛肉消費量では共和分ランク1となりました。
> tzai.vec2var<-vec2var(tzai.vecm,r=1)
> print(tzai.vec2var)
Coefficient matrix of lagged endogenous variables:
A1:
shotoku.l1 ushi.l1
shotoku 0.2629252 7.4695378
ushi 0.1215143 0.1326964
A2:
shotoku.l2 ushi.l2
shotoku 0.23531008 -0.09226474
ushi -0.02570774 -0.54130746
Coefficient matrix of deterministic regressor(s).
constant
shotoku 64389.54
ushi -13030.31
> tzai.prd<-predict(tzai.vec2var,n.ahead=5,ci=0.95)
> plot(tzai.prd)

> tzai.irf<-irf(tzai.vec2var,n.ahead=5,ci=0.95)
> plot(tzai.irf)
Hit


一通り結果は出たけど、「可処分所得↑⇒牛肉消費量↑」なのかはわからず・・・
Granger因果性検定をかけようとしたらエラーになりました。変数の型が違うのかも
続きはもう明日にします。