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(124.9
+ ,11554.5
+ ,132
+ ,13182.1
+ ,151.4
+ ,14800.1
+ ,108.9
+ ,12150.7
+ ,121.3
+ ,14478.2
+ ,123.4
+ ,13253.9
+ ,90.3
+ ,12036.8
+ ,79.3
+ ,12653.2
+ ,117.2
+ ,14035.4
+ ,116.9
+ ,14571.4
+ ,120.8
+ ,15400.9
+ ,96.1
+ ,14283.2
+ ,100.8
+ ,14485.3
+ ,105.3
+ ,14196.3
+ ,116.1
+ ,15559.1
+ ,112.8
+ ,13767.4
+ ,114.5
+ ,14634
+ ,117.2
+ ,14381.1
+ ,77.1
+ ,12509.9
+ ,80.1
+ ,12122.3
+ ,120.3
+ ,13122.3
+ ,133.4
+ ,13908.7
+ ,109.4
+ ,13456.5
+ ,93.2
+ ,12441.6
+ ,91.2
+ ,12953
+ ,99.2
+ ,13057.2
+ ,108.2
+ ,14350.1
+ ,101.5
+ ,13830.2
+ ,106.9
+ ,13755.5
+ ,104.4
+ ,13574.4
+ ,77.9
+ ,12802.6
+ ,60
+ ,11737.3
+ ,99.5
+ ,13850.2
+ ,95
+ ,15081.8
+ ,105.6
+ ,13653.3
+ ,102.5
+ ,14019.1
+ ,93.3
+ ,13962
+ ,97.3
+ ,13768.7
+ ,127
+ ,14747.1
+ ,111.7
+ ,13858.1
+ ,96.4
+ ,13188
+ ,133
+ ,13693.1
+ ,72.2
+ ,12970
+ ,95.8
+ ,11392.8
+ ,124.1
+ ,13985.2
+ ,127.6
+ ,14994.7
+ ,110.7
+ ,13584.7
+ ,104.6
+ ,14257.8
+ ,112.7
+ ,13553.4
+ ,115.3
+ ,14007.3
+ ,139.4
+ ,16535.8
+ ,119
+ ,14721.4
+ ,97.4
+ ,13664.6
+ ,154
+ ,16405.9
+ ,81.5
+ ,13829.4
+ ,88.8
+ ,13735.6
+ ,127.7
+ ,15870.5
+ ,105.1
+ ,15962.4
+ ,114.9
+ ,15744.1
+ ,106.4
+ ,16083.7
+ ,104.5
+ ,14863.9
+ ,121.6
+ ,15533.1
+ ,141.4
+ ,17473.1
+ ,99
+ ,15925.5
+ ,126.7
+ ,15573.7
+ ,134.1
+ ,17495
+ ,81.3
+ ,14155.8
+ ,88.6
+ ,14913.9
+ ,132.7
+ ,17250.4
+ ,132.9
+ ,15879.8
+ ,134.4
+ ,17647.8
+ ,103.7
+ ,17749.9)
+ ,dim=c(2
+ ,72)
+ ,dimnames=list(c('transport'
+ ,'Invoer')
+ ,1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('transport','Invoer'),1:72))
> 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 = '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
transport Invoer M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 124.9 11554.5 1 0 0 0 0 0 0 0 0 0 0
2 132.0 13182.1 0 1 0 0 0 0 0 0 0 0 0
3 151.4 14800.1 0 0 1 0 0 0 0 0 0 0 0
4 108.9 12150.7 0 0 0 1 0 0 0 0 0 0 0
5 121.3 14478.2 0 0 0 0 1 0 0 0 0 0 0
6 123.4 13253.9 0 0 0 0 0 1 0 0 0 0 0
7 90.3 12036.8 0 0 0 0 0 0 1 0 0 0 0
8 79.3 12653.2 0 0 0 0 0 0 0 1 0 0 0
9 117.2 14035.4 0 0 0 0 0 0 0 0 1 0 0
10 116.9 14571.4 0 0 0 0 0 0 0 0 0 1 0
11 120.8 15400.9 0 0 0 0 0 0 0 0 0 0 1
12 96.1 14283.2 0 0 0 0 0 0 0 0 0 0 0
13 100.8 14485.3 1 0 0 0 0 0 0 0 0 0 0
14 105.3 14196.3 0 1 0 0 0 0 0 0 0 0 0
15 116.1 15559.1 0 0 1 0 0 0 0 0 0 0 0
16 112.8 13767.4 0 0 0 1 0 0 0 0 0 0 0
17 114.5 14634.0 0 0 0 0 1 0 0 0 0 0 0
18 117.2 14381.1 0 0 0 0 0 1 0 0 0 0 0
19 77.1 12509.9 0 0 0 0 0 0 1 0 0 0 0
20 80.1 12122.3 0 0 0 0 0 0 0 1 0 0 0
21 120.3 13122.3 0 0 0 0 0 0 0 0 1 0 0
22 133.4 13908.7 0 0 0 0 0 0 0 0 0 1 0
23 109.4 13456.5 0 0 0 0 0 0 0 0 0 0 1
24 93.2 12441.6 0 0 0 0 0 0 0 0 0 0 0
25 91.2 12953.0 1 0 0 0 0 0 0 0 0 0 0
26 99.2 13057.2 0 1 0 0 0 0 0 0 0 0 0
27 108.2 14350.1 0 0 1 0 0 0 0 0 0 0 0
28 101.5 13830.2 0 0 0 1 0 0 0 0 0 0 0
29 106.9 13755.5 0 0 0 0 1 0 0 0 0 0 0
30 104.4 13574.4 0 0 0 0 0 1 0 0 0 0 0
31 77.9 12802.6 0 0 0 0 0 0 1 0 0 0 0
32 60.0 11737.3 0 0 0 0 0 0 0 1 0 0 0
33 99.5 13850.2 0 0 0 0 0 0 0 0 1 0 0
34 95.0 15081.8 0 0 0 0 0 0 0 0 0 1 0
35 105.6 13653.3 0 0 0 0 0 0 0 0 0 0 1
36 102.5 14019.1 0 0 0 0 0 0 0 0 0 0 0
37 93.3 13962.0 1 0 0 0 0 0 0 0 0 0 0
38 97.3 13768.7 0 1 0 0 0 0 0 0 0 0 0
39 127.0 14747.1 0 0 1 0 0 0 0 0 0 0 0
40 111.7 13858.1 0 0 0 1 0 0 0 0 0 0 0
41 96.4 13188.0 0 0 0 0 1 0 0 0 0 0 0
42 133.0 13693.1 0 0 0 0 0 1 0 0 0 0 0
43 72.2 12970.0 0 0 0 0 0 0 1 0 0 0 0
44 95.8 11392.8 0 0 0 0 0 0 0 1 0 0 0
45 124.1 13985.2 0 0 0 0 0 0 0 0 1 0 0
46 127.6 14994.7 0 0 0 0 0 0 0 0 0 1 0
47 110.7 13584.7 0 0 0 0 0 0 0 0 0 0 1
48 104.6 14257.8 0 0 0 0 0 0 0 0 0 0 0
49 112.7 13553.4 1 0 0 0 0 0 0 0 0 0 0
50 115.3 14007.3 0 1 0 0 0 0 0 0 0 0 0
51 139.4 16535.8 0 0 1 0 0 0 0 0 0 0 0
52 119.0 14721.4 0 0 0 1 0 0 0 0 0 0 0
53 97.4 13664.6 0 0 0 0 1 0 0 0 0 0 0
54 154.0 16405.9 0 0 0 0 0 1 0 0 0 0 0
55 81.5 13829.4 0 0 0 0 0 0 1 0 0 0 0
56 88.8 13735.6 0 0 0 0 0 0 0 1 0 0 0
57 127.7 15870.5 0 0 0 0 0 0 0 0 1 0 0
58 105.1 15962.4 0 0 0 0 0 0 0 0 0 1 0
59 114.9 15744.1 0 0 0 0 0 0 0 0 0 0 1
60 106.4 16083.7 0 0 0 0 0 0 0 0 0 0 0
61 104.5 14863.9 1 0 0 0 0 0 0 0 0 0 0
62 121.6 15533.1 0 1 0 0 0 0 0 0 0 0 0
63 141.4 17473.1 0 0 1 0 0 0 0 0 0 0 0
64 99.0 15925.5 0 0 0 1 0 0 0 0 0 0 0
65 126.7 15573.7 0 0 0 0 1 0 0 0 0 0 0
66 134.1 17495.0 0 0 0 0 0 1 0 0 0 0 0
67 81.3 14155.8 0 0 0 0 0 0 1 0 0 0 0
68 88.6 14913.9 0 0 0 0 0 0 0 1 0 0 0
69 132.7 17250.4 0 0 0 0 0 0 0 0 1 0 0
70 132.9 15879.8 0 0 0 0 0 0 0 0 0 1 0
71 134.4 17647.8 0 0 0 0 0 0 0 0 0 0 1
72 103.7 17749.9 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Invoer M1 M2 M3 M4
54.998510 0.003113 7.354995 13.340835 27.098109 10.110324
M5 M6 M7 M8 M9 M10
11.287110 26.616549 -15.570302 -12.612771 19.540853 16.588908
M11
14.545097
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-23.5311 -6.6445 -0.3655 5.3755 26.5819
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 54.998510 17.758212 3.097 0.002990 **
Invoer 0.003113 0.001155 2.695 0.009156 **
M1 7.354995 6.922864 1.062 0.292374
M2 13.340835 6.842687 1.950 0.055976 .
M3 27.098109 6.830554 3.967 0.000200 ***
M4 10.110324 6.829354 1.480 0.144081
M5 11.287110 6.806381 1.658 0.102562
M6 26.616549 6.772161 3.930 0.000225 ***
M7 -15.570302 7.069044 -2.203 0.031542 *
M8 -12.612771 7.172870 -1.758 0.083866 .
M9 19.540853 6.773582 2.885 0.005460 **
M10 16.588908 6.778843 2.447 0.017395 *
M11 14.545097 6.773321 2.147 0.035880 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.73 on 59 degrees of freedom
Multiple R-squared: 0.6818, Adjusted R-squared: 0.6171
F-statistic: 10.54 on 12 and 59 DF, p-value: 1.020e-10
> 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.8737519 0.2524962 0.12624809
[2,] 0.7832286 0.4335428 0.21677139
[3,] 0.6786228 0.6427544 0.32137721
[4,] 0.5841885 0.8316229 0.41581146
[5,] 0.4660140 0.9320281 0.53398597
[6,] 0.3681592 0.7363184 0.63184081
[7,] 0.3786488 0.7572977 0.62135117
[8,] 0.5203749 0.9592501 0.47962507
[9,] 0.4781174 0.9562348 0.52188260
[10,] 0.5636580 0.8726839 0.43634197
[11,] 0.6285440 0.7429119 0.37145596
[12,] 0.7779196 0.4441608 0.22208040
[13,] 0.7159580 0.5680840 0.28404198
[14,] 0.6753387 0.6493227 0.32466134
[15,] 0.7530164 0.4939672 0.24698358
[16,] 0.6851090 0.6297820 0.31489098
[17,] 0.7942564 0.4114872 0.20574360
[18,] 0.8594528 0.2810944 0.14054719
[19,] 0.9496551 0.1006897 0.05034486
[20,] 0.9389546 0.1220908 0.06104538
[21,] 0.9153597 0.1692806 0.08464031
[22,] 0.9115538 0.1768924 0.08844619
[23,] 0.9305084 0.1389831 0.06949156
[24,] 0.9066722 0.1866555 0.09332777
[25,] 0.8733359 0.2533281 0.12666407
[26,] 0.8879102 0.2241795 0.11208976
[27,] 0.8699622 0.2600756 0.13003780
[28,] 0.8345616 0.3308767 0.16543836
[29,] 0.8426760 0.3146480 0.15732400
[30,] 0.7927726 0.4144549 0.20722743
[31,] 0.7677030 0.4645941 0.23229703
[32,] 0.7043697 0.5912606 0.29563028
[33,] 0.6274985 0.7450030 0.37250151
[34,] 0.5760687 0.8478626 0.42393128
[35,] 0.4768441 0.9536881 0.52315594
[36,] 0.3935977 0.7871954 0.60640230
[37,] 0.4655652 0.9311304 0.53443478
[38,] 0.5405198 0.9189603 0.45948015
[39,] 0.6841147 0.6317706 0.31588530
[40,] 0.5356492 0.9287016 0.46435082
[41,] 0.3785806 0.7571612 0.62141940
> postscript(file="/var/www/html/rcomp/tmp/1umfm1229762914.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/2iqfp1229762914.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/3li861229762914.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/4v3w71229762914.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/58oi51229762914.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 = 72
Frequency = 1
1 2 3 4 5 6
26.58193394 22.63002271 23.23655918 5.97087210 9.94950486 0.53082459
7 8 9 10 11 12
13.40602291 -2.47011605 -1.02597860 -0.04238778 3.31951930 -3.35642809
13 14 15 16 17 18
-6.64048032 -7.22677835 -14.42590582 4.83872827 2.66456145 -9.17770050
19 20 21 22 23 24
-1.26654915 -0.01763559 4.91613838 18.52033363 -2.02833716 -0.52426004
25 26 27 28 29 30
-11.47104011 -9.78121329 -18.56276988 -6.65674314 -2.20101760 -19.46676438
31 32 33 34 35 36
-1.37760779 -18.91928378 -18.14952469 -23.53105990 -6.44089726 3.86561013
37 38 39 40 41 42
-12.51165563 -13.89582969 -0.99847291 3.45641526 -10.93461590 8.76376975
43 44 45 46 47 48
-7.59865738 17.95300764 6.03027402 9.34004774 -1.12737275 5.22263201
49 50 51 52 53 54
8.16015359 3.36150345 5.83401570 8.06930586 -11.41808206 21.31990275
55 56 57 58 59 60
-0.97362763 3.66080342 3.76208527 -16.17201732 -3.64872575 1.33933182
61 62 63 64 65 66
-4.11891148 4.91229515 4.91657374 -15.67857834 11.93964925 -1.97003221
67 68 69 70 71 72
-2.18958096 -0.20677564 4.46700562 11.88508362 9.92581362 -6.54688582
> postscript(file="/var/www/html/rcomp/tmp/6ssq41229762914.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 26.58193394 NA
1 22.63002271 26.58193394
2 23.23655918 22.63002271
3 5.97087210 23.23655918
4 9.94950486 5.97087210
5 0.53082459 9.94950486
6 13.40602291 0.53082459
7 -2.47011605 13.40602291
8 -1.02597860 -2.47011605
9 -0.04238778 -1.02597860
10 3.31951930 -0.04238778
11 -3.35642809 3.31951930
12 -6.64048032 -3.35642809
13 -7.22677835 -6.64048032
14 -14.42590582 -7.22677835
15 4.83872827 -14.42590582
16 2.66456145 4.83872827
17 -9.17770050 2.66456145
18 -1.26654915 -9.17770050
19 -0.01763559 -1.26654915
20 4.91613838 -0.01763559
21 18.52033363 4.91613838
22 -2.02833716 18.52033363
23 -0.52426004 -2.02833716
24 -11.47104011 -0.52426004
25 -9.78121329 -11.47104011
26 -18.56276988 -9.78121329
27 -6.65674314 -18.56276988
28 -2.20101760 -6.65674314
29 -19.46676438 -2.20101760
30 -1.37760779 -19.46676438
31 -18.91928378 -1.37760779
32 -18.14952469 -18.91928378
33 -23.53105990 -18.14952469
34 -6.44089726 -23.53105990
35 3.86561013 -6.44089726
36 -12.51165563 3.86561013
37 -13.89582969 -12.51165563
38 -0.99847291 -13.89582969
39 3.45641526 -0.99847291
40 -10.93461590 3.45641526
41 8.76376975 -10.93461590
42 -7.59865738 8.76376975
43 17.95300764 -7.59865738
44 6.03027402 17.95300764
45 9.34004774 6.03027402
46 -1.12737275 9.34004774
47 5.22263201 -1.12737275
48 8.16015359 5.22263201
49 3.36150345 8.16015359
50 5.83401570 3.36150345
51 8.06930586 5.83401570
52 -11.41808206 8.06930586
53 21.31990275 -11.41808206
54 -0.97362763 21.31990275
55 3.66080342 -0.97362763
56 3.76208527 3.66080342
57 -16.17201732 3.76208527
58 -3.64872575 -16.17201732
59 1.33933182 -3.64872575
60 -4.11891148 1.33933182
61 4.91229515 -4.11891148
62 4.91657374 4.91229515
63 -15.67857834 4.91657374
64 11.93964925 -15.67857834
65 -1.97003221 11.93964925
66 -2.18958096 -1.97003221
67 -0.20677564 -2.18958096
68 4.46700562 -0.20677564
69 11.88508362 4.46700562
70 9.92581362 11.88508362
71 -6.54688582 9.92581362
72 NA -6.54688582
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 22.63002271 26.58193394
[2,] 23.23655918 22.63002271
[3,] 5.97087210 23.23655918
[4,] 9.94950486 5.97087210
[5,] 0.53082459 9.94950486
[6,] 13.40602291 0.53082459
[7,] -2.47011605 13.40602291
[8,] -1.02597860 -2.47011605
[9,] -0.04238778 -1.02597860
[10,] 3.31951930 -0.04238778
[11,] -3.35642809 3.31951930
[12,] -6.64048032 -3.35642809
[13,] -7.22677835 -6.64048032
[14,] -14.42590582 -7.22677835
[15,] 4.83872827 -14.42590582
[16,] 2.66456145 4.83872827
[17,] -9.17770050 2.66456145
[18,] -1.26654915 -9.17770050
[19,] -0.01763559 -1.26654915
[20,] 4.91613838 -0.01763559
[21,] 18.52033363 4.91613838
[22,] -2.02833716 18.52033363
[23,] -0.52426004 -2.02833716
[24,] -11.47104011 -0.52426004
[25,] -9.78121329 -11.47104011
[26,] -18.56276988 -9.78121329
[27,] -6.65674314 -18.56276988
[28,] -2.20101760 -6.65674314
[29,] -19.46676438 -2.20101760
[30,] -1.37760779 -19.46676438
[31,] -18.91928378 -1.37760779
[32,] -18.14952469 -18.91928378
[33,] -23.53105990 -18.14952469
[34,] -6.44089726 -23.53105990
[35,] 3.86561013 -6.44089726
[36,] -12.51165563 3.86561013
[37,] -13.89582969 -12.51165563
[38,] -0.99847291 -13.89582969
[39,] 3.45641526 -0.99847291
[40,] -10.93461590 3.45641526
[41,] 8.76376975 -10.93461590
[42,] -7.59865738 8.76376975
[43,] 17.95300764 -7.59865738
[44,] 6.03027402 17.95300764
[45,] 9.34004774 6.03027402
[46,] -1.12737275 9.34004774
[47,] 5.22263201 -1.12737275
[48,] 8.16015359 5.22263201
[49,] 3.36150345 8.16015359
[50,] 5.83401570 3.36150345
[51,] 8.06930586 5.83401570
[52,] -11.41808206 8.06930586
[53,] 21.31990275 -11.41808206
[54,] -0.97362763 21.31990275
[55,] 3.66080342 -0.97362763
[56,] 3.76208527 3.66080342
[57,] -16.17201732 3.76208527
[58,] -3.64872575 -16.17201732
[59,] 1.33933182 -3.64872575
[60,] -4.11891148 1.33933182
[61,] 4.91229515 -4.11891148
[62,] 4.91657374 4.91229515
[63,] -15.67857834 4.91657374
[64,] 11.93964925 -15.67857834
[65,] -1.97003221 11.93964925
[66,] -2.18958096 -1.97003221
[67,] -0.20677564 -2.18958096
[68,] 4.46700562 -0.20677564
[69,] 11.88508362 4.46700562
[70,] 9.92581362 11.88508362
[71,] -6.54688582 9.92581362
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 22.63002271 26.58193394
2 23.23655918 22.63002271
3 5.97087210 23.23655918
4 9.94950486 5.97087210
5 0.53082459 9.94950486
6 13.40602291 0.53082459
7 -2.47011605 13.40602291
8 -1.02597860 -2.47011605
9 -0.04238778 -1.02597860
10 3.31951930 -0.04238778
11 -3.35642809 3.31951930
12 -6.64048032 -3.35642809
13 -7.22677835 -6.64048032
14 -14.42590582 -7.22677835
15 4.83872827 -14.42590582
16 2.66456145 4.83872827
17 -9.17770050 2.66456145
18 -1.26654915 -9.17770050
19 -0.01763559 -1.26654915
20 4.91613838 -0.01763559
21 18.52033363 4.91613838
22 -2.02833716 18.52033363
23 -0.52426004 -2.02833716
24 -11.47104011 -0.52426004
25 -9.78121329 -11.47104011
26 -18.56276988 -9.78121329
27 -6.65674314 -18.56276988
28 -2.20101760 -6.65674314
29 -19.46676438 -2.20101760
30 -1.37760779 -19.46676438
31 -18.91928378 -1.37760779
32 -18.14952469 -18.91928378
33 -23.53105990 -18.14952469
34 -6.44089726 -23.53105990
35 3.86561013 -6.44089726
36 -12.51165563 3.86561013
37 -13.89582969 -12.51165563
38 -0.99847291 -13.89582969
39 3.45641526 -0.99847291
40 -10.93461590 3.45641526
41 8.76376975 -10.93461590
42 -7.59865738 8.76376975
43 17.95300764 -7.59865738
44 6.03027402 17.95300764
45 9.34004774 6.03027402
46 -1.12737275 9.34004774
47 5.22263201 -1.12737275
48 8.16015359 5.22263201
49 3.36150345 8.16015359
50 5.83401570 3.36150345
51 8.06930586 5.83401570
52 -11.41808206 8.06930586
53 21.31990275 -11.41808206
54 -0.97362763 21.31990275
55 3.66080342 -0.97362763
56 3.76208527 3.66080342
57 -16.17201732 3.76208527
58 -3.64872575 -16.17201732
59 1.33933182 -3.64872575
60 -4.11891148 1.33933182
61 4.91229515 -4.11891148
62 4.91657374 4.91229515
63 -15.67857834 4.91657374
64 11.93964925 -15.67857834
65 -1.97003221 11.93964925
66 -2.18958096 -1.97003221
67 -0.20677564 -2.18958096
68 4.46700562 -0.20677564
69 11.88508362 4.46700562
70 9.92581362 11.88508362
71 -6.54688582 9.92581362
> 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/7rpgv1229762914.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/8ksyb1229762914.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/9odki1229762914.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/104t1w1229762914.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/11bcps1229762914.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/12ruml1229762914.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/13k9f81229762914.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/14ea1o1229762914.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/15lnzc1229762914.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/1648oa1229762914.tab")
+ }
>
> system("convert tmp/1umfm1229762914.ps tmp/1umfm1229762914.png")
> system("convert tmp/2iqfp1229762914.ps tmp/2iqfp1229762914.png")
> system("convert tmp/3li861229762914.ps tmp/3li861229762914.png")
> system("convert tmp/4v3w71229762914.ps tmp/4v3w71229762914.png")
> system("convert tmp/58oi51229762914.ps tmp/58oi51229762914.png")
> system("convert tmp/6ssq41229762914.ps tmp/6ssq41229762914.png")
> system("convert tmp/7rpgv1229762914.ps tmp/7rpgv1229762914.png")
> system("convert tmp/8ksyb1229762914.ps tmp/8ksyb1229762914.png")
> system("convert tmp/9odki1229762914.ps tmp/9odki1229762914.png")
> system("convert tmp/104t1w1229762914.ps tmp/104t1w1229762914.png")
>
>
> proc.time()
user system elapsed
2.478 1.588 3.912