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(17823.2
+ ,0
+ ,16704.4
+ ,17823.2
+ ,17872
+ ,0
+ ,15991.2
+ ,16704.4
+ ,17420.4
+ ,0
+ ,15583.6
+ ,15991.2
+ ,16704.4
+ ,0
+ ,19123.5
+ ,15583.6
+ ,15991.2
+ ,0
+ ,17838.7
+ ,19123.5
+ ,15583.6
+ ,0
+ ,17209.4
+ ,17838.7
+ ,19123.5
+ ,0
+ ,18586.5
+ ,17209.4
+ ,17838.7
+ ,0
+ ,16258.1
+ ,18586.5
+ ,17209.4
+ ,0
+ ,15141.6
+ ,16258.1
+ ,18586.5
+ ,0
+ ,19202.1
+ ,15141.6
+ ,16258.1
+ ,0
+ ,17746.5
+ ,19202.1
+ ,15141.6
+ ,0
+ ,19090.1
+ ,17746.5
+ ,19202.1
+ ,0
+ ,18040.3
+ ,19090.1
+ ,17746.5
+ ,0
+ ,17515.5
+ ,18040.3
+ ,19090.1
+ ,1
+ ,17751.8
+ ,17515.5
+ ,18040.3
+ ,1
+ ,21072.4
+ ,17751.8
+ ,17515.5
+ ,1
+ ,17170
+ ,21072.4
+ ,17751.8
+ ,1
+ ,19439.5
+ ,17170
+ ,21072.4
+ ,1
+ ,19795.4
+ ,19439.5
+ ,17170
+ ,1
+ ,17574.9
+ ,19795.4
+ ,19439.5
+ ,1
+ ,16165.4
+ ,17574.9
+ ,19795.4
+ ,1
+ ,19464.6
+ ,16165.4
+ ,17574.9
+ ,1
+ ,19932.1
+ ,19464.6
+ ,16165.4
+ ,1
+ ,19961.2
+ ,19932.1
+ ,19464.6
+ ,1
+ ,17343.4
+ ,19961.2
+ ,19932.1
+ ,1
+ ,18924.2
+ ,17343.4
+ ,19961.2
+ ,1
+ ,18574.1
+ ,18924.2
+ ,17343.4
+ ,1
+ ,21350.6
+ ,18574.1
+ ,18924.2
+ ,1
+ ,18594.6
+ ,21350.6
+ ,18574.1
+ ,1
+ ,19832.1
+ ,18594.6
+ ,21350.6
+ ,1
+ ,20844.4
+ ,19832.1
+ ,18594.6
+ ,1
+ ,19640.2
+ ,20844.4
+ ,19832.1
+ ,1
+ ,17735.4
+ ,19640.2
+ ,20844.4
+ ,1
+ ,19813.6
+ ,17735.4
+ ,19640.2
+ ,1
+ ,22160
+ ,19813.6
+ ,17735.4
+ ,1
+ ,20664.3
+ ,22160
+ ,19813.6
+ ,1
+ ,17877.4
+ ,20664.3
+ ,22160
+ ,1
+ ,20906.5
+ ,17877.4
+ ,20664.3
+ ,1
+ ,21164.1
+ ,20906.5
+ ,17877.4
+ ,1
+ ,21374.4
+ ,21164.1
+ ,20906.5
+ ,1
+ ,22952.3
+ ,21374.4
+ ,21164.1
+ ,1
+ ,21343.5
+ ,22952.3
+ ,21374.4
+ ,1
+ ,23899.3
+ ,21343.5
+ ,22952.3
+ ,1
+ ,22392.9
+ ,23899.3
+ ,21343.5
+ ,1
+ ,18274.1
+ ,22392.9
+ ,23899.3
+ ,1
+ ,22786.7
+ ,18274.1
+ ,22392.9
+ ,1
+ ,22321.5
+ ,22786.7
+ ,18274.1
+ ,1
+ ,17842.2
+ ,22321.5
+ ,22786.7
+ ,1
+ ,16373.5
+ ,17842.2
+ ,22321.5
+ ,1
+ ,15933.8
+ ,16373.5
+ ,17842.2
+ ,1
+ ,16446.1
+ ,15933.8
+ ,16373.5
+ ,1
+ ,17729
+ ,16446.1
+ ,15933.8
+ ,0
+ ,16643
+ ,17729
+ ,16446.1
+ ,0
+ ,16196.7
+ ,16643
+ ,17729
+ ,0
+ ,18252.1
+ ,16196.7
+ ,16643
+ ,0
+ ,17570.4
+ ,18252.1)
+ ,dim=c(4
+ ,56)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2')
+ ,1:56))
> y <- array(NA,dim=c(4,56),dimnames=list(c('Y','X','Y1','Y2'),1:56))
> 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
Y X Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 17823.2 0 16704.4 17823.2 1 0 0 0 0 0 0 0 0 0 0 1
2 17872.0 0 15991.2 16704.4 0 1 0 0 0 0 0 0 0 0 0 2
3 17420.4 0 15583.6 15991.2 0 0 1 0 0 0 0 0 0 0 0 3
4 16704.4 0 19123.5 15583.6 0 0 0 1 0 0 0 0 0 0 0 4
5 15991.2 0 17838.7 19123.5 0 0 0 0 1 0 0 0 0 0 0 5
6 15583.6 0 17209.4 17838.7 0 0 0 0 0 1 0 0 0 0 0 6
7 19123.5 0 18586.5 17209.4 0 0 0 0 0 0 1 0 0 0 0 7
8 17838.7 0 16258.1 18586.5 0 0 0 0 0 0 0 1 0 0 0 8
9 17209.4 0 15141.6 16258.1 0 0 0 0 0 0 0 0 1 0 0 9
10 18586.5 0 19202.1 15141.6 0 0 0 0 0 0 0 0 0 1 0 10
11 16258.1 0 17746.5 19202.1 0 0 0 0 0 0 0 0 0 0 1 11
12 15141.6 0 19090.1 17746.5 0 0 0 0 0 0 0 0 0 0 0 12
13 19202.1 0 18040.3 19090.1 1 0 0 0 0 0 0 0 0 0 0 13
14 17746.5 0 17515.5 18040.3 0 1 0 0 0 0 0 0 0 0 0 14
15 19090.1 1 17751.8 17515.5 0 0 1 0 0 0 0 0 0 0 0 15
16 18040.3 1 21072.4 17751.8 0 0 0 1 0 0 0 0 0 0 0 16
17 17515.5 1 17170.0 21072.4 0 0 0 0 1 0 0 0 0 0 0 17
18 17751.8 1 19439.5 17170.0 0 0 0 0 0 1 0 0 0 0 0 18
19 21072.4 1 19795.4 19439.5 0 0 0 0 0 0 1 0 0 0 0 19
20 17170.0 1 17574.9 19795.4 0 0 0 0 0 0 0 1 0 0 0 20
21 19439.5 1 16165.4 17574.9 0 0 0 0 0 0 0 0 1 0 0 21
22 19795.4 1 19464.6 16165.4 0 0 0 0 0 0 0 0 0 1 0 22
23 17574.9 1 19932.1 19464.6 0 0 0 0 0 0 0 0 0 0 1 23
24 16165.4 1 19961.2 19932.1 0 0 0 0 0 0 0 0 0 0 0 24
25 19464.6 1 17343.4 19961.2 1 0 0 0 0 0 0 0 0 0 0 25
26 19932.1 1 18924.2 17343.4 0 1 0 0 0 0 0 0 0 0 0 26
27 19961.2 1 18574.1 18924.2 0 0 1 0 0 0 0 0 0 0 0 27
28 17343.4 1 21350.6 18574.1 0 0 0 1 0 0 0 0 0 0 0 28
29 18924.2 1 18594.6 21350.6 0 0 0 0 1 0 0 0 0 0 0 29
30 18574.1 1 19832.1 18594.6 0 0 0 0 0 1 0 0 0 0 0 30
31 21350.6 1 20844.4 19832.1 0 0 0 0 0 0 1 0 0 0 0 31
32 18594.6 1 19640.2 20844.4 0 0 0 0 0 0 0 1 0 0 0 32
33 19832.1 1 17735.4 19640.2 0 0 0 0 0 0 0 0 1 0 0 33
34 20844.4 1 19813.6 17735.4 0 0 0 0 0 0 0 0 0 1 0 34
35 19640.2 1 22160.0 19813.6 0 0 0 0 0 0 0 0 0 0 1 35
36 17735.4 1 20664.3 22160.0 0 0 0 0 0 0 0 0 0 0 0 36
37 19813.6 1 17877.4 20664.3 1 0 0 0 0 0 0 0 0 0 0 37
38 22160.0 1 20906.5 17877.4 0 1 0 0 0 0 0 0 0 0 0 38
39 20664.3 1 21164.1 20906.5 0 0 1 0 0 0 0 0 0 0 0 39
40 17877.4 1 21374.4 21164.1 0 0 0 1 0 0 0 0 0 0 0 40
41 20906.5 1 22952.3 21374.4 0 0 0 0 1 0 0 0 0 0 0 41
42 21164.1 1 21343.5 22952.3 0 0 0 0 0 1 0 0 0 0 0 42
43 21374.4 1 23899.3 21343.5 0 0 0 0 0 0 1 0 0 0 0 43
44 22952.3 1 22392.9 23899.3 0 0 0 0 0 0 0 1 0 0 0 44
45 21343.5 1 18274.1 22392.9 0 0 0 0 0 0 0 0 1 0 0 45
46 23899.3 1 22786.7 18274.1 0 0 0 0 0 0 0 0 0 1 0 46
47 22392.9 1 22321.5 22786.7 0 0 0 0 0 0 0 0 0 0 1 47
48 18274.1 1 17842.2 22321.5 0 0 0 0 0 0 0 0 0 0 0 48
49 22786.7 1 16373.5 17842.2 1 0 0 0 0 0 0 0 0 0 0 49
50 22321.5 1 15933.8 16373.5 0 1 0 0 0 0 0 0 0 0 0 50
51 17842.2 1 16446.1 15933.8 0 0 1 0 0 0 0 0 0 0 0 51
52 16373.5 1 17729.0 16446.1 0 0 0 1 0 0 0 0 0 0 0 52
53 15933.8 0 16643.0 17729.0 0 0 0 0 1 0 0 0 0 0 0 53
54 16446.1 0 16196.7 16643.0 0 0 0 0 0 1 0 0 0 0 0 54
55 17729.0 0 18252.1 16196.7 0 0 0 0 0 0 1 0 0 0 0 55
56 16643.0 0 17570.4 18252.1 0 0 0 0 0 0 0 1 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 M1 M2
4191.7249 1080.2429 0.3281 0.2344 4298.6755 4696.8157
M3 M4 M5 M6 M7 M8
3294.5297 802.9460 1550.9549 1874.2848 3557.3111 2221.6253
M9 M10 M11 t
3900.9811 4561.2037 1833.9041 21.6933
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1421.4 -692.6 -191.7 426.4 2598.6
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4191.7249 2236.7586 1.874 0.068246 .
X 1080.2429 441.7049 2.446 0.018956 *
Y1 0.3281 0.1266 2.592 0.013275 *
Y2 0.2344 0.1324 1.771 0.084192 .
M1 4298.6755 755.4214 5.690 1.29e-06 ***
M2 4696.8157 799.3799 5.876 7.07e-07 ***
M3 3294.5297 790.2827 4.169 0.000159 ***
M4 802.9460 841.0783 0.955 0.345482
M5 1550.9549 734.0970 2.113 0.040913 *
M6 1874.2848 756.6455 2.477 0.017570 *
M7 3557.3111 792.7231 4.487 5.96e-05 ***
M8 2221.6253 735.7013 3.020 0.004392 **
M9 3900.9811 814.0875 4.792 2.29e-05 ***
M10 4561.2037 956.8075 4.767 2.48e-05 ***
M11 1833.9041 787.7036 2.328 0.025045 *
t 21.6933 10.2760 2.111 0.041065 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1089 on 40 degrees of freedom
Multiple R-squared: 0.8035, Adjusted R-squared: 0.7298
F-statistic: 10.9 on 15 and 40 DF, p-value: 8.8e-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.13198120 0.26396241 0.8680188
[2,] 0.46970046 0.93940092 0.5302995
[3,] 0.41727093 0.83454185 0.5827291
[4,] 0.28412439 0.56824878 0.7158756
[5,] 0.18794165 0.37588329 0.8120584
[6,] 0.11271689 0.22543377 0.8872831
[7,] 0.07310127 0.14620254 0.9268987
[8,] 0.04818559 0.09637118 0.9518144
[9,] 0.05047134 0.10094268 0.9495287
[10,] 0.08164752 0.16329505 0.9183525
[11,] 0.07518109 0.15036218 0.9248189
[12,] 0.04586150 0.09172299 0.9541385
[13,] 0.08485567 0.16971134 0.9151443
[14,] 0.04933003 0.09866006 0.9506700
[15,] 0.04320998 0.08641996 0.9567900
[16,] 0.02859514 0.05719029 0.9714049
[17,] 0.03744594 0.07489187 0.9625541
[18,] 0.11600901 0.23201803 0.8839910
[19,] 0.09576594 0.19153188 0.9042341
> postscript(file="/var/www/html/rcomp/tmp/189ok1258734291.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/2niya1258734291.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/3thmv1258734291.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/4fl2p1258734291.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/5jr7x1258734291.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 = 56
Frequency = 1
1 2 3 4 5 6
-347.501972 -222.284894 1007.616597 1695.544458 -195.517147 -440.509619
7 8 9 10 11 12
1090.323966 1560.722625 142.474055 -232.961560 -329.896707 266.137248
13 14 15 16 17 18
35.796560 -1421.376611 268.048141 543.207072 -249.173817 -187.867059
19 20 21 22 23 24
779.284164 -1163.959970 387.438801 -690.724656 -1132.318690 -848.734255
25 26 27 28 29 30
-1017.779622 -875.209049 278.830697 -698.034601 366.564029 -88.619540
31 32 33 34 35 36
360.948251 -923.215846 -479.513310 -384.551827 -140.152027 -291.954024
37 38 39 40 41 42
-1269.114061 316.780601 -592.846036 -1039.237927 653.131750 723.735993
43 44 45 46 47 48
-1232.194840 1554.914060 -50.399546 1308.238043 1602.367424 874.551030
49 50 51 52 53 54
2598.599095 2202.089952 -961.649399 -501.479003 -575.004815 -6.739774
55 56
-998.361542 -1028.460869
> postscript(file="/var/www/html/rcomp/tmp/62dva1258734291.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 -347.501972 NA
1 -222.284894 -347.501972
2 1007.616597 -222.284894
3 1695.544458 1007.616597
4 -195.517147 1695.544458
5 -440.509619 -195.517147
6 1090.323966 -440.509619
7 1560.722625 1090.323966
8 142.474055 1560.722625
9 -232.961560 142.474055
10 -329.896707 -232.961560
11 266.137248 -329.896707
12 35.796560 266.137248
13 -1421.376611 35.796560
14 268.048141 -1421.376611
15 543.207072 268.048141
16 -249.173817 543.207072
17 -187.867059 -249.173817
18 779.284164 -187.867059
19 -1163.959970 779.284164
20 387.438801 -1163.959970
21 -690.724656 387.438801
22 -1132.318690 -690.724656
23 -848.734255 -1132.318690
24 -1017.779622 -848.734255
25 -875.209049 -1017.779622
26 278.830697 -875.209049
27 -698.034601 278.830697
28 366.564029 -698.034601
29 -88.619540 366.564029
30 360.948251 -88.619540
31 -923.215846 360.948251
32 -479.513310 -923.215846
33 -384.551827 -479.513310
34 -140.152027 -384.551827
35 -291.954024 -140.152027
36 -1269.114061 -291.954024
37 316.780601 -1269.114061
38 -592.846036 316.780601
39 -1039.237927 -592.846036
40 653.131750 -1039.237927
41 723.735993 653.131750
42 -1232.194840 723.735993
43 1554.914060 -1232.194840
44 -50.399546 1554.914060
45 1308.238043 -50.399546
46 1602.367424 1308.238043
47 874.551030 1602.367424
48 2598.599095 874.551030
49 2202.089952 2598.599095
50 -961.649399 2202.089952
51 -501.479003 -961.649399
52 -575.004815 -501.479003
53 -6.739774 -575.004815
54 -998.361542 -6.739774
55 -1028.460869 -998.361542
56 NA -1028.460869
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -222.284894 -347.501972
[2,] 1007.616597 -222.284894
[3,] 1695.544458 1007.616597
[4,] -195.517147 1695.544458
[5,] -440.509619 -195.517147
[6,] 1090.323966 -440.509619
[7,] 1560.722625 1090.323966
[8,] 142.474055 1560.722625
[9,] -232.961560 142.474055
[10,] -329.896707 -232.961560
[11,] 266.137248 -329.896707
[12,] 35.796560 266.137248
[13,] -1421.376611 35.796560
[14,] 268.048141 -1421.376611
[15,] 543.207072 268.048141
[16,] -249.173817 543.207072
[17,] -187.867059 -249.173817
[18,] 779.284164 -187.867059
[19,] -1163.959970 779.284164
[20,] 387.438801 -1163.959970
[21,] -690.724656 387.438801
[22,] -1132.318690 -690.724656
[23,] -848.734255 -1132.318690
[24,] -1017.779622 -848.734255
[25,] -875.209049 -1017.779622
[26,] 278.830697 -875.209049
[27,] -698.034601 278.830697
[28,] 366.564029 -698.034601
[29,] -88.619540 366.564029
[30,] 360.948251 -88.619540
[31,] -923.215846 360.948251
[32,] -479.513310 -923.215846
[33,] -384.551827 -479.513310
[34,] -140.152027 -384.551827
[35,] -291.954024 -140.152027
[36,] -1269.114061 -291.954024
[37,] 316.780601 -1269.114061
[38,] -592.846036 316.780601
[39,] -1039.237927 -592.846036
[40,] 653.131750 -1039.237927
[41,] 723.735993 653.131750
[42,] -1232.194840 723.735993
[43,] 1554.914060 -1232.194840
[44,] -50.399546 1554.914060
[45,] 1308.238043 -50.399546
[46,] 1602.367424 1308.238043
[47,] 874.551030 1602.367424
[48,] 2598.599095 874.551030
[49,] 2202.089952 2598.599095
[50,] -961.649399 2202.089952
[51,] -501.479003 -961.649399
[52,] -575.004815 -501.479003
[53,] -6.739774 -575.004815
[54,] -998.361542 -6.739774
[55,] -1028.460869 -998.361542
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -222.284894 -347.501972
2 1007.616597 -222.284894
3 1695.544458 1007.616597
4 -195.517147 1695.544458
5 -440.509619 -195.517147
6 1090.323966 -440.509619
7 1560.722625 1090.323966
8 142.474055 1560.722625
9 -232.961560 142.474055
10 -329.896707 -232.961560
11 266.137248 -329.896707
12 35.796560 266.137248
13 -1421.376611 35.796560
14 268.048141 -1421.376611
15 543.207072 268.048141
16 -249.173817 543.207072
17 -187.867059 -249.173817
18 779.284164 -187.867059
19 -1163.959970 779.284164
20 387.438801 -1163.959970
21 -690.724656 387.438801
22 -1132.318690 -690.724656
23 -848.734255 -1132.318690
24 -1017.779622 -848.734255
25 -875.209049 -1017.779622
26 278.830697 -875.209049
27 -698.034601 278.830697
28 366.564029 -698.034601
29 -88.619540 366.564029
30 360.948251 -88.619540
31 -923.215846 360.948251
32 -479.513310 -923.215846
33 -384.551827 -479.513310
34 -140.152027 -384.551827
35 -291.954024 -140.152027
36 -1269.114061 -291.954024
37 316.780601 -1269.114061
38 -592.846036 316.780601
39 -1039.237927 -592.846036
40 653.131750 -1039.237927
41 723.735993 653.131750
42 -1232.194840 723.735993
43 1554.914060 -1232.194840
44 -50.399546 1554.914060
45 1308.238043 -50.399546
46 1602.367424 1308.238043
47 874.551030 1602.367424
48 2598.599095 874.551030
49 2202.089952 2598.599095
50 -961.649399 2202.089952
51 -501.479003 -961.649399
52 -575.004815 -501.479003
53 -6.739774 -575.004815
54 -998.361542 -6.739774
55 -1028.460869 -998.361542
> 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/7apo31258734291.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/8yab81258734291.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/9xmup1258734291.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/10wkxi1258734291.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/11ogpj1258734291.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/12t4eg1258734291.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/133k221258734291.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/14omzh1258734291.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/15ld8r1258734291.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/167qrv1258734291.tab")
+ }
> system("convert tmp/189ok1258734291.ps tmp/189ok1258734291.png")
> system("convert tmp/2niya1258734291.ps tmp/2niya1258734291.png")
> system("convert tmp/3thmv1258734291.ps tmp/3thmv1258734291.png")
> system("convert tmp/4fl2p1258734291.ps tmp/4fl2p1258734291.png")
> system("convert tmp/5jr7x1258734291.ps tmp/5jr7x1258734291.png")
> system("convert tmp/62dva1258734291.ps tmp/62dva1258734291.png")
> system("convert tmp/7apo31258734291.ps tmp/7apo31258734291.png")
> system("convert tmp/8yab81258734291.ps tmp/8yab81258734291.png")
> system("convert tmp/9xmup1258734291.ps tmp/9xmup1258734291.png")
> system("convert tmp/10wkxi1258734291.ps tmp/10wkxi1258734291.png")
>
>
> proc.time()
user system elapsed
2.374 1.576 2.747