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(160646.8
+ ,0
+ ,160637.2
+ ,0
+ ,164997.4
+ ,0
+ ,167984.4
+ ,0
+ ,172568.7
+ ,0
+ ,178880
+ ,0
+ ,181932.9
+ ,0
+ ,187714.3
+ ,0
+ ,188076.3
+ ,0
+ ,189892.2
+ ,0
+ ,182166.5
+ ,0
+ ,196657.6
+ ,0
+ ,176794.5
+ ,0
+ ,178830.4
+ ,0
+ ,168934.5
+ ,0
+ ,167902.6
+ ,0
+ ,166530.3
+ ,0
+ ,169323.4
+ ,0
+ ,175184.6
+ ,0
+ ,172493.7
+ ,0
+ ,158829.4
+ ,0
+ ,156139.6
+ ,0
+ ,162112.3
+ ,0
+ ,186258.3
+ ,0
+ ,167201.2
+ ,0
+ ,165990.2
+ ,0
+ ,165731.8
+ ,0
+ ,168118.1
+ ,0
+ ,162460.8
+ ,0
+ ,151526.9
+ ,0
+ ,136480.9
+ ,0
+ ,135780.2
+ ,0
+ ,114973.3
+ ,0
+ ,121127.6
+ ,0
+ ,124920.1
+ ,0
+ ,122454.3
+ ,0
+ ,114088.9
+ ,0
+ ,106266.2
+ ,0
+ ,104412
+ ,0
+ ,117742.8
+ ,0
+ ,121798.2
+ ,0
+ ,122644.1
+ ,0
+ ,127011.6
+ ,0
+ ,129469.6
+ ,0
+ ,129579.3
+ ,0
+ ,135693.2
+ ,0
+ ,136320.4
+ ,0
+ ,137592.5
+ ,0
+ ,148244.4
+ ,0
+ ,154458
+ ,0
+ ,159692.2
+ ,0
+ ,163144.1
+ ,0
+ ,162107.5
+ ,0
+ ,165131.3
+ ,0
+ ,164231.2
+ ,0
+ ,170001.9
+ ,0
+ ,182144.8
+ ,0
+ ,188313.5
+ ,0
+ ,193955.3
+ ,0
+ ,200918.4
+ ,0
+ ,206409
+ ,0
+ ,214390.6
+ ,0
+ ,203845.4
+ ,0
+ ,206986.7
+ ,0
+ ,209341
+ ,0
+ ,214284
+ ,0
+ ,222753
+ ,0
+ ,224041
+ ,0
+ ,232062
+ ,0
+ ,229253
+ ,0
+ ,237632
+ ,0
+ ,244574
+ ,0
+ ,257227
+ ,0
+ ,264083
+ ,0
+ ,265331
+ ,0
+ ,269216
+ ,0
+ ,253965
+ ,0
+ ,254036
+ ,0
+ ,259733
+ ,0
+ ,266302
+ ,0
+ ,277784
+ ,0
+ ,282973
+ ,0
+ ,283398
+ ,0
+ ,300454
+ ,0
+ ,304528
+ ,0
+ ,298325
+ ,0
+ ,311393
+ ,0
+ ,316867
+ ,0
+ ,322725
+ ,0
+ ,317988
+ ,0
+ ,274957
+ ,1
+ ,267993
+ ,1
+ ,260728
+ ,1
+ ,286828
+ ,1
+ ,265985
+ ,1
+ ,263718
+ ,1
+ ,239891
+ ,1
+ ,241398
+ ,1
+ ,238924
+ ,1
+ ,246829
+ ,1
+ ,234725
+ ,1
+ ,199177
+ ,1
+ ,189131
+ ,1
+ ,198293
+ ,1
+ ,165763
+ ,1
+ ,124900
+ ,1)
+ ,dim=c(2
+ ,106)
+ ,dimnames=list(c('beurskapitalisatie'
+ ,'Wel(1)_geen(0)_financiële_crisis')
+ ,1:106))
> y <- array(NA,dim=c(2,106),dimnames=list(c('beurskapitalisatie','Wel(1)_geen(0)_financiële_crisis'),1:106))
> 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
beurskapitalisatie Wel(1)_geen(0)_financi\353le_crisis M1 M2 M3 M4 M5 M6 M7
1 160646.8 0 1 0 0 0 0 0 0
2 160637.2 0 0 1 0 0 0 0 0
3 164997.4 0 0 0 1 0 0 0 0
4 167984.4 0 0 0 0 1 0 0 0
5 172568.7 0 0 0 0 0 1 0 0
6 178880.0 0 0 0 0 0 0 1 0
7 181932.9 0 0 0 0 0 0 0 1
8 187714.3 0 0 0 0 0 0 0 0
9 188076.3 0 0 0 0 0 0 0 0
10 189892.2 0 0 0 0 0 0 0 0
11 182166.5 0 0 0 0 0 0 0 0
12 196657.6 0 0 0 0 0 0 0 0
13 176794.5 0 1 0 0 0 0 0 0
14 178830.4 0 0 1 0 0 0 0 0
15 168934.5 0 0 0 1 0 0 0 0
16 167902.6 0 0 0 0 1 0 0 0
17 166530.3 0 0 0 0 0 1 0 0
18 169323.4 0 0 0 0 0 0 1 0
19 175184.6 0 0 0 0 0 0 0 1
20 172493.7 0 0 0 0 0 0 0 0
21 158829.4 0 0 0 0 0 0 0 0
22 156139.6 0 0 0 0 0 0 0 0
23 162112.3 0 0 0 0 0 0 0 0
24 186258.3 0 0 0 0 0 0 0 0
25 167201.2 0 1 0 0 0 0 0 0
26 165990.2 0 0 1 0 0 0 0 0
27 165731.8 0 0 0 1 0 0 0 0
28 168118.1 0 0 0 0 1 0 0 0
29 162460.8 0 0 0 0 0 1 0 0
30 151526.9 0 0 0 0 0 0 1 0
31 136480.9 0 0 0 0 0 0 0 1
32 135780.2 0 0 0 0 0 0 0 0
33 114973.3 0 0 0 0 0 0 0 0
34 121127.6 0 0 0 0 0 0 0 0
35 124920.1 0 0 0 0 0 0 0 0
36 122454.3 0 0 0 0 0 0 0 0
37 114088.9 0 1 0 0 0 0 0 0
38 106266.2 0 0 1 0 0 0 0 0
39 104412.0 0 0 0 1 0 0 0 0
40 117742.8 0 0 0 0 1 0 0 0
41 121798.2 0 0 0 0 0 1 0 0
42 122644.1 0 0 0 0 0 0 1 0
43 127011.6 0 0 0 0 0 0 0 1
44 129469.6 0 0 0 0 0 0 0 0
45 129579.3 0 0 0 0 0 0 0 0
46 135693.2 0 0 0 0 0 0 0 0
47 136320.4 0 0 0 0 0 0 0 0
48 137592.5 0 0 0 0 0 0 0 0
49 148244.4 0 1 0 0 0 0 0 0
50 154458.0 0 0 1 0 0 0 0 0
51 159692.2 0 0 0 1 0 0 0 0
52 163144.1 0 0 0 0 1 0 0 0
53 162107.5 0 0 0 0 0 1 0 0
54 165131.3 0 0 0 0 0 0 1 0
55 164231.2 0 0 0 0 0 0 0 1
56 170001.9 0 0 0 0 0 0 0 0
57 182144.8 0 0 0 0 0 0 0 0
58 188313.5 0 0 0 0 0 0 0 0
59 193955.3 0 0 0 0 0 0 0 0
60 200918.4 0 0 0 0 0 0 0 0
61 206409.0 0 1 0 0 0 0 0 0
62 214390.6 0 0 1 0 0 0 0 0
63 203845.4 0 0 0 1 0 0 0 0
64 206986.7 0 0 0 0 1 0 0 0
65 209341.0 0 0 0 0 0 1 0 0
66 214284.0 0 0 0 0 0 0 1 0
67 222753.0 0 0 0 0 0 0 0 1
68 224041.0 0 0 0 0 0 0 0 0
69 232062.0 0 0 0 0 0 0 0 0
70 229253.0 0 0 0 0 0 0 0 0
71 237632.0 0 0 0 0 0 0 0 0
72 244574.0 0 0 0 0 0 0 0 0
73 257227.0 0 1 0 0 0 0 0 0
74 264083.0 0 0 1 0 0 0 0 0
75 265331.0 0 0 0 1 0 0 0 0
76 269216.0 0 0 0 0 1 0 0 0
77 253965.0 0 0 0 0 0 1 0 0
78 254036.0 0 0 0 0 0 0 1 0
79 259733.0 0 0 0 0 0 0 0 1
80 266302.0 0 0 0 0 0 0 0 0
81 277784.0 0 0 0 0 0 0 0 0
82 282973.0 0 0 0 0 0 0 0 0
83 283398.0 0 0 0 0 0 0 0 0
84 300454.0 0 0 0 0 0 0 0 0
85 304528.0 0 1 0 0 0 0 0 0
86 298325.0 0 0 1 0 0 0 0 0
87 311393.0 0 0 0 1 0 0 0 0
88 316867.0 0 0 0 0 1 0 0 0
89 322725.0 0 0 0 0 0 1 0 0
90 317988.0 0 0 0 0 0 0 1 0
91 274957.0 1 0 0 0 0 0 0 1
92 267993.0 1 0 0 0 0 0 0 0
93 260728.0 1 0 0 0 0 0 0 0
94 286828.0 1 0 0 0 0 0 0 0
95 265985.0 1 0 0 0 0 0 0 0
96 263718.0 1 0 0 0 0 0 0 0
97 239891.0 1 1 0 0 0 0 0 0
98 241398.0 1 0 1 0 0 0 0 0
99 238924.0 1 0 0 1 0 0 0 0
100 246829.0 1 0 0 0 1 0 0 0
101 234725.0 1 0 0 0 0 1 0 0
102 199177.0 1 0 0 0 0 0 1 0
103 189131.0 1 0 0 0 0 0 0 1
104 198293.0 1 0 0 0 0 0 0 0
105 165763.0 1 0 0 0 0 0 0 0
106 124900.0 1 0 0 0 0 0 0 0
M8 M9 M10 M11 t
1 0 0 0 0 1
2 0 0 0 0 2
3 0 0 0 0 3
4 0 0 0 0 4
5 0 0 0 0 5
6 0 0 0 0 6
7 0 0 0 0 7
8 1 0 0 0 8
9 0 1 0 0 9
10 0 0 1 0 10
11 0 0 0 1 11
12 0 0 0 0 12
13 0 0 0 0 13
14 0 0 0 0 14
15 0 0 0 0 15
16 0 0 0 0 16
17 0 0 0 0 17
18 0 0 0 0 18
19 0 0 0 0 19
20 1 0 0 0 20
21 0 1 0 0 21
22 0 0 1 0 22
23 0 0 0 1 23
24 0 0 0 0 24
25 0 0 0 0 25
26 0 0 0 0 26
27 0 0 0 0 27
28 0 0 0 0 28
29 0 0 0 0 29
30 0 0 0 0 30
31 0 0 0 0 31
32 1 0 0 0 32
33 0 1 0 0 33
34 0 0 1 0 34
35 0 0 0 1 35
36 0 0 0 0 36
37 0 0 0 0 37
38 0 0 0 0 38
39 0 0 0 0 39
40 0 0 0 0 40
41 0 0 0 0 41
42 0 0 0 0 42
43 0 0 0 0 43
44 1 0 0 0 44
45 0 1 0 0 45
46 0 0 1 0 46
47 0 0 0 1 47
48 0 0 0 0 48
49 0 0 0 0 49
50 0 0 0 0 50
51 0 0 0 0 51
52 0 0 0 0 52
53 0 0 0 0 53
54 0 0 0 0 54
55 0 0 0 0 55
56 1 0 0 0 56
57 0 1 0 0 57
58 0 0 1 0 58
59 0 0 0 1 59
60 0 0 0 0 60
61 0 0 0 0 61
62 0 0 0 0 62
63 0 0 0 0 63
64 0 0 0 0 64
65 0 0 0 0 65
66 0 0 0 0 66
67 0 0 0 0 67
68 1 0 0 0 68
69 0 1 0 0 69
70 0 0 1 0 70
71 0 0 0 1 71
72 0 0 0 0 72
73 0 0 0 0 73
74 0 0 0 0 74
75 0 0 0 0 75
76 0 0 0 0 76
77 0 0 0 0 77
78 0 0 0 0 78
79 0 0 0 0 79
80 1 0 0 0 80
81 0 1 0 0 81
82 0 0 1 0 82
83 0 0 0 1 83
84 0 0 0 0 84
85 0 0 0 0 85
86 0 0 0 0 86
87 0 0 0 0 87
88 0 0 0 0 88
89 0 0 0 0 89
90 0 0 0 0 90
91 0 0 0 0 91
92 1 0 0 0 92
93 0 1 0 0 93
94 0 0 1 0 94
95 0 0 0 1 95
96 0 0 0 0 96
97 0 0 0 0 97
98 0 0 0 0 98
99 0 0 0 0 99
100 0 0 0 0 100
101 0 0 0 0 101
102 0 0 0 0 102
103 0 0 0 0 103
104 1 0 0 0 104
105 0 1 0 0 105
106 0 0 1 0 106
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `Wel(1)_geen(0)_financi\353le_crisis`
131973 -35410
M1 M2
-2527 -2952
M3 M4
-4539 -1389
M5 M6
-4915 -10071
M7 M8
-12220 -11386
M9 M10
-17533 -18421
M11 t
-6804 1464
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-108378 -35963 4651 29162 71113
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 131973.1 17647.8 7.478 4.32e-11 ***
`Wel(1)_geen(0)_financi\353le_crisis` -35410.2 15248.0 -2.322 0.0224 *
M1 -2526.8 21251.9 -0.119 0.9056
M2 -2951.7 21246.4 -0.139 0.8898
M3 -4539.4 21242.3 -0.214 0.8313
M4 -1388.6 21239.7 -0.065 0.9480
M5 -4915.4 21238.6 -0.231 0.8175
M6 -10071.2 21238.9 -0.474 0.6365
M7 -12219.8 21282.7 -0.574 0.5673
M8 -11386.3 21277.2 -0.535 0.5938
M9 -17533.0 21273.3 -0.824 0.4120
M10 -18421.0 21270.8 -0.866 0.3887
M11 -6803.6 21854.3 -0.311 0.7563
t 1463.5 177.2 8.258 1.04e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 43710 on 92 degrees of freedom
Multiple R-squared: 0.4711, Adjusted R-squared: 0.3963
F-statistic: 6.303 on 13 and 92 DF, p-value: 2.429e-08
> postscript(file="/var/www/html/freestat/rcomp/tmp/1tzcu1228652355.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/freestat/rcomp/tmp/2rtn31228652355.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/freestat/rcomp/tmp/3ooxd1228652355.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/freestat/rcomp/tmp/42mmy1228652355.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/freestat/rcomp/tmp/5xg3u1228652355.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 = 106
Frequency = 1
1 2 3 4 5 6
29736.968 28688.723 33173.068 31545.690 38193.234 48196.846
7 8 9 10 11 12
51934.778 55419.122 60464.300 61704.644 40898.019 47121.931
13 14 15 16 17 18
28322.098 29319.353 19547.598 13901.320 14592.264 21077.676
19 20 21 22 23 24
27623.908 22635.952 13654.830 10389.474 3281.249 19160.061
25 26 27 28 29 30
1166.228 -1083.417 -1217.672 -3445.750 -7039.806 -14281.394
31 32 33 34 35 36
-28642.362 -31640.118 -47763.840 -42185.096 -51473.521 -62206.509
37 38 39 40 41 42
-69508.642 -78369.987 -80100.042 -71383.620 -65264.976 -60726.765
43 44 45 46 47 48
-55674.232 -55513.288 -50720.410 -45182.066 -57635.791 -64630.879
49 50 51 52 53 54
-52915.712 -47740.757 -42382.412 -43544.890 -42518.246 -35802.135
55 56 57 58 59 60
-36017.202 -32543.558 -15717.480 -10124.336 -17563.461 -18867.549
61 62 63 64 65 66
-12313.682 -5370.727 -15791.782 -17264.860 -12847.316 -4212.005
67 68 69 70 71 72
4942.028 3932.972 16637.150 13252.594 8550.669 7225.481
73 74 75 76 77 78
20941.748 26759.103 28131.248 27401.870 14214.114 17977.425
79 80 81 82 83 84
24359.457 28631.402 44796.580 49410.024 36754.099 45542.911
85 86 87 88 89 90
50680.178 43438.533 56630.678 57490.300 65411.544 64366.855
91 92 93 94 95 96
57431.099 48170.043 45588.221 71112.665 37188.740 26654.552
97 98 99 100 101 102
3890.819 4359.174 2009.319 5299.941 -4740.815 -36596.504
103 104 105 106
-45957.472 -39092.527 -66939.349 -108377.905
> postscript(file="/var/www/html/freestat/rcomp/tmp/6y6001228652355.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 = 106
Frequency = 1
lag(myerror, k = 1) myerror
0 29736.968 NA
1 28688.723 29736.968
2 33173.068 28688.723
3 31545.690 33173.068
4 38193.234 31545.690
5 48196.846 38193.234
6 51934.778 48196.846
7 55419.122 51934.778
8 60464.300 55419.122
9 61704.644 60464.300
10 40898.019 61704.644
11 47121.931 40898.019
12 28322.098 47121.931
13 29319.353 28322.098
14 19547.598 29319.353
15 13901.320 19547.598
16 14592.264 13901.320
17 21077.676 14592.264
18 27623.908 21077.676
19 22635.952 27623.908
20 13654.830 22635.952
21 10389.474 13654.830
22 3281.249 10389.474
23 19160.061 3281.249
24 1166.228 19160.061
25 -1083.417 1166.228
26 -1217.672 -1083.417
27 -3445.750 -1217.672
28 -7039.806 -3445.750
29 -14281.394 -7039.806
30 -28642.362 -14281.394
31 -31640.118 -28642.362
32 -47763.840 -31640.118
33 -42185.096 -47763.840
34 -51473.521 -42185.096
35 -62206.509 -51473.521
36 -69508.642 -62206.509
37 -78369.987 -69508.642
38 -80100.042 -78369.987
39 -71383.620 -80100.042
40 -65264.976 -71383.620
41 -60726.765 -65264.976
42 -55674.232 -60726.765
43 -55513.288 -55674.232
44 -50720.410 -55513.288
45 -45182.066 -50720.410
46 -57635.791 -45182.066
47 -64630.879 -57635.791
48 -52915.712 -64630.879
49 -47740.757 -52915.712
50 -42382.412 -47740.757
51 -43544.890 -42382.412
52 -42518.246 -43544.890
53 -35802.135 -42518.246
54 -36017.202 -35802.135
55 -32543.558 -36017.202
56 -15717.480 -32543.558
57 -10124.336 -15717.480
58 -17563.461 -10124.336
59 -18867.549 -17563.461
60 -12313.682 -18867.549
61 -5370.727 -12313.682
62 -15791.782 -5370.727
63 -17264.860 -15791.782
64 -12847.316 -17264.860
65 -4212.005 -12847.316
66 4942.028 -4212.005
67 3932.972 4942.028
68 16637.150 3932.972
69 13252.594 16637.150
70 8550.669 13252.594
71 7225.481 8550.669
72 20941.748 7225.481
73 26759.103 20941.748
74 28131.248 26759.103
75 27401.870 28131.248
76 14214.114 27401.870
77 17977.425 14214.114
78 24359.457 17977.425
79 28631.402 24359.457
80 44796.580 28631.402
81 49410.024 44796.580
82 36754.099 49410.024
83 45542.911 36754.099
84 50680.178 45542.911
85 43438.533 50680.178
86 56630.678 43438.533
87 57490.300 56630.678
88 65411.544 57490.300
89 64366.855 65411.544
90 57431.099 64366.855
91 48170.043 57431.099
92 45588.221 48170.043
93 71112.665 45588.221
94 37188.740 71112.665
95 26654.552 37188.740
96 3890.819 26654.552
97 4359.174 3890.819
98 2009.319 4359.174
99 5299.941 2009.319
100 -4740.815 5299.941
101 -36596.504 -4740.815
102 -45957.472 -36596.504
103 -39092.527 -45957.472
104 -66939.349 -39092.527
105 -108377.905 -66939.349
106 NA -108377.905
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 28688.723 29736.968
[2,] 33173.068 28688.723
[3,] 31545.690 33173.068
[4,] 38193.234 31545.690
[5,] 48196.846 38193.234
[6,] 51934.778 48196.846
[7,] 55419.122 51934.778
[8,] 60464.300 55419.122
[9,] 61704.644 60464.300
[10,] 40898.019 61704.644
[11,] 47121.931 40898.019
[12,] 28322.098 47121.931
[13,] 29319.353 28322.098
[14,] 19547.598 29319.353
[15,] 13901.320 19547.598
[16,] 14592.264 13901.320
[17,] 21077.676 14592.264
[18,] 27623.908 21077.676
[19,] 22635.952 27623.908
[20,] 13654.830 22635.952
[21,] 10389.474 13654.830
[22,] 3281.249 10389.474
[23,] 19160.061 3281.249
[24,] 1166.228 19160.061
[25,] -1083.417 1166.228
[26,] -1217.672 -1083.417
[27,] -3445.750 -1217.672
[28,] -7039.806 -3445.750
[29,] -14281.394 -7039.806
[30,] -28642.362 -14281.394
[31,] -31640.118 -28642.362
[32,] -47763.840 -31640.118
[33,] -42185.096 -47763.840
[34,] -51473.521 -42185.096
[35,] -62206.509 -51473.521
[36,] -69508.642 -62206.509
[37,] -78369.987 -69508.642
[38,] -80100.042 -78369.987
[39,] -71383.620 -80100.042
[40,] -65264.976 -71383.620
[41,] -60726.765 -65264.976
[42,] -55674.232 -60726.765
[43,] -55513.288 -55674.232
[44,] -50720.410 -55513.288
[45,] -45182.066 -50720.410
[46,] -57635.791 -45182.066
[47,] -64630.879 -57635.791
[48,] -52915.712 -64630.879
[49,] -47740.757 -52915.712
[50,] -42382.412 -47740.757
[51,] -43544.890 -42382.412
[52,] -42518.246 -43544.890
[53,] -35802.135 -42518.246
[54,] -36017.202 -35802.135
[55,] -32543.558 -36017.202
[56,] -15717.480 -32543.558
[57,] -10124.336 -15717.480
[58,] -17563.461 -10124.336
[59,] -18867.549 -17563.461
[60,] -12313.682 -18867.549
[61,] -5370.727 -12313.682
[62,] -15791.782 -5370.727
[63,] -17264.860 -15791.782
[64,] -12847.316 -17264.860
[65,] -4212.005 -12847.316
[66,] 4942.028 -4212.005
[67,] 3932.972 4942.028
[68,] 16637.150 3932.972
[69,] 13252.594 16637.150
[70,] 8550.669 13252.594
[71,] 7225.481 8550.669
[72,] 20941.748 7225.481
[73,] 26759.103 20941.748
[74,] 28131.248 26759.103
[75,] 27401.870 28131.248
[76,] 14214.114 27401.870
[77,] 17977.425 14214.114
[78,] 24359.457 17977.425
[79,] 28631.402 24359.457
[80,] 44796.580 28631.402
[81,] 49410.024 44796.580
[82,] 36754.099 49410.024
[83,] 45542.911 36754.099
[84,] 50680.178 45542.911
[85,] 43438.533 50680.178
[86,] 56630.678 43438.533
[87,] 57490.300 56630.678
[88,] 65411.544 57490.300
[89,] 64366.855 65411.544
[90,] 57431.099 64366.855
[91,] 48170.043 57431.099
[92,] 45588.221 48170.043
[93,] 71112.665 45588.221
[94,] 37188.740 71112.665
[95,] 26654.552 37188.740
[96,] 3890.819 26654.552
[97,] 4359.174 3890.819
[98,] 2009.319 4359.174
[99,] 5299.941 2009.319
[100,] -4740.815 5299.941
[101,] -36596.504 -4740.815
[102,] -45957.472 -36596.504
[103,] -39092.527 -45957.472
[104,] -66939.349 -39092.527
[105,] -108377.905 -66939.349
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 28688.723 29736.968
2 33173.068 28688.723
3 31545.690 33173.068
4 38193.234 31545.690
5 48196.846 38193.234
6 51934.778 48196.846
7 55419.122 51934.778
8 60464.300 55419.122
9 61704.644 60464.300
10 40898.019 61704.644
11 47121.931 40898.019
12 28322.098 47121.931
13 29319.353 28322.098
14 19547.598 29319.353
15 13901.320 19547.598
16 14592.264 13901.320
17 21077.676 14592.264
18 27623.908 21077.676
19 22635.952 27623.908
20 13654.830 22635.952
21 10389.474 13654.830
22 3281.249 10389.474
23 19160.061 3281.249
24 1166.228 19160.061
25 -1083.417 1166.228
26 -1217.672 -1083.417
27 -3445.750 -1217.672
28 -7039.806 -3445.750
29 -14281.394 -7039.806
30 -28642.362 -14281.394
31 -31640.118 -28642.362
32 -47763.840 -31640.118
33 -42185.096 -47763.840
34 -51473.521 -42185.096
35 -62206.509 -51473.521
36 -69508.642 -62206.509
37 -78369.987 -69508.642
38 -80100.042 -78369.987
39 -71383.620 -80100.042
40 -65264.976 -71383.620
41 -60726.765 -65264.976
42 -55674.232 -60726.765
43 -55513.288 -55674.232
44 -50720.410 -55513.288
45 -45182.066 -50720.410
46 -57635.791 -45182.066
47 -64630.879 -57635.791
48 -52915.712 -64630.879
49 -47740.757 -52915.712
50 -42382.412 -47740.757
51 -43544.890 -42382.412
52 -42518.246 -43544.890
53 -35802.135 -42518.246
54 -36017.202 -35802.135
55 -32543.558 -36017.202
56 -15717.480 -32543.558
57 -10124.336 -15717.480
58 -17563.461 -10124.336
59 -18867.549 -17563.461
60 -12313.682 -18867.549
61 -5370.727 -12313.682
62 -15791.782 -5370.727
63 -17264.860 -15791.782
64 -12847.316 -17264.860
65 -4212.005 -12847.316
66 4942.028 -4212.005
67 3932.972 4942.028
68 16637.150 3932.972
69 13252.594 16637.150
70 8550.669 13252.594
71 7225.481 8550.669
72 20941.748 7225.481
73 26759.103 20941.748
74 28131.248 26759.103
75 27401.870 28131.248
76 14214.114 27401.870
77 17977.425 14214.114
78 24359.457 17977.425
79 28631.402 24359.457
80 44796.580 28631.402
81 49410.024 44796.580
82 36754.099 49410.024
83 45542.911 36754.099
84 50680.178 45542.911
85 43438.533 50680.178
86 56630.678 43438.533
87 57490.300 56630.678
88 65411.544 57490.300
89 64366.855 65411.544
90 57431.099 64366.855
91 48170.043 57431.099
92 45588.221 48170.043
93 71112.665 45588.221
94 37188.740 71112.665
95 26654.552 37188.740
96 3890.819 26654.552
97 4359.174 3890.819
98 2009.319 4359.174
99 5299.941 2009.319
100 -4740.815 5299.941
101 -36596.504 -4740.815
102 -45957.472 -36596.504
103 -39092.527 -45957.472
104 -66939.349 -39092.527
105 -108377.905 -66939.349
> 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/freestat/rcomp/tmp/7dy9n1228652355.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/freestat/rcomp/tmp/8zsg11228652355.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/freestat/rcomp/tmp/92ih71228652355.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/10cl581228652355.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/freestat/rcomp/tmp/11lej11228652355.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/freestat/rcomp/tmp/12aay01228652356.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/freestat/rcomp/tmp/1309yc1228652356.tab")
>
> system("convert tmp/1tzcu1228652355.ps tmp/1tzcu1228652355.png")
> system("convert tmp/2rtn31228652355.ps tmp/2rtn31228652355.png")
> system("convert tmp/3ooxd1228652355.ps tmp/3ooxd1228652355.png")
> system("convert tmp/42mmy1228652355.ps tmp/42mmy1228652355.png")
> system("convert tmp/5xg3u1228652355.ps tmp/5xg3u1228652355.png")
> system("convert tmp/6y6001228652355.ps tmp/6y6001228652355.png")
> system("convert tmp/7dy9n1228652355.ps tmp/7dy9n1228652355.png")
> system("convert tmp/8zsg11228652355.ps tmp/8zsg11228652355.png")
> system("convert tmp/92ih71228652355.ps tmp/92ih71228652355.png")
>
>
> proc.time()
user system elapsed
3.104 2.252 3.382