R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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(-4
+ ,-16
+ ,3
+ ,0
+ ,3
+ ,-6
+ ,-18
+ ,5
+ ,-2
+ ,0
+ ,-3
+ ,-14
+ ,0
+ ,1
+ ,-1
+ ,-3
+ ,-12
+ ,-2
+ ,-2
+ ,-1
+ ,-7
+ ,-17
+ ,6
+ ,-2
+ ,-4
+ ,-9
+ ,-23
+ ,11
+ ,-2
+ ,1
+ ,-11
+ ,-28
+ ,9
+ ,-6
+ ,-1
+ ,-13
+ ,-31
+ ,17
+ ,-4
+ ,0
+ ,-11
+ ,-21
+ ,21
+ ,-2
+ ,-1
+ ,-9
+ ,-19
+ ,21
+ ,0
+ ,6
+ ,-17
+ ,-22
+ ,41
+ ,-5
+ ,0
+ ,-22
+ ,-22
+ ,57
+ ,-4
+ ,-3
+ ,-25
+ ,-25
+ ,65
+ ,-5
+ ,-3
+ ,-20
+ ,-16
+ ,68
+ ,-1
+ ,4
+ ,-24
+ ,-22
+ ,73
+ ,-2
+ ,1
+ ,-24
+ ,-21
+ ,71
+ ,-4
+ ,0
+ ,-22
+ ,-10
+ ,71
+ ,-1
+ ,-4
+ ,-19
+ ,-7
+ ,70
+ ,1
+ ,-2
+ ,-18
+ ,-5
+ ,69
+ ,1
+ ,3
+ ,-17
+ ,-4
+ ,65
+ ,-2
+ ,2
+ ,-11
+ ,7
+ ,57
+ ,1
+ ,5
+ ,-11
+ ,6
+ ,57
+ ,1
+ ,6
+ ,-12
+ ,3
+ ,57
+ ,3
+ ,6
+ ,-10
+ ,10
+ ,55
+ ,3
+ ,3
+ ,-15
+ ,0
+ ,65
+ ,1
+ ,4
+ ,-15
+ ,-2
+ ,65
+ ,1
+ ,7
+ ,-15
+ ,-1
+ ,64
+ ,0
+ ,5
+ ,-13
+ ,2
+ ,60
+ ,2
+ ,6
+ ,-8
+ ,8
+ ,43
+ ,2
+ ,1
+ ,-13
+ ,-6
+ ,47
+ ,-1
+ ,3
+ ,-9
+ ,-4
+ ,40
+ ,1
+ ,6
+ ,-7
+ ,4
+ ,31
+ ,0
+ ,0
+ ,-4
+ ,7
+ ,27
+ ,1
+ ,3
+ ,-4
+ ,3
+ ,24
+ ,1
+ ,4
+ ,-2
+ ,3
+ ,23
+ ,3
+ ,7
+ ,0
+ ,8
+ ,17
+ ,2
+ ,6
+ ,-2
+ ,3
+ ,16
+ ,0
+ ,6
+ ,-3
+ ,-3
+ ,15
+ ,0
+ ,6
+ ,1
+ ,4
+ ,8
+ ,3
+ ,6
+ ,-2
+ ,-5
+ ,5
+ ,-2
+ ,2
+ ,-1
+ ,-1
+ ,6
+ ,0
+ ,2
+ ,1
+ ,5
+ ,5
+ ,1
+ ,2
+ ,-3
+ ,0
+ ,12
+ ,-1
+ ,3
+ ,-4
+ ,-6
+ ,8
+ ,-2
+ ,-1
+ ,-9
+ ,-13
+ ,17
+ ,-1
+ ,-4
+ ,-9
+ ,-15
+ ,22
+ ,-1
+ ,4
+ ,-7
+ ,-8
+ ,24
+ ,1
+ ,5
+ ,-14
+ ,-20
+ ,36
+ ,-2
+ ,3
+ ,-12
+ ,-10
+ ,31
+ ,-5
+ ,-1
+ ,-16
+ ,-22
+ ,34
+ ,-5
+ ,-4
+ ,-20
+ ,-25
+ ,47
+ ,-6
+ ,0
+ ,-12
+ ,-10
+ ,33
+ ,-4
+ ,-1
+ ,-12
+ ,-8
+ ,35
+ ,-3
+ ,-1
+ ,-10
+ ,-9
+ ,31
+ ,-3
+ ,3
+ ,-10
+ ,-5
+ ,35
+ ,-1
+ ,2
+ ,-13
+ ,-7
+ ,39
+ ,-2
+ ,-4
+ ,-16
+ ,-11
+ ,46
+ ,-3
+ ,-3
+ ,-14
+ ,-11
+ ,40
+ ,-3
+ ,-1
+ ,-17
+ ,-16
+ ,50
+ ,-3
+ ,3
+ ,-24
+ ,-28
+ ,62
+ ,-5
+ ,-2)
+ ,dim=c(5
+ ,60)
+ ,dimnames=list(c('Consumer_confidence_indicator'
+ ,'General_economic_situation'
+ ,'Unemployment_in_Belgium'
+ ,'Financial_situation_of_households'
+ ,'Saving_capacity_of_households
')
+ ,1:60))
> y <- array(NA,dim=c(5,60),dimnames=list(c('Consumer_confidence_indicator','General_economic_situation','Unemployment_in_Belgium','Financial_situation_of_households','Saving_capacity_of_households
'),1:60))
> 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 = '5'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, as.Date.numeric
> 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
Saving_capacity_of_households\r Consumer_confidence_indicator
1 3 -4
2 0 -6
3 -1 -3
4 -1 -3
5 -4 -7
6 1 -9
7 -1 -11
8 0 -13
9 -1 -11
10 6 -9
11 0 -17
12 -3 -22
13 -3 -25
14 4 -20
15 1 -24
16 0 -24
17 -4 -22
18 -2 -19
19 3 -18
20 2 -17
21 5 -11
22 6 -11
23 6 -12
24 3 -10
25 4 -15
26 7 -15
27 5 -15
28 6 -13
29 1 -8
30 3 -13
31 6 -9
32 0 -7
33 3 -4
34 4 -4
35 7 -2
36 6 0
37 6 -2
38 6 -3
39 6 1
40 2 -2
41 2 -1
42 2 1
43 3 -3
44 -1 -4
45 -4 -9
46 4 -9
47 5 -7
48 3 -14
49 -1 -12
50 -4 -16
51 0 -20
52 -1 -12
53 -1 -12
54 3 -10
55 2 -10
56 -4 -13
57 -3 -16
58 -1 -14
59 3 -17
60 -2 -24
General_economic_situation Unemployment_in_Belgium
1 -16 3
2 -18 5
3 -14 0
4 -12 -2
5 -17 6
6 -23 11
7 -28 9
8 -31 17
9 -21 21
10 -19 21
11 -22 41
12 -22 57
13 -25 65
14 -16 68
15 -22 73
16 -21 71
17 -10 71
18 -7 70
19 -5 69
20 -4 65
21 7 57
22 6 57
23 3 57
24 10 55
25 0 65
26 -2 65
27 -1 64
28 2 60
29 8 43
30 -6 47
31 -4 40
32 4 31
33 7 27
34 3 24
35 3 23
36 8 17
37 3 16
38 -3 15
39 4 8
40 -5 5
41 -1 6
42 5 5
43 0 12
44 -6 8
45 -13 17
46 -15 22
47 -8 24
48 -20 36
49 -10 31
50 -22 34
51 -25 47
52 -10 33
53 -8 35
54 -9 31
55 -5 35
56 -7 39
57 -11 46
58 -11 40
59 -16 50
60 -28 62
Financial_situation_of_households
1 0
2 -2
3 1
4 -2
5 -2
6 -2
7 -6
8 -4
9 -2
10 0
11 -5
12 -4
13 -5
14 -1
15 -2
16 -4
17 -1
18 1
19 1
20 -2
21 1
22 1
23 3
24 3
25 1
26 1
27 0
28 2
29 2
30 -1
31 1
32 0
33 1
34 1
35 3
36 2
37 0
38 0
39 3
40 -2
41 0
42 1
43 -1
44 -2
45 -1
46 -1
47 1
48 -2
49 -5
50 -5
51 -6
52 -4
53 -3
54 -3
55 -1
56 -2
57 -3
58 -3
59 -3
60 -5
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Consumer_confidence_indicator
0.1029 3.4504
General_economic_situation Unemployment_in_Belgium
-0.8635 0.8766
Financial_situation_of_households
-0.7478
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3.2066 -0.8213 0.0504 0.7765 2.1675
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.10292 0.35987 0.286 0.776
Consumer_confidence_indicator 3.45039 0.24351 14.170 < 2e-16 ***
General_economic_situation -0.86350 0.06666 -12.953 < 2e-16 ***
Unemployment_in_Belgium 0.87663 0.06188 14.168 < 2e-16 ***
Financial_situation_of_households -0.74776 0.15340 -4.875 9.66e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.177 on 55 degrees of freedom
Multiple R-squared: 0.8795, Adjusted R-squared: 0.8707
F-statistic: 100.4 on 4 and 55 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.3694067 0.7388133 0.6305933
[2,] 0.3900342 0.7800684 0.6099658
[3,] 0.4764016 0.9528031 0.5235984
[4,] 0.3882405 0.7764810 0.6117595
[5,] 0.4408645 0.8817291 0.5591355
[6,] 0.3363705 0.6727410 0.6636295
[7,] 0.5614090 0.8771819 0.4385910
[8,] 0.5332272 0.9335456 0.4667728
[9,] 0.4482985 0.8965970 0.5517015
[10,] 0.4078325 0.8156650 0.5921675
[11,] 0.7106922 0.5786156 0.2893078
[12,] 0.8422935 0.3154130 0.1577065
[13,] 0.8073918 0.3852163 0.1926082
[14,] 0.7946240 0.4107519 0.2053760
[15,] 0.7513479 0.4973042 0.2486521
[16,] 0.8977436 0.2045129 0.1022564
[17,] 0.8585743 0.2828514 0.1414257
[18,] 0.8203548 0.3592905 0.1796452
[19,] 0.7820507 0.4358987 0.2179493
[20,] 0.7230087 0.5539827 0.2769913
[21,] 0.7368142 0.5263717 0.2631858
[22,] 0.6887482 0.6225036 0.3112518
[23,] 0.6371333 0.7257334 0.3628667
[24,] 0.6039425 0.7921151 0.3960575
[25,] 0.5359200 0.9281601 0.4640800
[26,] 0.4561458 0.9122916 0.5438542
[27,] 0.3782351 0.7564702 0.6217649
[28,] 0.5057180 0.9885641 0.4942820
[29,] 0.5178227 0.9643545 0.4821773
[30,] 0.5140140 0.9719719 0.4859860
[31,] 0.4408557 0.8817113 0.5591443
[32,] 0.3894690 0.7789380 0.6105310
[33,] 0.4212576 0.8425151 0.5787424
[34,] 0.4248275 0.8496550 0.5751725
[35,] 0.5544348 0.8911303 0.4455652
[36,] 0.6026556 0.7946889 0.3973444
[37,] 0.6836344 0.6327313 0.3163656
[38,] 0.5873285 0.8253429 0.4126715
[39,] 0.5834619 0.8330761 0.4165381
[40,] 0.5683359 0.8633282 0.4316641
[41,] 0.5604961 0.8790079 0.4395039
[42,] 0.4447414 0.8894828 0.5552586
[43,] 0.3770293 0.7540585 0.6229707
[44,] 0.8644609 0.2710782 0.1355391
[45,] 0.7377333 0.5245334 0.2622667
> postscript(file="/var/fisher/rcomp/tmp/1j45r1355267948.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/fisher/rcomp/tmp/2beuf1355267948.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/fisher/rcomp/tmp/3skc31355267948.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/fisher/rcomp/tmp/4lxag1355267948.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/fisher/rcomp/tmp/59qjt1355267948.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 = 60
Frequency = 1
1 2 3 4 5 6
0.252669479 -0.822355183 -2.093047604 -0.856065806 -1.385094770 0.951492837
7 8 9 10 11 12
0.296959653 0.089688971 -1.187051855 2.134706427 -0.124176471 0.849403807
13 14 15 16 17 18
0.849229528 -1.270021842 -0.780419774 -0.659177851 0.181882620 -3.206611098
19 20 21 22 23 24
0.946641107 -1.377004318 -0.324435916 -0.187940122 2.167465318 0.064482349
25 26 27 28 29 30
-0.580473292 0.692518296 -0.315108640 1.376686608 -0.791470911 0.621591430
31 32 33 34 35 36
-0.820996752 0.328192482 -0.178165999 -0.002283255 -1.530900195 -0.602123150
37 38 39 40 41 42
1.362239139 0.508236488 1.130933668 -1.398358087 -0.775835185 -0.871191219
43 44 45 46 47 48
1.980884344 -0.990983069 0.074500093 1.964325731 1.850338666 0.878122695
49 50 51 52 53 54
0.752258919 -1.438133540 1.628915630 -0.253243129 0.468263235 0.210512995
55 56 57 58 59 60
0.653525724 -0.976611589 0.036343115 0.395363461 1.662678721 -1.561772918
> postscript(file="/var/fisher/rcomp/tmp/662yr1355267948.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 0.252669479 NA
1 -0.822355183 0.252669479
2 -2.093047604 -0.822355183
3 -0.856065806 -2.093047604
4 -1.385094770 -0.856065806
5 0.951492837 -1.385094770
6 0.296959653 0.951492837
7 0.089688971 0.296959653
8 -1.187051855 0.089688971
9 2.134706427 -1.187051855
10 -0.124176471 2.134706427
11 0.849403807 -0.124176471
12 0.849229528 0.849403807
13 -1.270021842 0.849229528
14 -0.780419774 -1.270021842
15 -0.659177851 -0.780419774
16 0.181882620 -0.659177851
17 -3.206611098 0.181882620
18 0.946641107 -3.206611098
19 -1.377004318 0.946641107
20 -0.324435916 -1.377004318
21 -0.187940122 -0.324435916
22 2.167465318 -0.187940122
23 0.064482349 2.167465318
24 -0.580473292 0.064482349
25 0.692518296 -0.580473292
26 -0.315108640 0.692518296
27 1.376686608 -0.315108640
28 -0.791470911 1.376686608
29 0.621591430 -0.791470911
30 -0.820996752 0.621591430
31 0.328192482 -0.820996752
32 -0.178165999 0.328192482
33 -0.002283255 -0.178165999
34 -1.530900195 -0.002283255
35 -0.602123150 -1.530900195
36 1.362239139 -0.602123150
37 0.508236488 1.362239139
38 1.130933668 0.508236488
39 -1.398358087 1.130933668
40 -0.775835185 -1.398358087
41 -0.871191219 -0.775835185
42 1.980884344 -0.871191219
43 -0.990983069 1.980884344
44 0.074500093 -0.990983069
45 1.964325731 0.074500093
46 1.850338666 1.964325731
47 0.878122695 1.850338666
48 0.752258919 0.878122695
49 -1.438133540 0.752258919
50 1.628915630 -1.438133540
51 -0.253243129 1.628915630
52 0.468263235 -0.253243129
53 0.210512995 0.468263235
54 0.653525724 0.210512995
55 -0.976611589 0.653525724
56 0.036343115 -0.976611589
57 0.395363461 0.036343115
58 1.662678721 0.395363461
59 -1.561772918 1.662678721
60 NA -1.561772918
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.822355183 0.252669479
[2,] -2.093047604 -0.822355183
[3,] -0.856065806 -2.093047604
[4,] -1.385094770 -0.856065806
[5,] 0.951492837 -1.385094770
[6,] 0.296959653 0.951492837
[7,] 0.089688971 0.296959653
[8,] -1.187051855 0.089688971
[9,] 2.134706427 -1.187051855
[10,] -0.124176471 2.134706427
[11,] 0.849403807 -0.124176471
[12,] 0.849229528 0.849403807
[13,] -1.270021842 0.849229528
[14,] -0.780419774 -1.270021842
[15,] -0.659177851 -0.780419774
[16,] 0.181882620 -0.659177851
[17,] -3.206611098 0.181882620
[18,] 0.946641107 -3.206611098
[19,] -1.377004318 0.946641107
[20,] -0.324435916 -1.377004318
[21,] -0.187940122 -0.324435916
[22,] 2.167465318 -0.187940122
[23,] 0.064482349 2.167465318
[24,] -0.580473292 0.064482349
[25,] 0.692518296 -0.580473292
[26,] -0.315108640 0.692518296
[27,] 1.376686608 -0.315108640
[28,] -0.791470911 1.376686608
[29,] 0.621591430 -0.791470911
[30,] -0.820996752 0.621591430
[31,] 0.328192482 -0.820996752
[32,] -0.178165999 0.328192482
[33,] -0.002283255 -0.178165999
[34,] -1.530900195 -0.002283255
[35,] -0.602123150 -1.530900195
[36,] 1.362239139 -0.602123150
[37,] 0.508236488 1.362239139
[38,] 1.130933668 0.508236488
[39,] -1.398358087 1.130933668
[40,] -0.775835185 -1.398358087
[41,] -0.871191219 -0.775835185
[42,] 1.980884344 -0.871191219
[43,] -0.990983069 1.980884344
[44,] 0.074500093 -0.990983069
[45,] 1.964325731 0.074500093
[46,] 1.850338666 1.964325731
[47,] 0.878122695 1.850338666
[48,] 0.752258919 0.878122695
[49,] -1.438133540 0.752258919
[50,] 1.628915630 -1.438133540
[51,] -0.253243129 1.628915630
[52,] 0.468263235 -0.253243129
[53,] 0.210512995 0.468263235
[54,] 0.653525724 0.210512995
[55,] -0.976611589 0.653525724
[56,] 0.036343115 -0.976611589
[57,] 0.395363461 0.036343115
[58,] 1.662678721 0.395363461
[59,] -1.561772918 1.662678721
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.822355183 0.252669479
2 -2.093047604 -0.822355183
3 -0.856065806 -2.093047604
4 -1.385094770 -0.856065806
5 0.951492837 -1.385094770
6 0.296959653 0.951492837
7 0.089688971 0.296959653
8 -1.187051855 0.089688971
9 2.134706427 -1.187051855
10 -0.124176471 2.134706427
11 0.849403807 -0.124176471
12 0.849229528 0.849403807
13 -1.270021842 0.849229528
14 -0.780419774 -1.270021842
15 -0.659177851 -0.780419774
16 0.181882620 -0.659177851
17 -3.206611098 0.181882620
18 0.946641107 -3.206611098
19 -1.377004318 0.946641107
20 -0.324435916 -1.377004318
21 -0.187940122 -0.324435916
22 2.167465318 -0.187940122
23 0.064482349 2.167465318
24 -0.580473292 0.064482349
25 0.692518296 -0.580473292
26 -0.315108640 0.692518296
27 1.376686608 -0.315108640
28 -0.791470911 1.376686608
29 0.621591430 -0.791470911
30 -0.820996752 0.621591430
31 0.328192482 -0.820996752
32 -0.178165999 0.328192482
33 -0.002283255 -0.178165999
34 -1.530900195 -0.002283255
35 -0.602123150 -1.530900195
36 1.362239139 -0.602123150
37 0.508236488 1.362239139
38 1.130933668 0.508236488
39 -1.398358087 1.130933668
40 -0.775835185 -1.398358087
41 -0.871191219 -0.775835185
42 1.980884344 -0.871191219
43 -0.990983069 1.980884344
44 0.074500093 -0.990983069
45 1.964325731 0.074500093
46 1.850338666 1.964325731
47 0.878122695 1.850338666
48 0.752258919 0.878122695
49 -1.438133540 0.752258919
50 1.628915630 -1.438133540
51 -0.253243129 1.628915630
52 0.468263235 -0.253243129
53 0.210512995 0.468263235
54 0.653525724 0.210512995
55 -0.976611589 0.653525724
56 0.036343115 -0.976611589
57 0.395363461 0.036343115
58 1.662678721 0.395363461
59 -1.561772918 1.662678721
> 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/fisher/rcomp/tmp/7hkde1355267948.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/fisher/rcomp/tmp/83nof1355267948.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/fisher/rcomp/tmp/9lcbd1355267948.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/fisher/rcomp/tmp/10b3q91355267948.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/11klca1355267948.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/fisher/rcomp/tmp/12zyfr1355267948.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/fisher/rcomp/tmp/13t19v1355267948.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/fisher/rcomp/tmp/14dq4o1355267948.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/fisher/rcomp/tmp/15if301355267948.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/fisher/rcomp/tmp/16x9731355267948.tab")
+ }
>
> try(system("convert tmp/1j45r1355267948.ps tmp/1j45r1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/2beuf1355267948.ps tmp/2beuf1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/3skc31355267948.ps tmp/3skc31355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/4lxag1355267948.ps tmp/4lxag1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/59qjt1355267948.ps tmp/59qjt1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/662yr1355267948.ps tmp/662yr1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/7hkde1355267948.ps tmp/7hkde1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/83nof1355267948.ps tmp/83nof1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/9lcbd1355267948.ps tmp/9lcbd1355267948.png",intern=TRUE))
character(0)
> try(system("convert tmp/10b3q91355267948.ps tmp/10b3q91355267948.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
5.897 1.500 7.393