R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(106.7,0,110.2,0,125.9,0,100.1,0,106.4,0,114.8,0,81.3,0,87,0,104.2,0,108,0,105,0,94.5,0,92,0,95.9,0,108.8,0,103.4,0,102.1,0,110.1,0,83.2,0,82.7,0,106.8,0,113.7,0,102.5,0,96.6,0,92.1,0,95.6,0,102.3,0,98.6,0,98.2,0,104.5,0,84,0,73.8,0,103.9,0,106,0,97.2,0,102.6,0,89,0,93.8,0,116.7,1,106.8,1,98.5,1,118.7,1,90,1,91.9,1,113.3,1,113.1,1,104.1,1,108.7,1,96.7,1,101,1,116.9,1,105.8,1,99,1,129.4,1,83,1,88.9,1,115.9,1,104.2,1,113.4,1,112.2,1,100.8,1,107.3,1,126.6,1,102.9,1,117.9,1,128.8,1,87.5,1,93.8,1,122.7,1,126.2,1,124.6,1,116.7,1,115.2,1,111.1,1,129.9,1,113.3,1,118.5,1,133.5,1,102.1,1,102.4,1),dim=c(2,80),dimnames=list(c('y','x'),1:80))
> y <- array(NA,dim=c(2,80),dimnames=list(c('y','x'),1:80))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
y x M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 106.7 0 1 0 0 0 0 0 0 0 0 0 0 1
2 110.2 0 0 1 0 0 0 0 0 0 0 0 0 2
3 125.9 0 0 0 1 0 0 0 0 0 0 0 0 3
4 100.1 0 0 0 0 1 0 0 0 0 0 0 0 4
5 106.4 0 0 0 0 0 1 0 0 0 0 0 0 5
6 114.8 0 0 0 0 0 0 1 0 0 0 0 0 6
7 81.3 0 0 0 0 0 0 0 1 0 0 0 0 7
8 87.0 0 0 0 0 0 0 0 0 1 0 0 0 8
9 104.2 0 0 0 0 0 0 0 0 0 1 0 0 9
10 108.0 0 0 0 0 0 0 0 0 0 0 1 0 10
11 105.0 0 0 0 0 0 0 0 0 0 0 0 1 11
12 94.5 0 0 0 0 0 0 0 0 0 0 0 0 12
13 92.0 0 1 0 0 0 0 0 0 0 0 0 0 13
14 95.9 0 0 1 0 0 0 0 0 0 0 0 0 14
15 108.8 0 0 0 1 0 0 0 0 0 0 0 0 15
16 103.4 0 0 0 0 1 0 0 0 0 0 0 0 16
17 102.1 0 0 0 0 0 1 0 0 0 0 0 0 17
18 110.1 0 0 0 0 0 0 1 0 0 0 0 0 18
19 83.2 0 0 0 0 0 0 0 1 0 0 0 0 19
20 82.7 0 0 0 0 0 0 0 0 1 0 0 0 20
21 106.8 0 0 0 0 0 0 0 0 0 1 0 0 21
22 113.7 0 0 0 0 0 0 0 0 0 0 1 0 22
23 102.5 0 0 0 0 0 0 0 0 0 0 0 1 23
24 96.6 0 0 0 0 0 0 0 0 0 0 0 0 24
25 92.1 0 1 0 0 0 0 0 0 0 0 0 0 25
26 95.6 0 0 1 0 0 0 0 0 0 0 0 0 26
27 102.3 0 0 0 1 0 0 0 0 0 0 0 0 27
28 98.6 0 0 0 0 1 0 0 0 0 0 0 0 28
29 98.2 0 0 0 0 0 1 0 0 0 0 0 0 29
30 104.5 0 0 0 0 0 0 1 0 0 0 0 0 30
31 84.0 0 0 0 0 0 0 0 1 0 0 0 0 31
32 73.8 0 0 0 0 0 0 0 0 1 0 0 0 32
33 103.9 0 0 0 0 0 0 0 0 0 1 0 0 33
34 106.0 0 0 0 0 0 0 0 0 0 0 1 0 34
35 97.2 0 0 0 0 0 0 0 0 0 0 0 1 35
36 102.6 0 0 0 0 0 0 0 0 0 0 0 0 36
37 89.0 0 1 0 0 0 0 0 0 0 0 0 0 37
38 93.8 0 0 1 0 0 0 0 0 0 0 0 0 38
39 116.7 1 0 0 1 0 0 0 0 0 0 0 0 39
40 106.8 1 0 0 0 1 0 0 0 0 0 0 0 40
41 98.5 1 0 0 0 0 1 0 0 0 0 0 0 41
42 118.7 1 0 0 0 0 0 1 0 0 0 0 0 42
43 90.0 1 0 0 0 0 0 0 1 0 0 0 0 43
44 91.9 1 0 0 0 0 0 0 0 1 0 0 0 44
45 113.3 1 0 0 0 0 0 0 0 0 1 0 0 45
46 113.1 1 0 0 0 0 0 0 0 0 0 1 0 46
47 104.1 1 0 0 0 0 0 0 0 0 0 0 1 47
48 108.7 1 0 0 0 0 0 0 0 0 0 0 0 48
49 96.7 1 1 0 0 0 0 0 0 0 0 0 0 49
50 101.0 1 0 1 0 0 0 0 0 0 0 0 0 50
51 116.9 1 0 0 1 0 0 0 0 0 0 0 0 51
52 105.8 1 0 0 0 1 0 0 0 0 0 0 0 52
53 99.0 1 0 0 0 0 1 0 0 0 0 0 0 53
54 129.4 1 0 0 0 0 0 1 0 0 0 0 0 54
55 83.0 1 0 0 0 0 0 0 1 0 0 0 0 55
56 88.9 1 0 0 0 0 0 0 0 1 0 0 0 56
57 115.9 1 0 0 0 0 0 0 0 0 1 0 0 57
58 104.2 1 0 0 0 0 0 0 0 0 0 1 0 58
59 113.4 1 0 0 0 0 0 0 0 0 0 0 1 59
60 112.2 1 0 0 0 0 0 0 0 0 0 0 0 60
61 100.8 1 1 0 0 0 0 0 0 0 0 0 0 61
62 107.3 1 0 1 0 0 0 0 0 0 0 0 0 62
63 126.6 1 0 0 1 0 0 0 0 0 0 0 0 63
64 102.9 1 0 0 0 1 0 0 0 0 0 0 0 64
65 117.9 1 0 0 0 0 1 0 0 0 0 0 0 65
66 128.8 1 0 0 0 0 0 1 0 0 0 0 0 66
67 87.5 1 0 0 0 0 0 0 1 0 0 0 0 67
68 93.8 1 0 0 0 0 0 0 0 1 0 0 0 68
69 122.7 1 0 0 0 0 0 0 0 0 1 0 0 69
70 126.2 1 0 0 0 0 0 0 0 0 0 1 0 70
71 124.6 1 0 0 0 0 0 0 0 0 0 0 1 71
72 116.7 1 0 0 0 0 0 0 0 0 0 0 0 72
73 115.2 1 1 0 0 0 0 0 0 0 0 0 0 73
74 111.1 1 0 1 0 0 0 0 0 0 0 0 0 74
75 129.9 1 0 0 1 0 0 0 0 0 0 0 0 75
76 113.3 1 0 0 0 1 0 0 0 0 0 0 0 76
77 118.5 1 0 0 0 0 1 0 0 0 0 0 0 77
78 133.5 1 0 0 0 0 0 1 0 0 0 0 0 78
79 102.1 1 0 0 0 0 0 0 1 0 0 0 0 79
80 102.4 1 0 0 0 0 0 0 0 1 0 0 0 80
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
97.5450 5.5387 -5.3089 -2.2256 12.8950 -0.9646
M5 M6 M7 M8 M9 M10
0.3044 14.3591 -18.4290 -17.2029 6.2668 6.8834
M11 t
2.7001 0.1167
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-12.537024 -3.780446 -0.002976 3.516637 15.109821
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 97.54500 3.11727 31.292 < 2e-16 ***
x 5.53875 2.96945 1.865 0.066593 .
M1 -5.30886 3.66028 -1.450 0.151683
M2 -2.22559 3.65845 -0.608 0.545049
M3 12.89501 3.67702 3.507 0.000821 ***
M4 -0.96456 3.67102 -0.263 0.793561
M5 0.30443 3.66613 0.083 0.934072
M6 14.35914 3.66235 3.921 0.000213 ***
M7 -18.42901 3.65969 -5.036 3.93e-06 ***
M8 -17.20288 3.65816 -4.703 1.35e-05 ***
M9 6.26683 3.79909 1.650 0.103785
M10 6.88344 3.79639 1.813 0.074355 .
M11 2.70005 3.79476 0.712 0.479269
t 0.11672 0.06408 1.822 0.073057 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.572 on 66 degrees of freedom
Multiple R-squared: 0.777, Adjusted R-squared: 0.733
F-statistic: 17.69 on 13 and 66 DF, p-value: < 2.2e-16
> postscript(file="/var/www/html/rcomp/tmp/1rywr1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/251zl1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3ollx1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/46lt41227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5rp7q1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 80
Frequency = 1
1 2 3 4 5 6
14.34714286 14.64714286 15.10982143 3.05267857 7.96696429 2.19553571
7 8 9 10 11 12
1.36696429 5.72410714 -0.66232143 2.40434524 3.47101190 -4.44565476
13 14 15 16 17 18
-1.75351190 -1.05351190 -3.39083333 4.95202381 2.26630952 -3.90511905
19 20 21 22 23 24
1.86630952 0.02345238 0.53702381 6.70369048 -0.42964286 -3.74630952
25 26 27 28 29 30
-3.05416667 -2.75416667 -11.29148810 -1.24863095 -3.03434524 -10.90577381
31 32 33 34 35 36
1.26565476 -10.27720238 -3.76363095 -2.39696429 -7.13029762 0.85303571
37 38 39 40 41 42
-7.55482143 -5.95482143 -3.83089286 0.01196429 -9.67375000 -3.64517857
43 44 45 46 47 48
0.32625000 0.88339286 -1.30303571 -2.23636905 -7.16970238 0.01363095
49 50 51 52 53 54
-6.79422619 -5.69422619 -5.03154762 -2.38869048 -10.57440476 5.65416667
55 56 57 58 59 60
-8.07440476 -3.51726190 -0.10369048 -12.53702381 0.72964286 2.11297619
61 62 63 64 65 66
-4.09488095 -0.79488095 3.26779762 -6.68934524 6.92494048 3.65351190
67 68 69 70 71 72
-4.97505952 -0.01791667 5.29565476 8.06232143 10.52898810 5.21232143
73 74 75 76 77 78
8.90446429 1.60446429 5.16714286 2.31000000 6.12428571 6.95285714
79 80
8.22428571 7.18142857
> postscript(file="/var/www/html/rcomp/tmp/6bh4f1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 80
Frequency = 1
lag(myerror, k = 1) myerror
0 14.34714286 NA
1 14.64714286 14.34714286
2 15.10982143 14.64714286
3 3.05267857 15.10982143
4 7.96696429 3.05267857
5 2.19553571 7.96696429
6 1.36696429 2.19553571
7 5.72410714 1.36696429
8 -0.66232143 5.72410714
9 2.40434524 -0.66232143
10 3.47101190 2.40434524
11 -4.44565476 3.47101190
12 -1.75351190 -4.44565476
13 -1.05351190 -1.75351190
14 -3.39083333 -1.05351190
15 4.95202381 -3.39083333
16 2.26630952 4.95202381
17 -3.90511905 2.26630952
18 1.86630952 -3.90511905
19 0.02345238 1.86630952
20 0.53702381 0.02345238
21 6.70369048 0.53702381
22 -0.42964286 6.70369048
23 -3.74630952 -0.42964286
24 -3.05416667 -3.74630952
25 -2.75416667 -3.05416667
26 -11.29148810 -2.75416667
27 -1.24863095 -11.29148810
28 -3.03434524 -1.24863095
29 -10.90577381 -3.03434524
30 1.26565476 -10.90577381
31 -10.27720238 1.26565476
32 -3.76363095 -10.27720238
33 -2.39696429 -3.76363095
34 -7.13029762 -2.39696429
35 0.85303571 -7.13029762
36 -7.55482143 0.85303571
37 -5.95482143 -7.55482143
38 -3.83089286 -5.95482143
39 0.01196429 -3.83089286
40 -9.67375000 0.01196429
41 -3.64517857 -9.67375000
42 0.32625000 -3.64517857
43 0.88339286 0.32625000
44 -1.30303571 0.88339286
45 -2.23636905 -1.30303571
46 -7.16970238 -2.23636905
47 0.01363095 -7.16970238
48 -6.79422619 0.01363095
49 -5.69422619 -6.79422619
50 -5.03154762 -5.69422619
51 -2.38869048 -5.03154762
52 -10.57440476 -2.38869048
53 5.65416667 -10.57440476
54 -8.07440476 5.65416667
55 -3.51726190 -8.07440476
56 -0.10369048 -3.51726190
57 -12.53702381 -0.10369048
58 0.72964286 -12.53702381
59 2.11297619 0.72964286
60 -4.09488095 2.11297619
61 -0.79488095 -4.09488095
62 3.26779762 -0.79488095
63 -6.68934524 3.26779762
64 6.92494048 -6.68934524
65 3.65351190 6.92494048
66 -4.97505952 3.65351190
67 -0.01791667 -4.97505952
68 5.29565476 -0.01791667
69 8.06232143 5.29565476
70 10.52898810 8.06232143
71 5.21232143 10.52898810
72 8.90446429 5.21232143
73 1.60446429 8.90446429
74 5.16714286 1.60446429
75 2.31000000 5.16714286
76 6.12428571 2.31000000
77 6.95285714 6.12428571
78 8.22428571 6.95285714
79 7.18142857 8.22428571
80 NA 7.18142857
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 14.64714286 14.34714286
[2,] 15.10982143 14.64714286
[3,] 3.05267857 15.10982143
[4,] 7.96696429 3.05267857
[5,] 2.19553571 7.96696429
[6,] 1.36696429 2.19553571
[7,] 5.72410714 1.36696429
[8,] -0.66232143 5.72410714
[9,] 2.40434524 -0.66232143
[10,] 3.47101190 2.40434524
[11,] -4.44565476 3.47101190
[12,] -1.75351190 -4.44565476
[13,] -1.05351190 -1.75351190
[14,] -3.39083333 -1.05351190
[15,] 4.95202381 -3.39083333
[16,] 2.26630952 4.95202381
[17,] -3.90511905 2.26630952
[18,] 1.86630952 -3.90511905
[19,] 0.02345238 1.86630952
[20,] 0.53702381 0.02345238
[21,] 6.70369048 0.53702381
[22,] -0.42964286 6.70369048
[23,] -3.74630952 -0.42964286
[24,] -3.05416667 -3.74630952
[25,] -2.75416667 -3.05416667
[26,] -11.29148810 -2.75416667
[27,] -1.24863095 -11.29148810
[28,] -3.03434524 -1.24863095
[29,] -10.90577381 -3.03434524
[30,] 1.26565476 -10.90577381
[31,] -10.27720238 1.26565476
[32,] -3.76363095 -10.27720238
[33,] -2.39696429 -3.76363095
[34,] -7.13029762 -2.39696429
[35,] 0.85303571 -7.13029762
[36,] -7.55482143 0.85303571
[37,] -5.95482143 -7.55482143
[38,] -3.83089286 -5.95482143
[39,] 0.01196429 -3.83089286
[40,] -9.67375000 0.01196429
[41,] -3.64517857 -9.67375000
[42,] 0.32625000 -3.64517857
[43,] 0.88339286 0.32625000
[44,] -1.30303571 0.88339286
[45,] -2.23636905 -1.30303571
[46,] -7.16970238 -2.23636905
[47,] 0.01363095 -7.16970238
[48,] -6.79422619 0.01363095
[49,] -5.69422619 -6.79422619
[50,] -5.03154762 -5.69422619
[51,] -2.38869048 -5.03154762
[52,] -10.57440476 -2.38869048
[53,] 5.65416667 -10.57440476
[54,] -8.07440476 5.65416667
[55,] -3.51726190 -8.07440476
[56,] -0.10369048 -3.51726190
[57,] -12.53702381 -0.10369048
[58,] 0.72964286 -12.53702381
[59,] 2.11297619 0.72964286
[60,] -4.09488095 2.11297619
[61,] -0.79488095 -4.09488095
[62,] 3.26779762 -0.79488095
[63,] -6.68934524 3.26779762
[64,] 6.92494048 -6.68934524
[65,] 3.65351190 6.92494048
[66,] -4.97505952 3.65351190
[67,] -0.01791667 -4.97505952
[68,] 5.29565476 -0.01791667
[69,] 8.06232143 5.29565476
[70,] 10.52898810 8.06232143
[71,] 5.21232143 10.52898810
[72,] 8.90446429 5.21232143
[73,] 1.60446429 8.90446429
[74,] 5.16714286 1.60446429
[75,] 2.31000000 5.16714286
[76,] 6.12428571 2.31000000
[77,] 6.95285714 6.12428571
[78,] 8.22428571 6.95285714
[79,] 7.18142857 8.22428571
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 14.64714286 14.34714286
2 15.10982143 14.64714286
3 3.05267857 15.10982143
4 7.96696429 3.05267857
5 2.19553571 7.96696429
6 1.36696429 2.19553571
7 5.72410714 1.36696429
8 -0.66232143 5.72410714
9 2.40434524 -0.66232143
10 3.47101190 2.40434524
11 -4.44565476 3.47101190
12 -1.75351190 -4.44565476
13 -1.05351190 -1.75351190
14 -3.39083333 -1.05351190
15 4.95202381 -3.39083333
16 2.26630952 4.95202381
17 -3.90511905 2.26630952
18 1.86630952 -3.90511905
19 0.02345238 1.86630952
20 0.53702381 0.02345238
21 6.70369048 0.53702381
22 -0.42964286 6.70369048
23 -3.74630952 -0.42964286
24 -3.05416667 -3.74630952
25 -2.75416667 -3.05416667
26 -11.29148810 -2.75416667
27 -1.24863095 -11.29148810
28 -3.03434524 -1.24863095
29 -10.90577381 -3.03434524
30 1.26565476 -10.90577381
31 -10.27720238 1.26565476
32 -3.76363095 -10.27720238
33 -2.39696429 -3.76363095
34 -7.13029762 -2.39696429
35 0.85303571 -7.13029762
36 -7.55482143 0.85303571
37 -5.95482143 -7.55482143
38 -3.83089286 -5.95482143
39 0.01196429 -3.83089286
40 -9.67375000 0.01196429
41 -3.64517857 -9.67375000
42 0.32625000 -3.64517857
43 0.88339286 0.32625000
44 -1.30303571 0.88339286
45 -2.23636905 -1.30303571
46 -7.16970238 -2.23636905
47 0.01363095 -7.16970238
48 -6.79422619 0.01363095
49 -5.69422619 -6.79422619
50 -5.03154762 -5.69422619
51 -2.38869048 -5.03154762
52 -10.57440476 -2.38869048
53 5.65416667 -10.57440476
54 -8.07440476 5.65416667
55 -3.51726190 -8.07440476
56 -0.10369048 -3.51726190
57 -12.53702381 -0.10369048
58 0.72964286 -12.53702381
59 2.11297619 0.72964286
60 -4.09488095 2.11297619
61 -0.79488095 -4.09488095
62 3.26779762 -0.79488095
63 -6.68934524 3.26779762
64 6.92494048 -6.68934524
65 3.65351190 6.92494048
66 -4.97505952 3.65351190
67 -0.01791667 -4.97505952
68 5.29565476 -0.01791667
69 8.06232143 5.29565476
70 10.52898810 8.06232143
71 5.21232143 10.52898810
72 8.90446429 5.21232143
73 1.60446429 8.90446429
74 5.16714286 1.60446429
75 2.31000000 5.16714286
76 6.12428571 2.31000000
77 6.95285714 6.12428571
78 8.22428571 6.95285714
79 7.18142857 8.22428571
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7q4ax1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/83zjp1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9uboy1227973425.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/10jnvo1227973425.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11fmpd1227973425.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/12v2rj1227973425.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/130coe1227973425.tab")
>
> system("convert tmp/1rywr1227973425.ps tmp/1rywr1227973425.png")
> system("convert tmp/251zl1227973425.ps tmp/251zl1227973425.png")
> system("convert tmp/3ollx1227973425.ps tmp/3ollx1227973425.png")
> system("convert tmp/46lt41227973425.ps tmp/46lt41227973425.png")
> system("convert tmp/5rp7q1227973425.ps tmp/5rp7q1227973425.png")
> system("convert tmp/6bh4f1227973425.ps tmp/6bh4f1227973425.png")
> system("convert tmp/7q4ax1227973425.ps tmp/7q4ax1227973425.png")
> system("convert tmp/83zjp1227973425.ps tmp/83zjp1227973425.png")
> system("convert tmp/9uboy1227973425.ps tmp/9uboy1227973425.png")
>
>
> proc.time()
user system elapsed
2.031 1.458 2.520