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(-6,2,-3,2.3,-2,2.8,-5,2.4,-11,2.3,-11,2.7,-11,2.7,-10,2.9,-14,3,-8,2.2,-9,2.3,-5,2.8,-1,2.8,-2,2.8,-5,2.2,-4,2.6,-6,2.8,-2,2.5,-2,2.4,-2,2.3,-2,1.9,2,1.7,1,2,-8,2.1,-1,1.7,1,1.8,-1,1.8,2,1.8,2,1.3,1,1.3,-1,1.3,-2,1.2,-2,1.4,-1,2.2,-8,2.9,-4,3.1,-6,3.5,-3,3.6,-3,4.4,-7,4.1,-9,5.1,-11,5.8,-13,5.9,-11,5.4,-9,5.5,-17,4.8,-22,3.2,-25,2.7,-20,2.1,-24,1.9,-24,0.6,-22,0.7,-19,-0.2,-18,-1,-17,-1.7,-11,-0.7,-11,-1,-12,-0.9,-10,0,-15,0.3,-15,0.8,-15,0.8,-13,1.9,-8,2.1,-13,2.5,-9,2.7,-7,2.4,-4,2.4,-4,2.9,-2,3.1,0,3,-2,3.4,-3,3.7,1,3.5,-2,3.5,-1,3.3,1,3.1,-3,3.4,-4,4,-9,3.4,-9,3.4,-7,3.4),dim=c(2,82),dimnames=list(c('Consumentenvertrouwen','HICP'),1:82))
> y <- array(NA,dim=c(2,82),dimnames=list(c('Consumentenvertrouwen','HICP'),1:82))
> 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'
> 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
Consumentenvertrouwen HICP
1 -6 2.0
2 -3 2.3
3 -2 2.8
4 -5 2.4
5 -11 2.3
6 -11 2.7
7 -11 2.7
8 -10 2.9
9 -14 3.0
10 -8 2.2
11 -9 2.3
12 -5 2.8
13 -1 2.8
14 -2 2.8
15 -5 2.2
16 -4 2.6
17 -6 2.8
18 -2 2.5
19 -2 2.4
20 -2 2.3
21 -2 1.9
22 2 1.7
23 1 2.0
24 -8 2.1
25 -1 1.7
26 1 1.8
27 -1 1.8
28 2 1.8
29 2 1.3
30 1 1.3
31 -1 1.3
32 -2 1.2
33 -2 1.4
34 -1 2.2
35 -8 2.9
36 -4 3.1
37 -6 3.5
38 -3 3.6
39 -3 4.4
40 -7 4.1
41 -9 5.1
42 -11 5.8
43 -13 5.9
44 -11 5.4
45 -9 5.5
46 -17 4.8
47 -22 3.2
48 -25 2.7
49 -20 2.1
50 -24 1.9
51 -24 0.6
52 -22 0.7
53 -19 -0.2
54 -18 -1.0
55 -17 -1.7
56 -11 -0.7
57 -11 -1.0
58 -12 -0.9
59 -10 0.0
60 -15 0.3
61 -15 0.8
62 -15 0.8
63 -13 1.9
64 -8 2.1
65 -13 2.5
66 -9 2.7
67 -7 2.4
68 -4 2.4
69 -4 2.9
70 -2 3.1
71 0 3.0
72 -2 3.4
73 -3 3.7
74 1 3.5
75 -2 3.5
76 -1 3.3
77 1 3.1
78 -3 3.4
79 -4 4.0
80 -9 3.4
81 -9 3.4
82 -7 3.4
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) HICP
-9.6702 0.9435
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-17.8771 -4.0754 0.7172 5.2408 10.4437
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -9.6702 1.4078 -6.869 1.26e-09 ***
HICP 0.9435 0.4984 1.893 0.062 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.696 on 80 degrees of freedom
Multiple R-squared: 0.04288, Adjusted R-squared: 0.03091
F-statistic: 3.584 on 1 and 80 DF, p-value: 0.06196
> 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.536327e-01 3.072655e-01 8.463673e-01
[2,] 1.893075e-01 3.786150e-01 8.106925e-01
[3,] 1.443655e-01 2.887310e-01 8.556345e-01
[4,] 8.169307e-02 1.633861e-01 9.183069e-01
[5,] 6.629795e-02 1.325959e-01 9.337021e-01
[6,] 3.609817e-02 7.219633e-02 9.639018e-01
[7,] 1.937484e-02 3.874969e-02 9.806252e-01
[8,] 1.508423e-02 3.016847e-02 9.849158e-01
[9,] 2.789659e-02 5.579317e-02 9.721034e-01
[10,] 2.790649e-02 5.581298e-02 9.720935e-01
[11,] 1.614434e-02 3.228867e-02 9.838557e-01
[12,] 1.026985e-02 2.053969e-02 9.897302e-01
[13,] 5.415339e-03 1.083068e-02 9.945847e-01
[14,] 4.540128e-03 9.080257e-03 9.954599e-01
[15,] 3.546362e-03 7.092724e-03 9.964536e-01
[16,] 2.573652e-03 5.147303e-03 9.974263e-01
[17,] 1.581375e-03 3.162750e-03 9.984186e-01
[18,] 1.641905e-03 3.283810e-03 9.983581e-01
[19,] 1.477217e-03 2.954435e-03 9.985228e-01
[20,] 1.187742e-03 2.375484e-03 9.988123e-01
[21,] 7.235003e-04 1.447001e-03 9.992765e-01
[22,] 5.890145e-04 1.178029e-03 9.994110e-01
[23,] 3.670652e-04 7.341303e-04 9.996329e-01
[24,] 3.725011e-04 7.450023e-04 9.996275e-01
[25,] 3.201375e-04 6.402749e-04 9.996799e-01
[26,] 2.747361e-04 5.494721e-04 9.997253e-01
[27,] 2.424784e-04 4.849567e-04 9.997575e-01
[28,] 2.460129e-04 4.920258e-04 9.997540e-01
[29,] 2.111940e-04 4.223879e-04 9.997888e-01
[30,] 2.068106e-04 4.136212e-04 9.997932e-01
[31,] 1.080002e-04 2.160003e-04 9.998920e-01
[32,] 9.678139e-05 1.935628e-04 9.999032e-01
[33,] 6.782720e-05 1.356544e-04 9.999322e-01
[34,] 1.003345e-04 2.006690e-04 9.998997e-01
[35,] 1.870932e-04 3.741863e-04 9.998129e-01
[36,] 1.020787e-04 2.041575e-04 9.998979e-01
[37,] 5.602260e-05 1.120452e-04 9.999440e-01
[38,] 3.449414e-05 6.898828e-05 9.999655e-01
[39,] 2.858795e-05 5.717590e-05 9.999714e-01
[40,] 1.906905e-05 3.813811e-05 9.999809e-01
[41,] 1.280787e-05 2.561575e-05 9.999872e-01
[42,] 8.167736e-05 1.633547e-04 9.999183e-01
[43,] 9.443990e-03 1.888798e-02 9.905560e-01
[44,] 3.109400e-01 6.218801e-01 6.890600e-01
[45,] 6.262892e-01 7.474216e-01 3.737108e-01
[46,] 9.578550e-01 8.428998e-02 4.214499e-02
[47,] 9.974838e-01 5.032411e-03 2.516205e-03
[48,] 9.998235e-01 3.529959e-04 1.764979e-04
[49,] 9.999162e-01 1.675562e-04 8.377809e-05
[50,] 9.999109e-01 1.782603e-04 8.913015e-05
[51,] 9.998542e-01 2.916985e-04 1.458492e-04
[52,] 9.997646e-01 4.708547e-04 2.354274e-04
[53,] 9.997336e-01 5.328152e-04 2.664076e-04
[54,] 9.997392e-01 5.215421e-04 2.607710e-04
[55,] 9.998261e-01 3.477719e-04 1.738859e-04
[56,] 9.996739e-01 6.521508e-04 3.260754e-04
[57,] 9.993589e-01 1.282163e-03 6.410815e-04
[58,] 9.987676e-01 2.464793e-03 1.232396e-03
[59,] 9.984014e-01 3.197280e-03 1.598640e-03
[60,] 9.967452e-01 6.509675e-03 3.254837e-03
[61,] 9.986319e-01 2.736194e-03 1.368097e-03
[62,] 9.986480e-01 2.704040e-03 1.352020e-03
[63,] 9.981874e-01 3.625195e-03 1.812597e-03
[64,] 9.966810e-01 6.638040e-03 3.319020e-03
[65,] 9.939974e-01 1.200525e-02 6.002623e-03
[66,] 9.874968e-01 2.500633e-02 1.250317e-02
[67,] 9.780692e-01 4.386157e-02 2.193079e-02
[68,] 9.589493e-01 8.210150e-02 4.105075e-02
[69,] 9.244327e-01 1.511345e-01 7.556725e-02
[70,] 9.233239e-01 1.533521e-01 7.667605e-02
[71,] 8.740816e-01 2.518369e-01 1.259184e-01
[72,] 8.149121e-01 3.701759e-01 1.850879e-01
[73,] 9.172394e-01 1.655213e-01 8.276064e-02
> postscript(file="/var/wessaorg/rcomp/tmp/1j7of1321985347.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/2ak8g1321985347.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/331o71321985347.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/49izt1321985347.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/5voul1321985347.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 = 82
Frequency = 1
1 2 3 4 5 6
1.7832723 4.5002361 5.0285090 2.4058907 -3.4997639 -3.8771455
7 8 9 10 11 12
-3.8771455 -3.0658364 -7.1601818 -0.4054185 -1.4997639 2.0285090
13 14 15 16 17 18
6.0285090 5.0285090 2.5945815 3.2171999 1.0285090 5.3115453
19 20 21 22 23 24
5.4058907 5.5002361 5.8776177 10.0663086 8.7832723 -0.3110731
25 26 27 28 29 30
7.0663086 8.9719631 6.9719631 9.9719631 10.4436902 9.4436902
31 32 33 34 35 36
7.4436902 6.5380356 6.3493448 6.5945815 -1.0658364 2.7454728
37 38 39 40 41 42
0.3680912 3.2737458 2.5189825 -1.1979813 -4.1414354 -6.8018532
43 44 45 46 47 48
-8.8961986 -6.4244716 -4.5188170 -11.8583991 -15.3488726 -17.8771455
49 50 51 52 53 54
-12.3110731 -16.1223823 -14.8958919 -12.9902374 -9.1411287 -7.3863654
55 56 57 58 59 60
-5.7259475 -0.6694016 -0.3863654 -1.4807108 -0.3298195 -5.6128557
61 62 63 64 65 66
-6.0845828 -6.0845828 -5.1223823 -0.3110731 -5.6884547 -1.8771455
67 68 69 70 71 72
0.4058907 3.4058907 2.9341636 4.7454728 6.8398182 4.4624366
73 74 75 76 77 78
3.1794004 7.3680912 4.3680912 5.5567820 7.7454728 3.4624366
79 80 81 82
1.8963641 -2.5375634 -2.5375634 -0.5375634
> postscript(file="/var/wessaorg/rcomp/tmp/662uw1321985347.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 = 82
Frequency = 1
lag(myerror, k = 1) myerror
0 1.7832723 NA
1 4.5002361 1.7832723
2 5.0285090 4.5002361
3 2.4058907 5.0285090
4 -3.4997639 2.4058907
5 -3.8771455 -3.4997639
6 -3.8771455 -3.8771455
7 -3.0658364 -3.8771455
8 -7.1601818 -3.0658364
9 -0.4054185 -7.1601818
10 -1.4997639 -0.4054185
11 2.0285090 -1.4997639
12 6.0285090 2.0285090
13 5.0285090 6.0285090
14 2.5945815 5.0285090
15 3.2171999 2.5945815
16 1.0285090 3.2171999
17 5.3115453 1.0285090
18 5.4058907 5.3115453
19 5.5002361 5.4058907
20 5.8776177 5.5002361
21 10.0663086 5.8776177
22 8.7832723 10.0663086
23 -0.3110731 8.7832723
24 7.0663086 -0.3110731
25 8.9719631 7.0663086
26 6.9719631 8.9719631
27 9.9719631 6.9719631
28 10.4436902 9.9719631
29 9.4436902 10.4436902
30 7.4436902 9.4436902
31 6.5380356 7.4436902
32 6.3493448 6.5380356
33 6.5945815 6.3493448
34 -1.0658364 6.5945815
35 2.7454728 -1.0658364
36 0.3680912 2.7454728
37 3.2737458 0.3680912
38 2.5189825 3.2737458
39 -1.1979813 2.5189825
40 -4.1414354 -1.1979813
41 -6.8018532 -4.1414354
42 -8.8961986 -6.8018532
43 -6.4244716 -8.8961986
44 -4.5188170 -6.4244716
45 -11.8583991 -4.5188170
46 -15.3488726 -11.8583991
47 -17.8771455 -15.3488726
48 -12.3110731 -17.8771455
49 -16.1223823 -12.3110731
50 -14.8958919 -16.1223823
51 -12.9902374 -14.8958919
52 -9.1411287 -12.9902374
53 -7.3863654 -9.1411287
54 -5.7259475 -7.3863654
55 -0.6694016 -5.7259475
56 -0.3863654 -0.6694016
57 -1.4807108 -0.3863654
58 -0.3298195 -1.4807108
59 -5.6128557 -0.3298195
60 -6.0845828 -5.6128557
61 -6.0845828 -6.0845828
62 -5.1223823 -6.0845828
63 -0.3110731 -5.1223823
64 -5.6884547 -0.3110731
65 -1.8771455 -5.6884547
66 0.4058907 -1.8771455
67 3.4058907 0.4058907
68 2.9341636 3.4058907
69 4.7454728 2.9341636
70 6.8398182 4.7454728
71 4.4624366 6.8398182
72 3.1794004 4.4624366
73 7.3680912 3.1794004
74 4.3680912 7.3680912
75 5.5567820 4.3680912
76 7.7454728 5.5567820
77 3.4624366 7.7454728
78 1.8963641 3.4624366
79 -2.5375634 1.8963641
80 -2.5375634 -2.5375634
81 -0.5375634 -2.5375634
82 NA -0.5375634
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 4.5002361 1.7832723
[2,] 5.0285090 4.5002361
[3,] 2.4058907 5.0285090
[4,] -3.4997639 2.4058907
[5,] -3.8771455 -3.4997639
[6,] -3.8771455 -3.8771455
[7,] -3.0658364 -3.8771455
[8,] -7.1601818 -3.0658364
[9,] -0.4054185 -7.1601818
[10,] -1.4997639 -0.4054185
[11,] 2.0285090 -1.4997639
[12,] 6.0285090 2.0285090
[13,] 5.0285090 6.0285090
[14,] 2.5945815 5.0285090
[15,] 3.2171999 2.5945815
[16,] 1.0285090 3.2171999
[17,] 5.3115453 1.0285090
[18,] 5.4058907 5.3115453
[19,] 5.5002361 5.4058907
[20,] 5.8776177 5.5002361
[21,] 10.0663086 5.8776177
[22,] 8.7832723 10.0663086
[23,] -0.3110731 8.7832723
[24,] 7.0663086 -0.3110731
[25,] 8.9719631 7.0663086
[26,] 6.9719631 8.9719631
[27,] 9.9719631 6.9719631
[28,] 10.4436902 9.9719631
[29,] 9.4436902 10.4436902
[30,] 7.4436902 9.4436902
[31,] 6.5380356 7.4436902
[32,] 6.3493448 6.5380356
[33,] 6.5945815 6.3493448
[34,] -1.0658364 6.5945815
[35,] 2.7454728 -1.0658364
[36,] 0.3680912 2.7454728
[37,] 3.2737458 0.3680912
[38,] 2.5189825 3.2737458
[39,] -1.1979813 2.5189825
[40,] -4.1414354 -1.1979813
[41,] -6.8018532 -4.1414354
[42,] -8.8961986 -6.8018532
[43,] -6.4244716 -8.8961986
[44,] -4.5188170 -6.4244716
[45,] -11.8583991 -4.5188170
[46,] -15.3488726 -11.8583991
[47,] -17.8771455 -15.3488726
[48,] -12.3110731 -17.8771455
[49,] -16.1223823 -12.3110731
[50,] -14.8958919 -16.1223823
[51,] -12.9902374 -14.8958919
[52,] -9.1411287 -12.9902374
[53,] -7.3863654 -9.1411287
[54,] -5.7259475 -7.3863654
[55,] -0.6694016 -5.7259475
[56,] -0.3863654 -0.6694016
[57,] -1.4807108 -0.3863654
[58,] -0.3298195 -1.4807108
[59,] -5.6128557 -0.3298195
[60,] -6.0845828 -5.6128557
[61,] -6.0845828 -6.0845828
[62,] -5.1223823 -6.0845828
[63,] -0.3110731 -5.1223823
[64,] -5.6884547 -0.3110731
[65,] -1.8771455 -5.6884547
[66,] 0.4058907 -1.8771455
[67,] 3.4058907 0.4058907
[68,] 2.9341636 3.4058907
[69,] 4.7454728 2.9341636
[70,] 6.8398182 4.7454728
[71,] 4.4624366 6.8398182
[72,] 3.1794004 4.4624366
[73,] 7.3680912 3.1794004
[74,] 4.3680912 7.3680912
[75,] 5.5567820 4.3680912
[76,] 7.7454728 5.5567820
[77,] 3.4624366 7.7454728
[78,] 1.8963641 3.4624366
[79,] -2.5375634 1.8963641
[80,] -2.5375634 -2.5375634
[81,] -0.5375634 -2.5375634
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 4.5002361 1.7832723
2 5.0285090 4.5002361
3 2.4058907 5.0285090
4 -3.4997639 2.4058907
5 -3.8771455 -3.4997639
6 -3.8771455 -3.8771455
7 -3.0658364 -3.8771455
8 -7.1601818 -3.0658364
9 -0.4054185 -7.1601818
10 -1.4997639 -0.4054185
11 2.0285090 -1.4997639
12 6.0285090 2.0285090
13 5.0285090 6.0285090
14 2.5945815 5.0285090
15 3.2171999 2.5945815
16 1.0285090 3.2171999
17 5.3115453 1.0285090
18 5.4058907 5.3115453
19 5.5002361 5.4058907
20 5.8776177 5.5002361
21 10.0663086 5.8776177
22 8.7832723 10.0663086
23 -0.3110731 8.7832723
24 7.0663086 -0.3110731
25 8.9719631 7.0663086
26 6.9719631 8.9719631
27 9.9719631 6.9719631
28 10.4436902 9.9719631
29 9.4436902 10.4436902
30 7.4436902 9.4436902
31 6.5380356 7.4436902
32 6.3493448 6.5380356
33 6.5945815 6.3493448
34 -1.0658364 6.5945815
35 2.7454728 -1.0658364
36 0.3680912 2.7454728
37 3.2737458 0.3680912
38 2.5189825 3.2737458
39 -1.1979813 2.5189825
40 -4.1414354 -1.1979813
41 -6.8018532 -4.1414354
42 -8.8961986 -6.8018532
43 -6.4244716 -8.8961986
44 -4.5188170 -6.4244716
45 -11.8583991 -4.5188170
46 -15.3488726 -11.8583991
47 -17.8771455 -15.3488726
48 -12.3110731 -17.8771455
49 -16.1223823 -12.3110731
50 -14.8958919 -16.1223823
51 -12.9902374 -14.8958919
52 -9.1411287 -12.9902374
53 -7.3863654 -9.1411287
54 -5.7259475 -7.3863654
55 -0.6694016 -5.7259475
56 -0.3863654 -0.6694016
57 -1.4807108 -0.3863654
58 -0.3298195 -1.4807108
59 -5.6128557 -0.3298195
60 -6.0845828 -5.6128557
61 -6.0845828 -6.0845828
62 -5.1223823 -6.0845828
63 -0.3110731 -5.1223823
64 -5.6884547 -0.3110731
65 -1.8771455 -5.6884547
66 0.4058907 -1.8771455
67 3.4058907 0.4058907
68 2.9341636 3.4058907
69 4.7454728 2.9341636
70 6.8398182 4.7454728
71 4.4624366 6.8398182
72 3.1794004 4.4624366
73 7.3680912 3.1794004
74 4.3680912 7.3680912
75 5.5567820 4.3680912
76 7.7454728 5.5567820
77 3.4624366 7.7454728
78 1.8963641 3.4624366
79 -2.5375634 1.8963641
80 -2.5375634 -2.5375634
81 -0.5375634 -2.5375634
> 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/7fav71321985347.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/8v3ce1321985347.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/9a0tk1321985347.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/10l20o1321985347.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/114pwd1321985347.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/128v731321985347.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/13k1oq1321985347.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/143jmj1321985347.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/15thro1321985347.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/16k33v1321985347.tab")
+ }
>
> try(system("convert tmp/1j7of1321985347.ps tmp/1j7of1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/2ak8g1321985347.ps tmp/2ak8g1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/331o71321985347.ps tmp/331o71321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/49izt1321985347.ps tmp/49izt1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/5voul1321985347.ps tmp/5voul1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/662uw1321985347.ps tmp/662uw1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/7fav71321985347.ps tmp/7fav71321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/8v3ce1321985347.ps tmp/8v3ce1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/9a0tk1321985347.ps tmp/9a0tk1321985347.png",intern=TRUE))
character(0)
> try(system("convert tmp/10l20o1321985347.ps tmp/10l20o1321985347.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.342 0.496 4.111