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(97.4
+ ,134.6
+ ,102.9
+ ,112.7
+ ,97
+ ,95.1
+ ,111.4
+ ,131.8
+ ,97.4
+ ,102.9
+ ,112.7
+ ,97
+ ,87.4
+ ,135.9
+ ,111.4
+ ,97.4
+ ,102.9
+ ,112.7
+ ,96.8
+ ,142.7
+ ,87.4
+ ,111.4
+ ,97.4
+ ,102.9
+ ,114.1
+ ,141.7
+ ,96.8
+ ,87.4
+ ,111.4
+ ,97.4
+ ,110.3
+ ,153.4
+ ,114.1
+ ,96.8
+ ,87.4
+ ,111.4
+ ,103.9
+ ,145
+ ,110.3
+ ,114.1
+ ,96.8
+ ,87.4
+ ,101.6
+ ,137.7
+ ,103.9
+ ,110.3
+ ,114.1
+ ,96.8
+ ,94.6
+ ,148.3
+ ,101.6
+ ,103.9
+ ,110.3
+ ,114.1
+ ,95.9
+ ,152.2
+ ,94.6
+ ,101.6
+ ,103.9
+ ,110.3
+ ,104.7
+ ,169.4
+ ,95.9
+ ,94.6
+ ,101.6
+ ,103.9
+ ,102.8
+ ,168.6
+ ,104.7
+ ,95.9
+ ,94.6
+ ,101.6
+ ,98.1
+ ,161.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,94.6
+ ,113.9
+ ,174.1
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,80.9
+ ,179
+ ,113.9
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.7
+ ,190.6
+ ,80.9
+ ,113.9
+ ,98.1
+ ,102.8
+ ,113.2
+ ,190
+ ,95.7
+ ,80.9
+ ,113.9
+ ,98.1
+ ,105.9
+ ,181.6
+ ,113.2
+ ,95.7
+ ,80.9
+ ,113.9
+ ,108.8
+ ,174.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,80.9
+ ,102.3
+ ,180.5
+ ,108.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,99
+ ,196.8
+ ,102.3
+ ,108.8
+ ,105.9
+ ,113.2
+ ,100.7
+ ,193.8
+ ,99
+ ,102.3
+ ,108.8
+ ,105.9
+ ,115.5
+ ,197
+ ,100.7
+ ,99
+ ,102.3
+ ,108.8
+ ,100.7
+ ,216.3
+ ,115.5
+ ,100.7
+ ,99
+ ,102.3
+ ,109.9
+ ,221.4
+ ,100.7
+ ,115.5
+ ,100.7
+ ,99
+ ,114.6
+ ,217.9
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.7
+ ,85.4
+ ,229.7
+ ,114.6
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.5
+ ,227.4
+ ,85.4
+ ,114.6
+ ,109.9
+ ,100.7
+ ,114.8
+ ,204.2
+ ,100.5
+ ,85.4
+ ,114.6
+ ,109.9
+ ,116.5
+ ,196.6
+ ,114.8
+ ,100.5
+ ,85.4
+ ,114.6
+ ,112.9
+ ,198.8
+ ,116.5
+ ,114.8
+ ,100.5
+ ,85.4
+ ,102
+ ,207.5
+ ,112.9
+ ,116.5
+ ,114.8
+ ,100.5
+ ,106
+ ,190.7
+ ,102
+ ,112.9
+ ,116.5
+ ,114.8
+ ,105.3
+ ,201.6
+ ,106
+ ,102
+ ,112.9
+ ,116.5
+ ,118.8
+ ,210.5
+ ,105.3
+ ,106
+ ,102
+ ,112.9
+ ,106.1
+ ,223.5
+ ,118.8
+ ,105.3
+ ,106
+ ,102
+ ,109.3
+ ,223.8
+ ,106.1
+ ,118.8
+ ,105.3
+ ,106
+ ,117.2
+ ,231.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,105.3
+ ,92.5
+ ,244
+ ,117.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,104.2
+ ,234.7
+ ,92.5
+ ,117.2
+ ,109.3
+ ,106.1
+ ,112.5
+ ,250.2
+ ,104.2
+ ,92.5
+ ,117.2
+ ,109.3
+ ,122.4
+ ,265.7
+ ,112.5
+ ,104.2
+ ,92.5
+ ,117.2
+ ,113.3
+ ,287.6
+ ,122.4
+ ,112.5
+ ,104.2
+ ,92.5
+ ,100
+ ,283.3
+ ,113.3
+ ,122.4
+ ,112.5
+ ,104.2
+ ,110.7
+ ,295.4
+ ,100
+ ,113.3
+ ,122.4
+ ,112.5
+ ,112.8
+ ,312.3
+ ,110.7
+ ,100
+ ,113.3
+ ,122.4
+ ,109.8
+ ,333.8
+ ,112.8
+ ,110.7
+ ,100
+ ,113.3
+ ,117.3
+ ,347.7
+ ,109.8
+ ,112.8
+ ,110.7
+ ,100
+ ,109.1
+ ,383.2
+ ,117.3
+ ,109.8
+ ,112.8
+ ,110.7
+ ,115.9
+ ,407.1
+ ,109.1
+ ,117.3
+ ,109.8
+ ,112.8
+ ,96
+ ,413.6
+ ,115.9
+ ,109.1
+ ,117.3
+ ,109.8
+ ,99.8
+ ,362.7
+ ,96
+ ,115.9
+ ,109.1
+ ,117.3
+ ,116.8
+ ,321.9
+ ,99.8
+ ,96
+ ,115.9
+ ,109.1
+ ,115.7
+ ,239.4
+ ,116.8
+ ,99.8
+ ,96
+ ,115.9
+ ,99.4
+ ,191
+ ,115.7
+ ,116.8
+ ,99.8
+ ,96
+ ,94.3
+ ,159.7
+ ,99.4
+ ,115.7
+ ,116.8
+ ,99.8
+ ,91
+ ,163.4
+ ,94.3
+ ,99.4
+ ,115.7
+ ,116.8)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('tot.ind.prod.index'
+ ,'prijsindex.grondst.incl.energie'
+ ,'y(t-1)'
+ ,'y(t-2)'
+ ,'y(t-3)'
+ ,'y(t-4)')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('tot.ind.prod.index','prijsindex.grondst.incl.energie','y(t-1)','y(t-2)','y(t-3)','y(t-4)'),1:57))
> 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'
> #'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)
1 97.4 134.6 102.9 112.7 97.0
2 111.4 131.8 97.4 102.9 112.7
3 87.4 135.9 111.4 97.4 102.9
4 96.8 142.7 87.4 111.4 97.4
5 114.1 141.7 96.8 87.4 111.4
6 110.3 153.4 114.1 96.8 87.4
7 103.9 145.0 110.3 114.1 96.8
8 101.6 137.7 103.9 110.3 114.1
9 94.6 148.3 101.6 103.9 110.3
10 95.9 152.2 94.6 101.6 103.9
11 104.7 169.4 95.9 94.6 101.6
12 102.8 168.6 104.7 95.9 94.6
13 98.1 161.1 102.8 104.7 95.9
14 113.9 174.1 98.1 102.8 104.7
15 80.9 179.0 113.9 98.1 102.8
16 95.7 190.6 80.9 113.9 98.1
17 113.2 190.0 95.7 80.9 113.9
18 105.9 181.6 113.2 95.7 80.9
19 108.8 174.8 105.9 113.2 95.7
20 102.3 180.5 108.8 105.9 113.2
21 99.0 196.8 102.3 108.8 105.9
22 100.7 193.8 99.0 102.3 108.8
23 115.5 197.0 100.7 99.0 102.3
24 100.7 216.3 115.5 100.7 99.0
25 109.9 221.4 100.7 115.5 100.7
26 114.6 217.9 109.9 100.7 115.5
27 85.4 229.7 114.6 109.9 100.7
28 100.5 227.4 85.4 114.6 109.9
29 114.8 204.2 100.5 85.4 114.6
30 116.5 196.6 114.8 100.5 85.4
31 112.9 198.8 116.5 114.8 100.5
32 102.0 207.5 112.9 116.5 114.8
33 106.0 190.7 102.0 112.9 116.5
34 105.3 201.6 106.0 102.0 112.9
35 118.8 210.5 105.3 106.0 102.0
36 106.1 223.5 118.8 105.3 106.0
37 109.3 223.8 106.1 118.8 105.3
38 117.2 231.2 109.3 106.1 118.8
39 92.5 244.0 117.2 109.3 106.1
40 104.2 234.7 92.5 117.2 109.3
41 112.5 250.2 104.2 92.5 117.2
42 122.4 265.7 112.5 104.2 92.5
43 113.3 287.6 122.4 112.5 104.2
44 100.0 283.3 113.3 122.4 112.5
45 110.7 295.4 100.0 113.3 122.4
46 112.8 312.3 110.7 100.0 113.3
47 109.8 333.8 112.8 110.7 100.0
48 117.3 347.7 109.8 112.8 110.7
49 109.1 383.2 117.3 109.8 112.8
50 115.9 407.1 109.1 117.3 109.8
51 96.0 413.6 115.9 109.1 117.3
52 99.8 362.7 96.0 115.9 109.1
53 116.8 321.9 99.8 96.0 115.9
54 115.7 239.4 116.8 99.8 96.0
55 99.4 191.0 115.7 116.8 99.8
56 94.3 159.7 99.4 115.7 116.8
57 91.0 163.4 94.3 99.4 115.7
y(t-4)
1 95.1
2 97.0
3 112.7
4 102.9
5 97.4
6 111.4
7 87.4
8 96.8
9 114.1
10 110.3
11 103.9
12 101.6
13 94.6
14 95.9
15 104.7
16 102.8
17 98.1
18 113.9
19 80.9
20 95.7
21 113.2
22 105.9
23 108.8
24 102.3
25 99.0
26 100.7
27 115.5
28 100.7
29 109.9
30 114.6
31 85.4
32 100.5
33 114.8
34 116.5
35 112.9
36 102.0
37 106.0
38 105.3
39 118.8
40 106.1
41 109.3
42 117.2
43 92.5
44 104.2
45 112.5
46 122.4
47 113.3
48 100.0
49 110.7
50 112.8
51 109.8
52 117.3
53 109.1
54 115.9
55 96.0
56 99.8
57 116.8
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) prijsindex.grondst.incl.energie
181.26150 0.07230
`y(t-1)` `y(t-2)`
-0.03446 -0.40535
`y(t-3)` `y(t-4)`
-0.11286 -0.31404
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-25.1310 -3.7790 0.5788 5.3747 15.8823
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 181.26150 33.24801 5.452 1.46e-06 ***
prijsindex.grondst.incl.energie 0.07230 0.02090 3.459 0.00110 **
`y(t-1)` -0.03446 0.13934 -0.247 0.80566
`y(t-2)` -0.40535 0.13929 -2.910 0.00534 **
`y(t-3)` -0.11286 0.13977 -0.807 0.42316
`y(t-4)` -0.31404 0.14226 -2.208 0.03180 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 8.406 on 51 degrees of freedom
Multiple R-squared: 0.2413, Adjusted R-squared: 0.1669
F-statistic: 3.244 on 5 and 51 DF, p-value: 0.01281
> 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.5334661 0.9330678 0.4665339
[2,] 0.4312994 0.8625988 0.5687006
[3,] 0.3624464 0.7248928 0.6375536
[4,] 0.2846607 0.5693213 0.7153393
[5,] 0.2561332 0.5122665 0.7438668
[6,] 0.2522027 0.5044053 0.7477973
[7,] 0.6804919 0.6390161 0.3195081
[8,] 0.6087996 0.7824008 0.3912004
[9,] 0.5176354 0.9647291 0.4823646
[10,] 0.5514993 0.8970013 0.4485007
[11,] 0.4690076 0.9380152 0.5309924
[12,] 0.4297272 0.8594543 0.5702728
[13,] 0.4393383 0.8786765 0.5606617
[14,] 0.3825403 0.7650806 0.6174597
[15,] 0.4711456 0.9422912 0.5288544
[16,] 0.4742452 0.9484904 0.5257548
[17,] 0.4430419 0.8860839 0.5569581
[18,] 0.4210982 0.8421965 0.5789018
[19,] 0.6481067 0.7037866 0.3518933
[20,] 0.6109827 0.7780345 0.3890173
[21,] 0.5475820 0.9048360 0.4524180
[22,] 0.6339569 0.7320862 0.3660431
[23,] 0.5730101 0.8539798 0.4269899
[24,] 0.4979969 0.9959938 0.5020031
[25,] 0.5456999 0.9086003 0.4543001
[26,] 0.4724675 0.9449350 0.5275325
[27,] 0.5842277 0.8315447 0.4157723
[28,] 0.5031551 0.9936899 0.4968449
[29,] 0.4818352 0.9636705 0.5181648
[30,] 0.6376207 0.7247586 0.3623793
[31,] 0.6431079 0.7137843 0.3568921
[32,] 0.5508403 0.8983194 0.4491597
[33,] 0.4542365 0.9084730 0.5457635
[34,] 0.4785361 0.9570722 0.5214639
[35,] 0.3784235 0.7568470 0.6215765
[36,] 0.2871238 0.5742475 0.7128762
[37,] 0.4054006 0.8108011 0.5945994
[38,] 0.4457128 0.8914256 0.5542872
[39,] 0.3230046 0.6460092 0.6769954
[40,] 0.2183647 0.4367293 0.7816353
> postscript(file="/var/www/html/rcomp/tmp/1iuj41258645164.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/20iph1258645164.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/3q8601258645164.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/4naax1258645164.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/5qskf1258645164.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 = 57
Frequency = 1
1 2 3 4 5 6
-3.55114903 8.85784223 -13.36119493 -3.30324289 4.51729126 5.96581288
7 8 9 10 11 12
0.57876485 1.95008794 -3.48581909 -5.55698080 -3.06265605 -5.58690082
13 14 15 16 17 18
-8.29455730 7.03480851 -25.13103579 -7.02944193 -2.04555361 -0.89844970
19 20 21 22 23 24
0.64236852 -2.50608470 -1.36124000 -4.15805904 9.30862082 -8.10133673
25 26 27 28 29 30
5.37469083 6.84971523 -16.33473807 -3.77901444 4.30195173 11.34557958
31 32 33 34 35 36
5.97591467 1.36781881 9.43017826 3.78915445 15.88227252 -0.54774276
37 38 39 40 41 42
8.84235533 12.47337423 -8.77647902 2.31988377 1.78667160 15.28797948
43 44 45 46 47 48
1.87390360 -2.80480181 6.59713172 4.53473692 0.03116289 4.30492611
49 50 51 52 53 54
-3.82212191 4.32838404 -19.22681488 -8.24624406 1.96032516 8.84085674
55 56 57
-2.92719107 -3.65984206 -8.79587217
> postscript(file="/var/www/html/rcomp/tmp/6cbdf1258645164.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.55114903 NA
1 8.85784223 -3.55114903
2 -13.36119493 8.85784223
3 -3.30324289 -13.36119493
4 4.51729126 -3.30324289
5 5.96581288 4.51729126
6 0.57876485 5.96581288
7 1.95008794 0.57876485
8 -3.48581909 1.95008794
9 -5.55698080 -3.48581909
10 -3.06265605 -5.55698080
11 -5.58690082 -3.06265605
12 -8.29455730 -5.58690082
13 7.03480851 -8.29455730
14 -25.13103579 7.03480851
15 -7.02944193 -25.13103579
16 -2.04555361 -7.02944193
17 -0.89844970 -2.04555361
18 0.64236852 -0.89844970
19 -2.50608470 0.64236852
20 -1.36124000 -2.50608470
21 -4.15805904 -1.36124000
22 9.30862082 -4.15805904
23 -8.10133673 9.30862082
24 5.37469083 -8.10133673
25 6.84971523 5.37469083
26 -16.33473807 6.84971523
27 -3.77901444 -16.33473807
28 4.30195173 -3.77901444
29 11.34557958 4.30195173
30 5.97591467 11.34557958
31 1.36781881 5.97591467
32 9.43017826 1.36781881
33 3.78915445 9.43017826
34 15.88227252 3.78915445
35 -0.54774276 15.88227252
36 8.84235533 -0.54774276
37 12.47337423 8.84235533
38 -8.77647902 12.47337423
39 2.31988377 -8.77647902
40 1.78667160 2.31988377
41 15.28797948 1.78667160
42 1.87390360 15.28797948
43 -2.80480181 1.87390360
44 6.59713172 -2.80480181
45 4.53473692 6.59713172
46 0.03116289 4.53473692
47 4.30492611 0.03116289
48 -3.82212191 4.30492611
49 4.32838404 -3.82212191
50 -19.22681488 4.32838404
51 -8.24624406 -19.22681488
52 1.96032516 -8.24624406
53 8.84085674 1.96032516
54 -2.92719107 8.84085674
55 -3.65984206 -2.92719107
56 -8.79587217 -3.65984206
57 NA -8.79587217
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 8.85784223 -3.55114903
[2,] -13.36119493 8.85784223
[3,] -3.30324289 -13.36119493
[4,] 4.51729126 -3.30324289
[5,] 5.96581288 4.51729126
[6,] 0.57876485 5.96581288
[7,] 1.95008794 0.57876485
[8,] -3.48581909 1.95008794
[9,] -5.55698080 -3.48581909
[10,] -3.06265605 -5.55698080
[11,] -5.58690082 -3.06265605
[12,] -8.29455730 -5.58690082
[13,] 7.03480851 -8.29455730
[14,] -25.13103579 7.03480851
[15,] -7.02944193 -25.13103579
[16,] -2.04555361 -7.02944193
[17,] -0.89844970 -2.04555361
[18,] 0.64236852 -0.89844970
[19,] -2.50608470 0.64236852
[20,] -1.36124000 -2.50608470
[21,] -4.15805904 -1.36124000
[22,] 9.30862082 -4.15805904
[23,] -8.10133673 9.30862082
[24,] 5.37469083 -8.10133673
[25,] 6.84971523 5.37469083
[26,] -16.33473807 6.84971523
[27,] -3.77901444 -16.33473807
[28,] 4.30195173 -3.77901444
[29,] 11.34557958 4.30195173
[30,] 5.97591467 11.34557958
[31,] 1.36781881 5.97591467
[32,] 9.43017826 1.36781881
[33,] 3.78915445 9.43017826
[34,] 15.88227252 3.78915445
[35,] -0.54774276 15.88227252
[36,] 8.84235533 -0.54774276
[37,] 12.47337423 8.84235533
[38,] -8.77647902 12.47337423
[39,] 2.31988377 -8.77647902
[40,] 1.78667160 2.31988377
[41,] 15.28797948 1.78667160
[42,] 1.87390360 15.28797948
[43,] -2.80480181 1.87390360
[44,] 6.59713172 -2.80480181
[45,] 4.53473692 6.59713172
[46,] 0.03116289 4.53473692
[47,] 4.30492611 0.03116289
[48,] -3.82212191 4.30492611
[49,] 4.32838404 -3.82212191
[50,] -19.22681488 4.32838404
[51,] -8.24624406 -19.22681488
[52,] 1.96032516 -8.24624406
[53,] 8.84085674 1.96032516
[54,] -2.92719107 8.84085674
[55,] -3.65984206 -2.92719107
[56,] -8.79587217 -3.65984206
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 8.85784223 -3.55114903
2 -13.36119493 8.85784223
3 -3.30324289 -13.36119493
4 4.51729126 -3.30324289
5 5.96581288 4.51729126
6 0.57876485 5.96581288
7 1.95008794 0.57876485
8 -3.48581909 1.95008794
9 -5.55698080 -3.48581909
10 -3.06265605 -5.55698080
11 -5.58690082 -3.06265605
12 -8.29455730 -5.58690082
13 7.03480851 -8.29455730
14 -25.13103579 7.03480851
15 -7.02944193 -25.13103579
16 -2.04555361 -7.02944193
17 -0.89844970 -2.04555361
18 0.64236852 -0.89844970
19 -2.50608470 0.64236852
20 -1.36124000 -2.50608470
21 -4.15805904 -1.36124000
22 9.30862082 -4.15805904
23 -8.10133673 9.30862082
24 5.37469083 -8.10133673
25 6.84971523 5.37469083
26 -16.33473807 6.84971523
27 -3.77901444 -16.33473807
28 4.30195173 -3.77901444
29 11.34557958 4.30195173
30 5.97591467 11.34557958
31 1.36781881 5.97591467
32 9.43017826 1.36781881
33 3.78915445 9.43017826
34 15.88227252 3.78915445
35 -0.54774276 15.88227252
36 8.84235533 -0.54774276
37 12.47337423 8.84235533
38 -8.77647902 12.47337423
39 2.31988377 -8.77647902
40 1.78667160 2.31988377
41 15.28797948 1.78667160
42 1.87390360 15.28797948
43 -2.80480181 1.87390360
44 6.59713172 -2.80480181
45 4.53473692 6.59713172
46 0.03116289 4.53473692
47 4.30492611 0.03116289
48 -3.82212191 4.30492611
49 4.32838404 -3.82212191
50 -19.22681488 4.32838404
51 -8.24624406 -19.22681488
52 1.96032516 -8.24624406
53 8.84085674 1.96032516
54 -2.92719107 8.84085674
55 -3.65984206 -2.92719107
56 -8.79587217 -3.65984206
> 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/76p1q1258645164.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/8ukst1258645164.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/9iihc1258645164.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/102ayo1258645164.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/1185071258645164.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/12wfsm1258645164.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/13rn5s1258645164.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/143t7n1258645164.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/158pti1258645164.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/16rv2f1258645164.tab")
+ }
>
> system("convert tmp/1iuj41258645164.ps tmp/1iuj41258645164.png")
> system("convert tmp/20iph1258645164.ps tmp/20iph1258645164.png")
> system("convert tmp/3q8601258645164.ps tmp/3q8601258645164.png")
> system("convert tmp/4naax1258645164.ps tmp/4naax1258645164.png")
> system("convert tmp/5qskf1258645164.ps tmp/5qskf1258645164.png")
> system("convert tmp/6cbdf1258645164.ps tmp/6cbdf1258645164.png")
> system("convert tmp/76p1q1258645164.ps tmp/76p1q1258645164.png")
> system("convert tmp/8ukst1258645164.ps tmp/8ukst1258645164.png")
> system("convert tmp/9iihc1258645164.ps tmp/9iihc1258645164.png")
> system("convert tmp/102ayo1258645164.ps tmp/102ayo1258645164.png")
>
>
> proc.time()
user system elapsed
2.427 1.555 2.954