R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
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(78.40
+ ,97.80
+ ,114.60
+ ,107.40
+ ,113.30
+ ,117.50
+ ,117.00
+ ,105.60
+ ,99.60
+ ,97.40
+ ,99.40
+ ,99.50
+ ,101.90
+ ,98.00
+ ,115.20
+ ,104.30
+ ,108.50
+ ,100.60
+ ,113.80
+ ,101.10
+ ,121.00
+ ,103.90
+ ,92.20
+ ,96.90
+ ,90.20
+ ,95.50
+ ,101.50
+ ,108.40
+ ,126.60
+ ,117.00
+ ,93.90
+ ,103.80
+ ,89.80
+ ,100.80
+ ,93.40
+ ,110.60
+ ,101.50
+ ,104.00
+ ,110.40
+ ,112.60
+ ,105.90
+ ,107.30
+ ,108.40
+ ,98.90
+ ,113.90
+ ,109.80
+ ,86.10
+ ,104.90
+ ,69.40
+ ,102.20
+ ,101.20
+ ,123.90
+ ,100.50
+ ,124.90
+ ,98.00
+ ,112.70
+ ,106.60
+ ,121.90
+ ,90.10
+ ,100.60
+ ,96.90
+ ,104.30
+ ,125.90
+ ,120.40
+ ,112.00
+ ,107.50
+ ,100.00
+ ,102.90
+ ,123.90
+ ,125.60
+ ,79.80
+ ,107.50
+ ,83.40
+ ,108.80
+ ,113.60
+ ,128.40
+ ,112.90
+ ,121.10
+ ,104.00
+ ,119.50
+ ,109.90
+ ,128.70
+ ,99.00
+ ,108.70
+ ,106.30
+ ,105.50
+ ,128.90
+ ,119.80
+ ,111.10
+ ,111.30
+ ,102.90
+ ,110.60
+ ,130.00
+ ,120.10
+ ,87.00
+ ,97.50
+ ,87.50
+ ,107.70
+ ,117.60
+ ,127.30
+ ,103.40
+ ,117.20
+ ,110.80
+ ,119.80
+ ,112.60
+ ,116.20
+ ,102.50
+ ,111.00
+ ,112.40
+ ,112.40
+ ,135.60
+ ,130.60
+ ,105.10
+ ,109.10
+ ,127.70
+ ,118.80
+ ,137.00
+ ,123.90
+ ,91.00
+ ,101.60
+ ,90.50
+ ,112.80
+ ,122.40
+ ,128.00
+ ,123.30
+ ,129.60
+ ,124.30
+ ,125.80
+ ,120.00
+ ,119.50
+ ,118.10
+ ,115.70
+ ,119.00
+ ,113.60
+ ,142.70
+ ,129.70
+ ,123.60
+ ,112.00
+ ,129.60
+ ,116.80
+ ,151.60
+ ,127.00
+ ,110.40
+ ,112.10
+ ,99.20
+ ,114.20
+ ,130.50
+ ,121.10
+ ,136.20
+ ,131.60
+ ,129.70
+ ,125.00
+ ,128.00
+ ,120.40
+ ,121.60
+ ,117.70
+ ,135.80
+ ,117.50
+ ,143.80
+ ,120.60
+ ,147.50
+ ,127.50
+ ,136.20
+ ,112.30
+ ,156.60
+ ,124.50
+ ,123.30
+ ,115.20
+ ,100.40
+ ,105.40)
+ ,dim=c(3
+ ,85)
+ ,dimnames=list(c('investerings'
+ ,'consumptie'
+ ,'')
+ ,1:85))
> y <- array(NA,dim=c(3,85),dimnames=list(c('investerings','consumptie',''),1:85))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
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
investerings consumptie M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 78.4 97.8 114.6 1 0 0 0 0 0 0 0 0 0 0 1
2 107.4 113.3 117.5 0 1 0 0 0 0 0 0 0 0 0 2
3 117.0 105.6 99.6 0 0 1 0 0 0 0 0 0 0 0 3
4 97.4 99.4 99.5 0 0 0 1 0 0 0 0 0 0 0 4
5 101.9 98.0 115.2 0 0 0 0 1 0 0 0 0 0 0 5
6 104.3 108.5 100.6 0 0 0 0 0 1 0 0 0 0 0 6
7 113.8 101.1 121.0 0 0 0 0 0 0 1 0 0 0 0 7
8 103.9 92.2 96.9 0 0 0 0 0 0 0 1 0 0 0 8
9 90.2 95.5 101.5 0 0 0 0 0 0 0 0 1 0 0 9
10 108.4 126.6 117.0 0 0 0 0 0 0 0 0 0 1 0 10
11 93.9 103.8 89.8 0 0 0 0 0 0 0 0 0 0 1 11
12 100.8 93.4 110.6 0 0 0 0 0 0 0 0 0 0 0 12
13 101.5 104.0 110.4 1 0 0 0 0 0 0 0 0 0 0 13
14 112.6 105.9 107.3 0 1 0 0 0 0 0 0 0 0 0 14
15 108.4 98.9 113.9 0 0 1 0 0 0 0 0 0 0 0 15
16 109.8 86.1 104.9 0 0 0 1 0 0 0 0 0 0 0 16
17 69.4 102.2 101.2 0 0 0 0 1 0 0 0 0 0 0 17
18 123.9 100.5 124.9 0 0 0 0 0 1 0 0 0 0 0 18
19 98.0 112.7 106.6 0 0 0 0 0 0 1 0 0 0 0 19
20 121.9 90.1 100.6 0 0 0 0 0 0 0 1 0 0 0 20
21 96.9 104.3 125.9 0 0 0 0 0 0 0 0 1 0 0 21
22 120.4 112.0 107.5 0 0 0 0 0 0 0 0 0 1 0 22
23 100.0 102.9 123.9 0 0 0 0 0 0 0 0 0 0 1 23
24 125.6 79.8 107.5 0 0 0 0 0 0 0 0 0 0 0 24
25 83.4 108.8 113.6 1 0 0 0 0 0 0 0 0 0 0 25
26 128.4 112.9 121.1 0 1 0 0 0 0 0 0 0 0 0 26
27 104.0 119.5 109.9 0 0 1 0 0 0 0 0 0 0 0 27
28 128.7 99.0 108.7 0 0 0 1 0 0 0 0 0 0 0 28
29 106.3 105.5 128.9 0 0 0 0 1 0 0 0 0 0 0 29
30 119.8 111.1 111.3 0 0 0 0 0 1 0 0 0 0 0 30
31 102.9 110.6 130.0 0 0 0 0 0 0 1 0 0 0 0 31
32 120.1 87.0 97.5 0 0 0 0 0 0 0 1 0 0 0 32
33 87.5 107.7 117.6 0 0 0 0 0 0 0 0 1 0 0 33
34 127.3 103.4 117.2 0 0 0 0 0 0 0 0 0 1 0 34
35 110.8 119.8 112.6 0 0 0 0 0 0 0 0 0 0 1 35
36 116.2 102.5 111.0 0 0 0 0 0 0 0 0 0 0 0 36
37 112.4 112.4 135.6 1 0 0 0 0 0 0 0 0 0 0 37
38 130.6 105.1 109.1 0 1 0 0 0 0 0 0 0 0 0 38
39 127.7 118.8 137.0 0 0 1 0 0 0 0 0 0 0 0 39
40 123.9 91.0 101.6 0 0 0 1 0 0 0 0 0 0 0 40
41 90.5 112.8 122.4 0 0 0 0 1 0 0 0 0 0 0 41
42 128.0 123.3 129.6 0 0 0 0 0 1 0 0 0 0 0 42
43 124.3 125.8 120.0 0 0 0 0 0 0 1 0 0 0 0 43
44 119.5 118.1 115.7 0 0 0 0 0 0 0 1 0 0 0 44
45 119.0 113.6 142.7 0 0 0 0 0 0 0 0 1 0 0 45
46 129.7 123.6 112.0 0 0 0 0 0 0 0 0 0 1 0 46
47 129.6 116.8 151.6 0 0 0 0 0 0 0 0 0 0 1 47
48 127.0 110.4 112.1 0 0 0 0 0 0 0 0 0 0 0 48
49 99.2 114.2 130.5 1 0 0 0 0 0 0 0 0 0 0 49
50 121.1 136.2 131.6 0 1 0 0 0 0 0 0 0 0 0 50
51 129.7 125.0 128.0 0 0 1 0 0 0 0 0 0 0 0 51
52 120.4 121.6 117.7 0 0 0 1 0 0 0 0 0 0 0 52
53 135.8 117.5 143.8 0 0 0 0 1 0 0 0 0 0 0 53
54 120.6 147.5 127.5 0 0 0 0 0 1 0 0 0 0 0 54
55 136.2 112.3 156.6 0 0 0 0 0 0 1 0 0 0 0 55
56 124.5 123.3 115.2 0 0 0 0 0 0 0 1 0 0 0 56
57 100.4 105.4 78.4 0 0 0 0 0 0 0 0 1 0 0 57
58 97.8 114.6 107.4 0 0 0 0 0 0 0 0 0 1 0 58
59 113.3 117.5 117.0 0 0 0 0 0 0 0 0 0 0 1 59
60 105.6 99.6 97.4 0 0 0 0 0 0 0 0 0 0 0 60
61 99.4 99.5 101.9 1 0 0 0 0 0 0 0 0 0 0 61
62 98.0 115.2 104.3 0 1 0 0 0 0 0 0 0 0 0 62
63 108.5 100.6 113.8 0 0 1 0 0 0 0 0 0 0 0 63
64 101.1 121.0 103.9 0 0 0 1 0 0 0 0 0 0 0 64
65 92.2 96.9 90.2 0 0 0 0 1 0 0 0 0 0 0 65
66 95.5 101.5 108.4 0 0 0 0 0 1 0 0 0 0 0 66
67 126.6 117.0 93.9 0 0 0 0 0 0 1 0 0 0 0 67
68 103.8 89.8 100.8 0 0 0 0 0 0 0 1 0 0 0 68
69 93.4 110.6 101.5 0 0 0 0 0 0 0 0 1 0 0 69
70 104.0 110.4 112.6 0 0 0 0 0 0 0 0 0 1 0 70
71 105.9 107.3 108.4 0 0 0 0 0 0 0 0 0 0 1 71
72 98.9 113.9 109.8 0 0 0 0 0 0 0 0 0 0 0 72
73 86.1 104.9 69.4 1 0 0 0 0 0 0 0 0 0 0 73
74 102.2 101.2 123.9 0 1 0 0 0 0 0 0 0 0 0 74
75 100.5 124.9 98.0 0 0 1 0 0 0 0 0 0 0 0 75
76 112.7 106.6 121.9 0 0 0 1 0 0 0 0 0 0 0 76
77 90.1 100.6 96.9 0 0 0 0 1 0 0 0 0 0 0 77
78 104.3 125.9 120.4 0 0 0 0 0 1 0 0 0 0 0 78
79 112.0 107.5 100.0 0 0 0 0 0 0 1 0 0 0 0 79
80 102.9 123.9 125.6 0 0 0 0 0 0 0 1 0 0 0 80
81 79.8 107.5 83.4 0 0 0 0 0 0 0 0 1 0 0 81
82 108.8 113.6 128.4 0 0 0 0 0 0 0 0 0 1 0 82
83 112.9 121.1 104.0 0 0 0 0 0 0 0 0 0 0 1 83
84 119.5 109.9 128.7 0 0 0 0 0 0 0 0 0 0 0 84
85 99.0 108.7 106.3 1 0 0 0 0 0 0 0 0 0 0 85
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) consumptie V3 M1 M2 M3
66.150589 0.025181 0.400773 -18.260860 -1.453282 -1.276520
M4 M5 M6 M7 M8 M9
1.114059 -16.634319 -2.580001 -0.294550 1.809608 -16.678030
M10 M11 t
-1.364615 -5.897777 0.003688
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-23.3107 -7.2485 0.2095 7.6113 25.4983
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 66.150589 14.113009 4.687 1.32e-05 ***
consumptie 0.025181 0.140632 0.179 0.85841
V3 0.400773 0.092534 4.331 4.86e-05 ***
M1 -18.260860 5.927365 -3.081 0.00295 **
M2 -1.453282 6.311027 -0.230 0.81855
M3 -1.276520 6.330316 -0.202 0.84077
M4 1.114059 6.101213 0.183 0.85564
M5 -16.634319 6.093701 -2.730 0.00801 **
M6 -2.580001 6.435418 -0.401 0.68971
M7 -0.294550 6.252135 -0.047 0.96256
M8 1.809608 6.088160 0.297 0.76717
M9 -16.678030 6.132893 -2.719 0.00824 **
M10 -1.364615 6.330505 -0.216 0.82996
M11 -5.897777 6.241581 -0.945 0.34795
t 0.003688 0.055355 0.067 0.94707
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.33 on 70 degrees of freedom
Multiple R-squared: 0.4755, Adjusted R-squared: 0.3706
F-statistic: 4.533 on 14 and 70 DF, p-value: 9.812e-06
> 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.9079507 0.18409851 0.09204926
[2,] 0.8608622 0.27827560 0.13913780
[3,] 0.8228583 0.35428345 0.17714172
[4,] 0.7448697 0.51026053 0.25513026
[5,] 0.6563287 0.68734259 0.34367129
[6,] 0.6250873 0.74982545 0.37491272
[7,] 0.5903082 0.81938353 0.40969176
[8,] 0.5719800 0.85603991 0.42801995
[9,] 0.5732078 0.85358447 0.42679223
[10,] 0.5227883 0.95442343 0.47721172
[11,] 0.6208949 0.75821020 0.37910510
[12,] 0.5722647 0.85547062 0.42773531
[13,] 0.4891571 0.97831420 0.51084290
[14,] 0.6740260 0.65194791 0.32597395
[15,] 0.6037646 0.79247079 0.39623539
[16,] 0.6882731 0.62345380 0.31172690
[17,] 0.6372598 0.72548041 0.36274021
[18,] 0.6778005 0.64439893 0.32219947
[19,] 0.6209303 0.75813935 0.37906968
[20,] 0.5952244 0.80955128 0.40477564
[21,] 0.6215967 0.75680667 0.37840333
[22,] 0.5466665 0.90666709 0.45333355
[23,] 0.5218291 0.95634186 0.47817093
[24,] 0.7627535 0.47449309 0.23724655
[25,] 0.7341834 0.53163317 0.26581659
[26,] 0.8099169 0.38016612 0.19008306
[27,] 0.7557268 0.48854631 0.24427316
[28,] 0.7201308 0.55973843 0.27986922
[29,] 0.7582854 0.48342917 0.24171459
[30,] 0.7006696 0.59866085 0.29933042
[31,] 0.6968024 0.60639527 0.30319764
[32,] 0.8485197 0.30296056 0.15148028
[33,] 0.8109188 0.37816234 0.18908117
[34,] 0.7731029 0.45379423 0.22689711
[35,] 0.7132941 0.57341185 0.28670593
[36,] 0.8818673 0.23626541 0.11813271
[37,] 0.8558010 0.28839805 0.14419903
[38,] 0.8376229 0.32475420 0.16237710
[39,] 0.8933304 0.21333914 0.10666957
[40,] 0.9614015 0.07719709 0.03859855
[41,] 0.9801254 0.03974926 0.01987463
[42,] 0.9647311 0.07053789 0.03526895
[43,] 0.9482273 0.10354537 0.05177269
[44,] 0.9108321 0.17833589 0.08916795
[45,] 0.8933866 0.21322671 0.10661336
[46,] 0.8436177 0.31276465 0.15638233
[47,] 0.7862486 0.42750283 0.21375142
[48,] 0.6734548 0.65309034 0.32654517
[49,] 0.5990059 0.80198815 0.40099407
[50,] 0.7385941 0.52281171 0.26140586
> postscript(file="/var/www/html/rcomp/tmp/1vo9l1227800020.ps",horizontal=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/www/html/rcomp/tmp/28g0i1227800020.ps",horizontal=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/www/html/rcomp/tmp/36lht1227800020.ps",horizontal=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/www/html/rcomp/tmp/4wwny1227800020.ps",horizontal=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/www/html/rcomp/tmp/5pilk1227800020.ps",horizontal=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 = 85
Frequency = 1
1 2 3 4 5 6
-17.88470241 -7.24851222 9.53876901 -12.25930071 3.72850251 -2.34261181
7 8 9 10 11 12
-3.12118834 -5.24629150 -2.38899535 -6.50120308 -4.99657830 -12.07224673
13 14 15 16 17 18
6.69816445 2.18145171 -4.66783746 -1.73283279 -23.31069164 7.67578445
19 20 21 22 23 24
-13.48641051 11.27946687 -5.73371244 9.62952075 -12.58454268 14.26834777
25 26 27 28 29 30
-12.84943751 12.23025604 -8.02772756 15.27513751 2.36053358 8.71512443
31 32 33 34 35 36
-17.95588457 10.75566385 -11.93716937 12.81431446 2.27438038 2.84977902
37 38 39 40 41 42
7.19864085 19.39168404 4.78468446 13.47781288 -11.06251994 9.22950954
43 44 45 46 47 48
7.02484052 2.03421075 9.31059636 16.74542451 5.47550673 12.96574060
49 50 51 52 53 54
-4.04700124 0.04690609 10.19126278 2.71057390 25.49832356 2.01749975
55 56 57 58 59 60
4.55222012 7.05939741 16.64253606 -13.12865245 2.98037342 -2.31520155
61 62 63 64 65 66
7.94100916 -11.62745018 -4.74760824 -11.08790746 3.85423069 -14.31367901
67 68 69 70 71 72
19.91809142 -7.07017444 0.20947473 -8.95117441 -0.76039380 -14.38913395
73 74 75 76 77 78
7.48590273 -14.97433548 -7.07154299 -6.38348332 -1.06837875 -10.98162736
79 80 81 82 83 84
3.06833137 -18.81227295 -6.10272999 -10.60822979 7.61125426 -1.30728516
85
5.45742396
> postscript(file="/var/www/html/rcomp/tmp/655gf1227800020.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 85
Frequency = 1
lag(myerror, k = 1) myerror
0 -17.88470241 NA
1 -7.24851222 -17.88470241
2 9.53876901 -7.24851222
3 -12.25930071 9.53876901
4 3.72850251 -12.25930071
5 -2.34261181 3.72850251
6 -3.12118834 -2.34261181
7 -5.24629150 -3.12118834
8 -2.38899535 -5.24629150
9 -6.50120308 -2.38899535
10 -4.99657830 -6.50120308
11 -12.07224673 -4.99657830
12 6.69816445 -12.07224673
13 2.18145171 6.69816445
14 -4.66783746 2.18145171
15 -1.73283279 -4.66783746
16 -23.31069164 -1.73283279
17 7.67578445 -23.31069164
18 -13.48641051 7.67578445
19 11.27946687 -13.48641051
20 -5.73371244 11.27946687
21 9.62952075 -5.73371244
22 -12.58454268 9.62952075
23 14.26834777 -12.58454268
24 -12.84943751 14.26834777
25 12.23025604 -12.84943751
26 -8.02772756 12.23025604
27 15.27513751 -8.02772756
28 2.36053358 15.27513751
29 8.71512443 2.36053358
30 -17.95588457 8.71512443
31 10.75566385 -17.95588457
32 -11.93716937 10.75566385
33 12.81431446 -11.93716937
34 2.27438038 12.81431446
35 2.84977902 2.27438038
36 7.19864085 2.84977902
37 19.39168404 7.19864085
38 4.78468446 19.39168404
39 13.47781288 4.78468446
40 -11.06251994 13.47781288
41 9.22950954 -11.06251994
42 7.02484052 9.22950954
43 2.03421075 7.02484052
44 9.31059636 2.03421075
45 16.74542451 9.31059636
46 5.47550673 16.74542451
47 12.96574060 5.47550673
48 -4.04700124 12.96574060
49 0.04690609 -4.04700124
50 10.19126278 0.04690609
51 2.71057390 10.19126278
52 25.49832356 2.71057390
53 2.01749975 25.49832356
54 4.55222012 2.01749975
55 7.05939741 4.55222012
56 16.64253606 7.05939741
57 -13.12865245 16.64253606
58 2.98037342 -13.12865245
59 -2.31520155 2.98037342
60 7.94100916 -2.31520155
61 -11.62745018 7.94100916
62 -4.74760824 -11.62745018
63 -11.08790746 -4.74760824
64 3.85423069 -11.08790746
65 -14.31367901 3.85423069
66 19.91809142 -14.31367901
67 -7.07017444 19.91809142
68 0.20947473 -7.07017444
69 -8.95117441 0.20947473
70 -0.76039380 -8.95117441
71 -14.38913395 -0.76039380
72 7.48590273 -14.38913395
73 -14.97433548 7.48590273
74 -7.07154299 -14.97433548
75 -6.38348332 -7.07154299
76 -1.06837875 -6.38348332
77 -10.98162736 -1.06837875
78 3.06833137 -10.98162736
79 -18.81227295 3.06833137
80 -6.10272999 -18.81227295
81 -10.60822979 -6.10272999
82 7.61125426 -10.60822979
83 -1.30728516 7.61125426
84 5.45742396 -1.30728516
85 NA 5.45742396
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -7.24851222 -17.88470241
[2,] 9.53876901 -7.24851222
[3,] -12.25930071 9.53876901
[4,] 3.72850251 -12.25930071
[5,] -2.34261181 3.72850251
[6,] -3.12118834 -2.34261181
[7,] -5.24629150 -3.12118834
[8,] -2.38899535 -5.24629150
[9,] -6.50120308 -2.38899535
[10,] -4.99657830 -6.50120308
[11,] -12.07224673 -4.99657830
[12,] 6.69816445 -12.07224673
[13,] 2.18145171 6.69816445
[14,] -4.66783746 2.18145171
[15,] -1.73283279 -4.66783746
[16,] -23.31069164 -1.73283279
[17,] 7.67578445 -23.31069164
[18,] -13.48641051 7.67578445
[19,] 11.27946687 -13.48641051
[20,] -5.73371244 11.27946687
[21,] 9.62952075 -5.73371244
[22,] -12.58454268 9.62952075
[23,] 14.26834777 -12.58454268
[24,] -12.84943751 14.26834777
[25,] 12.23025604 -12.84943751
[26,] -8.02772756 12.23025604
[27,] 15.27513751 -8.02772756
[28,] 2.36053358 15.27513751
[29,] 8.71512443 2.36053358
[30,] -17.95588457 8.71512443
[31,] 10.75566385 -17.95588457
[32,] -11.93716937 10.75566385
[33,] 12.81431446 -11.93716937
[34,] 2.27438038 12.81431446
[35,] 2.84977902 2.27438038
[36,] 7.19864085 2.84977902
[37,] 19.39168404 7.19864085
[38,] 4.78468446 19.39168404
[39,] 13.47781288 4.78468446
[40,] -11.06251994 13.47781288
[41,] 9.22950954 -11.06251994
[42,] 7.02484052 9.22950954
[43,] 2.03421075 7.02484052
[44,] 9.31059636 2.03421075
[45,] 16.74542451 9.31059636
[46,] 5.47550673 16.74542451
[47,] 12.96574060 5.47550673
[48,] -4.04700124 12.96574060
[49,] 0.04690609 -4.04700124
[50,] 10.19126278 0.04690609
[51,] 2.71057390 10.19126278
[52,] 25.49832356 2.71057390
[53,] 2.01749975 25.49832356
[54,] 4.55222012 2.01749975
[55,] 7.05939741 4.55222012
[56,] 16.64253606 7.05939741
[57,] -13.12865245 16.64253606
[58,] 2.98037342 -13.12865245
[59,] -2.31520155 2.98037342
[60,] 7.94100916 -2.31520155
[61,] -11.62745018 7.94100916
[62,] -4.74760824 -11.62745018
[63,] -11.08790746 -4.74760824
[64,] 3.85423069 -11.08790746
[65,] -14.31367901 3.85423069
[66,] 19.91809142 -14.31367901
[67,] -7.07017444 19.91809142
[68,] 0.20947473 -7.07017444
[69,] -8.95117441 0.20947473
[70,] -0.76039380 -8.95117441
[71,] -14.38913395 -0.76039380
[72,] 7.48590273 -14.38913395
[73,] -14.97433548 7.48590273
[74,] -7.07154299 -14.97433548
[75,] -6.38348332 -7.07154299
[76,] -1.06837875 -6.38348332
[77,] -10.98162736 -1.06837875
[78,] 3.06833137 -10.98162736
[79,] -18.81227295 3.06833137
[80,] -6.10272999 -18.81227295
[81,] -10.60822979 -6.10272999
[82,] 7.61125426 -10.60822979
[83,] -1.30728516 7.61125426
[84,] 5.45742396 -1.30728516
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -7.24851222 -17.88470241
2 9.53876901 -7.24851222
3 -12.25930071 9.53876901
4 3.72850251 -12.25930071
5 -2.34261181 3.72850251
6 -3.12118834 -2.34261181
7 -5.24629150 -3.12118834
8 -2.38899535 -5.24629150
9 -6.50120308 -2.38899535
10 -4.99657830 -6.50120308
11 -12.07224673 -4.99657830
12 6.69816445 -12.07224673
13 2.18145171 6.69816445
14 -4.66783746 2.18145171
15 -1.73283279 -4.66783746
16 -23.31069164 -1.73283279
17 7.67578445 -23.31069164
18 -13.48641051 7.67578445
19 11.27946687 -13.48641051
20 -5.73371244 11.27946687
21 9.62952075 -5.73371244
22 -12.58454268 9.62952075
23 14.26834777 -12.58454268
24 -12.84943751 14.26834777
25 12.23025604 -12.84943751
26 -8.02772756 12.23025604
27 15.27513751 -8.02772756
28 2.36053358 15.27513751
29 8.71512443 2.36053358
30 -17.95588457 8.71512443
31 10.75566385 -17.95588457
32 -11.93716937 10.75566385
33 12.81431446 -11.93716937
34 2.27438038 12.81431446
35 2.84977902 2.27438038
36 7.19864085 2.84977902
37 19.39168404 7.19864085
38 4.78468446 19.39168404
39 13.47781288 4.78468446
40 -11.06251994 13.47781288
41 9.22950954 -11.06251994
42 7.02484052 9.22950954
43 2.03421075 7.02484052
44 9.31059636 2.03421075
45 16.74542451 9.31059636
46 5.47550673 16.74542451
47 12.96574060 5.47550673
48 -4.04700124 12.96574060
49 0.04690609 -4.04700124
50 10.19126278 0.04690609
51 2.71057390 10.19126278
52 25.49832356 2.71057390
53 2.01749975 25.49832356
54 4.55222012 2.01749975
55 7.05939741 4.55222012
56 16.64253606 7.05939741
57 -13.12865245 16.64253606
58 2.98037342 -13.12865245
59 -2.31520155 2.98037342
60 7.94100916 -2.31520155
61 -11.62745018 7.94100916
62 -4.74760824 -11.62745018
63 -11.08790746 -4.74760824
64 3.85423069 -11.08790746
65 -14.31367901 3.85423069
66 19.91809142 -14.31367901
67 -7.07017444 19.91809142
68 0.20947473 -7.07017444
69 -8.95117441 0.20947473
70 -0.76039380 -8.95117441
71 -14.38913395 -0.76039380
72 7.48590273 -14.38913395
73 -14.97433548 7.48590273
74 -7.07154299 -14.97433548
75 -6.38348332 -7.07154299
76 -1.06837875 -6.38348332
77 -10.98162736 -1.06837875
78 3.06833137 -10.98162736
79 -18.81227295 3.06833137
80 -6.10272999 -18.81227295
81 -10.60822979 -6.10272999
82 7.61125426 -10.60822979
83 -1.30728516 7.61125426
84 5.45742396 -1.30728516
> 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/www/html/rcomp/tmp/78gir1227800020.ps",horizontal=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/www/html/rcomp/tmp/85jka1227800020.ps",horizontal=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/www/html/rcomp/tmp/9zhk01227800020.ps",horizontal=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/www/html/rcomp/tmp/10cdbl1227800020.ps",horizontal=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/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/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/www/html/rcomp/tmp/11qazn1227800020.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/www/html/rcomp/tmp/128kjf1227800020.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/www/html/rcomp/tmp/13b42d1227800020.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/www/html/rcomp/tmp/14kmtx1227800020.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/www/html/rcomp/tmp/15bhz21227800020.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/www/html/rcomp/tmp/1611hf1227800021.tab")
+ }
>
> system("convert tmp/1vo9l1227800020.ps tmp/1vo9l1227800020.png")
> system("convert tmp/28g0i1227800020.ps tmp/28g0i1227800020.png")
> system("convert tmp/36lht1227800020.ps tmp/36lht1227800020.png")
> system("convert tmp/4wwny1227800020.ps tmp/4wwny1227800020.png")
> system("convert tmp/5pilk1227800020.ps tmp/5pilk1227800020.png")
> system("convert tmp/655gf1227800020.ps tmp/655gf1227800020.png")
> system("convert tmp/78gir1227800020.ps tmp/78gir1227800020.png")
> system("convert tmp/85jka1227800020.ps tmp/85jka1227800020.png")
> system("convert tmp/9zhk01227800020.ps tmp/9zhk01227800020.png")
> system("convert tmp/10cdbl1227800020.ps tmp/10cdbl1227800020.png")
>
>
> proc.time()
user system elapsed
2.780 1.595 3.252