R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(9.3
+ ,141
+ ,16
+ ,6
+ ,7
+ ,140002
+ ,135
+ ,20
+ ,20
+ ,0
+ ,23
+ ,308
+ ,8
+ ,15
+ ,0
+ ,160003
+ ,94
+ ,21
+ ,25
+ ,0
+ ,180004
+ ,160
+ ,7
+ ,4
+ ,0
+ ,14.2
+ ,108
+ ,17
+ ,6
+ ,0
+ ,901
+ ,79
+ ,20
+ ,2
+ ,0
+ ,5.9
+ ,40
+ ,18
+ ,1
+ ,1
+ ,7.2
+ ,35
+ ,26
+ ,4
+ ,2
+ ,6.8
+ ,48
+ ,18
+ ,4
+ ,2
+ ,8
+ ,144
+ ,20
+ ,0
+ ,2
+ ,14.3
+ ,284
+ ,0
+ ,3
+ ,0
+ ,14.6
+ ,164
+ ,22
+ ,14
+ ,0
+ ,17.5
+ ,130
+ ,19
+ ,17
+ ,0
+ ,17.2
+ ,178
+ ,18
+ ,14
+ ,0
+ ,17.5
+ ,150
+ ,13
+ ,10
+ ,0
+ ,14.1
+ ,103
+ ,16
+ ,7
+ ,0
+ ,10.4
+ ,110
+ ,11
+ ,4
+ ,0
+ ,6.8
+ ,51
+ ,22
+ ,1
+ ,1
+ ,4.1
+ ,70
+ ,19
+ ,6
+ ,0
+ ,6.5
+ ,41
+ ,23
+ ,2
+ ,1
+ ,6.1
+ ,125
+ ,11
+ ,2
+ ,0
+ ,6.3
+ ,68
+ ,24
+ ,8
+ ,7
+ ,9.3
+ ,135
+ ,14
+ ,10
+ ,0
+ ,16.4
+ ,231
+ ,11
+ ,13
+ ,0
+ ,16.1
+ ,184
+ ,17
+ ,10
+ ,0
+ ,18
+ ,181
+ ,20
+ ,14
+ ,0
+ ,17.6
+ ,138
+ ,19
+ ,13
+ ,0
+ ,14
+ ,157
+ ,12
+ ,6
+ ,0
+ ,10.5
+ ,122
+ ,19
+ ,6
+ ,2
+ ,6.9
+ ,39
+ ,26
+ ,9
+ ,3
+ ,2.8
+ ,61
+ ,13
+ ,2
+ ,5
+ ,0.7
+ ,88
+ ,12
+ ,4
+ ,5
+ ,3.6
+ ,32
+ ,20
+ ,3
+ ,7
+ ,6.7
+ ,149
+ ,15
+ ,4
+ ,2
+ ,12.5
+ ,196
+ ,15
+ ,10
+ ,0
+ ,14.4
+ ,195
+ ,17
+ ,15
+ ,0
+ ,16.5
+ ,224
+ ,11
+ ,14
+ ,0
+ ,18.7
+ ,212
+ ,20
+ ,18
+ ,0
+ ,19.4
+ ,257
+ ,9
+ ,10
+ ,0
+ ,15.8
+ ,156
+ ,10
+ ,5
+ ,0
+ ,11.3
+ ,89
+ ,17
+ ,5
+ ,0
+ ,9.7
+ ,48
+ ,25
+ ,7
+ ,0
+ ,2.9
+ ,46
+ ,19
+ ,2
+ ,7
+ ,0.1
+ ,48
+ ,18
+ ,0
+ ,4
+ ,2.5
+ ,28
+ ,24
+ ,4
+ ,10
+ ,6.7
+ ,117
+ ,13
+ ,7
+ ,2
+ ,10.3
+ ,223
+ ,6
+ ,8
+ ,0
+ ,11.2
+ ,171
+ ,14
+ ,6
+ ,0
+ ,17.4
+ ,258
+ ,9
+ ,3
+ ,0
+ ,20.5
+ ,252
+ ,13
+ ,12
+ ,0
+ ,17
+ ,136
+ ,23
+ ,15
+ ,0
+ ,14.2
+ ,142
+ ,18
+ ,8
+ ,0
+ ,10.6
+ ,118
+ ,16
+ ,6
+ ,0
+ ,6.1
+ ,23
+ ,21
+ ,1
+ ,6
+ ,-0.7
+ ,33
+ ,26
+ ,1
+ ,23
+ ,4
+ ,52
+ ,21
+ ,0
+ ,4
+ ,5.4
+ ,54
+ ,15
+ ,0
+ ,1
+ ,7.7
+ ,204
+ ,7
+ ,0
+ ,1
+ ,14.1
+ ,238
+ ,11
+ ,10
+ ,0
+ ,14.8
+ ,264
+ ,9
+ ,9
+ ,0
+ ,16.8
+ ,180
+ ,19
+ ,16
+ ,0
+ ,16
+ ,140
+ ,20
+ ,10
+ ,0
+ ,17.3
+ ,144
+ ,22
+ ,15
+ ,0
+ ,16.5
+ ,173
+ ,10
+ ,8
+ ,0
+ ,12.1
+ ,161
+ ,16
+ ,4
+ ,0)
+ ,dim=c(5
+ ,66)
+ ,dimnames=list(c('temperatuur'
+ ,'aantaldagenzonneschijn'
+ ,'aantaldagenregen'
+ ,'aantaldagenonweer'
+ ,'aantaldagensneeuw')
+ ,1:66))
> y <- array(NA,dim=c(5,66),dimnames=list(c('temperatuur','aantaldagenzonneschijn','aantaldagenregen','aantaldagenonweer','aantaldagensneeuw'),1:66))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No Linear Trend'
> par2 = 'Do not include Seasonal 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)
> library(lmtest)
Loading required package: zoo
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> 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
temperatuur aantaldagenzonneschijn aantaldagenregen aantaldagenonweer
1 9.3 141 16 6
2 140002.0 135 20 20
3 23.0 308 8 15
4 160003.0 94 21 25
5 180004.0 160 7 4
6 14.2 108 17 6
7 901.0 79 20 2
8 5.9 40 18 1
9 7.2 35 26 4
10 6.8 48 18 4
11 8.0 144 20 0
12 14.3 284 0 3
13 14.6 164 22 14
14 17.5 130 19 17
15 17.2 178 18 14
16 17.5 150 13 10
17 14.1 103 16 7
18 10.4 110 11 4
19 6.8 51 22 1
20 4.1 70 19 6
21 6.5 41 23 2
22 6.1 125 11 2
23 6.3 68 24 8
24 9.3 135 14 10
25 16.4 231 11 13
26 16.1 184 17 10
27 18.0 181 20 14
28 17.6 138 19 13
29 14.0 157 12 6
30 10.5 122 19 6
31 6.9 39 26 9
32 2.8 61 13 2
33 0.7 88 12 4
34 3.6 32 20 3
35 6.7 149 15 4
36 12.5 196 15 10
37 14.4 195 17 15
38 16.5 224 11 14
39 18.7 212 20 18
40 19.4 257 9 10
41 15.8 156 10 5
42 11.3 89 17 5
43 9.7 48 25 7
44 2.9 46 19 2
45 0.1 48 18 0
46 2.5 28 24 4
47 6.7 117 13 7
48 10.3 223 6 8
49 11.2 171 14 6
50 17.4 258 9 3
51 20.5 252 13 12
52 17.0 136 23 15
53 14.2 142 18 8
54 10.6 118 16 6
55 6.1 23 21 1
56 -0.7 33 26 1
57 4.0 52 21 0
58 5.4 54 15 0
59 7.7 204 7 0
60 14.1 238 11 10
61 14.8 264 9 9
62 16.8 180 19 16
63 16.0 140 20 10
64 17.3 144 22 15
65 16.5 173 10 8
66 12.1 161 16 4
aantaldagensneeuw
1 7
2 0
3 0
4 0
5 0
6 0
7 0
8 1
9 2
10 2
11 2
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 1
20 0
21 1
22 0
23 7
24 0
25 0
26 0
27 0
28 0
29 0
30 2
31 3
32 5
33 5
34 7
35 2
36 0
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 7
45 4
46 10
47 2
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 6
56 23
57 4
58 1
59 1
60 0
61 0
62 0
63 0
64 0
65 0
66 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) aantaldagenzonneschijn aantaldagenregen
82575.9 -343.3 -3774.7
aantaldagenonweer aantaldagensneeuw
4259.8 326.3
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-38623 -13765 -5235 3120 161744
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 82575.9 27245.1 3.031 0.00358 **
aantaldagenzonneschijn -343.3 100.1 -3.431 0.00109 **
aantaldagenregen -3774.7 1207.5 -3.126 0.00271 **
aantaldagenonweer 4259.8 976.1 4.364 5.01e-05 ***
aantaldagensneeuw 326.3 1262.2 0.259 0.79686
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 30160 on 61 degrees of freedom
Multiple R-squared: 0.2511, Adjusted R-squared: 0.202
F-statistic: 5.113 on 4 and 61 DF, p-value: 0.001282
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 1 4.854861e-199 2.427430e-199
[2,] 1 2.270903e-197 1.135451e-197
[3,] 1 4.303618e-196 2.151809e-196
[4,] 1 7.180227e-195 3.590114e-195
[5,] 1 2.069816e-191 1.034908e-191
[6,] 1 2.095828e-187 1.047914e-187
[7,] 1 2.145982e-185 1.072991e-185
[8,] 1 3.077013e-181 1.538506e-181
[9,] 1 9.723116e-179 4.861558e-179
[10,] 1 1.608300e-175 8.041502e-176
[11,] 1 4.667064e-172 2.333532e-172
[12,] 1 1.043502e-167 5.217510e-168
[13,] 1 3.295131e-164 1.647565e-164
[14,] 1 7.096706e-160 3.548353e-160
[15,] 1 9.909413e-156 4.954707e-156
[16,] 1 1.690116e-151 8.450578e-152
[17,] 1 9.945254e-148 4.972627e-148
[18,] 1 1.477814e-143 7.389071e-144
[19,] 1 2.852485e-139 1.426242e-139
[20,] 1 5.235045e-135 2.617523e-135
[21,] 1 3.145575e-131 1.572787e-131
[22,] 1 2.593649e-127 1.296825e-127
[23,] 1 4.638854e-123 2.319427e-123
[24,] 1 5.370419e-119 2.685209e-119
[25,] 1 6.686307e-115 3.343154e-115
[26,] 1 2.720795e-111 1.360397e-111
[27,] 1 4.598389e-107 2.299195e-107
[28,] 1 2.563116e-103 1.281558e-103
[29,] 1 2.107899e-99 1.053949e-99
[30,] 1 1.351881e-95 6.759403e-96
[31,] 1 1.753009e-91 8.765043e-92
[32,] 1 1.901275e-87 9.506374e-88
[33,] 1 1.903179e-83 9.515897e-84
[34,] 1 1.358027e-80 6.790135e-81
[35,] 1 1.157247e-76 5.786235e-77
[36,] 1 1.799235e-72 8.996173e-73
[37,] 1 2.959729e-68 1.479865e-68
[38,] 1 1.077396e-64 5.386982e-65
[39,] 1 1.225967e-60 6.129837e-61
[40,] 1 1.193919e-56 5.969596e-57
[41,] 1 7.266375e-53 3.633188e-53
[42,] 1 8.656517e-49 4.328258e-49
[43,] 1 1.514814e-45 7.574070e-46
[44,] 1 5.184770e-42 2.592385e-42
[45,] 1 1.060245e-37 5.301225e-38
[46,] 1 1.662716e-33 8.313580e-34
[47,] 1 2.797107e-29 1.398553e-29
[48,] 1 4.641894e-25 2.320947e-25
[49,] 1 3.990874e-21 1.995437e-21
[50,] 1 1.640065e-17 8.200327e-18
[51,] 1 5.934970e-14 2.967485e-14
> postscript(file="/var/wessaorg/rcomp/tmp/1vten1321791992.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2b0iq1321791992.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3dyuy1321791992.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4f5vc1321791992.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5m6f21321791992.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 66
Frequency = 1
1 2 3 4 5 6
-1605.1600 94072.8241 -10508.1246 82472.9272 161744.1026 -6871.1327
7 8 9 10 11 12
12422.7483 -5478.0072 9898.6055 -15836.3421 41713.0496 2163.6862
13 14 15 16 17 18
-2849.5808 -38623.4972 -13139.3045 -24586.3912 -16622.4358 -20316.9342
19 20 21 22 23 24
13398.3835 -12378.1979 9479.6955 -6651.6431 -4992.9041 -25969.7671
25 26 27 28 29 30
-17107.0151 2184.2131 -4559.0759 -18837.4019 -8921.9469 4828.5656
31 32 33 34 35 36
-10353.9270 -22709.9616 -25736.6565 -11155.0345 7515.3797 -1248.9153
37 38 39 40 41 42
-15340.1207 -23770.0473 -10954.6306 -2947.4337 -12553.0767 -9137.3941
43 44 45 46 47 48
-1537.2845 -5864.0398 543.7159 -2669.3253 -23800.0591 -17434.1228
49 50 51 52 53 54
3431.2752 27212.8112 1916.2392 -12945.4490 57.0078 -7216.1902
55 56 57 58 59 60
-1621.7475 15131.0381 13245.0955 -7736.2611 13567.2464 -1926.4920
61 62 63 64 65 66
3711.0985 -17198.0178 -1598.0879 -13973.2599 -19495.3595 16068.0480
> postscript(file="/var/wessaorg/rcomp/tmp/6n4gl1321791992.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 66
Frequency = 1
lag(myerror, k = 1) myerror
0 -1605.1600 NA
1 94072.8241 -1605.1600
2 -10508.1246 94072.8241
3 82472.9272 -10508.1246
4 161744.1026 82472.9272
5 -6871.1327 161744.1026
6 12422.7483 -6871.1327
7 -5478.0072 12422.7483
8 9898.6055 -5478.0072
9 -15836.3421 9898.6055
10 41713.0496 -15836.3421
11 2163.6862 41713.0496
12 -2849.5808 2163.6862
13 -38623.4972 -2849.5808
14 -13139.3045 -38623.4972
15 -24586.3912 -13139.3045
16 -16622.4358 -24586.3912
17 -20316.9342 -16622.4358
18 13398.3835 -20316.9342
19 -12378.1979 13398.3835
20 9479.6955 -12378.1979
21 -6651.6431 9479.6955
22 -4992.9041 -6651.6431
23 -25969.7671 -4992.9041
24 -17107.0151 -25969.7671
25 2184.2131 -17107.0151
26 -4559.0759 2184.2131
27 -18837.4019 -4559.0759
28 -8921.9469 -18837.4019
29 4828.5656 -8921.9469
30 -10353.9270 4828.5656
31 -22709.9616 -10353.9270
32 -25736.6565 -22709.9616
33 -11155.0345 -25736.6565
34 7515.3797 -11155.0345
35 -1248.9153 7515.3797
36 -15340.1207 -1248.9153
37 -23770.0473 -15340.1207
38 -10954.6306 -23770.0473
39 -2947.4337 -10954.6306
40 -12553.0767 -2947.4337
41 -9137.3941 -12553.0767
42 -1537.2845 -9137.3941
43 -5864.0398 -1537.2845
44 543.7159 -5864.0398
45 -2669.3253 543.7159
46 -23800.0591 -2669.3253
47 -17434.1228 -23800.0591
48 3431.2752 -17434.1228
49 27212.8112 3431.2752
50 1916.2392 27212.8112
51 -12945.4490 1916.2392
52 57.0078 -12945.4490
53 -7216.1902 57.0078
54 -1621.7475 -7216.1902
55 15131.0381 -1621.7475
56 13245.0955 15131.0381
57 -7736.2611 13245.0955
58 13567.2464 -7736.2611
59 -1926.4920 13567.2464
60 3711.0985 -1926.4920
61 -17198.0178 3711.0985
62 -1598.0879 -17198.0178
63 -13973.2599 -1598.0879
64 -19495.3595 -13973.2599
65 16068.0480 -19495.3595
66 NA 16068.0480
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 94072.8241 -1605.1600
[2,] -10508.1246 94072.8241
[3,] 82472.9272 -10508.1246
[4,] 161744.1026 82472.9272
[5,] -6871.1327 161744.1026
[6,] 12422.7483 -6871.1327
[7,] -5478.0072 12422.7483
[8,] 9898.6055 -5478.0072
[9,] -15836.3421 9898.6055
[10,] 41713.0496 -15836.3421
[11,] 2163.6862 41713.0496
[12,] -2849.5808 2163.6862
[13,] -38623.4972 -2849.5808
[14,] -13139.3045 -38623.4972
[15,] -24586.3912 -13139.3045
[16,] -16622.4358 -24586.3912
[17,] -20316.9342 -16622.4358
[18,] 13398.3835 -20316.9342
[19,] -12378.1979 13398.3835
[20,] 9479.6955 -12378.1979
[21,] -6651.6431 9479.6955
[22,] -4992.9041 -6651.6431
[23,] -25969.7671 -4992.9041
[24,] -17107.0151 -25969.7671
[25,] 2184.2131 -17107.0151
[26,] -4559.0759 2184.2131
[27,] -18837.4019 -4559.0759
[28,] -8921.9469 -18837.4019
[29,] 4828.5656 -8921.9469
[30,] -10353.9270 4828.5656
[31,] -22709.9616 -10353.9270
[32,] -25736.6565 -22709.9616
[33,] -11155.0345 -25736.6565
[34,] 7515.3797 -11155.0345
[35,] -1248.9153 7515.3797
[36,] -15340.1207 -1248.9153
[37,] -23770.0473 -15340.1207
[38,] -10954.6306 -23770.0473
[39,] -2947.4337 -10954.6306
[40,] -12553.0767 -2947.4337
[41,] -9137.3941 -12553.0767
[42,] -1537.2845 -9137.3941
[43,] -5864.0398 -1537.2845
[44,] 543.7159 -5864.0398
[45,] -2669.3253 543.7159
[46,] -23800.0591 -2669.3253
[47,] -17434.1228 -23800.0591
[48,] 3431.2752 -17434.1228
[49,] 27212.8112 3431.2752
[50,] 1916.2392 27212.8112
[51,] -12945.4490 1916.2392
[52,] 57.0078 -12945.4490
[53,] -7216.1902 57.0078
[54,] -1621.7475 -7216.1902
[55,] 15131.0381 -1621.7475
[56,] 13245.0955 15131.0381
[57,] -7736.2611 13245.0955
[58,] 13567.2464 -7736.2611
[59,] -1926.4920 13567.2464
[60,] 3711.0985 -1926.4920
[61,] -17198.0178 3711.0985
[62,] -1598.0879 -17198.0178
[63,] -13973.2599 -1598.0879
[64,] -19495.3595 -13973.2599
[65,] 16068.0480 -19495.3595
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 94072.8241 -1605.1600
2 -10508.1246 94072.8241
3 82472.9272 -10508.1246
4 161744.1026 82472.9272
5 -6871.1327 161744.1026
6 12422.7483 -6871.1327
7 -5478.0072 12422.7483
8 9898.6055 -5478.0072
9 -15836.3421 9898.6055
10 41713.0496 -15836.3421
11 2163.6862 41713.0496
12 -2849.5808 2163.6862
13 -38623.4972 -2849.5808
14 -13139.3045 -38623.4972
15 -24586.3912 -13139.3045
16 -16622.4358 -24586.3912
17 -20316.9342 -16622.4358
18 13398.3835 -20316.9342
19 -12378.1979 13398.3835
20 9479.6955 -12378.1979
21 -6651.6431 9479.6955
22 -4992.9041 -6651.6431
23 -25969.7671 -4992.9041
24 -17107.0151 -25969.7671
25 2184.2131 -17107.0151
26 -4559.0759 2184.2131
27 -18837.4019 -4559.0759
28 -8921.9469 -18837.4019
29 4828.5656 -8921.9469
30 -10353.9270 4828.5656
31 -22709.9616 -10353.9270
32 -25736.6565 -22709.9616
33 -11155.0345 -25736.6565
34 7515.3797 -11155.0345
35 -1248.9153 7515.3797
36 -15340.1207 -1248.9153
37 -23770.0473 -15340.1207
38 -10954.6306 -23770.0473
39 -2947.4337 -10954.6306
40 -12553.0767 -2947.4337
41 -9137.3941 -12553.0767
42 -1537.2845 -9137.3941
43 -5864.0398 -1537.2845
44 543.7159 -5864.0398
45 -2669.3253 543.7159
46 -23800.0591 -2669.3253
47 -17434.1228 -23800.0591
48 3431.2752 -17434.1228
49 27212.8112 3431.2752
50 1916.2392 27212.8112
51 -12945.4490 1916.2392
52 57.0078 -12945.4490
53 -7216.1902 57.0078
54 -1621.7475 -7216.1902
55 15131.0381 -1621.7475
56 13245.0955 15131.0381
57 -7736.2611 13245.0955
58 13567.2464 -7736.2611
59 -1926.4920 13567.2464
60 3711.0985 -1926.4920
61 -17198.0178 3711.0985
62 -1598.0879 -17198.0178
63 -13973.2599 -1598.0879
64 -19495.3595 -13973.2599
65 16068.0480 -19495.3595
> 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/wessaorg/rcomp/tmp/7f8ba1321791993.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/8cj271321791993.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/9cguo1321791993.ps",horizontal=F,onefile=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
> if (n > n25) {
+ postscript(file="/var/wessaorg/rcomp/tmp/10hcfu1321791993.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11b9sq1321791993.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/wessaorg/rcomp/tmp/12fo311321791993.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/wessaorg/rcomp/tmp/13uj4i1321791993.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/wessaorg/rcomp/tmp/14nl321321791993.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/wessaorg/rcomp/tmp/15ted61321791993.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/wessaorg/rcomp/tmp/16yfdb1321791993.tab")
+ }
>
> try(system("convert tmp/1vten1321791992.ps tmp/1vten1321791992.png",intern=TRUE))
character(0)
> try(system("convert tmp/2b0iq1321791992.ps tmp/2b0iq1321791992.png",intern=TRUE))
character(0)
> try(system("convert tmp/3dyuy1321791992.ps tmp/3dyuy1321791992.png",intern=TRUE))
character(0)
> try(system("convert tmp/4f5vc1321791992.ps tmp/4f5vc1321791992.png",intern=TRUE))
character(0)
> try(system("convert tmp/5m6f21321791992.ps tmp/5m6f21321791992.png",intern=TRUE))
character(0)
> try(system("convert tmp/6n4gl1321791992.ps tmp/6n4gl1321791992.png",intern=TRUE))
character(0)
> try(system("convert tmp/7f8ba1321791993.ps tmp/7f8ba1321791993.png",intern=TRUE))
character(0)
> try(system("convert tmp/8cj271321791993.ps tmp/8cj271321791993.png",intern=TRUE))
character(0)
> try(system("convert tmp/9cguo1321791993.ps tmp/9cguo1321791993.png",intern=TRUE))
character(0)
> try(system("convert tmp/10hcfu1321791993.ps tmp/10hcfu1321791993.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.144 0.643 3.851