R version 2.7.0 (2008-04-22)
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(99.2
+ ,11554.5
+ ,93.6
+ ,13182.1
+ ,104.2
+ ,14800.1
+ ,95.3
+ ,12150.7
+ ,102.7
+ ,14478.2
+ ,103.1
+ ,13253.9
+ ,100
+ ,12036.8
+ ,107.2
+ ,12653.2
+ ,107
+ ,14035.4
+ ,119
+ ,14571.4
+ ,110.4
+ ,15400.9
+ ,101.7
+ ,14283.2
+ ,102.4
+ ,14485.3
+ ,98.8
+ ,14196.3
+ ,105.6
+ ,15559.1
+ ,104.4
+ ,13767.4
+ ,106.3
+ ,14634
+ ,107.2
+ ,14381.1
+ ,108.5
+ ,12509.9
+ ,106.9
+ ,12122.3
+ ,114.2
+ ,13122.3
+ ,125.9
+ ,13908.7
+ ,110.6
+ ,13456.5
+ ,110.5
+ ,12441.6
+ ,106.7
+ ,12953
+ ,104.7
+ ,13057.2
+ ,107.4
+ ,14350.1
+ ,109.8
+ ,13830.2
+ ,103.4
+ ,13755.5
+ ,114.8
+ ,13574.4
+ ,114.3
+ ,12802.6
+ ,109.6
+ ,11737.3
+ ,118.3
+ ,13850.2
+ ,127.3
+ ,15081.8
+ ,112.3
+ ,13653.3
+ ,114.9
+ ,14019.1
+ ,108.2
+ ,13962
+ ,105.4
+ ,13768.7
+ ,122.1
+ ,14747.1
+ ,113.5
+ ,13858.1
+ ,110
+ ,13188
+ ,125.3
+ ,13693.1
+ ,114.3
+ ,12970
+ ,115.6
+ ,11392.8
+ ,127.1
+ ,13985.2
+ ,123
+ ,14994.7
+ ,122.2
+ ,13584.7
+ ,126.4
+ ,14257.8
+ ,112.7
+ ,13553.4
+ ,105.8
+ ,14007.3
+ ,120.9
+ ,16535.8
+ ,116.3
+ ,14721.4
+ ,115.7
+ ,13664.6
+ ,127.9
+ ,16405.9
+ ,108.3
+ ,13829.4
+ ,121.1
+ ,13735.6
+ ,128.6
+ ,15870.5
+ ,123.1
+ ,15962.4
+ ,127.7
+ ,15744.1
+ ,126.6
+ ,16083.7
+ ,118.4
+ ,14863.9
+ ,110
+ ,15533.1
+ ,129.6
+ ,17473.1
+ ,115.8
+ ,15925.5
+ ,125.9
+ ,15573.7
+ ,128.4
+ ,17495
+ ,114
+ ,14155.8
+ ,125.6
+ ,14913.9
+ ,128.5
+ ,17250.4
+ ,136.6
+ ,15879.8
+ ,133.1
+ ,17647.8
+ ,124.6
+ ,17749.9)
+ ,dim=c(2
+ ,72)
+ ,dimnames=list(c('Voeding'
+ ,'Invoer')
+ ,1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('Voeding','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
Voeding Invoer M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 99.2 11554.5 1 0 0 0 0 0 0 0 0 0 0
2 93.6 13182.1 0 1 0 0 0 0 0 0 0 0 0
3 104.2 14800.1 0 0 1 0 0 0 0 0 0 0 0
4 95.3 12150.7 0 0 0 1 0 0 0 0 0 0 0
5 102.7 14478.2 0 0 0 0 1 0 0 0 0 0 0
6 103.1 13253.9 0 0 0 0 0 1 0 0 0 0 0
7 100.0 12036.8 0 0 0 0 0 0 1 0 0 0 0
8 107.2 12653.2 0 0 0 0 0 0 0 1 0 0 0
9 107.0 14035.4 0 0 0 0 0 0 0 0 1 0 0
10 119.0 14571.4 0 0 0 0 0 0 0 0 0 1 0
11 110.4 15400.9 0 0 0 0 0 0 0 0 0 0 1
12 101.7 14283.2 0 0 0 0 0 0 0 0 0 0 0
13 102.4 14485.3 1 0 0 0 0 0 0 0 0 0 0
14 98.8 14196.3 0 1 0 0 0 0 0 0 0 0 0
15 105.6 15559.1 0 0 1 0 0 0 0 0 0 0 0
16 104.4 13767.4 0 0 0 1 0 0 0 0 0 0 0
17 106.3 14634.0 0 0 0 0 1 0 0 0 0 0 0
18 107.2 14381.1 0 0 0 0 0 1 0 0 0 0 0
19 108.5 12509.9 0 0 0 0 0 0 1 0 0 0 0
20 106.9 12122.3 0 0 0 0 0 0 0 1 0 0 0
21 114.2 13122.3 0 0 0 0 0 0 0 0 1 0 0
22 125.9 13908.7 0 0 0 0 0 0 0 0 0 1 0
23 110.6 13456.5 0 0 0 0 0 0 0 0 0 0 1
24 110.5 12441.6 0 0 0 0 0 0 0 0 0 0 0
25 106.7 12953.0 1 0 0 0 0 0 0 0 0 0 0
26 104.7 13057.2 0 1 0 0 0 0 0 0 0 0 0
27 107.4 14350.1 0 0 1 0 0 0 0 0 0 0 0
28 109.8 13830.2 0 0 0 1 0 0 0 0 0 0 0
29 103.4 13755.5 0 0 0 0 1 0 0 0 0 0 0
30 114.8 13574.4 0 0 0 0 0 1 0 0 0 0 0
31 114.3 12802.6 0 0 0 0 0 0 1 0 0 0 0
32 109.6 11737.3 0 0 0 0 0 0 0 1 0 0 0
33 118.3 13850.2 0 0 0 0 0 0 0 0 1 0 0
34 127.3 15081.8 0 0 0 0 0 0 0 0 0 1 0
35 112.3 13653.3 0 0 0 0 0 0 0 0 0 0 1
36 114.9 14019.1 0 0 0 0 0 0 0 0 0 0 0
37 108.2 13962.0 1 0 0 0 0 0 0 0 0 0 0
38 105.4 13768.7 0 1 0 0 0 0 0 0 0 0 0
39 122.1 14747.1 0 0 1 0 0 0 0 0 0 0 0
40 113.5 13858.1 0 0 0 1 0 0 0 0 0 0 0
41 110.0 13188.0 0 0 0 0 1 0 0 0 0 0 0
42 125.3 13693.1 0 0 0 0 0 1 0 0 0 0 0
43 114.3 12970.0 0 0 0 0 0 0 1 0 0 0 0
44 115.6 11392.8 0 0 0 0 0 0 0 1 0 0 0
45 127.1 13985.2 0 0 0 0 0 0 0 0 1 0 0
46 123.0 14994.7 0 0 0 0 0 0 0 0 0 1 0
47 122.2 13584.7 0 0 0 0 0 0 0 0 0 0 1
48 126.4 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 105.8 14007.3 0 1 0 0 0 0 0 0 0 0 0
51 120.9 16535.8 0 0 1 0 0 0 0 0 0 0 0
52 116.3 14721.4 0 0 0 1 0 0 0 0 0 0 0
53 115.7 13664.6 0 0 0 0 1 0 0 0 0 0 0
54 127.9 16405.9 0 0 0 0 0 1 0 0 0 0 0
55 108.3 13829.4 0 0 0 0 0 0 1 0 0 0 0
56 121.1 13735.6 0 0 0 0 0 0 0 1 0 0 0
57 128.6 15870.5 0 0 0 0 0 0 0 0 1 0 0
58 123.1 15962.4 0 0 0 0 0 0 0 0 0 1 0
59 127.7 15744.1 0 0 0 0 0 0 0 0 0 0 1
60 126.6 16083.7 0 0 0 0 0 0 0 0 0 0 0
61 118.4 14863.9 1 0 0 0 0 0 0 0 0 0 0
62 110.0 15533.1 0 1 0 0 0 0 0 0 0 0 0
63 129.6 17473.1 0 0 1 0 0 0 0 0 0 0 0
64 115.8 15925.5 0 0 0 1 0 0 0 0 0 0 0
65 125.9 15573.7 0 0 0 0 1 0 0 0 0 0 0
66 128.4 17495.0 0 0 0 0 0 1 0 0 0 0 0
67 114.0 14155.8 0 0 0 0 0 0 1 0 0 0 0
68 125.6 14913.9 0 0 0 0 0 0 0 1 0 0 0
69 128.5 17250.4 0 0 0 0 0 0 0 0 1 0 0
70 136.6 15879.8 0 0 0 0 0 0 0 0 0 1 0
71 133.1 17647.8 0 0 0 0 0 0 0 0 0 0 1
72 124.6 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.661509 0.004241 -4.241702 -10.801981 -5.755802 -5.028124
M5 M6 M7 M8 M9 M10
-4.280354 0.355880 -0.106866 5.562937 3.676479 7.261590
M11
1.472502
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.5334 -4.9923 0.8401 4.3629 12.2132
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.466e+01 9.817e+00 5.568 6.66e-07 ***
Invoer 4.241e-03 6.385e-04 6.642 1.09e-08 ***
M1 -4.242e+00 3.827e+00 -1.108 0.27222
M2 -1.080e+01 3.783e+00 -2.856 0.00592 **
M3 -5.756e+00 3.776e+00 -1.524 0.13279
M4 -5.028e+00 3.775e+00 -1.332 0.18805
M5 -4.280e+00 3.763e+00 -1.138 0.25991
M6 3.559e-01 3.744e+00 0.095 0.92459
M7 -1.069e-01 3.908e+00 -0.027 0.97828
M8 5.563e+00 3.965e+00 1.403 0.16589
M9 3.676e+00 3.745e+00 0.982 0.33021
M10 7.262e+00 3.748e+00 1.938 0.05745 .
M11 1.473e+00 3.744e+00 0.393 0.69556
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.485 on 59 degrees of freedom
Multiple R-squared: 0.6464, Adjusted R-squared: 0.5745
F-statistic: 8.988 on 12 and 59 DF, p-value: 1.786e-09
> 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.18338270 0.36676539 0.81661730
[2,] 0.12056486 0.24112971 0.87943514
[3,] 0.07616742 0.15233483 0.92383258
[4,] 0.13509731 0.27019463 0.86490269
[5,] 0.08725871 0.17451741 0.91274129
[6,] 0.20503659 0.41007318 0.79496341
[7,] 0.26574466 0.53148932 0.73425534
[8,] 0.23136357 0.46272714 0.76863643
[9,] 0.35784728 0.71569456 0.64215272
[10,] 0.35162848 0.70325696 0.64837152
[11,] 0.42317963 0.84635926 0.57682037
[12,] 0.44815423 0.89630846 0.55184577
[13,] 0.54112797 0.91774407 0.45887203
[14,] 0.62552384 0.74895232 0.37447616
[15,] 0.73096614 0.53806772 0.26903386
[16,] 0.78976256 0.42047488 0.21023744
[17,] 0.78529451 0.42941099 0.21470549
[18,] 0.80482048 0.39035904 0.19517952
[19,] 0.75932617 0.48134765 0.24067383
[20,] 0.84279564 0.31440872 0.15720436
[21,] 0.88935321 0.22129358 0.11064679
[22,] 0.90200761 0.19598478 0.09799239
[23,] 0.88173290 0.23653419 0.11826710
[24,] 0.94799042 0.10401916 0.05200958
[25,] 0.94306845 0.11386310 0.05693155
[26,] 0.96332082 0.07335835 0.03667918
[27,] 0.97942056 0.04115887 0.02057944
[28,] 0.97707209 0.04585582 0.02292791
[29,] 0.96921405 0.06157189 0.03078595
[30,] 0.97126944 0.05746113 0.02873056
[31,] 0.96303069 0.07393862 0.03696931
[32,] 0.95441047 0.09117907 0.04558953
[33,] 0.97004025 0.05991949 0.02995975
[34,] 0.95303972 0.09392056 0.04696028
[35,] 0.91898712 0.16202577 0.08101288
[36,] 0.90968219 0.18063563 0.09031781
[37,] 0.86355182 0.27289637 0.13644818
[38,] 0.85246198 0.29507604 0.14753802
[39,] 0.76239784 0.47520432 0.23760216
[40,] 0.67711981 0.64576037 0.32288019
[41,] 0.53275927 0.93448146 0.46724073
> postscript(file="/var/www/html/rcomp/tmp/1v1un1229761108.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/2gc251229761108.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/386bc1229761108.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/4zwup1229761108.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/5r0zf1229761108.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
-0.2198972 -6.1619114 -7.4696724 -5.8618277 -9.0800127 -8.1242606
7 8 9 10 11 12
-5.6000613 -6.6838814 -10.8590289 -4.7171979 -11.0458366 -13.5334151
13 14 15 16 17 18
-9.4487746 -5.2629103 -9.2884243 -3.6178964 -6.1407262 -8.8044676
19 20 21 22 23 24
0.8936258 -4.7324514 0.2132271 4.9931668 -2.6000643 3.0764050
25 26 27 28 29 30
1.3493722 5.4677620 -2.3613215 1.5157827 -5.3152012 2.2165695
31 32 33 34 35 36
5.4523495 -0.3997511 1.2263635 1.4183080 -1.7346498 0.7865749
37 38 39 40 41 42
-1.4295746 3.1504472 10.6550889 5.0974649 3.6914414 12.2131889
43 44 45 46 47 48
4.7424430 7.0611975 9.4538582 -2.5123200 8.4562677 11.2743007
49 50 51 52 53 54
4.8032081 2.5385971 1.8696061 4.2363997 7.3702857 3.3088015
55 56 57 58 59 60
-4.9020832 2.6258986 2.9587161 -6.5161227 4.7987278 3.7310609
61 62 63 64 65 66
4.9456661 0.2680153 6.5947232 -1.3699233 9.4742130 -0.8098318
67 68 69 70 71 72
-0.5862737 2.1289877 -2.9931360 7.3341658 2.1255553 -5.3349264
> postscript(file="/var/www/html/rcomp/tmp/6j2k91229761109.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 -0.2198972 NA
1 -6.1619114 -0.2198972
2 -7.4696724 -6.1619114
3 -5.8618277 -7.4696724
4 -9.0800127 -5.8618277
5 -8.1242606 -9.0800127
6 -5.6000613 -8.1242606
7 -6.6838814 -5.6000613
8 -10.8590289 -6.6838814
9 -4.7171979 -10.8590289
10 -11.0458366 -4.7171979
11 -13.5334151 -11.0458366
12 -9.4487746 -13.5334151
13 -5.2629103 -9.4487746
14 -9.2884243 -5.2629103
15 -3.6178964 -9.2884243
16 -6.1407262 -3.6178964
17 -8.8044676 -6.1407262
18 0.8936258 -8.8044676
19 -4.7324514 0.8936258
20 0.2132271 -4.7324514
21 4.9931668 0.2132271
22 -2.6000643 4.9931668
23 3.0764050 -2.6000643
24 1.3493722 3.0764050
25 5.4677620 1.3493722
26 -2.3613215 5.4677620
27 1.5157827 -2.3613215
28 -5.3152012 1.5157827
29 2.2165695 -5.3152012
30 5.4523495 2.2165695
31 -0.3997511 5.4523495
32 1.2263635 -0.3997511
33 1.4183080 1.2263635
34 -1.7346498 1.4183080
35 0.7865749 -1.7346498
36 -1.4295746 0.7865749
37 3.1504472 -1.4295746
38 10.6550889 3.1504472
39 5.0974649 10.6550889
40 3.6914414 5.0974649
41 12.2131889 3.6914414
42 4.7424430 12.2131889
43 7.0611975 4.7424430
44 9.4538582 7.0611975
45 -2.5123200 9.4538582
46 8.4562677 -2.5123200
47 11.2743007 8.4562677
48 4.8032081 11.2743007
49 2.5385971 4.8032081
50 1.8696061 2.5385971
51 4.2363997 1.8696061
52 7.3702857 4.2363997
53 3.3088015 7.3702857
54 -4.9020832 3.3088015
55 2.6258986 -4.9020832
56 2.9587161 2.6258986
57 -6.5161227 2.9587161
58 4.7987278 -6.5161227
59 3.7310609 4.7987278
60 4.9456661 3.7310609
61 0.2680153 4.9456661
62 6.5947232 0.2680153
63 -1.3699233 6.5947232
64 9.4742130 -1.3699233
65 -0.8098318 9.4742130
66 -0.5862737 -0.8098318
67 2.1289877 -0.5862737
68 -2.9931360 2.1289877
69 7.3341658 -2.9931360
70 2.1255553 7.3341658
71 -5.3349264 2.1255553
72 NA -5.3349264
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -6.1619114 -0.2198972
[2,] -7.4696724 -6.1619114
[3,] -5.8618277 -7.4696724
[4,] -9.0800127 -5.8618277
[5,] -8.1242606 -9.0800127
[6,] -5.6000613 -8.1242606
[7,] -6.6838814 -5.6000613
[8,] -10.8590289 -6.6838814
[9,] -4.7171979 -10.8590289
[10,] -11.0458366 -4.7171979
[11,] -13.5334151 -11.0458366
[12,] -9.4487746 -13.5334151
[13,] -5.2629103 -9.4487746
[14,] -9.2884243 -5.2629103
[15,] -3.6178964 -9.2884243
[16,] -6.1407262 -3.6178964
[17,] -8.8044676 -6.1407262
[18,] 0.8936258 -8.8044676
[19,] -4.7324514 0.8936258
[20,] 0.2132271 -4.7324514
[21,] 4.9931668 0.2132271
[22,] -2.6000643 4.9931668
[23,] 3.0764050 -2.6000643
[24,] 1.3493722 3.0764050
[25,] 5.4677620 1.3493722
[26,] -2.3613215 5.4677620
[27,] 1.5157827 -2.3613215
[28,] -5.3152012 1.5157827
[29,] 2.2165695 -5.3152012
[30,] 5.4523495 2.2165695
[31,] -0.3997511 5.4523495
[32,] 1.2263635 -0.3997511
[33,] 1.4183080 1.2263635
[34,] -1.7346498 1.4183080
[35,] 0.7865749 -1.7346498
[36,] -1.4295746 0.7865749
[37,] 3.1504472 -1.4295746
[38,] 10.6550889 3.1504472
[39,] 5.0974649 10.6550889
[40,] 3.6914414 5.0974649
[41,] 12.2131889 3.6914414
[42,] 4.7424430 12.2131889
[43,] 7.0611975 4.7424430
[44,] 9.4538582 7.0611975
[45,] -2.5123200 9.4538582
[46,] 8.4562677 -2.5123200
[47,] 11.2743007 8.4562677
[48,] 4.8032081 11.2743007
[49,] 2.5385971 4.8032081
[50,] 1.8696061 2.5385971
[51,] 4.2363997 1.8696061
[52,] 7.3702857 4.2363997
[53,] 3.3088015 7.3702857
[54,] -4.9020832 3.3088015
[55,] 2.6258986 -4.9020832
[56,] 2.9587161 2.6258986
[57,] -6.5161227 2.9587161
[58,] 4.7987278 -6.5161227
[59,] 3.7310609 4.7987278
[60,] 4.9456661 3.7310609
[61,] 0.2680153 4.9456661
[62,] 6.5947232 0.2680153
[63,] -1.3699233 6.5947232
[64,] 9.4742130 -1.3699233
[65,] -0.8098318 9.4742130
[66,] -0.5862737 -0.8098318
[67,] 2.1289877 -0.5862737
[68,] -2.9931360 2.1289877
[69,] 7.3341658 -2.9931360
[70,] 2.1255553 7.3341658
[71,] -5.3349264 2.1255553
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -6.1619114 -0.2198972
2 -7.4696724 -6.1619114
3 -5.8618277 -7.4696724
4 -9.0800127 -5.8618277
5 -8.1242606 -9.0800127
6 -5.6000613 -8.1242606
7 -6.6838814 -5.6000613
8 -10.8590289 -6.6838814
9 -4.7171979 -10.8590289
10 -11.0458366 -4.7171979
11 -13.5334151 -11.0458366
12 -9.4487746 -13.5334151
13 -5.2629103 -9.4487746
14 -9.2884243 -5.2629103
15 -3.6178964 -9.2884243
16 -6.1407262 -3.6178964
17 -8.8044676 -6.1407262
18 0.8936258 -8.8044676
19 -4.7324514 0.8936258
20 0.2132271 -4.7324514
21 4.9931668 0.2132271
22 -2.6000643 4.9931668
23 3.0764050 -2.6000643
24 1.3493722 3.0764050
25 5.4677620 1.3493722
26 -2.3613215 5.4677620
27 1.5157827 -2.3613215
28 -5.3152012 1.5157827
29 2.2165695 -5.3152012
30 5.4523495 2.2165695
31 -0.3997511 5.4523495
32 1.2263635 -0.3997511
33 1.4183080 1.2263635
34 -1.7346498 1.4183080
35 0.7865749 -1.7346498
36 -1.4295746 0.7865749
37 3.1504472 -1.4295746
38 10.6550889 3.1504472
39 5.0974649 10.6550889
40 3.6914414 5.0974649
41 12.2131889 3.6914414
42 4.7424430 12.2131889
43 7.0611975 4.7424430
44 9.4538582 7.0611975
45 -2.5123200 9.4538582
46 8.4562677 -2.5123200
47 11.2743007 8.4562677
48 4.8032081 11.2743007
49 2.5385971 4.8032081
50 1.8696061 2.5385971
51 4.2363997 1.8696061
52 7.3702857 4.2363997
53 3.3088015 7.3702857
54 -4.9020832 3.3088015
55 2.6258986 -4.9020832
56 2.9587161 2.6258986
57 -6.5161227 2.9587161
58 4.7987278 -6.5161227
59 3.7310609 4.7987278
60 4.9456661 3.7310609
61 0.2680153 4.9456661
62 6.5947232 0.2680153
63 -1.3699233 6.5947232
64 9.4742130 -1.3699233
65 -0.8098318 9.4742130
66 -0.5862737 -0.8098318
67 2.1289877 -0.5862737
68 -2.9931360 2.1289877
69 7.3341658 -2.9931360
70 2.1255553 7.3341658
71 -5.3349264 2.1255553
> 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/7yh2k1229761109.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/8jf4u1229761109.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/9dv941229761109.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/109v1c1229761109.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/11xbp41229761109.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/12d18x1229761109.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/1345ec1229761109.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/14qn2s1229761109.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/15vjbd1229761109.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/166is41229761109.tab")
+ }
>
> system("convert tmp/1v1un1229761108.ps tmp/1v1un1229761108.png")
> system("convert tmp/2gc251229761108.ps tmp/2gc251229761108.png")
> system("convert tmp/386bc1229761108.ps tmp/386bc1229761108.png")
> system("convert tmp/4zwup1229761108.ps tmp/4zwup1229761108.png")
> system("convert tmp/5r0zf1229761108.ps tmp/5r0zf1229761108.png")
> system("convert tmp/6j2k91229761109.ps tmp/6j2k91229761109.png")
> system("convert tmp/7yh2k1229761109.ps tmp/7yh2k1229761109.png")
> system("convert tmp/8jf4u1229761109.ps tmp/8jf4u1229761109.png")
> system("convert tmp/9dv941229761109.ps tmp/9dv941229761109.png")
> system("convert tmp/109v1c1229761109.ps tmp/109v1c1229761109.png")
>
>
> proc.time()
user system elapsed
5.225 2.742 5.623