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(655362,873127,1107897,1555964,1671159,1493308,2957796,2638691,1305669,1280496,921900,867888,652586,913831,1108544,1555827,1699283,1509458,3268975,2425016,1312703,1365498,934453,775019,651142,843192,1146766,1652601,1465906,1652734,2922334,2702805,1458956,1410363,1019279,936574,708917,885295,1099663,1576220,1487870,1488635,2882530,2677026,1404398,1344370,936865,872705,628151,953712,1160384,1400618,1661511,1495347,2918786,2775677,1407026,1370199,964526,850851,683118,847224,1073256,1514326,1503734,1507712,2865698,2788128,1391596,1366378,946295,859626),dim=c(1,72),dimnames=list(c('Overnachtingen'),1:72))
> y <- array(NA,dim=c(1,72),dimnames=list(c('Overnachtingen'),1:72))
> 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 = 'Include Monthly Dummies'
> par1 = '1'
> 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
Overnachtingen M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 655362 1 0 0 0 0 0 0 0 0 0 0
2 873127 0 1 0 0 0 0 0 0 0 0 0
3 1107897 0 0 1 0 0 0 0 0 0 0 0
4 1555964 0 0 0 1 0 0 0 0 0 0 0
5 1671159 0 0 0 0 1 0 0 0 0 0 0
6 1493308 0 0 0 0 0 1 0 0 0 0 0
7 2957796 0 0 0 0 0 0 1 0 0 0 0
8 2638691 0 0 0 0 0 0 0 1 0 0 0
9 1305669 0 0 0 0 0 0 0 0 1 0 0
10 1280496 0 0 0 0 0 0 0 0 0 1 0
11 921900 0 0 0 0 0 0 0 0 0 0 1
12 867888 0 0 0 0 0 0 0 0 0 0 0
13 652586 1 0 0 0 0 0 0 0 0 0 0
14 913831 0 1 0 0 0 0 0 0 0 0 0
15 1108544 0 0 1 0 0 0 0 0 0 0 0
16 1555827 0 0 0 1 0 0 0 0 0 0 0
17 1699283 0 0 0 0 1 0 0 0 0 0 0
18 1509458 0 0 0 0 0 1 0 0 0 0 0
19 3268975 0 0 0 0 0 0 1 0 0 0 0
20 2425016 0 0 0 0 0 0 0 1 0 0 0
21 1312703 0 0 0 0 0 0 0 0 1 0 0
22 1365498 0 0 0 0 0 0 0 0 0 1 0
23 934453 0 0 0 0 0 0 0 0 0 0 1
24 775019 0 0 0 0 0 0 0 0 0 0 0
25 651142 1 0 0 0 0 0 0 0 0 0 0
26 843192 0 1 0 0 0 0 0 0 0 0 0
27 1146766 0 0 1 0 0 0 0 0 0 0 0
28 1652601 0 0 0 1 0 0 0 0 0 0 0
29 1465906 0 0 0 0 1 0 0 0 0 0 0
30 1652734 0 0 0 0 0 1 0 0 0 0 0
31 2922334 0 0 0 0 0 0 1 0 0 0 0
32 2702805 0 0 0 0 0 0 0 1 0 0 0
33 1458956 0 0 0 0 0 0 0 0 1 0 0
34 1410363 0 0 0 0 0 0 0 0 0 1 0
35 1019279 0 0 0 0 0 0 0 0 0 0 1
36 936574 0 0 0 0 0 0 0 0 0 0 0
37 708917 1 0 0 0 0 0 0 0 0 0 0
38 885295 0 1 0 0 0 0 0 0 0 0 0
39 1099663 0 0 1 0 0 0 0 0 0 0 0
40 1576220 0 0 0 1 0 0 0 0 0 0 0
41 1487870 0 0 0 0 1 0 0 0 0 0 0
42 1488635 0 0 0 0 0 1 0 0 0 0 0
43 2882530 0 0 0 0 0 0 1 0 0 0 0
44 2677026 0 0 0 0 0 0 0 1 0 0 0
45 1404398 0 0 0 0 0 0 0 0 1 0 0
46 1344370 0 0 0 0 0 0 0 0 0 1 0
47 936865 0 0 0 0 0 0 0 0 0 0 1
48 872705 0 0 0 0 0 0 0 0 0 0 0
49 628151 1 0 0 0 0 0 0 0 0 0 0
50 953712 0 1 0 0 0 0 0 0 0 0 0
51 1160384 0 0 1 0 0 0 0 0 0 0 0
52 1400618 0 0 0 1 0 0 0 0 0 0 0
53 1661511 0 0 0 0 1 0 0 0 0 0 0
54 1495347 0 0 0 0 0 1 0 0 0 0 0
55 2918786 0 0 0 0 0 0 1 0 0 0 0
56 2775677 0 0 0 0 0 0 0 1 0 0 0
57 1407026 0 0 0 0 0 0 0 0 1 0 0
58 1370199 0 0 0 0 0 0 0 0 0 1 0
59 964526 0 0 0 0 0 0 0 0 0 0 1
60 850851 0 0 0 0 0 0 0 0 0 0 0
61 683118 1 0 0 0 0 0 0 0 0 0 0
62 847224 0 1 0 0 0 0 0 0 0 0 0
63 1073256 0 0 1 0 0 0 0 0 0 0 0
64 1514326 0 0 0 1 0 0 0 0 0 0 0
65 1503734 0 0 0 0 1 0 0 0 0 0 0
66 1507712 0 0 0 0 0 1 0 0 0 0 0
67 2865698 0 0 0 0 0 0 1 0 0 0 0
68 2788128 0 0 0 0 0 0 0 1 0 0 0
69 1391596 0 0 0 0 0 0 0 0 1 0 0
70 1366378 0 0 0 0 0 0 0 0 0 1 0
71 946295 0 0 0 0 0 0 0 0 0 0 1
72 859626 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) M1 M2 M3 M4 M5
860444 -197231 25620 255641 682149 721133
M6 M7 M8 M9 M10 M11
664089 2108909 1807447 519614 495774 93442
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-242875 -32755 -7721 28496 299622
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 860444 32308 26.633 < 2e-16 ***
M1 -197231 45690 -4.317 6.02e-05 ***
M2 25620 45690 0.561 0.5771
M3 255641 45690 5.595 5.76e-07 ***
M4 682149 45690 14.930 < 2e-16 ***
M5 721133 45690 15.783 < 2e-16 ***
M6 664088 45690 14.535 < 2e-16 ***
M7 2108909 45690 46.157 < 2e-16 ***
M8 1807447 45690 39.559 < 2e-16 ***
M9 519614 45690 11.373 < 2e-16 ***
M10 495774 45690 10.851 8.87e-16 ***
M11 93442 45690 2.045 0.0452 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 79140 on 60 degrees of freedom
Multiple R-squared: 0.9887, Adjusted R-squared: 0.9866
F-statistic: 477.1 on 11 and 60 DF, p-value: < 2.2e-16
> 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,] 0.0092536935 1.850739e-02 9.907463e-01
[2,] 0.0014015312 2.803062e-03 9.985985e-01
[3,] 0.0005817791 1.163558e-03 9.994182e-01
[4,] 0.0001216785 2.433570e-04 9.998783e-01
[5,] 0.7557813461 4.884373e-01 2.442187e-01
[6,] 0.9813527348 3.729453e-02 1.864727e-02
[7,] 0.9757048509 4.859030e-02 2.429515e-02
[8,] 0.9668858266 6.622835e-02 3.311417e-02
[9,] 0.9469587849 1.060824e-01 5.304122e-02
[10,] 0.9529754162 9.404917e-02 4.702458e-02
[11,] 0.9271053859 1.457892e-01 7.289461e-02
[12,] 0.9065956412 1.868087e-01 9.340436e-02
[13,] 0.8743387374 2.513225e-01 1.256613e-01
[14,] 0.9348729174 1.302542e-01 6.512708e-02
[15,] 0.9852524498 2.949510e-02 1.474755e-02
[16,] 0.9973371491 5.325702e-03 2.662851e-03
[17,] 0.9986138843 2.772231e-03 1.386116e-03
[18,] 0.9990231456 1.953709e-03 9.768544e-04
[19,] 0.9991968389 1.606322e-03 8.031611e-04
[20,] 0.9989171681 2.165664e-03 1.082832e-03
[21,] 0.9988400621 2.319876e-03 1.159938e-03
[22,] 0.9989792259 2.041548e-03 1.020774e-03
[23,] 0.9984883315 3.023337e-03 1.511668e-03
[24,] 0.9970653582 5.869284e-03 2.934642e-03
[25,] 0.9945775213 1.084496e-02 5.422479e-03
[26,] 0.9967336988 6.532602e-03 3.266301e-03
[27,] 0.9980273770 3.945246e-03 1.972623e-03
[28,] 0.9963577403 7.284519e-03 3.642260e-03
[29,] 0.9956171891 8.765622e-03 4.382811e-03
[30,] 0.9974797225 5.040555e-03 2.520278e-03
[31,] 0.9949108946 1.017821e-02 5.089105e-03
[32,] 0.9903602310 1.927954e-02 9.639769e-03
[33,] 0.9820837127 3.583257e-02 1.791629e-02
[34,] 0.9677455210 6.450896e-02 3.225448e-02
[35,] 0.9525442166 9.491157e-02 4.745578e-02
[36,] 0.9602569966 7.948601e-02 3.974300e-02
[37,] 0.9574945128 8.501097e-02 4.250549e-02
[38,] 0.9800254466 3.994911e-02 1.997455e-02
[39,] 0.9999277663 1.444675e-04 7.223375e-05
[40,] 0.9996546465 6.907069e-04 3.453535e-04
[41,] 0.9999563055 8.738895e-05 4.369448e-05
[42,] 0.9997502178 4.995645e-04 2.497822e-04
[43,] 0.9986927058 2.614588e-03 1.307294e-03
> postscript(file="/var/wessaorg/rcomp/tmp/19d6c1324046155.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/2yxpq1324046155.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/3uxnk1324046155.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/4p5e51324046155.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/5qidt1324046155.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 = 72
Frequency = 1
1 2 3 4 5 6
-7850.6667 -12936.5000 -8188.0000 13371.3333 89581.8333 -31224.3333
7 8 9 10 11 12
-11557.1667 -29199.5000 -74389.0000 -75721.3333 -31986.3333 7444.1667
13 14 15 16 17 18
-10626.6667 27767.5000 -7541.0000 13234.3333 117705.8333 -15074.3333
19 20 21 22 23 24
299621.8333 -242874.5000 -67355.0000 9280.6667 -19433.3333 -85424.8333
25 26 27 28 29 30
-12070.6667 -42871.5000 30681.0000 110008.3333 -115671.1667 128201.6667
31 32 33 34 35 36
-47019.1667 34914.5000 78898.0000 54145.6667 65392.6667 76130.1667
37 38 39 40 41 42
45704.3333 -768.5000 -16422.0000 33627.3333 -93707.1667 -35897.3333
43 44 45 46 47 48
-86823.1667 9135.5000 24340.0000 -11847.3333 -17021.3333 12261.1667
49 50 51 52 53 54
-35061.6667 67648.5000 44299.0000 -141974.6667 79933.8333 -29185.3333
55 56 57 58 59 60
-50567.1667 107786.5000 26968.0000 13981.6667 10639.6667 -9592.8333
61 62 63 64 65 66
19905.3333 -38839.5000 -42829.0000 -28266.6667 -77843.1667 -16820.3333
67 68 69 70 71 72
-103655.1667 120237.5000 11538.0000 10160.6667 -7591.3333 -817.8333
> postscript(file="/var/wessaorg/rcomp/tmp/6d2ps1324046155.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 -7850.6667 NA
1 -12936.5000 -7850.6667
2 -8188.0000 -12936.5000
3 13371.3333 -8188.0000
4 89581.8333 13371.3333
5 -31224.3333 89581.8333
6 -11557.1667 -31224.3333
7 -29199.5000 -11557.1667
8 -74389.0000 -29199.5000
9 -75721.3333 -74389.0000
10 -31986.3333 -75721.3333
11 7444.1667 -31986.3333
12 -10626.6667 7444.1667
13 27767.5000 -10626.6667
14 -7541.0000 27767.5000
15 13234.3333 -7541.0000
16 117705.8333 13234.3333
17 -15074.3333 117705.8333
18 299621.8333 -15074.3333
19 -242874.5000 299621.8333
20 -67355.0000 -242874.5000
21 9280.6667 -67355.0000
22 -19433.3333 9280.6667
23 -85424.8333 -19433.3333
24 -12070.6667 -85424.8333
25 -42871.5000 -12070.6667
26 30681.0000 -42871.5000
27 110008.3333 30681.0000
28 -115671.1667 110008.3333
29 128201.6667 -115671.1667
30 -47019.1667 128201.6667
31 34914.5000 -47019.1667
32 78898.0000 34914.5000
33 54145.6667 78898.0000
34 65392.6667 54145.6667
35 76130.1667 65392.6667
36 45704.3333 76130.1667
37 -768.5000 45704.3333
38 -16422.0000 -768.5000
39 33627.3333 -16422.0000
40 -93707.1667 33627.3333
41 -35897.3333 -93707.1667
42 -86823.1667 -35897.3333
43 9135.5000 -86823.1667
44 24340.0000 9135.5000
45 -11847.3333 24340.0000
46 -17021.3333 -11847.3333
47 12261.1667 -17021.3333
48 -35061.6667 12261.1667
49 67648.5000 -35061.6667
50 44299.0000 67648.5000
51 -141974.6667 44299.0000
52 79933.8333 -141974.6667
53 -29185.3333 79933.8333
54 -50567.1667 -29185.3333
55 107786.5000 -50567.1667
56 26968.0000 107786.5000
57 13981.6667 26968.0000
58 10639.6667 13981.6667
59 -9592.8333 10639.6667
60 19905.3333 -9592.8333
61 -38839.5000 19905.3333
62 -42829.0000 -38839.5000
63 -28266.6667 -42829.0000
64 -77843.1667 -28266.6667
65 -16820.3333 -77843.1667
66 -103655.1667 -16820.3333
67 120237.5000 -103655.1667
68 11538.0000 120237.5000
69 10160.6667 11538.0000
70 -7591.3333 10160.6667
71 -817.8333 -7591.3333
72 NA -817.8333
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -12936.5000 -7850.667
[2,] -8188.0000 -12936.500
[3,] 13371.3333 -8188.000
[4,] 89581.8333 13371.333
[5,] -31224.3333 89581.833
[6,] -11557.1667 -31224.333
[7,] -29199.5000 -11557.167
[8,] -74389.0000 -29199.500
[9,] -75721.3333 -74389.000
[10,] -31986.3333 -75721.333
[11,] 7444.1667 -31986.333
[12,] -10626.6667 7444.167
[13,] 27767.5000 -10626.667
[14,] -7541.0000 27767.500
[15,] 13234.3333 -7541.000
[16,] 117705.8333 13234.333
[17,] -15074.3333 117705.833
[18,] 299621.8333 -15074.333
[19,] -242874.5000 299621.833
[20,] -67355.0000 -242874.500
[21,] 9280.6667 -67355.000
[22,] -19433.3333 9280.667
[23,] -85424.8333 -19433.333
[24,] -12070.6667 -85424.833
[25,] -42871.5000 -12070.667
[26,] 30681.0000 -42871.500
[27,] 110008.3333 30681.000
[28,] -115671.1667 110008.333
[29,] 128201.6667 -115671.167
[30,] -47019.1667 128201.667
[31,] 34914.5000 -47019.167
[32,] 78898.0000 34914.500
[33,] 54145.6667 78898.000
[34,] 65392.6667 54145.667
[35,] 76130.1667 65392.667
[36,] 45704.3333 76130.167
[37,] -768.5000 45704.333
[38,] -16422.0000 -768.500
[39,] 33627.3333 -16422.000
[40,] -93707.1667 33627.333
[41,] -35897.3333 -93707.167
[42,] -86823.1667 -35897.333
[43,] 9135.5000 -86823.167
[44,] 24340.0000 9135.500
[45,] -11847.3333 24340.000
[46,] -17021.3333 -11847.333
[47,] 12261.1667 -17021.333
[48,] -35061.6667 12261.167
[49,] 67648.5000 -35061.667
[50,] 44299.0000 67648.500
[51,] -141974.6667 44299.000
[52,] 79933.8333 -141974.667
[53,] -29185.3333 79933.833
[54,] -50567.1667 -29185.333
[55,] 107786.5000 -50567.167
[56,] 26968.0000 107786.500
[57,] 13981.6667 26968.000
[58,] 10639.6667 13981.667
[59,] -9592.8333 10639.667
[60,] 19905.3333 -9592.833
[61,] -38839.5000 19905.333
[62,] -42829.0000 -38839.500
[63,] -28266.6667 -42829.000
[64,] -77843.1667 -28266.667
[65,] -16820.3333 -77843.167
[66,] -103655.1667 -16820.333
[67,] 120237.5000 -103655.167
[68,] 11538.0000 120237.500
[69,] 10160.6667 11538.000
[70,] -7591.3333 10160.667
[71,] -817.8333 -7591.333
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -12936.5000 -7850.667
2 -8188.0000 -12936.500
3 13371.3333 -8188.000
4 89581.8333 13371.333
5 -31224.3333 89581.833
6 -11557.1667 -31224.333
7 -29199.5000 -11557.167
8 -74389.0000 -29199.500
9 -75721.3333 -74389.000
10 -31986.3333 -75721.333
11 7444.1667 -31986.333
12 -10626.6667 7444.167
13 27767.5000 -10626.667
14 -7541.0000 27767.500
15 13234.3333 -7541.000
16 117705.8333 13234.333
17 -15074.3333 117705.833
18 299621.8333 -15074.333
19 -242874.5000 299621.833
20 -67355.0000 -242874.500
21 9280.6667 -67355.000
22 -19433.3333 9280.667
23 -85424.8333 -19433.333
24 -12070.6667 -85424.833
25 -42871.5000 -12070.667
26 30681.0000 -42871.500
27 110008.3333 30681.000
28 -115671.1667 110008.333
29 128201.6667 -115671.167
30 -47019.1667 128201.667
31 34914.5000 -47019.167
32 78898.0000 34914.500
33 54145.6667 78898.000
34 65392.6667 54145.667
35 76130.1667 65392.667
36 45704.3333 76130.167
37 -768.5000 45704.333
38 -16422.0000 -768.500
39 33627.3333 -16422.000
40 -93707.1667 33627.333
41 -35897.3333 -93707.167
42 -86823.1667 -35897.333
43 9135.5000 -86823.167
44 24340.0000 9135.500
45 -11847.3333 24340.000
46 -17021.3333 -11847.333
47 12261.1667 -17021.333
48 -35061.6667 12261.167
49 67648.5000 -35061.667
50 44299.0000 67648.500
51 -141974.6667 44299.000
52 79933.8333 -141974.667
53 -29185.3333 79933.833
54 -50567.1667 -29185.333
55 107786.5000 -50567.167
56 26968.0000 107786.500
57 13981.6667 26968.000
58 10639.6667 13981.667
59 -9592.8333 10639.667
60 19905.3333 -9592.833
61 -38839.5000 19905.333
62 -42829.0000 -38839.500
63 -28266.6667 -42829.000
64 -77843.1667 -28266.667
65 -16820.3333 -77843.167
66 -103655.1667 -16820.333
67 120237.5000 -103655.167
68 11538.0000 120237.500
69 10160.6667 11538.000
70 -7591.3333 10160.667
71 -817.8333 -7591.333
> 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/72m0y1324046155.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/8s9h11324046155.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/9nnem1324046155.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')
hat values (leverages) are all = 0.1666667
and there are no factor predictors; no plot no. 5
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/wessaorg/rcomp/tmp/10l3cg1324046155.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/110z0q1324046155.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/125fww1324046155.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/13x9pa1324046155.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/14be3d1324046155.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/1503ct1324046155.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/16dtu11324046155.tab")
+ }
>
> try(system("convert tmp/19d6c1324046155.ps tmp/19d6c1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/2yxpq1324046155.ps tmp/2yxpq1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/3uxnk1324046155.ps tmp/3uxnk1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/4p5e51324046155.ps tmp/4p5e51324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/5qidt1324046155.ps tmp/5qidt1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/6d2ps1324046155.ps tmp/6d2ps1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/72m0y1324046155.ps tmp/72m0y1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/8s9h11324046155.ps tmp/8s9h11324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/9nnem1324046155.ps tmp/9nnem1324046155.png",intern=TRUE))
character(0)
> try(system("convert tmp/10l3cg1324046155.ps tmp/10l3cg1324046155.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.358 0.607 3.986