R version 2.6.0 (2007-10-03)
Copyright (C) 2007 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.
Natural language support but running in an English locale
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(99.5,0,101.6,0,103.9,0,106.6,0,108.3,0,102,0,93.8,0,91.6,0,97.7,0,94.8,0,98,0,103.8,0,97.8,0,91.2,0,89.3,0,87.5,0,90.4,0,94.2,0,102.2,0,101.3,0,96,0,90.8,0,93.2,0,90.9,0,91.1,0,90.2,0,94.3,0,96,0,99,0,103.3,0,113.1,0,112.8,0,112.1,0,107.4,0,111,0,110.5,0,110.8,0,112.4,0,111.5,0,116.2,0,122.5,0,121.3,0,113.9,0,110.7,0,120.8,0,141.1,1,147.4,1,148,1,158.1,1,165,1,187,1,190.3,1,182.4,1,168.8,1,151.2,1,120.1,1,112.5,1,106.2,1,107.1,1,108.5,1,106.5,1,108.3,1,125.6,1,124,1,127.2,1,136.9,1,135.8,1,124.3,1,115.4,1,113.6,1,114.4,1,118.4,1,117,1,116.5,1,115.4,1,113.6,1,117.4,1,116.9,1,116.4,1,111.1,1,110.2,1,118.9,1,131.8,1,130.6,1,138.3,1,148.4,1,148.7,1,144.3,1,152.5,1,162.9,1,167.2,1,166.5,1,185.6,1),dim=c(2,93),dimnames=list(c('Y','x'),1:93))
> y <- array(NA,dim=c(2,93),dimnames=list(c('Y','x'),1:93))
> 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 99.5 0 1 0 0 0 0 0 0 0 0 0 0 1
2 101.6 0 0 1 0 0 0 0 0 0 0 0 0 2
3 103.9 0 0 0 1 0 0 0 0 0 0 0 0 3
4 106.6 0 0 0 0 1 0 0 0 0 0 0 0 4
5 108.3 0 0 0 0 0 1 0 0 0 0 0 0 5
6 102.0 0 0 0 0 0 0 1 0 0 0 0 0 6
7 93.8 0 0 0 0 0 0 0 1 0 0 0 0 7
8 91.6 0 0 0 0 0 0 0 0 1 0 0 0 8
9 97.7 0 0 0 0 0 0 0 0 0 1 0 0 9
10 94.8 0 0 0 0 0 0 0 0 0 0 1 0 10
11 98.0 0 0 0 0 0 0 0 0 0 0 0 1 11
12 103.8 0 0 0 0 0 0 0 0 0 0 0 0 12
13 97.8 0 1 0 0 0 0 0 0 0 0 0 0 13
14 91.2 0 0 1 0 0 0 0 0 0 0 0 0 14
15 89.3 0 0 0 1 0 0 0 0 0 0 0 0 15
16 87.5 0 0 0 0 1 0 0 0 0 0 0 0 16
17 90.4 0 0 0 0 0 1 0 0 0 0 0 0 17
18 94.2 0 0 0 0 0 0 1 0 0 0 0 0 18
19 102.2 0 0 0 0 0 0 0 1 0 0 0 0 19
20 101.3 0 0 0 0 0 0 0 0 1 0 0 0 20
21 96.0 0 0 0 0 0 0 0 0 0 1 0 0 21
22 90.8 0 0 0 0 0 0 0 0 0 0 1 0 22
23 93.2 0 0 0 0 0 0 0 0 0 0 0 1 23
24 90.9 0 0 0 0 0 0 0 0 0 0 0 0 24
25 91.1 0 1 0 0 0 0 0 0 0 0 0 0 25
26 90.2 0 0 1 0 0 0 0 0 0 0 0 0 26
27 94.3 0 0 0 1 0 0 0 0 0 0 0 0 27
28 96.0 0 0 0 0 1 0 0 0 0 0 0 0 28
29 99.0 0 0 0 0 0 1 0 0 0 0 0 0 29
30 103.3 0 0 0 0 0 0 1 0 0 0 0 0 30
31 113.1 0 0 0 0 0 0 0 1 0 0 0 0 31
32 112.8 0 0 0 0 0 0 0 0 1 0 0 0 32
33 112.1 0 0 0 0 0 0 0 0 0 1 0 0 33
34 107.4 0 0 0 0 0 0 0 0 0 0 1 0 34
35 111.0 0 0 0 0 0 0 0 0 0 0 0 1 35
36 110.5 0 0 0 0 0 0 0 0 0 0 0 0 36
37 110.8 0 1 0 0 0 0 0 0 0 0 0 0 37
38 112.4 0 0 1 0 0 0 0 0 0 0 0 0 38
39 111.5 0 0 0 1 0 0 0 0 0 0 0 0 39
40 116.2 0 0 0 0 1 0 0 0 0 0 0 0 40
41 122.5 0 0 0 0 0 1 0 0 0 0 0 0 41
42 121.3 0 0 0 0 0 0 1 0 0 0 0 0 42
43 113.9 0 0 0 0 0 0 0 1 0 0 0 0 43
44 110.7 0 0 0 0 0 0 0 0 1 0 0 0 44
45 120.8 0 0 0 0 0 0 0 0 0 1 0 0 45
46 141.1 1 0 0 0 0 0 0 0 0 0 1 0 46
47 147.4 1 0 0 0 0 0 0 0 0 0 0 1 47
48 148.0 1 0 0 0 0 0 0 0 0 0 0 0 48
49 158.1 1 1 0 0 0 0 0 0 0 0 0 0 49
50 165.0 1 0 1 0 0 0 0 0 0 0 0 0 50
51 187.0 1 0 0 1 0 0 0 0 0 0 0 0 51
52 190.3 1 0 0 0 1 0 0 0 0 0 0 0 52
53 182.4 1 0 0 0 0 1 0 0 0 0 0 0 53
54 168.8 1 0 0 0 0 0 1 0 0 0 0 0 54
55 151.2 1 0 0 0 0 0 0 1 0 0 0 0 55
56 120.1 1 0 0 0 0 0 0 0 1 0 0 0 56
57 112.5 1 0 0 0 0 0 0 0 0 1 0 0 57
58 106.2 1 0 0 0 0 0 0 0 0 0 1 0 58
59 107.1 1 0 0 0 0 0 0 0 0 0 0 1 59
60 108.5 1 0 0 0 0 0 0 0 0 0 0 0 60
61 106.5 1 1 0 0 0 0 0 0 0 0 0 0 61
62 108.3 1 0 1 0 0 0 0 0 0 0 0 0 62
63 125.6 1 0 0 1 0 0 0 0 0 0 0 0 63
64 124.0 1 0 0 0 1 0 0 0 0 0 0 0 64
65 127.2 1 0 0 0 0 1 0 0 0 0 0 0 65
66 136.9 1 0 0 0 0 0 1 0 0 0 0 0 66
67 135.8 1 0 0 0 0 0 0 1 0 0 0 0 67
68 124.3 1 0 0 0 0 0 0 0 1 0 0 0 68
69 115.4 1 0 0 0 0 0 0 0 0 1 0 0 69
70 113.6 1 0 0 0 0 0 0 0 0 0 1 0 70
71 114.4 1 0 0 0 0 0 0 0 0 0 0 1 71
72 118.4 1 0 0 0 0 0 0 0 0 0 0 0 72
73 117.0 1 1 0 0 0 0 0 0 0 0 0 0 73
74 116.5 1 0 1 0 0 0 0 0 0 0 0 0 74
75 115.4 1 0 0 1 0 0 0 0 0 0 0 0 75
76 113.6 1 0 0 0 1 0 0 0 0 0 0 0 76
77 117.4 1 0 0 0 0 1 0 0 0 0 0 0 77
78 116.9 1 0 0 0 0 0 1 0 0 0 0 0 78
79 116.4 1 0 0 0 0 0 0 1 0 0 0 0 79
80 111.1 1 0 0 0 0 0 0 0 1 0 0 0 80
81 110.2 1 0 0 0 0 0 0 0 0 1 0 0 81
82 118.9 1 0 0 0 0 0 0 0 0 0 1 0 82
83 131.8 1 0 0 0 0 0 0 0 0 0 0 1 83
84 130.6 1 0 0 0 0 0 0 0 0 0 0 0 84
85 138.3 1 1 0 0 0 0 0 0 0 0 0 0 85
86 148.4 1 0 1 0 0 0 0 0 0 0 0 0 86
87 148.7 1 0 0 1 0 0 0 0 0 0 0 0 87
88 144.3 1 0 0 0 1 0 0 0 0 0 0 0 88
89 152.5 1 0 0 0 0 1 0 0 0 0 0 0 89
90 162.9 1 0 0 0 0 0 1 0 0 0 0 0 90
91 167.2 1 0 0 0 0 0 0 1 0 0 0 0 91
92 166.5 1 0 0 0 0 0 0 0 1 0 0 0 92
93 185.6 1 0 0 0 0 0 0 0 0 1 0 0 93
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
94.5481 27.6650 1.6178 3.3166 8.4654 8.7017
M5 M6 M7 M8 M9 M10
11.2380 11.9493 10.2481 3.2344 4.6082 -5.1869
M11 t
-1.0006 0.1137
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-26.131 -12.242 -1.164 10.027 53.473
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 94.5481 8.2656 11.439 < 2e-16 ***
x 27.6650 8.1091 3.412 0.00102 **
M1 1.6178 9.9481 0.163 0.87123
M2 3.3166 9.9454 0.333 0.73966
M3 8.4654 9.9450 0.851 0.39722
M4 8.7017 9.9470 0.875 0.38433
M5 11.2380 9.9512 1.129 0.26218
M6 11.9493 9.9577 1.200 0.23372
M7 10.2481 9.9665 1.028 0.30697
M8 3.2344 9.9776 0.324 0.74667
M9 4.6082 9.9909 0.461 0.64590
M10 -5.1869 10.2713 -0.505 0.61497
M11 -1.0006 10.2680 -0.097 0.92262
t 0.1137 0.1512 0.752 0.45443
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 19.21 on 79 degrees of freedom
Multiple R-Squared: 0.4838, Adjusted R-squared: 0.3988
F-statistic: 5.694 on 13 and 79 DF, p-value: 3.150e-07
> postscript(file="/var/www/html/rcomp/tmp/1c9gq1195513030.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/28mn61195513030.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/3kcdr1195513030.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/40vv21195513030.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/55ijy1195513030.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 = 93
Frequency = 1
1 2 3 4 5 6
3.2203704 3.5078704 0.5453704 2.8953704 1.9453704 -5.1796296
7 8 9 10 11 12
-11.7921296 -7.0921296 -2.4796296 4.3017526 3.2017526 7.8874669
13 14 15 16 17 18
0.1559854 -8.2565146 -15.4190146 -17.5690146 -17.3190146 -14.3440146
19 20 21 22 23 24
-4.7565146 1.2434854 -5.5440146 -1.0626323 -2.9626323 -6.3769180
25 26 27 28 29 30
-7.9083995 -10.6208995 -11.7833995 -10.4333995 -10.0833995 -6.6083995
31 32 33 34 35 36
4.7791005 11.3791005 9.1916005 14.1729828 13.4729828 11.8586971
37 38 39 40 41 42
10.4272156 10.2147156 4.0522156 8.4022156 12.0522156 10.0272156
43 44 45 46 47 48
4.2147156 7.9147156 16.5272156 18.8435516 20.8435516 20.3292659
49 50 51 52 53 54
28.6977844 33.7852844 50.5227844 53.4727844 42.9227844 28.4977844
55 56 57 58 59 60
12.4852844 -11.7147156 -20.8022156 -17.4208333 -20.8208333 -20.5351190
61 62 63 64 65 66
-24.2666005 -24.2791005 -12.2416005 -14.1916005 -13.6416005 -4.7666005
67 68 69 70 71 72
-4.2791005 -8.8791005 -19.2666005 -11.3852183 -14.8852183 -11.9995040
73 74 75 76 77 78
-15.1309854 -17.4434854 -23.8059854 -25.9559854 -24.8059854 -26.1309854
79 80 81 82 83 84
-25.0434854 -23.4434854 -25.8309854 -7.4496032 1.1503968 -1.1638889
85 86 87 88 89 90
4.8046296 13.0921296 8.1296296 3.3796296 8.9296296 18.5046296
91 92 93
24.3921296 30.5921296 48.2046296
> postscript(file="/var/www/html/rcomp/tmp/617py1195513030.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 = 93
Frequency = 1
lag(myerror, k = 1) myerror
0 3.2203704 NA
1 3.5078704 3.2203704
2 0.5453704 3.5078704
3 2.8953704 0.5453704
4 1.9453704 2.8953704
5 -5.1796296 1.9453704
6 -11.7921296 -5.1796296
7 -7.0921296 -11.7921296
8 -2.4796296 -7.0921296
9 4.3017526 -2.4796296
10 3.2017526 4.3017526
11 7.8874669 3.2017526
12 0.1559854 7.8874669
13 -8.2565146 0.1559854
14 -15.4190146 -8.2565146
15 -17.5690146 -15.4190146
16 -17.3190146 -17.5690146
17 -14.3440146 -17.3190146
18 -4.7565146 -14.3440146
19 1.2434854 -4.7565146
20 -5.5440146 1.2434854
21 -1.0626323 -5.5440146
22 -2.9626323 -1.0626323
23 -6.3769180 -2.9626323
24 -7.9083995 -6.3769180
25 -10.6208995 -7.9083995
26 -11.7833995 -10.6208995
27 -10.4333995 -11.7833995
28 -10.0833995 -10.4333995
29 -6.6083995 -10.0833995
30 4.7791005 -6.6083995
31 11.3791005 4.7791005
32 9.1916005 11.3791005
33 14.1729828 9.1916005
34 13.4729828 14.1729828
35 11.8586971 13.4729828
36 10.4272156 11.8586971
37 10.2147156 10.4272156
38 4.0522156 10.2147156
39 8.4022156 4.0522156
40 12.0522156 8.4022156
41 10.0272156 12.0522156
42 4.2147156 10.0272156
43 7.9147156 4.2147156
44 16.5272156 7.9147156
45 18.8435516 16.5272156
46 20.8435516 18.8435516
47 20.3292659 20.8435516
48 28.6977844 20.3292659
49 33.7852844 28.6977844
50 50.5227844 33.7852844
51 53.4727844 50.5227844
52 42.9227844 53.4727844
53 28.4977844 42.9227844
54 12.4852844 28.4977844
55 -11.7147156 12.4852844
56 -20.8022156 -11.7147156
57 -17.4208333 -20.8022156
58 -20.8208333 -17.4208333
59 -20.5351190 -20.8208333
60 -24.2666005 -20.5351190
61 -24.2791005 -24.2666005
62 -12.2416005 -24.2791005
63 -14.1916005 -12.2416005
64 -13.6416005 -14.1916005
65 -4.7666005 -13.6416005
66 -4.2791005 -4.7666005
67 -8.8791005 -4.2791005
68 -19.2666005 -8.8791005
69 -11.3852183 -19.2666005
70 -14.8852183 -11.3852183
71 -11.9995040 -14.8852183
72 -15.1309854 -11.9995040
73 -17.4434854 -15.1309854
74 -23.8059854 -17.4434854
75 -25.9559854 -23.8059854
76 -24.8059854 -25.9559854
77 -26.1309854 -24.8059854
78 -25.0434854 -26.1309854
79 -23.4434854 -25.0434854
80 -25.8309854 -23.4434854
81 -7.4496032 -25.8309854
82 1.1503968 -7.4496032
83 -1.1638889 1.1503968
84 4.8046296 -1.1638889
85 13.0921296 4.8046296
86 8.1296296 13.0921296
87 3.3796296 8.1296296
88 8.9296296 3.3796296
89 18.5046296 8.9296296
90 24.3921296 18.5046296
91 30.5921296 24.3921296
92 48.2046296 30.5921296
93 NA 48.2046296
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3.5078704 3.2203704
[2,] 0.5453704 3.5078704
[3,] 2.8953704 0.5453704
[4,] 1.9453704 2.8953704
[5,] -5.1796296 1.9453704
[6,] -11.7921296 -5.1796296
[7,] -7.0921296 -11.7921296
[8,] -2.4796296 -7.0921296
[9,] 4.3017526 -2.4796296
[10,] 3.2017526 4.3017526
[11,] 7.8874669 3.2017526
[12,] 0.1559854 7.8874669
[13,] -8.2565146 0.1559854
[14,] -15.4190146 -8.2565146
[15,] -17.5690146 -15.4190146
[16,] -17.3190146 -17.5690146
[17,] -14.3440146 -17.3190146
[18,] -4.7565146 -14.3440146
[19,] 1.2434854 -4.7565146
[20,] -5.5440146 1.2434854
[21,] -1.0626323 -5.5440146
[22,] -2.9626323 -1.0626323
[23,] -6.3769180 -2.9626323
[24,] -7.9083995 -6.3769180
[25,] -10.6208995 -7.9083995
[26,] -11.7833995 -10.6208995
[27,] -10.4333995 -11.7833995
[28,] -10.0833995 -10.4333995
[29,] -6.6083995 -10.0833995
[30,] 4.7791005 -6.6083995
[31,] 11.3791005 4.7791005
[32,] 9.1916005 11.3791005
[33,] 14.1729828 9.1916005
[34,] 13.4729828 14.1729828
[35,] 11.8586971 13.4729828
[36,] 10.4272156 11.8586971
[37,] 10.2147156 10.4272156
[38,] 4.0522156 10.2147156
[39,] 8.4022156 4.0522156
[40,] 12.0522156 8.4022156
[41,] 10.0272156 12.0522156
[42,] 4.2147156 10.0272156
[43,] 7.9147156 4.2147156
[44,] 16.5272156 7.9147156
[45,] 18.8435516 16.5272156
[46,] 20.8435516 18.8435516
[47,] 20.3292659 20.8435516
[48,] 28.6977844 20.3292659
[49,] 33.7852844 28.6977844
[50,] 50.5227844 33.7852844
[51,] 53.4727844 50.5227844
[52,] 42.9227844 53.4727844
[53,] 28.4977844 42.9227844
[54,] 12.4852844 28.4977844
[55,] -11.7147156 12.4852844
[56,] -20.8022156 -11.7147156
[57,] -17.4208333 -20.8022156
[58,] -20.8208333 -17.4208333
[59,] -20.5351190 -20.8208333
[60,] -24.2666005 -20.5351190
[61,] -24.2791005 -24.2666005
[62,] -12.2416005 -24.2791005
[63,] -14.1916005 -12.2416005
[64,] -13.6416005 -14.1916005
[65,] -4.7666005 -13.6416005
[66,] -4.2791005 -4.7666005
[67,] -8.8791005 -4.2791005
[68,] -19.2666005 -8.8791005
[69,] -11.3852183 -19.2666005
[70,] -14.8852183 -11.3852183
[71,] -11.9995040 -14.8852183
[72,] -15.1309854 -11.9995040
[73,] -17.4434854 -15.1309854
[74,] -23.8059854 -17.4434854
[75,] -25.9559854 -23.8059854
[76,] -24.8059854 -25.9559854
[77,] -26.1309854 -24.8059854
[78,] -25.0434854 -26.1309854
[79,] -23.4434854 -25.0434854
[80,] -25.8309854 -23.4434854
[81,] -7.4496032 -25.8309854
[82,] 1.1503968 -7.4496032
[83,] -1.1638889 1.1503968
[84,] 4.8046296 -1.1638889
[85,] 13.0921296 4.8046296
[86,] 8.1296296 13.0921296
[87,] 3.3796296 8.1296296
[88,] 8.9296296 3.3796296
[89,] 18.5046296 8.9296296
[90,] 24.3921296 18.5046296
[91,] 30.5921296 24.3921296
[92,] 48.2046296 30.5921296
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3.5078704 3.2203704
2 0.5453704 3.5078704
3 2.8953704 0.5453704
4 1.9453704 2.8953704
5 -5.1796296 1.9453704
6 -11.7921296 -5.1796296
7 -7.0921296 -11.7921296
8 -2.4796296 -7.0921296
9 4.3017526 -2.4796296
10 3.2017526 4.3017526
11 7.8874669 3.2017526
12 0.1559854 7.8874669
13 -8.2565146 0.1559854
14 -15.4190146 -8.2565146
15 -17.5690146 -15.4190146
16 -17.3190146 -17.5690146
17 -14.3440146 -17.3190146
18 -4.7565146 -14.3440146
19 1.2434854 -4.7565146
20 -5.5440146 1.2434854
21 -1.0626323 -5.5440146
22 -2.9626323 -1.0626323
23 -6.3769180 -2.9626323
24 -7.9083995 -6.3769180
25 -10.6208995 -7.9083995
26 -11.7833995 -10.6208995
27 -10.4333995 -11.7833995
28 -10.0833995 -10.4333995
29 -6.6083995 -10.0833995
30 4.7791005 -6.6083995
31 11.3791005 4.7791005
32 9.1916005 11.3791005
33 14.1729828 9.1916005
34 13.4729828 14.1729828
35 11.8586971 13.4729828
36 10.4272156 11.8586971
37 10.2147156 10.4272156
38 4.0522156 10.2147156
39 8.4022156 4.0522156
40 12.0522156 8.4022156
41 10.0272156 12.0522156
42 4.2147156 10.0272156
43 7.9147156 4.2147156
44 16.5272156 7.9147156
45 18.8435516 16.5272156
46 20.8435516 18.8435516
47 20.3292659 20.8435516
48 28.6977844 20.3292659
49 33.7852844 28.6977844
50 50.5227844 33.7852844
51 53.4727844 50.5227844
52 42.9227844 53.4727844
53 28.4977844 42.9227844
54 12.4852844 28.4977844
55 -11.7147156 12.4852844
56 -20.8022156 -11.7147156
57 -17.4208333 -20.8022156
58 -20.8208333 -17.4208333
59 -20.5351190 -20.8208333
60 -24.2666005 -20.5351190
61 -24.2791005 -24.2666005
62 -12.2416005 -24.2791005
63 -14.1916005 -12.2416005
64 -13.6416005 -14.1916005
65 -4.7666005 -13.6416005
66 -4.2791005 -4.7666005
67 -8.8791005 -4.2791005
68 -19.2666005 -8.8791005
69 -11.3852183 -19.2666005
70 -14.8852183 -11.3852183
71 -11.9995040 -14.8852183
72 -15.1309854 -11.9995040
73 -17.4434854 -15.1309854
74 -23.8059854 -17.4434854
75 -25.9559854 -23.8059854
76 -24.8059854 -25.9559854
77 -26.1309854 -24.8059854
78 -25.0434854 -26.1309854
79 -23.4434854 -25.0434854
80 -25.8309854 -23.4434854
81 -7.4496032 -25.8309854
82 1.1503968 -7.4496032
83 -1.1638889 1.1503968
84 4.8046296 -1.1638889
85 13.0921296 4.8046296
86 8.1296296 13.0921296
87 3.3796296 8.1296296
88 8.9296296 3.3796296
89 18.5046296 8.9296296
90 24.3921296 18.5046296
91 30.5921296 24.3921296
92 48.2046296 30.5921296
> 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/7qmt11195513030.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/88yk51195513030.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/9i0dj1195513030.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
> 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/10bi6k1195513030.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/11sdfi1195513030.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/1253hw1195513030.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/13h2461195513031.tab")
>
> system("convert tmp/1c9gq1195513030.ps tmp/1c9gq1195513030.png")
> system("convert tmp/28mn61195513030.ps tmp/28mn61195513030.png")
> system("convert tmp/3kcdr1195513030.ps tmp/3kcdr1195513030.png")
> system("convert tmp/40vv21195513030.ps tmp/40vv21195513030.png")
> system("convert tmp/55ijy1195513030.ps tmp/55ijy1195513030.png")
> system("convert tmp/617py1195513030.ps tmp/617py1195513030.png")
> system("convert tmp/7qmt11195513030.ps tmp/7qmt11195513030.png")
> system("convert tmp/88yk51195513030.ps tmp/88yk51195513030.png")
> system("convert tmp/9i0dj1195513030.ps tmp/9i0dj1195513030.png")
>
>
> proc.time()
user system elapsed
4.301 2.483 4.647