download data from here.
modify data like below. use %s/\s/,/g in vi.
2020-12-31,1.342020-09-30,1.582020-06-30,1.452020-03-31,1.222019-12-31,1.21<skip>2005-06-30,0.132005-03-31,0.13
store data into csv file. " ~/nasdaqeps.txt" is used in the sample. change end date accordingly!.
w <- as.xts(read.zoo(read.csv("~/nasdaqeps.txt",header=FALSE)))
ndx_eps <- as.xts(as.vector(na.omit(filter(as.vector(w),rep(1,4)))),seq(as.Date("2005-10-01"),as.Date("2020-10-01"),by='quarters'))
when k2007 is as below.
> k2007
[1] "2007-01-01::2020-12-31"
summary(lm(apply.quarterly(NDX[,4][k2007],mean) ~ ndx_eps[k2007]+apply.quarterly(PA[k2007],mean)+apply.quarterly(UC[k2007],mean)+apply.quarterly(CS[k2007],mean)))
Call:
lm(formula = apply.quarterly(NDX[, 4][k2007], mean) ~ ndx_eps[k2007] +
apply.quarterly(PA[k2007], mean) + apply.quarterly(UC[k2007],
mean) + apply.quarterly(CS[k2007], mean))
Residuals:
Min 1Q Median 3Q Max
-787.4 -293.1 -105.6 106.1 2281.4
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.335e+04 8.966e+02 -14.893 < 2e-16 ***
ndx_eps[k2007] 2.612e+02 7.864e+01 3.321 0.001664 **
apply.quarterly(PA[k2007], mean) 7.181e-01 5.575e-02 12.882 < 2e-16 ***
apply.quarterly(UC[k2007], mean) -2.917e+00 9.409e-01 -3.100 0.003144 **
apply.quarterly(CS[k2007], mean) 4.479e+01 1.096e+01 4.088 0.000154 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 532.2 on 51 degrees of freedom
Multiple R-squared: 0.9611, Adjusted R-squared: 0.958
F-statistic: 314.8 on 4 and 51 DF, p-value: < 2.2e-16
0 件のコメント:
コメントを投稿