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(31/01/2006
+ ,-1
+ ,-3
+ ,24
+ ,6
+ ,17
+ ,28/02/2006
+ ,-2
+ ,-4
+ ,24
+ ,6
+ ,13
+ ,31/03/2006
+ ,-5
+ ,-7
+ ,31
+ ,5
+ ,12
+ ,30/04/2006
+ ,-4
+ ,-7
+ ,25
+ ,5
+ ,13
+ ,31/05/2006
+ ,-6
+ ,-7
+ ,28
+ ,3
+ ,10
+ ,30/06/2006
+ ,-2
+ ,-3
+ ,24
+ ,5
+ ,14
+ ,31/07/2006
+ ,-2
+ ,0
+ ,25
+ ,5
+ ,13
+ ,31/08/2006
+ ,-2
+ ,-5
+ ,16
+ ,5
+ ,10
+ ,30/09/2006
+ ,-2
+ ,-3
+ ,17
+ ,3
+ ,11
+ ,31/10/2006
+ ,2
+ ,3
+ ,11
+ ,6
+ ,12
+ ,30/11/2006
+ ,1
+ ,2
+ ,12
+ ,6
+ ,7
+ ,31/12/2006
+ ,-8
+ ,-7
+ ,39
+ ,4
+ ,11
+ ,31/01/2007
+ ,-1
+ ,-1
+ ,19
+ ,6
+ ,9
+ ,28/02/2007
+ ,1
+ ,0
+ ,14
+ ,5
+ ,13
+ ,31/03/2007
+ ,-1
+ ,-3
+ ,15
+ ,4
+ ,12
+ ,30/04/2007
+ ,2
+ ,4
+ ,7
+ ,5
+ ,5
+ ,31/05/2007
+ ,2
+ ,2
+ ,12
+ ,5
+ ,13
+ ,30/06/2007
+ ,1
+ ,3
+ ,12
+ ,4
+ ,11
+ ,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1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '2'
> 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
CVI Maand Econ.Sit. Werkloos Fin.Sit. Spaarverm. t
1 -1 0.015453639 -3 24 6 17 1
2 -2 0.006979063 -4 24 6 13 2
3 -5 0.005151213 -7 31 5 12 3
4 -4 0.003738784 -7 25 5 13 4
5 -6 0.003090728 -7 28 3 10 5
6 -2 0.002492522 -3 24 5 14 6
7 -2 0.002207663 0 25 5 13 7
8 -2 0.001931705 -5 16 5 10 8
9 -2 0.001661682 -3 17 3 11 9
10 2 0.001545364 3 11 6 12 10
11 1 0.001359558 2 12 6 7 11
12 -8 0.001287803 -7 39 4 11 12
13 -1 0.015445939 -1 19 6 9 13
14 1 0.006975585 0 14 5 13 14
15 -1 0.005148646 -3 15 4 12 15
16 2 0.003736921 4 7 5 5 16
17 2 0.003089188 2 12 5 13 17
18 1 0.002491281 3 12 4 11 18
19 -1 0.002206563 0 14 3 8 19
20 -2 0.001930742 -10 9 2 8 20
21 -2 0.001660854 -10 8 3 8 21
22 -1 0.001544594 -9 4 2 8 22
23 -8 0.001358880 -22 7 -1 0 23
24 -4 0.001287162 -16 3 0 3 24
25 -6 0.015438247 -18 5 -2 0 25
26 -3 0.007221116 -14 0 1 -1 26
27 -3 0.005146082 -12 -2 -2 -1 27
28 -7 0.003735060 -17 6 -2 -4 28
29 -9 0.003087649 -23 11 -2 1 29
30 -11 0.002490040 -28 9 -6 -1 30
31 -13 0.002205464 -31 17 -4 0 31
32 -11 0.001929781 -21 21 -2 -1 32
33 -9 0.001660027 -19 21 0 6 33
34 -17 0.001543825 -22 41 -5 0 34
35 -22 0.001358204 -22 57 -4 -3 35
36 -25 0.001286521 -25 65 -5 -3 36
37 -20 0.015430562 -16 68 -1 4 37
38 -24 0.006968641 -22 73 -2 1 38
39 -24 0.005143521 -21 71 -4 0 39
40 -22 0.003733201 -10 71 -1 -4 40
41 -19 0.003086112 -7 70 1 -2 41
42 -18 0.002488800 -5 69 1 3 42
43 -17 0.002204366 -4 65 -2 2 43
44 -11 0.001928820 7 57 1 5 44
45 -11 0.001659200 6 57 1 6 45
46 -12 0.001543056 3 57 3 6 46
47 -10 0.001357527 10 55 3 3 47
48 -15 0.001285880 0 65 1 4 48
49 -15 0.015422886 -2 65 1 7 49
50 -15 0.006965174 -1 64 0 5 50
51 -13 0.005140962 2 60 2 6 51
52 -8 0.003731343 8 43 2 1 52
53 -13 0.003084577 -6 47 -1 3 53
54 -9 0.002487562 -4 40 1 6 54
55 -7 0.002203269 4 31 0 0 55
56 -4 0.001927861 7 27 1 3 56
57 -4 0.001658375 3 24 1 4 57
58 -2 0.001542289 3 23 3 7 58
59 0 0.001356852 8 17 2 6 59
60 -2 0.001285240 3 16 0 6 60
61 -3 0.015415216 -3 15 0 6 61
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Maand Econ.Sit. Werkloos Fin.Sit. Spaarverm.
-0.03127 25.04364 0.25082 -0.25354 0.28106 0.22093
t
0.00220
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.57827 -0.25487 0.03196 0.20914 0.55423
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.031267 0.246981 -0.127 0.8997
Maand 25.043638 9.582205 2.614 0.0116 *
Econ.Sit. 0.250821 0.009393 26.702 < 2e-16 ***
Werkloos -0.253535 0.001874 -135.270 < 2e-16 ***
Fin.Sit. 0.281058 0.038903 7.225 1.78e-09 ***
Spaarverm. 0.220929 0.014327 15.420 < 2e-16 ***
t 0.002200 0.004616 0.477 0.6356
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.295 on 54 degrees of freedom
Multiple R-squared: 0.9986, Adjusted R-squared: 0.9984
F-statistic: 6376 on 6 and 54 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.68110407 0.63779187 0.31889593
[2,] 0.63894764 0.72210472 0.36105236
[3,] 0.49746456 0.99492912 0.50253544
[4,] 0.36471188 0.72942376 0.63528812
[5,] 0.49343891 0.98687781 0.50656109
[6,] 0.39413351 0.78826702 0.60586649
[7,] 0.33267410 0.66534819 0.66732590
[8,] 0.33395885 0.66791770 0.66604115
[9,] 0.29826837 0.59653673 0.70173163
[10,] 0.23583400 0.47166800 0.76416600
[11,] 0.49655986 0.99311971 0.50344014
[12,] 0.44523352 0.89046704 0.55476648
[13,] 0.36020057 0.72040114 0.63979943
[14,] 0.39447893 0.78895786 0.60552107
[15,] 0.37049820 0.74099640 0.62950180
[16,] 0.31011131 0.62022261 0.68988869
[17,] 0.27989231 0.55978463 0.72010769
[18,] 0.26250344 0.52500688 0.73749656
[19,] 0.21205853 0.42411706 0.78794147
[20,] 0.17086658 0.34173316 0.82913342
[21,] 0.15067088 0.30134175 0.84932912
[22,] 0.11177007 0.22354014 0.88822993
[23,] 0.10546917 0.21093834 0.89453083
[24,] 0.11985030 0.23970061 0.88014970
[25,] 0.08545340 0.17090680 0.91454660
[26,] 0.12486273 0.24972547 0.87513727
[27,] 0.15284323 0.30568647 0.84715677
[28,] 0.12801970 0.25603940 0.87198030
[29,] 0.09072800 0.18145600 0.90927200
[30,] 0.06495119 0.12990238 0.93504881
[31,] 0.12001580 0.24003161 0.87998420
[32,] 0.28892295 0.57784590 0.71107705
[33,] 0.27285721 0.54571442 0.72714279
[34,] 0.34974609 0.69949217 0.65025391
[35,] 0.30609391 0.61218783 0.69390609
[36,] 0.46159829 0.92319659 0.53840171
[37,] 0.71094508 0.57810985 0.28905492
[38,] 0.73952166 0.52095668 0.26047834
[39,] 0.63928724 0.72142551 0.36071276
[40,] 0.71746565 0.56506869 0.28253435
[41,] 0.94766405 0.10467190 0.05233595
[42,] 0.95899421 0.08201158 0.04100579
> postscript(file="/var/wessaorg/rcomp/tmp/1hvet1322130619.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/26prk1322130619.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/3wrlb1322130619.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/4y4091322130619.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/5w98c1322130619.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 = 61
Frequency = 1
1 2 3 4 5 6
0.037211714 0.381784717 0.454557316 -0.254410650 -0.254870986 0.294652965
7 8 9 10 11 12
0.021589331 -0.338623850 -0.240981208 -0.330507243 0.280949422 0.061783028
13 14 15 16 17 18
0.009125965 0.097898164 -0.350563295 0.164012231 0.179916583 -0.335213428
19 20 21 22 23 24
-0.126903693 0.399394358 -0.130639442 -0.113831308 -0.479494615 0.057189848
25 26 27 28 29 30
-0.065788365 0.244595133 0.128823482 0.107134989 -0.210897187 0.114993647
31 32 33 34 35 36
0.117619721 0.287070252 -0.318637134 0.236105956 -0.323151449 -0.261753855
37 38 39 40 41 42
0.214308853 0.140473631 0.209135582 -0.476229792 0.527803632 -0.319261089
43 44 45 46 47 48
0.484803974 0.196232199 0.230676212 -0.578268122 -0.175849500 0.208491940
49 50 51 52 53 54
-0.308896340 0.119276528 -0.386886793 -0.064160984 -0.123215896 0.388243689
55 56 57 58 59 60
-0.288585434 0.005662663 0.031960186 0.554228479 0.283344714 -0.154376779
61
-0.259052672
> postscript(file="/var/wessaorg/rcomp/tmp/65qy71322130619.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 0.037211714 NA
1 0.381784717 0.037211714
2 0.454557316 0.381784717
3 -0.254410650 0.454557316
4 -0.254870986 -0.254410650
5 0.294652965 -0.254870986
6 0.021589331 0.294652965
7 -0.338623850 0.021589331
8 -0.240981208 -0.338623850
9 -0.330507243 -0.240981208
10 0.280949422 -0.330507243
11 0.061783028 0.280949422
12 0.009125965 0.061783028
13 0.097898164 0.009125965
14 -0.350563295 0.097898164
15 0.164012231 -0.350563295
16 0.179916583 0.164012231
17 -0.335213428 0.179916583
18 -0.126903693 -0.335213428
19 0.399394358 -0.126903693
20 -0.130639442 0.399394358
21 -0.113831308 -0.130639442
22 -0.479494615 -0.113831308
23 0.057189848 -0.479494615
24 -0.065788365 0.057189848
25 0.244595133 -0.065788365
26 0.128823482 0.244595133
27 0.107134989 0.128823482
28 -0.210897187 0.107134989
29 0.114993647 -0.210897187
30 0.117619721 0.114993647
31 0.287070252 0.117619721
32 -0.318637134 0.287070252
33 0.236105956 -0.318637134
34 -0.323151449 0.236105956
35 -0.261753855 -0.323151449
36 0.214308853 -0.261753855
37 0.140473631 0.214308853
38 0.209135582 0.140473631
39 -0.476229792 0.209135582
40 0.527803632 -0.476229792
41 -0.319261089 0.527803632
42 0.484803974 -0.319261089
43 0.196232199 0.484803974
44 0.230676212 0.196232199
45 -0.578268122 0.230676212
46 -0.175849500 -0.578268122
47 0.208491940 -0.175849500
48 -0.308896340 0.208491940
49 0.119276528 -0.308896340
50 -0.386886793 0.119276528
51 -0.064160984 -0.386886793
52 -0.123215896 -0.064160984
53 0.388243689 -0.123215896
54 -0.288585434 0.388243689
55 0.005662663 -0.288585434
56 0.031960186 0.005662663
57 0.554228479 0.031960186
58 0.283344714 0.554228479
59 -0.154376779 0.283344714
60 -0.259052672 -0.154376779
61 NA -0.259052672
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.381784717 0.037211714
[2,] 0.454557316 0.381784717
[3,] -0.254410650 0.454557316
[4,] -0.254870986 -0.254410650
[5,] 0.294652965 -0.254870986
[6,] 0.021589331 0.294652965
[7,] -0.338623850 0.021589331
[8,] -0.240981208 -0.338623850
[9,] -0.330507243 -0.240981208
[10,] 0.280949422 -0.330507243
[11,] 0.061783028 0.280949422
[12,] 0.009125965 0.061783028
[13,] 0.097898164 0.009125965
[14,] -0.350563295 0.097898164
[15,] 0.164012231 -0.350563295
[16,] 0.179916583 0.164012231
[17,] -0.335213428 0.179916583
[18,] -0.126903693 -0.335213428
[19,] 0.399394358 -0.126903693
[20,] -0.130639442 0.399394358
[21,] -0.113831308 -0.130639442
[22,] -0.479494615 -0.113831308
[23,] 0.057189848 -0.479494615
[24,] -0.065788365 0.057189848
[25,] 0.244595133 -0.065788365
[26,] 0.128823482 0.244595133
[27,] 0.107134989 0.128823482
[28,] -0.210897187 0.107134989
[29,] 0.114993647 -0.210897187
[30,] 0.117619721 0.114993647
[31,] 0.287070252 0.117619721
[32,] -0.318637134 0.287070252
[33,] 0.236105956 -0.318637134
[34,] -0.323151449 0.236105956
[35,] -0.261753855 -0.323151449
[36,] 0.214308853 -0.261753855
[37,] 0.140473631 0.214308853
[38,] 0.209135582 0.140473631
[39,] -0.476229792 0.209135582
[40,] 0.527803632 -0.476229792
[41,] -0.319261089 0.527803632
[42,] 0.484803974 -0.319261089
[43,] 0.196232199 0.484803974
[44,] 0.230676212 0.196232199
[45,] -0.578268122 0.230676212
[46,] -0.175849500 -0.578268122
[47,] 0.208491940 -0.175849500
[48,] -0.308896340 0.208491940
[49,] 0.119276528 -0.308896340
[50,] -0.386886793 0.119276528
[51,] -0.064160984 -0.386886793
[52,] -0.123215896 -0.064160984
[53,] 0.388243689 -0.123215896
[54,] -0.288585434 0.388243689
[55,] 0.005662663 -0.288585434
[56,] 0.031960186 0.005662663
[57,] 0.554228479 0.031960186
[58,] 0.283344714 0.554228479
[59,] -0.154376779 0.283344714
[60,] -0.259052672 -0.154376779
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.381784717 0.037211714
2 0.454557316 0.381784717
3 -0.254410650 0.454557316
4 -0.254870986 -0.254410650
5 0.294652965 -0.254870986
6 0.021589331 0.294652965
7 -0.338623850 0.021589331
8 -0.240981208 -0.338623850
9 -0.330507243 -0.240981208
10 0.280949422 -0.330507243
11 0.061783028 0.280949422
12 0.009125965 0.061783028
13 0.097898164 0.009125965
14 -0.350563295 0.097898164
15 0.164012231 -0.350563295
16 0.179916583 0.164012231
17 -0.335213428 0.179916583
18 -0.126903693 -0.335213428
19 0.399394358 -0.126903693
20 -0.130639442 0.399394358
21 -0.113831308 -0.130639442
22 -0.479494615 -0.113831308
23 0.057189848 -0.479494615
24 -0.065788365 0.057189848
25 0.244595133 -0.065788365
26 0.128823482 0.244595133
27 0.107134989 0.128823482
28 -0.210897187 0.107134989
29 0.114993647 -0.210897187
30 0.117619721 0.114993647
31 0.287070252 0.117619721
32 -0.318637134 0.287070252
33 0.236105956 -0.318637134
34 -0.323151449 0.236105956
35 -0.261753855 -0.323151449
36 0.214308853 -0.261753855
37 0.140473631 0.214308853
38 0.209135582 0.140473631
39 -0.476229792 0.209135582
40 0.527803632 -0.476229792
41 -0.319261089 0.527803632
42 0.484803974 -0.319261089
43 0.196232199 0.484803974
44 0.230676212 0.196232199
45 -0.578268122 0.230676212
46 -0.175849500 -0.578268122
47 0.208491940 -0.175849500
48 -0.308896340 0.208491940
49 0.119276528 -0.308896340
50 -0.386886793 0.119276528
51 -0.064160984 -0.386886793
52 -0.123215896 -0.064160984
53 0.388243689 -0.123215896
54 -0.288585434 0.388243689
55 0.005662663 -0.288585434
56 0.031960186 0.005662663
57 0.554228479 0.031960186
58 0.283344714 0.554228479
59 -0.154376779 0.283344714
60 -0.259052672 -0.154376779
> 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/7g6cf1322130619.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/89hxr1322130619.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/9cbkj1322130619.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/101b3x1322130619.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/112p911322130619.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/12t9bq1322130619.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/13jj2o1322130619.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/1491wq1322130619.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/15785h1322130619.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/16q3831322130619.tab")
+ }
>
> try(system("convert tmp/1hvet1322130619.ps tmp/1hvet1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/26prk1322130619.ps tmp/26prk1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/3wrlb1322130619.ps tmp/3wrlb1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/4y4091322130619.ps tmp/4y4091322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/5w98c1322130619.ps tmp/5w98c1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/65qy71322130619.ps tmp/65qy71322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/7g6cf1322130619.ps tmp/7g6cf1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/89hxr1322130619.ps tmp/89hxr1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/9cbkj1322130619.ps tmp/9cbkj1322130619.png",intern=TRUE))
character(0)
> try(system("convert tmp/101b3x1322130619.ps tmp/101b3x1322130619.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.343 0.522 3.897