R version 2.9.0 (2009-04-17)
Copyright (C) 2009 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(102.9
+ ,127.5
+ ,112.7
+ ,97
+ ,95.1
+ ,97.4
+ ,134.6
+ ,102.9
+ ,112.7
+ ,97
+ ,111.4
+ ,131.8
+ ,97.4
+ ,102.9
+ ,112.7
+ ,87.4
+ ,135.9
+ ,111.4
+ ,97.4
+ ,102.9
+ ,96.8
+ ,142.7
+ ,87.4
+ ,111.4
+ ,97.4
+ ,114.1
+ ,141.7
+ ,96.8
+ ,87.4
+ ,111.4
+ ,110.3
+ ,153.4
+ ,114.1
+ ,96.8
+ ,87.4
+ ,103.9
+ ,145
+ ,110.3
+ ,114.1
+ ,96.8
+ ,101.6
+ ,137.7
+ ,103.9
+ ,110.3
+ ,114.1
+ ,94.6
+ ,148.3
+ ,101.6
+ ,103.9
+ ,110.3
+ ,95.9
+ ,152.2
+ ,94.6
+ ,101.6
+ ,103.9
+ ,104.7
+ ,169.4
+ ,95.9
+ ,94.6
+ ,101.6
+ ,102.8
+ ,168.6
+ ,104.7
+ ,95.9
+ ,94.6
+ ,98.1
+ ,161.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,113.9
+ ,174.1
+ ,98.1
+ ,102.8
+ ,104.7
+ ,80.9
+ ,179
+ ,113.9
+ ,98.1
+ ,102.8
+ ,95.7
+ ,190.6
+ ,80.9
+ ,113.9
+ ,98.1
+ ,113.2
+ ,190
+ ,95.7
+ ,80.9
+ ,113.9
+ ,105.9
+ ,181.6
+ ,113.2
+ ,95.7
+ ,80.9
+ ,108.8
+ ,174.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,102.3
+ ,180.5
+ ,108.8
+ ,105.9
+ ,113.2
+ ,99
+ ,196.8
+ ,102.3
+ ,108.8
+ ,105.9
+ ,100.7
+ ,193.8
+ ,99
+ ,102.3
+ ,108.8
+ ,115.5
+ ,197
+ ,100.7
+ ,99
+ ,102.3
+ ,100.7
+ ,216.3
+ ,115.5
+ ,100.7
+ ,99
+ ,109.9
+ ,221.4
+ ,100.7
+ ,115.5
+ ,100.7
+ ,114.6
+ ,217.9
+ ,109.9
+ ,100.7
+ ,115.5
+ ,85.4
+ ,229.7
+ ,114.6
+ ,109.9
+ ,100.7
+ ,100.5
+ ,227.4
+ ,85.4
+ ,114.6
+ ,109.9
+ ,114.8
+ ,204.2
+ ,100.5
+ ,85.4
+ ,114.6
+ ,116.5
+ ,196.6
+ ,114.8
+ ,100.5
+ ,85.4
+ ,112.9
+ ,198.8
+ ,116.5
+ ,114.8
+ ,100.5
+ ,102
+ ,207.5
+ ,112.9
+ ,116.5
+ ,114.8
+ ,106
+ ,190.7
+ ,102
+ ,112.9
+ ,116.5
+ ,105.3
+ ,201.6
+ ,106
+ ,102
+ ,112.9
+ ,118.8
+ ,210.5
+ ,105.3
+ ,106
+ ,102
+ ,106.1
+ ,223.5
+ ,118.8
+ ,105.3
+ ,106
+ ,109.3
+ ,223.8
+ ,106.1
+ ,118.8
+ ,105.3
+ ,117.2
+ ,231.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,92.5
+ ,244
+ ,117.2
+ ,109.3
+ ,106.1
+ ,104.2
+ ,234.7
+ ,92.5
+ ,117.2
+ ,109.3
+ ,112.5
+ ,250.2
+ ,104.2
+ ,92.5
+ ,117.2
+ ,122.4
+ ,265.7
+ ,112.5
+ ,104.2
+ ,92.5
+ ,113.3
+ ,287.6
+ ,122.4
+ ,112.5
+ ,104.2
+ ,100
+ ,283.3
+ ,113.3
+ ,122.4
+ ,112.5
+ ,110.7
+ ,295.4
+ ,100
+ ,113.3
+ ,122.4
+ ,112.8
+ ,312.3
+ ,110.7
+ ,100
+ ,113.3
+ ,109.8
+ ,333.8
+ ,112.8
+ ,110.7
+ ,100
+ ,117.3
+ ,347.7
+ ,109.8
+ ,112.8
+ ,110.7
+ ,109.1
+ ,383.2
+ ,117.3
+ ,109.8
+ ,112.8
+ ,115.9
+ ,407.1
+ ,109.1
+ ,117.3
+ ,109.8
+ ,96
+ ,413.6
+ ,115.9
+ ,109.1
+ ,117.3
+ ,99.8
+ ,362.7
+ ,96
+ ,115.9
+ ,109.1
+ ,116.8
+ ,321.9
+ ,99.8
+ ,96
+ ,115.9
+ ,115.7
+ ,239.4
+ ,116.8
+ ,99.8
+ ,96
+ ,99.4
+ ,191
+ ,115.7
+ ,116.8
+ ,99.8
+ ,94.3
+ ,159.7
+ ,99.4
+ ,115.7
+ ,116.8
+ ,91
+ ,163.4
+ ,94.3
+ ,99.4
+ ,115.7)
+ ,dim=c(5
+ ,58)
+ ,dimnames=list(c('tot.ind.prod.index'
+ ,'prijsindex.grondst.incl.energie'
+ ,'y(t-1)'
+ ,'y(t-2)'
+ ,'y(t-3)')
+ ,1:58))
> y <- array(NA,dim=c(5,58),dimnames=list(c('tot.ind.prod.index','prijsindex.grondst.incl.energie','y(t-1)','y(t-2)','y(t-3)'),1:58))
> 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
tot.ind.prod.index prijsindex.grondst.incl.energie y(t-1) y(t-2) y(t-3) M1
1 102.9 127.5 112.7 97.0 95.1 1
2 97.4 134.6 102.9 112.7 97.0 0
3 111.4 131.8 97.4 102.9 112.7 0
4 87.4 135.9 111.4 97.4 102.9 0
5 96.8 142.7 87.4 111.4 97.4 0
6 114.1 141.7 96.8 87.4 111.4 0
7 110.3 153.4 114.1 96.8 87.4 0
8 103.9 145.0 110.3 114.1 96.8 0
9 101.6 137.7 103.9 110.3 114.1 0
10 94.6 148.3 101.6 103.9 110.3 0
11 95.9 152.2 94.6 101.6 103.9 0
12 104.7 169.4 95.9 94.6 101.6 0
13 102.8 168.6 104.7 95.9 94.6 1
14 98.1 161.1 102.8 104.7 95.9 0
15 113.9 174.1 98.1 102.8 104.7 0
16 80.9 179.0 113.9 98.1 102.8 0
17 95.7 190.6 80.9 113.9 98.1 0
18 113.2 190.0 95.7 80.9 113.9 0
19 105.9 181.6 113.2 95.7 80.9 0
20 108.8 174.8 105.9 113.2 95.7 0
21 102.3 180.5 108.8 105.9 113.2 0
22 99.0 196.8 102.3 108.8 105.9 0
23 100.7 193.8 99.0 102.3 108.8 0
24 115.5 197.0 100.7 99.0 102.3 0
25 100.7 216.3 115.5 100.7 99.0 1
26 109.9 221.4 100.7 115.5 100.7 0
27 114.6 217.9 109.9 100.7 115.5 0
28 85.4 229.7 114.6 109.9 100.7 0
29 100.5 227.4 85.4 114.6 109.9 0
30 114.8 204.2 100.5 85.4 114.6 0
31 116.5 196.6 114.8 100.5 85.4 0
32 112.9 198.8 116.5 114.8 100.5 0
33 102.0 207.5 112.9 116.5 114.8 0
34 106.0 190.7 102.0 112.9 116.5 0
35 105.3 201.6 106.0 102.0 112.9 0
36 118.8 210.5 105.3 106.0 102.0 0
37 106.1 223.5 118.8 105.3 106.0 1
38 109.3 223.8 106.1 118.8 105.3 0
39 117.2 231.2 109.3 106.1 118.8 0
40 92.5 244.0 117.2 109.3 106.1 0
41 104.2 234.7 92.5 117.2 109.3 0
42 112.5 250.2 104.2 92.5 117.2 0
43 122.4 265.7 112.5 104.2 92.5 0
44 113.3 287.6 122.4 112.5 104.2 0
45 100.0 283.3 113.3 122.4 112.5 0
46 110.7 295.4 100.0 113.3 122.4 0
47 112.8 312.3 110.7 100.0 113.3 0
48 109.8 333.8 112.8 110.7 100.0 0
49 117.3 347.7 109.8 112.8 110.7 1
50 109.1 383.2 117.3 109.8 112.8 0
51 115.9 407.1 109.1 117.3 109.8 0
52 96.0 413.6 115.9 109.1 117.3 0
53 99.8 362.7 96.0 115.9 109.1 0
54 116.8 321.9 99.8 96.0 115.9 0
55 115.7 239.4 116.8 99.8 96.0 0
56 99.4 191.0 115.7 116.8 99.8 0
57 94.3 159.7 99.4 115.7 116.8 0
58 91.0 163.4 94.3 99.4 115.7 0
M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 0 0 0 0 0 0 0 0 0 0 1
2 1 0 0 0 0 0 0 0 0 0 2
3 0 1 0 0 0 0 0 0 0 0 3
4 0 0 1 0 0 0 0 0 0 0 4
5 0 0 0 1 0 0 0 0 0 0 5
6 0 0 0 0 1 0 0 0 0 0 6
7 0 0 0 0 0 1 0 0 0 0 7
8 0 0 0 0 0 0 1 0 0 0 8
9 0 0 0 0 0 0 0 1 0 0 9
10 0 0 0 0 0 0 0 0 1 0 10
11 0 0 0 0 0 0 0 0 0 1 11
12 0 0 0 0 0 0 0 0 0 0 12
13 0 0 0 0 0 0 0 0 0 0 13
14 1 0 0 0 0 0 0 0 0 0 14
15 0 1 0 0 0 0 0 0 0 0 15
16 0 0 1 0 0 0 0 0 0 0 16
17 0 0 0 1 0 0 0 0 0 0 17
18 0 0 0 0 1 0 0 0 0 0 18
19 0 0 0 0 0 1 0 0 0 0 19
20 0 0 0 0 0 0 1 0 0 0 20
21 0 0 0 0 0 0 0 1 0 0 21
22 0 0 0 0 0 0 0 0 1 0 22
23 0 0 0 0 0 0 0 0 0 1 23
24 0 0 0 0 0 0 0 0 0 0 24
25 0 0 0 0 0 0 0 0 0 0 25
26 1 0 0 0 0 0 0 0 0 0 26
27 0 1 0 0 0 0 0 0 0 0 27
28 0 0 1 0 0 0 0 0 0 0 28
29 0 0 0 1 0 0 0 0 0 0 29
30 0 0 0 0 1 0 0 0 0 0 30
31 0 0 0 0 0 1 0 0 0 0 31
32 0 0 0 0 0 0 1 0 0 0 32
33 0 0 0 0 0 0 0 1 0 0 33
34 0 0 0 0 0 0 0 0 1 0 34
35 0 0 0 0 0 0 0 0 0 1 35
36 0 0 0 0 0 0 0 0 0 0 36
37 0 0 0 0 0 0 0 0 0 0 37
38 1 0 0 0 0 0 0 0 0 0 38
39 0 1 0 0 0 0 0 0 0 0 39
40 0 0 1 0 0 0 0 0 0 0 40
41 0 0 0 1 0 0 0 0 0 0 41
42 0 0 0 0 1 0 0 0 0 0 42
43 0 0 0 0 0 1 0 0 0 0 43
44 0 0 0 0 0 0 1 0 0 0 44
45 0 0 0 0 0 0 0 1 0 0 45
46 0 0 0 0 0 0 0 0 1 0 46
47 0 0 0 0 0 0 0 0 0 1 47
48 0 0 0 0 0 0 0 0 0 0 48
49 0 0 0 0 0 0 0 0 0 0 49
50 1 0 0 0 0 0 0 0 0 0 50
51 0 1 0 0 0 0 0 0 0 0 51
52 0 0 1 0 0 0 0 0 0 0 52
53 0 0 0 1 0 0 0 0 0 0 53
54 0 0 0 0 1 0 0 0 0 0 54
55 0 0 0 0 0 1 0 0 0 0 55
56 0 0 0 0 0 0 1 0 0 0 56
57 0 0 0 0 0 0 0 1 0 0 57
58 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) prijsindex.grondst.incl.energie
8.93968 0.02788
`y(t-1)` `y(t-2)`
0.02094 0.32772
`y(t-3)` M1
0.64591 -6.51910
M2 M3
-11.74283 -6.29787
M4 M5
-28.25196 -18.80076
M6 M7
-1.50640 11.91191
M8 M9
-6.17371 -22.92328
M10 M11
-20.33325 -13.26339
t
-0.14721
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-5.8296 -2.9982 0.2151 2.5451 7.0658
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.93968 26.16602 0.342 0.734358
prijsindex.grondst.incl.energie 0.02788 0.01501 1.857 0.070511 .
`y(t-1)` 0.02094 0.13907 0.151 0.881059
`y(t-2)` 0.32772 0.14630 2.240 0.030569 *
`y(t-3)` 0.64591 0.15905 4.061 0.000215 ***
M1 -6.51910 2.95974 -2.203 0.033303 *
M2 -11.74283 3.11413 -3.771 0.000514 ***
M3 -6.29787 3.30804 -1.904 0.063971 .
M4 -28.25196 3.15571 -8.953 3.40e-11 ***
M5 -18.80076 3.85705 -4.874 1.68e-05 ***
M6 -1.50640 3.81783 -0.395 0.695205
M7 11.91191 3.81248 3.124 0.003266 **
M8 -6.17371 3.68833 -1.674 0.101774
M9 -22.92328 4.12154 -5.562 1.81e-06 ***
M10 -20.33325 3.57962 -5.680 1.23e-06 ***
M11 -13.26339 3.11978 -4.251 0.000120 ***
t -0.14721 0.06001 -2.453 0.018514 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.971 on 41 degrees of freedom
Multiple R-squared: 0.8641, Adjusted R-squared: 0.811
F-statistic: 16.29 on 16 and 41 DF, p-value: 6.664e-13
> 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.4770111 0.9540222 0.5229889
[2,] 0.3918520 0.7837041 0.6081480
[3,] 0.4035297 0.8070595 0.5964703
[4,] 0.5293620 0.9412761 0.4706380
[5,] 0.4932390 0.9864780 0.5067610
[6,] 0.5508955 0.8982090 0.4491045
[7,] 0.6628034 0.6743932 0.3371966
[8,] 0.5519175 0.8961649 0.4480825
[9,] 0.5344245 0.9311510 0.4655755
[10,] 0.6417932 0.7164136 0.3582068
[11,] 0.5668832 0.8662337 0.4331168
[12,] 0.4887910 0.9775820 0.5112090
[13,] 0.3841571 0.7683142 0.6158429
[14,] 0.3365076 0.6730153 0.6634924
[15,] 0.2307385 0.4614769 0.7692615
[16,] 0.5259692 0.9480616 0.4740308
[17,] 0.4799279 0.9598559 0.5200721
[18,] 0.4543029 0.9086058 0.5456971
[19,] 0.3061017 0.6122034 0.6938983
> postscript(file="/var/www/html/rcomp/tmp/1m7el1261301029.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/2zpnp1261301029.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/3ddx21261301029.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/4ygr41261301029.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/5ziac1261301029.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 = 58
Frequency = 1
1 2 3 4 5 6
1.49834136 -4.99580381 -3.02946254 2.79672304 2.17017031 0.97655183
7 8 9 10 11 12
-4.36170900 -3.95617267 1.04923518 -4.08908330 -4.78633190 -5.82960986
13 14 15 16 17 18
2.87004669 0.06625982 5.24320831 -3.35543660 0.36604251 1.03501399
19 20 21 22 23 24
-3.20362593 2.97715377 4.24326209 1.94690926 -2.86599721 3.97287629
25 26 27 28 29 30
-3.43435606 5.35607266 -0.04598120 -1.02759884 -2.03867016 1.97826943
31 32 33 34 35 36
4.23157189 4.32793302 0.36397536 2.69944675 0.58655262 6.46644986
37 38 39 40 41 42
-2.56654509 2.28992512 0.06113112 4.09452349 2.61111075 -3.92119011
43 44 45 46 47 48
4.22145975 2.25933973 -2.43889125 2.34721217 7.06577649 -4.60971629
49 50 51 52 53 54
1.63251310 -2.71645378 -2.22889569 -2.50821110 -3.10865342 -0.06864513
55 56 57 58
-0.88769670 -5.60825385 -3.21758139 -2.90448487
> postscript(file="/var/www/html/rcomp/tmp/6jc251261301029.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 1.49834136 NA
1 -4.99580381 1.49834136
2 -3.02946254 -4.99580381
3 2.79672304 -3.02946254
4 2.17017031 2.79672304
5 0.97655183 2.17017031
6 -4.36170900 0.97655183
7 -3.95617267 -4.36170900
8 1.04923518 -3.95617267
9 -4.08908330 1.04923518
10 -4.78633190 -4.08908330
11 -5.82960986 -4.78633190
12 2.87004669 -5.82960986
13 0.06625982 2.87004669
14 5.24320831 0.06625982
15 -3.35543660 5.24320831
16 0.36604251 -3.35543660
17 1.03501399 0.36604251
18 -3.20362593 1.03501399
19 2.97715377 -3.20362593
20 4.24326209 2.97715377
21 1.94690926 4.24326209
22 -2.86599721 1.94690926
23 3.97287629 -2.86599721
24 -3.43435606 3.97287629
25 5.35607266 -3.43435606
26 -0.04598120 5.35607266
27 -1.02759884 -0.04598120
28 -2.03867016 -1.02759884
29 1.97826943 -2.03867016
30 4.23157189 1.97826943
31 4.32793302 4.23157189
32 0.36397536 4.32793302
33 2.69944675 0.36397536
34 0.58655262 2.69944675
35 6.46644986 0.58655262
36 -2.56654509 6.46644986
37 2.28992512 -2.56654509
38 0.06113112 2.28992512
39 4.09452349 0.06113112
40 2.61111075 4.09452349
41 -3.92119011 2.61111075
42 4.22145975 -3.92119011
43 2.25933973 4.22145975
44 -2.43889125 2.25933973
45 2.34721217 -2.43889125
46 7.06577649 2.34721217
47 -4.60971629 7.06577649
48 1.63251310 -4.60971629
49 -2.71645378 1.63251310
50 -2.22889569 -2.71645378
51 -2.50821110 -2.22889569
52 -3.10865342 -2.50821110
53 -0.06864513 -3.10865342
54 -0.88769670 -0.06864513
55 -5.60825385 -0.88769670
56 -3.21758139 -5.60825385
57 -2.90448487 -3.21758139
58 NA -2.90448487
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.99580381 1.49834136
[2,] -3.02946254 -4.99580381
[3,] 2.79672304 -3.02946254
[4,] 2.17017031 2.79672304
[5,] 0.97655183 2.17017031
[6,] -4.36170900 0.97655183
[7,] -3.95617267 -4.36170900
[8,] 1.04923518 -3.95617267
[9,] -4.08908330 1.04923518
[10,] -4.78633190 -4.08908330
[11,] -5.82960986 -4.78633190
[12,] 2.87004669 -5.82960986
[13,] 0.06625982 2.87004669
[14,] 5.24320831 0.06625982
[15,] -3.35543660 5.24320831
[16,] 0.36604251 -3.35543660
[17,] 1.03501399 0.36604251
[18,] -3.20362593 1.03501399
[19,] 2.97715377 -3.20362593
[20,] 4.24326209 2.97715377
[21,] 1.94690926 4.24326209
[22,] -2.86599721 1.94690926
[23,] 3.97287629 -2.86599721
[24,] -3.43435606 3.97287629
[25,] 5.35607266 -3.43435606
[26,] -0.04598120 5.35607266
[27,] -1.02759884 -0.04598120
[28,] -2.03867016 -1.02759884
[29,] 1.97826943 -2.03867016
[30,] 4.23157189 1.97826943
[31,] 4.32793302 4.23157189
[32,] 0.36397536 4.32793302
[33,] 2.69944675 0.36397536
[34,] 0.58655262 2.69944675
[35,] 6.46644986 0.58655262
[36,] -2.56654509 6.46644986
[37,] 2.28992512 -2.56654509
[38,] 0.06113112 2.28992512
[39,] 4.09452349 0.06113112
[40,] 2.61111075 4.09452349
[41,] -3.92119011 2.61111075
[42,] 4.22145975 -3.92119011
[43,] 2.25933973 4.22145975
[44,] -2.43889125 2.25933973
[45,] 2.34721217 -2.43889125
[46,] 7.06577649 2.34721217
[47,] -4.60971629 7.06577649
[48,] 1.63251310 -4.60971629
[49,] -2.71645378 1.63251310
[50,] -2.22889569 -2.71645378
[51,] -2.50821110 -2.22889569
[52,] -3.10865342 -2.50821110
[53,] -0.06864513 -3.10865342
[54,] -0.88769670 -0.06864513
[55,] -5.60825385 -0.88769670
[56,] -3.21758139 -5.60825385
[57,] -2.90448487 -3.21758139
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.99580381 1.49834136
2 -3.02946254 -4.99580381
3 2.79672304 -3.02946254
4 2.17017031 2.79672304
5 0.97655183 2.17017031
6 -4.36170900 0.97655183
7 -3.95617267 -4.36170900
8 1.04923518 -3.95617267
9 -4.08908330 1.04923518
10 -4.78633190 -4.08908330
11 -5.82960986 -4.78633190
12 2.87004669 -5.82960986
13 0.06625982 2.87004669
14 5.24320831 0.06625982
15 -3.35543660 5.24320831
16 0.36604251 -3.35543660
17 1.03501399 0.36604251
18 -3.20362593 1.03501399
19 2.97715377 -3.20362593
20 4.24326209 2.97715377
21 1.94690926 4.24326209
22 -2.86599721 1.94690926
23 3.97287629 -2.86599721
24 -3.43435606 3.97287629
25 5.35607266 -3.43435606
26 -0.04598120 5.35607266
27 -1.02759884 -0.04598120
28 -2.03867016 -1.02759884
29 1.97826943 -2.03867016
30 4.23157189 1.97826943
31 4.32793302 4.23157189
32 0.36397536 4.32793302
33 2.69944675 0.36397536
34 0.58655262 2.69944675
35 6.46644986 0.58655262
36 -2.56654509 6.46644986
37 2.28992512 -2.56654509
38 0.06113112 2.28992512
39 4.09452349 0.06113112
40 2.61111075 4.09452349
41 -3.92119011 2.61111075
42 4.22145975 -3.92119011
43 2.25933973 4.22145975
44 -2.43889125 2.25933973
45 2.34721217 -2.43889125
46 7.06577649 2.34721217
47 -4.60971629 7.06577649
48 1.63251310 -4.60971629
49 -2.71645378 1.63251310
50 -2.22889569 -2.71645378
51 -2.50821110 -2.22889569
52 -3.10865342 -2.50821110
53 -0.06864513 -3.10865342
54 -0.88769670 -0.06864513
55 -5.60825385 -0.88769670
56 -3.21758139 -5.60825385
57 -2.90448487 -3.21758139
> 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/7wqtq1261301029.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/8vxwl1261301029.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/9org31261301029.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/10ozc61261301029.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/11lpo51261301029.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/122hjg1261301030.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/13fr901261301030.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/14sqwh1261301030.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/152i681261301030.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/16crxl1261301030.tab")
+ }
> try(system("convert tmp/1m7el1261301029.ps tmp/1m7el1261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/2zpnp1261301029.ps tmp/2zpnp1261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/3ddx21261301029.ps tmp/3ddx21261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ygr41261301029.ps tmp/4ygr41261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ziac1261301029.ps tmp/5ziac1261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/6jc251261301029.ps tmp/6jc251261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/7wqtq1261301029.ps tmp/7wqtq1261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/8vxwl1261301029.ps tmp/8vxwl1261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/9org31261301029.ps tmp/9org31261301029.png",intern=TRUE))
character(0)
> try(system("convert tmp/10ozc61261301029.ps tmp/10ozc61261301029.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.358 1.564 3.472