###随机游走以及回归 library(TSA) win.graph(width=4.8, height=3,pointsize=10) data(rwalk) plot(rwalk,type='o',ylab='数值',main='随机游走') model1=lm(rwalk~time(rwalk)) summary(model1) abline(model1)
Call: lm(formula = rwalk ~ time(rwalk)) Residuals: Min 1Q Median 3Q Max -2.70045 -0.79782 0.06391 0.63064 2.22128 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.007888 0.297245 -3.391 0.00126 ** time(rwalk) 0.134087 0.008475 15.822 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.137 on 58 degrees of freedom Multiple R-squared: 0.8119, Adjusted R-squared: 0.8086 F-statistic: 250.3 on 1 and 58 DF, p-value: < 2.2e-16