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
+ ,-4
+ ,38
+ ,6
+ ,14
+ ,-3
+ ,-2
+ ,37
+ ,6
+ ,19
+ ,-2
+ ,2
+ ,32
+ ,5
+ ,16
+ ,-5
+ ,-5
+ ,32
+ ,3
+ ,16
+ ,-11
+ ,-15
+ ,44
+ ,2
+ ,11
+ ,-11
+ ,-16
+ ,43
+ ,3
+ ,13
+ ,-11
+ ,-18
+ ,42
+ ,3
+ ,12
+ ,-10
+ ,-13
+ ,38
+ ,2
+ ,11
+ ,-14
+ ,-23
+ ,37
+ ,0
+ ,6
+ ,-8
+ ,-10
+ ,35
+ ,4
+ ,9
+ ,-9
+ ,-10
+ ,37
+ ,4
+ ,6
+ ,-5
+ ,-6
+ ,33
+ ,5
+ ,15
+ ,-1
+ ,-3
+ ,24
+ ,6
+ ,17
+ ,-2
+ ,-4
+ ,24
+ ,6
+ ,13
+ ,-5
+ ,-7
+ ,31
+ ,5
+ ,12
+ ,-4
+ ,-7
+ ,25
+ ,5
+ ,13
+ ,-6
+ ,-7
+ ,28
+ ,3
+ ,10
+ ,-2
+ ,-3
+ ,24
+ ,5
+ ,14
+ ,-2
+ ,0
+ ,25
+ ,5
+ ,13
+ ,-2
+ ,-5
+ ,16
+ ,5
+ ,10
+ ,-2
+ ,-3
+ ,17
+ ,3
+ ,11
+ ,2
+ ,3
+ ,11
+ ,6
+ ,12
+ ,1
+ ,2
+ ,12
+ ,6
+ ,7
+ ,-8
+ ,-7
+ ,39
+ ,4
+ ,11
+ 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vertrouwen','Economische_situatie','Werkloosheid','Financiële_situatie_gezinnen','Spaarvermogen_gezinnen'),1:83))
> 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 Economische_situatie Werkloosheid
1 -6 -4 38
2 -3 -2 37
3 -2 2 32
4 -5 -5 32
5 -11 -15 44
6 -11 -16 43
7 -11 -18 42
8 -10 -13 38
9 -14 -23 37
10 -8 -10 35
11 -9 -10 37
12 -5 -6 33
13 -1 -3 24
14 -2 -4 24
15 -5 -7 31
16 -4 -7 25
17 -6 -7 28
18 -2 -3 24
19 -2 0 25
20 -2 -5 16
21 -2 -3 17
22 2 3 11
23 1 2 12
24 -8 -7 39
25 -1 -1 19
26 1 0 14
27 -1 -3 15
28 2 4 7
29 2 2 12
30 1 3 12
31 -1 0 14
32 -2 -10 9
33 -2 -10 8
34 -1 -9 4
35 -8 -22 7
36 -4 -16 3
37 -6 -18 5
38 -3 -14 0
39 -3 -12 -2
40 -7 -17 6
41 -9 -23 11
42 -11 -28 9
43 -13 -31 17
44 -11 -21 21
45 -9 -19 21
46 -17 -22 41
47 -22 -22 57
48 -25 -25 65
49 -20 -16 68
50 -24 -22 73
51 -24 -21 71
52 -22 -10 71
53 -19 -7 70
54 -18 -5 69
55 -17 -4 65
56 -11 7 57
57 -11 6 57
58 -12 3 57
59 -10 10 55
60 -15 0 65
61 -15 -2 65
62 -15 -1 64
63 -13 2 60
64 -8 8 43
65 -13 -6 47
66 -9 -4 40
67 -7 4 31
68 -4 7 27
69 -4 3 24
70 -2 3 23
71 0 8 17
72 -2 3 16
73 -3 -3 15
74 1 4 8
75 -2 -5 5
76 -1 -1 6
77 1 5 5
78 -3 0 12
79 -4 -6 8
80 -9 -13 17
81 -9 -15 22
82 -7 -8 24
83 -14 -20 36
Financi\353le_situatie_gezinnen Spaarvermogen_gezinnen
1 6 14
2 6 19
3 5 16
4 3 16
5 2 11
6 3 13
7 3 12
8 2 11
9 0 6
10 4 9
11 4 6
12 5 15
13 6 17
14 6 13
15 5 12
16 5 13
17 3 10
18 5 14
19 5 13
20 5 10
21 3 11
22 6 12
23 6 7
24 4 11
25 6 9
26 5 13
27 4 12
28 5 5
29 5 13
30 4 11
31 3 8
32 2 8
33 3 8
34 2 8
35 -1 0
36 0 3
37 -2 0
38 1 -1
39 -2 -1
40 -2 -4
41 -2 1
42 -6 -1
43 -4 0
44 -2 -1
45 0 6
46 -5 0
47 -4 -3
48 -5 -3
49 -1 4
50 -2 1
51 -4 0
52 -1 -4
53 1 -2
54 1 3
55 -2 2
56 1 5
57 1 6
58 3 6
59 3 3
60 1 4
61 1 7
62 0 5
63 2 6
64 2 1
65 -1 3
66 1 6
67 0 0
68 1 3
69 1 4
70 3 7
71 2 6
72 0 6
73 0 6
74 3 6
75 -2 2
76 0 2
77 1 2
78 -1 3
79 -2 -1
80 -1 -4
81 -1 4
82 1 5
83 -2 3
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Economische_situatie
0.04781 0.25145
Werkloosheid `Financi\353le_situatie_gezinnen`
-0.25201 0.26684
Spaarvermogen_gezinnen
0.23511
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.64860 -0.30535 0.03887 0.23993 0.71149
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.047813 0.088712 0.539 0.591
Economische_situatie 0.251451 0.005026 50.027 < 2e-16 ***
Werkloosheid -0.252013 0.001772 -142.216 < 2e-16 ***
`Financi\353le_situatie_gezinnen` 0.266841 0.027485 9.709 4.59e-15 ***
Spaarvermogen_gezinnen 0.235107 0.012579 18.690 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.3313 on 78 degrees of freedom
Multiple R-squared: 0.9977, Adjusted R-squared: 0.9976
F-statistic: 8616 on 4 and 78 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.9507723 0.09845547 0.04922773
[2,] 0.9532830 0.09343405 0.04671702
[3,] 0.9540745 0.09185098 0.04592549
[4,] 0.9391704 0.12165926 0.06082963
[5,] 0.8982847 0.20343057 0.10171529
[6,] 0.9084505 0.18309892 0.09154946
[7,] 0.9094745 0.18105096 0.09052548
[8,] 0.9001831 0.19963371 0.09981686
[9,] 0.8978450 0.20431008 0.10215504
[10,] 0.8695273 0.26094550 0.13047275
[11,] 0.8444841 0.31103190 0.15551595
[12,] 0.7920815 0.41583692 0.20791846
[13,] 0.7482555 0.50348897 0.25174448
[14,] 0.7018956 0.59620886 0.29810443
[15,] 0.6597076 0.68058488 0.34029244
[16,] 0.7110852 0.57782966 0.28891483
[17,] 0.6959454 0.60810924 0.30405462
[18,] 0.6893972 0.62120568 0.31060284
[19,] 0.6824845 0.63503103 0.31751552
[20,] 0.6332776 0.73344480 0.36672240
[21,] 0.6506639 0.69867230 0.34933615
[22,] 0.6286284 0.74274324 0.37137162
[23,] 0.5999974 0.80000513 0.40000257
[24,] 0.5410962 0.91780757 0.45890378
[25,] 0.7167754 0.56644928 0.28322464
[26,] 0.6566110 0.68677794 0.34338897
[27,] 0.6006821 0.79863587 0.39931794
[28,] 0.5973811 0.80523784 0.40261892
[29,] 0.5855940 0.82881209 0.41440604
[30,] 0.6483644 0.70327125 0.35163562
[31,] 0.7180822 0.56383555 0.28191778
[32,] 0.7089284 0.58214326 0.29107163
[33,] 0.6751463 0.64970732 0.32485366
[34,] 0.6242572 0.75148570 0.37574285
[35,] 0.5715934 0.85681315 0.42840658
[36,] 0.5141738 0.97165239 0.48582619
[37,] 0.5113822 0.97723562 0.48861781
[38,] 0.5053346 0.98933088 0.49466544
[39,] 0.4420637 0.88412746 0.55793627
[40,] 0.4988477 0.99769543 0.50115228
[41,] 0.5177406 0.96451875 0.48225938
[42,] 0.5736718 0.85265645 0.42632823
[43,] 0.5375265 0.92494707 0.46247353
[44,] 0.4886814 0.97736272 0.51131864
[45,] 0.5348401 0.93031975 0.46515988
[46,] 0.7634846 0.47303085 0.23651542
[47,] 0.7383037 0.52339269 0.26169635
[48,] 0.7587620 0.48247607 0.24123804
[49,] 0.7023660 0.59526801 0.29763401
[50,] 0.6422079 0.71558419 0.35779209
[51,] 0.7611043 0.47779139 0.23889570
[52,] 0.7165422 0.56691550 0.28345775
[53,] 0.6737063 0.65258742 0.32629371
[54,] 0.5996170 0.80076592 0.40038296
[55,] 0.5717715 0.85645699 0.42822850
[56,] 0.5455160 0.90896795 0.45448397
[57,] 0.4618029 0.92360576 0.53819712
[58,] 0.3791992 0.75839839 0.62080081
[59,] 0.4557228 0.91144559 0.54427720
[60,] 0.3968012 0.79360238 0.60319881
[61,] 0.3148149 0.62962989 0.68518505
[62,] 0.2353016 0.47060315 0.76469843
[63,] 0.5003710 0.99925805 0.49962902
[64,] 0.6539678 0.69206441 0.34603220
[65,] 0.5349852 0.93002956 0.46501478
[66,] 0.4271620 0.85432405 0.57283798
[67,] 0.2991641 0.59832821 0.70083590
[68,] 0.2482825 0.49656497 0.75171751
> postscript(file="/var/wessaorg/rcomp/tmp/1xo301321983404.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/21grh1321983404.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/35xdp1321983404.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/498v11321983404.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/5ail01321983404.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 = 83
Frequency = 1
1 2 3 4 5 6
-0.358061441 0.711488321 0.417781014 -0.288379850 0.692661562 -0.044954711
7 8 9 10 11 12
0.441041751 -0.322317881 -0.350603070 0.103823050 0.313169810 -0.083489900
13 14 15 16 17 18
0.156986367 0.348865581 0.369256585 -0.377927571 -0.382886880 0.129147950
19 20 21 22 23 24
-0.138085633 -0.443624538 -0.395939926 -0.452352603 0.226646483 -0.112693009
25 26 27 28 29 30
0.274875904 0.089772944 -0.401913192 0.200734464 0.082844927 -0.431551657
31 32 33 34 35 36
-0.201010905 0.320276866 -0.198576528 -0.191238569 -0.484957292 0.026122787
37 38 39 40 41 42
0.272052925 0.440769439 0.234363033 0.213042691 -0.193721192 0.097085032
43 44 45 46 47 48
0.098753251 0.293719102 -0.388613384 0.150841983 -0.378471801 -0.341174955
49 50 51 52 53 54
0.438691993 0.179624770 0.192935995 -0.433120223 0.556618360 -0.373831877
55 56 57 58 59 60
0.402294171 0.114385991 0.130730127 -0.648597492 -0.207460221 0.125753922
61 62 63 64 65 66
-0.076664821 0.156925738 -0.374267233 0.008342371 -0.132982499 0.361023081
67 68 69 70 71 72
-0.241219213 0.024214321 0.038873343 0.547858366 0.280473019 -0.180603005
73 74 75 76 77 78
0.076091049 -0.248678621 0.532973921 0.245501097 0.217940793 -0.462139393
79 80 81 82 83
0.245784690 -0.287461029 -0.405350566 -0.430271004 -0.117967261
> postscript(file="/var/wessaorg/rcomp/tmp/6l09o1321983404.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 = 83
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.358061441 NA
1 0.711488321 -0.358061441
2 0.417781014 0.711488321
3 -0.288379850 0.417781014
4 0.692661562 -0.288379850
5 -0.044954711 0.692661562
6 0.441041751 -0.044954711
7 -0.322317881 0.441041751
8 -0.350603070 -0.322317881
9 0.103823050 -0.350603070
10 0.313169810 0.103823050
11 -0.083489900 0.313169810
12 0.156986367 -0.083489900
13 0.348865581 0.156986367
14 0.369256585 0.348865581
15 -0.377927571 0.369256585
16 -0.382886880 -0.377927571
17 0.129147950 -0.382886880
18 -0.138085633 0.129147950
19 -0.443624538 -0.138085633
20 -0.395939926 -0.443624538
21 -0.452352603 -0.395939926
22 0.226646483 -0.452352603
23 -0.112693009 0.226646483
24 0.274875904 -0.112693009
25 0.089772944 0.274875904
26 -0.401913192 0.089772944
27 0.200734464 -0.401913192
28 0.082844927 0.200734464
29 -0.431551657 0.082844927
30 -0.201010905 -0.431551657
31 0.320276866 -0.201010905
32 -0.198576528 0.320276866
33 -0.191238569 -0.198576528
34 -0.484957292 -0.191238569
35 0.026122787 -0.484957292
36 0.272052925 0.026122787
37 0.440769439 0.272052925
38 0.234363033 0.440769439
39 0.213042691 0.234363033
40 -0.193721192 0.213042691
41 0.097085032 -0.193721192
42 0.098753251 0.097085032
43 0.293719102 0.098753251
44 -0.388613384 0.293719102
45 0.150841983 -0.388613384
46 -0.378471801 0.150841983
47 -0.341174955 -0.378471801
48 0.438691993 -0.341174955
49 0.179624770 0.438691993
50 0.192935995 0.179624770
51 -0.433120223 0.192935995
52 0.556618360 -0.433120223
53 -0.373831877 0.556618360
54 0.402294171 -0.373831877
55 0.114385991 0.402294171
56 0.130730127 0.114385991
57 -0.648597492 0.130730127
58 -0.207460221 -0.648597492
59 0.125753922 -0.207460221
60 -0.076664821 0.125753922
61 0.156925738 -0.076664821
62 -0.374267233 0.156925738
63 0.008342371 -0.374267233
64 -0.132982499 0.008342371
65 0.361023081 -0.132982499
66 -0.241219213 0.361023081
67 0.024214321 -0.241219213
68 0.038873343 0.024214321
69 0.547858366 0.038873343
70 0.280473019 0.547858366
71 -0.180603005 0.280473019
72 0.076091049 -0.180603005
73 -0.248678621 0.076091049
74 0.532973921 -0.248678621
75 0.245501097 0.532973921
76 0.217940793 0.245501097
77 -0.462139393 0.217940793
78 0.245784690 -0.462139393
79 -0.287461029 0.245784690
80 -0.405350566 -0.287461029
81 -0.430271004 -0.405350566
82 -0.117967261 -0.430271004
83 NA -0.117967261
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.711488321 -0.358061441
[2,] 0.417781014 0.711488321
[3,] -0.288379850 0.417781014
[4,] 0.692661562 -0.288379850
[5,] -0.044954711 0.692661562
[6,] 0.441041751 -0.044954711
[7,] -0.322317881 0.441041751
[8,] -0.350603070 -0.322317881
[9,] 0.103823050 -0.350603070
[10,] 0.313169810 0.103823050
[11,] -0.083489900 0.313169810
[12,] 0.156986367 -0.083489900
[13,] 0.348865581 0.156986367
[14,] 0.369256585 0.348865581
[15,] -0.377927571 0.369256585
[16,] -0.382886880 -0.377927571
[17,] 0.129147950 -0.382886880
[18,] -0.138085633 0.129147950
[19,] -0.443624538 -0.138085633
[20,] -0.395939926 -0.443624538
[21,] -0.452352603 -0.395939926
[22,] 0.226646483 -0.452352603
[23,] -0.112693009 0.226646483
[24,] 0.274875904 -0.112693009
[25,] 0.089772944 0.274875904
[26,] -0.401913192 0.089772944
[27,] 0.200734464 -0.401913192
[28,] 0.082844927 0.200734464
[29,] -0.431551657 0.082844927
[30,] -0.201010905 -0.431551657
[31,] 0.320276866 -0.201010905
[32,] -0.198576528 0.320276866
[33,] -0.191238569 -0.198576528
[34,] -0.484957292 -0.191238569
[35,] 0.026122787 -0.484957292
[36,] 0.272052925 0.026122787
[37,] 0.440769439 0.272052925
[38,] 0.234363033 0.440769439
[39,] 0.213042691 0.234363033
[40,] -0.193721192 0.213042691
[41,] 0.097085032 -0.193721192
[42,] 0.098753251 0.097085032
[43,] 0.293719102 0.098753251
[44,] -0.388613384 0.293719102
[45,] 0.150841983 -0.388613384
[46,] -0.378471801 0.150841983
[47,] -0.341174955 -0.378471801
[48,] 0.438691993 -0.341174955
[49,] 0.179624770 0.438691993
[50,] 0.192935995 0.179624770
[51,] -0.433120223 0.192935995
[52,] 0.556618360 -0.433120223
[53,] -0.373831877 0.556618360
[54,] 0.402294171 -0.373831877
[55,] 0.114385991 0.402294171
[56,] 0.130730127 0.114385991
[57,] -0.648597492 0.130730127
[58,] -0.207460221 -0.648597492
[59,] 0.125753922 -0.207460221
[60,] -0.076664821 0.125753922
[61,] 0.156925738 -0.076664821
[62,] -0.374267233 0.156925738
[63,] 0.008342371 -0.374267233
[64,] -0.132982499 0.008342371
[65,] 0.361023081 -0.132982499
[66,] -0.241219213 0.361023081
[67,] 0.024214321 -0.241219213
[68,] 0.038873343 0.024214321
[69,] 0.547858366 0.038873343
[70,] 0.280473019 0.547858366
[71,] -0.180603005 0.280473019
[72,] 0.076091049 -0.180603005
[73,] -0.248678621 0.076091049
[74,] 0.532973921 -0.248678621
[75,] 0.245501097 0.532973921
[76,] 0.217940793 0.245501097
[77,] -0.462139393 0.217940793
[78,] 0.245784690 -0.462139393
[79,] -0.287461029 0.245784690
[80,] -0.405350566 -0.287461029
[81,] -0.430271004 -0.405350566
[82,] -0.117967261 -0.430271004
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.711488321 -0.358061441
2 0.417781014 0.711488321
3 -0.288379850 0.417781014
4 0.692661562 -0.288379850
5 -0.044954711 0.692661562
6 0.441041751 -0.044954711
7 -0.322317881 0.441041751
8 -0.350603070 -0.322317881
9 0.103823050 -0.350603070
10 0.313169810 0.103823050
11 -0.083489900 0.313169810
12 0.156986367 -0.083489900
13 0.348865581 0.156986367
14 0.369256585 0.348865581
15 -0.377927571 0.369256585
16 -0.382886880 -0.377927571
17 0.129147950 -0.382886880
18 -0.138085633 0.129147950
19 -0.443624538 -0.138085633
20 -0.395939926 -0.443624538
21 -0.452352603 -0.395939926
22 0.226646483 -0.452352603
23 -0.112693009 0.226646483
24 0.274875904 -0.112693009
25 0.089772944 0.274875904
26 -0.401913192 0.089772944
27 0.200734464 -0.401913192
28 0.082844927 0.200734464
29 -0.431551657 0.082844927
30 -0.201010905 -0.431551657
31 0.320276866 -0.201010905
32 -0.198576528 0.320276866
33 -0.191238569 -0.198576528
34 -0.484957292 -0.191238569
35 0.026122787 -0.484957292
36 0.272052925 0.026122787
37 0.440769439 0.272052925
38 0.234363033 0.440769439
39 0.213042691 0.234363033
40 -0.193721192 0.213042691
41 0.097085032 -0.193721192
42 0.098753251 0.097085032
43 0.293719102 0.098753251
44 -0.388613384 0.293719102
45 0.150841983 -0.388613384
46 -0.378471801 0.150841983
47 -0.341174955 -0.378471801
48 0.438691993 -0.341174955
49 0.179624770 0.438691993
50 0.192935995 0.179624770
51 -0.433120223 0.192935995
52 0.556618360 -0.433120223
53 -0.373831877 0.556618360
54 0.402294171 -0.373831877
55 0.114385991 0.402294171
56 0.130730127 0.114385991
57 -0.648597492 0.130730127
58 -0.207460221 -0.648597492
59 0.125753922 -0.207460221
60 -0.076664821 0.125753922
61 0.156925738 -0.076664821
62 -0.374267233 0.156925738
63 0.008342371 -0.374267233
64 -0.132982499 0.008342371
65 0.361023081 -0.132982499
66 -0.241219213 0.361023081
67 0.024214321 -0.241219213
68 0.038873343 0.024214321
69 0.547858366 0.038873343
70 0.280473019 0.547858366
71 -0.180603005 0.280473019
72 0.076091049 -0.180603005
73 -0.248678621 0.076091049
74 0.532973921 -0.248678621
75 0.245501097 0.532973921
76 0.217940793 0.245501097
77 -0.462139393 0.217940793
78 0.245784690 -0.462139393
79 -0.287461029 0.245784690
80 -0.405350566 -0.287461029
81 -0.430271004 -0.405350566
82 -0.117967261 -0.430271004
> 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/7ghbe1321983404.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/8eoec1321983404.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/9dhde1321983404.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/10y4w31321983404.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/111atb1321983404.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/12joct1321983404.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/137xus1321983404.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/14y3he1321983404.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/15lst01321983404.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/16h8cv1321983404.tab")
+ }
>
> try(system("convert tmp/1xo301321983404.ps tmp/1xo301321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/21grh1321983404.ps tmp/21grh1321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/35xdp1321983404.ps tmp/35xdp1321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/498v11321983404.ps tmp/498v11321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ail01321983404.ps tmp/5ail01321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/6l09o1321983404.ps tmp/6l09o1321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ghbe1321983404.ps tmp/7ghbe1321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/8eoec1321983404.ps tmp/8eoec1321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/9dhde1321983404.ps tmp/9dhde1321983404.png",intern=TRUE))
character(0)
> try(system("convert tmp/10y4w31321983404.ps tmp/10y4w31321983404.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.438 0.495 3.998