> mdata <-read.table("mm.csv", header=T, sep=",") > topix <-mdata[,1] > a <-mdata[,2] > b <-mdata[,3] > topix <-ts(topix) > a <-ts(a) > y <-diff(a)/lag(a, k=-1)*100 > x <-diff(topix)/lag(topix, k=-1)*100 > x <-as.numeric(x) > y <-as.numeric(y) > ols_result <-lm(y~x) > summary(ols_result) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -2.3307 -0.6262 -0.2243 0.8661 3.1369 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.08355 0.15171 0.551 0.584 x 1.05237 0.10959 9.603 1.15e-13 *** --- Signif. codes: 0 e***f 0.001 e**f 0.01 e*f 0.05 e.f 0.1 e f 1 Residual standard error: 1.182 on 59 degrees of freedom Multiple R-squared: 0.6098, Adjusted R-squared: 0.6032 F-statistic: 92.22 on 1 and 59 DF, p-value: 1.147e-13 > plot(x,y) > abline(ols_result) > mm.conf <- predict(ols_result, interval="confidence", level=0.95) > mm.conf <- as.data.frame(mm.conf) > z <- cbind(x,y, mm.conf) > z <-z[order(z[,1]),] > matplot(z$x, cbind(z$upr,z$fit,z$lwr), type="l", lty=c(1,1,1), lwd=c(2,2,2), col=c("blue", "black","blue"), xlab="X",ylab="Y") > points(z$x, z$y)