R version 2.12.1 (2010-12-16)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(9743
+ ,9084
+ ,9081
+ ,9700
+ ,8587
+ ,9743
+ ,9084
+ ,9081
+ ,9731
+ ,8587
+ ,9743
+ ,9084
+ ,9563
+ ,9731
+ ,8587
+ ,9743
+ ,9998
+ ,9563
+ ,9731
+ ,8587
+ ,9437
+ ,9998
+ ,9563
+ ,9731
+ ,10038
+ ,9437
+ ,9998
+ ,9563
+ ,9918
+ ,10038
+ ,9437
+ ,9998
+ ,9252
+ ,9918
+ ,10038
+ ,9437
+ ,9737
+ ,9252
+ ,9918
+ ,10038
+ ,9035
+ ,9737
+ ,9252
+ ,9918
+ ,9133
+ ,9035
+ ,9737
+ ,9252
+ ,9487
+ ,9133
+ ,9035
+ ,9737
+ ,8700
+ ,9487
+ ,9133
+ ,9035
+ ,9627
+ ,8700
+ ,9487
+ ,9133
+ ,8947
+ ,9627
+ ,8700
+ ,9487
+ ,9283
+ ,8947
+ ,9627
+ ,8700
+ ,8829
+ ,9283
+ ,8947
+ ,9627
+ ,9947
+ ,8829
+ ,9283
+ ,8947
+ ,9628
+ ,9947
+ ,8829
+ ,9283
+ ,9318
+ ,9628
+ ,9947
+ ,8829
+ ,9605
+ ,9318
+ ,9628
+ ,9947
+ ,8640
+ ,9605
+ ,9318
+ ,9628
+ ,9214
+ ,8640
+ ,9605
+ ,9318
+ ,9567
+ ,9214
+ ,8640
+ ,9605
+ ,8547
+ ,9567
+ ,9214
+ ,8640
+ ,9185
+ ,8547
+ ,9567
+ ,9214
+ ,9470
+ ,9185
+ ,8547
+ ,9567
+ ,9123
+ ,9470
+ ,9185
+ ,8547
+ ,9278
+ ,9123
+ ,9470
+ ,9185
+ ,10170
+ ,9278
+ ,9123
+ ,9470
+ ,9434
+ ,10170
+ ,9278
+ ,9123
+ ,9655
+ ,9434
+ ,10170
+ ,9278
+ ,9429
+ ,9655
+ ,9434
+ ,10170
+ ,8739
+ ,9429
+ ,9655
+ ,9434
+ ,9552
+ ,8739
+ ,9429
+ ,9655
+ ,9687
+ ,9552
+ ,8739
+ ,9429
+ ,9019
+ ,9687
+ ,9552
+ ,8739
+ ,9672
+ ,9019
+ ,9687
+ ,9552
+ ,9206
+ ,9672
+ ,9019
+ ,9687
+ ,9069
+ ,9206
+ ,9672
+ ,9019
+ ,9788
+ ,9069
+ ,9206
+ ,9672
+ ,10312
+ ,9788
+ ,9069
+ ,9206
+ ,10105
+ ,10312
+ ,9788
+ ,9069
+ ,9863
+ ,10105
+ ,10312
+ ,9788
+ ,9656
+ ,9863
+ ,10105
+ ,10312
+ ,9295
+ ,9656
+ ,9863
+ ,10105
+ ,9946
+ ,9295
+ ,9656
+ ,9863
+ ,9701
+ ,9946
+ ,9295
+ ,9656
+ ,9049
+ ,9701
+ ,9946
+ ,9295
+ ,10190
+ ,9049
+ ,9701
+ ,9946
+ ,9706
+ ,10190
+ ,9049
+ ,9701
+ ,9765
+ ,9706
+ ,10190
+ ,9049
+ ,9893
+ ,9765
+ ,9706
+ ,10190
+ ,9994
+ ,9893
+ ,9765
+ ,9706
+ ,10433
+ ,9994
+ ,9893
+ ,9765
+ ,10073
+ ,10433
+ ,9994
+ ,9893
+ ,10112
+ ,10073
+ ,10433
+ ,9994
+ ,9266
+ ,10112
+ ,10073
+ ,10433
+ ,9820
+ ,9266
+ ,10112
+ ,10073
+ ,10097
+ ,9820
+ ,9266
+ ,10112
+ ,9115
+ ,10097
+ ,9820
+ ,9266
+ ,10411
+ ,9115
+ ,10097
+ ,9820
+ ,9678
+ ,10411
+ ,9115
+ ,10097
+ ,10408
+ ,9678
+ ,10411
+ ,9115
+ ,10153
+ ,10408
+ ,9678
+ ,10411
+ ,10368
+ ,10153
+ ,10408
+ ,9678
+ ,10581
+ ,10368
+ ,10153
+ ,10408
+ ,10597
+ ,10581
+ ,10368
+ ,10153
+ ,10680
+ ,10597
+ ,10581
+ ,10368
+ ,9738
+ ,10680
+ ,10597
+ ,10581
+ ,9556
+ ,9738
+ ,10680
+ ,10597)
+ ,dim=c(4
+ ,72)
+ ,dimnames=list(c('Yt'
+ ,'Yt-1'
+ ,'Yt-2'
+ ,'Yt-3')
+ ,1:72))
> y <- array(NA,dim=c(4,72),dimnames=list(c('Yt','Yt-1','Yt-2','Yt-3'),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 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> library(lattice)
> library(lmtest)
Loading required package: zoo
> 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
Yt Yt-1 Yt-2 Yt-3 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 9743 9084 9081 9700 1 0 0 0 0 0 0 0 0 0 0 1
2 8587 9743 9084 9081 0 1 0 0 0 0 0 0 0 0 0 2
3 9731 8587 9743 9084 0 0 1 0 0 0 0 0 0 0 0 3
4 9563 9731 8587 9743 0 0 0 1 0 0 0 0 0 0 0 4
5 9998 9563 9731 8587 0 0 0 0 1 0 0 0 0 0 0 5
6 9437 9998 9563 9731 0 0 0 0 0 1 0 0 0 0 0 6
7 10038 9437 9998 9563 0 0 0 0 0 0 1 0 0 0 0 7
8 9918 10038 9437 9998 0 0 0 0 0 0 0 1 0 0 0 8
9 9252 9918 10038 9437 0 0 0 0 0 0 0 0 1 0 0 9
10 9737 9252 9918 10038 0 0 0 0 0 0 0 0 0 1 0 10
11 9035 9737 9252 9918 0 0 0 0 0 0 0 0 0 0 1 11
12 9133 9035 9737 9252 0 0 0 0 0 0 0 0 0 0 0 12
13 9487 9133 9035 9737 1 0 0 0 0 0 0 0 0 0 0 13
14 8700 9487 9133 9035 0 1 0 0 0 0 0 0 0 0 0 14
15 9627 8700 9487 9133 0 0 1 0 0 0 0 0 0 0 0 15
16 8947 9627 8700 9487 0 0 0 1 0 0 0 0 0 0 0 16
17 9283 8947 9627 8700 0 0 0 0 1 0 0 0 0 0 0 17
18 8829 9283 8947 9627 0 0 0 0 0 1 0 0 0 0 0 18
19 9947 8829 9283 8947 0 0 0 0 0 0 1 0 0 0 0 19
20 9628 9947 8829 9283 0 0 0 0 0 0 0 1 0 0 0 20
21 9318 9628 9947 8829 0 0 0 0 0 0 0 0 1 0 0 21
22 9605 9318 9628 9947 0 0 0 0 0 0 0 0 0 1 0 22
23 8640 9605 9318 9628 0 0 0 0 0 0 0 0 0 0 1 23
24 9214 8640 9605 9318 0 0 0 0 0 0 0 0 0 0 0 24
25 9567 9214 8640 9605 1 0 0 0 0 0 0 0 0 0 0 25
26 8547 9567 9214 8640 0 1 0 0 0 0 0 0 0 0 0 26
27 9185 8547 9567 9214 0 0 1 0 0 0 0 0 0 0 0 27
28 9470 9185 8547 9567 0 0 0 1 0 0 0 0 0 0 0 28
29 9123 9470 9185 8547 0 0 0 0 1 0 0 0 0 0 0 29
30 9278 9123 9470 9185 0 0 0 0 0 1 0 0 0 0 0 30
31 10170 9278 9123 9470 0 0 0 0 0 0 1 0 0 0 0 31
32 9434 10170 9278 9123 0 0 0 0 0 0 0 1 0 0 0 32
33 9655 9434 10170 9278 0 0 0 0 0 0 0 0 1 0 0 33
34 9429 9655 9434 10170 0 0 0 0 0 0 0 0 0 1 0 34
35 8739 9429 9655 9434 0 0 0 0 0 0 0 0 0 0 1 35
36 9552 8739 9429 9655 0 0 0 0 0 0 0 0 0 0 0 36
37 9687 9552 8739 9429 1 0 0 0 0 0 0 0 0 0 0 37
38 9019 9687 9552 8739 0 1 0 0 0 0 0 0 0 0 0 38
39 9672 9019 9687 9552 0 0 1 0 0 0 0 0 0 0 0 39
40 9206 9672 9019 9687 0 0 0 1 0 0 0 0 0 0 0 40
41 9069 9206 9672 9019 0 0 0 0 1 0 0 0 0 0 0 41
42 9788 9069 9206 9672 0 0 0 0 0 1 0 0 0 0 0 42
43 10312 9788 9069 9206 0 0 0 0 0 0 1 0 0 0 0 43
44 10105 10312 9788 9069 0 0 0 0 0 0 0 1 0 0 0 44
45 9863 10105 10312 9788 0 0 0 0 0 0 0 0 1 0 0 45
46 9656 9863 10105 10312 0 0 0 0 0 0 0 0 0 1 0 46
47 9295 9656 9863 10105 0 0 0 0 0 0 0 0 0 0 1 47
48 9946 9295 9656 9863 0 0 0 0 0 0 0 0 0 0 0 48
49 9701 9946 9295 9656 1 0 0 0 0 0 0 0 0 0 0 49
50 9049 9701 9946 9295 0 1 0 0 0 0 0 0 0 0 0 50
51 10190 9049 9701 9946 0 0 1 0 0 0 0 0 0 0 0 51
52 9706 10190 9049 9701 0 0 0 1 0 0 0 0 0 0 0 52
53 9765 9706 10190 9049 0 0 0 0 1 0 0 0 0 0 0 53
54 9893 9765 9706 10190 0 0 0 0 0 1 0 0 0 0 0 54
55 9994 9893 9765 9706 0 0 0 0 0 0 1 0 0 0 0 55
56 10433 9994 9893 9765 0 0 0 0 0 0 0 1 0 0 0 56
57 10073 10433 9994 9893 0 0 0 0 0 0 0 0 1 0 0 57
58 10112 10073 10433 9994 0 0 0 0 0 0 0 0 0 1 0 58
59 9266 10112 10073 10433 0 0 0 0 0 0 0 0 0 0 1 59
60 9820 9266 10112 10073 0 0 0 0 0 0 0 0 0 0 0 60
61 10097 9820 9266 10112 1 0 0 0 0 0 0 0 0 0 0 61
62 9115 10097 9820 9266 0 1 0 0 0 0 0 0 0 0 0 62
63 10411 9115 10097 9820 0 0 1 0 0 0 0 0 0 0 0 63
64 9678 10411 9115 10097 0 0 0 1 0 0 0 0 0 0 0 64
65 10408 9678 10411 9115 0 0 0 0 1 0 0 0 0 0 0 65
66 10153 10408 9678 10411 0 0 0 0 0 1 0 0 0 0 0 66
67 10368 10153 10408 9678 0 0 0 0 0 0 1 0 0 0 0 67
68 10581 10368 10153 10408 0 0 0 0 0 0 0 1 0 0 0 68
69 10597 10581 10368 10153 0 0 0 0 0 0 0 0 1 0 0 69
70 10680 10597 10581 10368 0 0 0 0 0 0 0 0 0 1 0 70
71 9738 10680 10597 10581 0 0 0 0 0 0 0 0 0 0 1 71
72 9556 9738 10680 10597 0 0 0 0 0 0 0 0 0 0 0 72
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `Yt-1` `Yt-2` `Yt-3` M1 M2
3540.6920 0.1309 0.2018 0.2648 385.7733 -436.3001
M3 M4 M5 M6 M7 M8
469.5032 72.8939 333.4011 79.6861 718.4771 477.8622
M9 M10 M11 t
160.8783 134.0485 -554.8482 5.1634
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-593.23 -117.44 18.52 151.65 608.05
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3540.6920 1487.8912 2.380 0.020759 *
`Yt-1` 0.1309 0.1339 0.978 0.332371
`Yt-2` 0.2018 0.1290 1.564 0.123476
`Yt-3` 0.2648 0.1343 1.973 0.053486 .
M1 385.7733 200.1878 1.927 0.059052 .
M2 -436.3001 220.7649 -1.976 0.053053 .
M3 469.5032 159.0440 2.952 0.004605 **
M4 72.8939 235.7203 0.309 0.758287
M5 333.4011 212.0660 1.572 0.121548
M6 79.6861 183.3585 0.435 0.665529
M7 718.4771 182.2650 3.942 0.000227 ***
M8 477.8622 222.7426 2.145 0.036275 *
M9 160.8783 205.8738 0.781 0.437834
M10 134.0485 177.7129 0.754 0.453830
M11 -554.8482 184.7935 -3.003 0.003996 **
t 5.1634 2.4226 2.131 0.037467 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 268.9 on 56 degrees of freedom
Multiple R-squared: 0.777, Adjusted R-squared: 0.7173
F-statistic: 13.01 on 15 and 56 DF, p-value: 3.577e-13
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.7242996 0.5514007 0.2757004
[2,] 0.6380187 0.7239625 0.3619813
[3,] 0.5762434 0.8475132 0.4237566
[4,] 0.4682464 0.9364927 0.5317536
[5,] 0.3771518 0.7543036 0.6228482
[6,] 0.4560715 0.9121430 0.5439285
[7,] 0.4029167 0.8058334 0.5970833
[8,] 0.3164430 0.6328861 0.6835570
[9,] 0.2824304 0.5648608 0.7175696
[10,] 0.5428545 0.9142910 0.4571455
[11,] 0.4999873 0.9999745 0.5000127
[12,] 0.4457816 0.8915633 0.5542184
[13,] 0.6793760 0.6412479 0.3206240
[14,] 0.7154442 0.5691116 0.2845558
[15,] 0.7381579 0.5236842 0.2618421
[16,] 0.6705676 0.6588648 0.3294324
[17,] 0.6938316 0.6123367 0.3061684
[18,] 0.7147343 0.5705314 0.2852657
[19,] 0.6725455 0.6549090 0.3274545
[20,] 0.6852060 0.6295881 0.3147940
[21,] 0.6082902 0.7834196 0.3917098
[22,] 0.5526765 0.8946470 0.4473235
[23,] 0.7828174 0.4343652 0.2171826
[24,] 0.8261914 0.3476172 0.1738086
[25,] 0.8109405 0.3781190 0.1890595
[26,] 0.8052590 0.3894821 0.1947410
[27,] 0.7407073 0.5185854 0.2592927
[28,] 0.6756923 0.6486153 0.3243077
[29,] 0.5883277 0.8233446 0.4116723
[30,] 0.7809080 0.4381841 0.2190920
[31,] 0.6950575 0.6098849 0.3049425
[32,] 0.7004411 0.5991179 0.2995589
[33,] 0.7213533 0.5572933 0.2786467
[34,] 0.7720658 0.4558684 0.2279342
[35,] 0.6292871 0.7414258 0.3707129
> postscript(file="/var/www/rcomp/tmp/1h1191322614337.ps",horizontal=F,onefile=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/rcomp/tmp/2h8hh1322614337.ps",horizontal=F,onefile=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/rcomp/tmp/34n721322614337.ps",horizontal=F,onefile=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/rcomp/tmp/4qv161322614337.ps",horizontal=F,onefile=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/rcomp/tmp/5pk551322614337.ps",horizontal=F,onefile=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
220.483660 -41.570369 209.027561 341.470647 608.052220 -30.404112
7 8 9 10 11 12
-43.206374 -8.423032 -319.617723 139.308730 223.729950 -67.876924
13 14 15 16 17 18
-104.407719 45.280110 66.960533 -277.884002 -97.190470 -454.886776
19 20 21 22 23 24
190.870871 -36.414703 -98.230188 19.332619 -152.469136 12.042027
25 26 27 28 29 30
17.700892 -91.897381 -454.563938 250.719415 -257.907053 -35.397651
31 32 33 34 35 36
186.909792 -369.818189 38.298480 -282.655210 -109.023074 221.393415
37 38 39 40 41 42
58.113870 207.997712 -205.053293 -266.042517 -562.584163 344.022848
43 44 45 46 47 48
280.985154 132.001607 -67.235988 -317.875101 135.619683 379.738240
49 50 51 52 53 54
-213.760245 -52.554552 139.891956 94.411717 -106.497752 57.845472
55 56 57 58 59 60
-385.600995 234.169037 74.229232 66.685672 -144.290189 47.932220
61 62 63 64 65 66
21.869541 -67.255519 243.737181 -142.675260 416.127218 118.820220
67 68 69 70 71 72
-229.958448 48.485281 372.556187 375.203290 46.432767 -593.228979
> postscript(file="/var/www/rcomp/tmp/6x2tn1322614337.ps",horizontal=F,onefile=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 220.483660 NA
1 -41.570369 220.483660
2 209.027561 -41.570369
3 341.470647 209.027561
4 608.052220 341.470647
5 -30.404112 608.052220
6 -43.206374 -30.404112
7 -8.423032 -43.206374
8 -319.617723 -8.423032
9 139.308730 -319.617723
10 223.729950 139.308730
11 -67.876924 223.729950
12 -104.407719 -67.876924
13 45.280110 -104.407719
14 66.960533 45.280110
15 -277.884002 66.960533
16 -97.190470 -277.884002
17 -454.886776 -97.190470
18 190.870871 -454.886776
19 -36.414703 190.870871
20 -98.230188 -36.414703
21 19.332619 -98.230188
22 -152.469136 19.332619
23 12.042027 -152.469136
24 17.700892 12.042027
25 -91.897381 17.700892
26 -454.563938 -91.897381
27 250.719415 -454.563938
28 -257.907053 250.719415
29 -35.397651 -257.907053
30 186.909792 -35.397651
31 -369.818189 186.909792
32 38.298480 -369.818189
33 -282.655210 38.298480
34 -109.023074 -282.655210
35 221.393415 -109.023074
36 58.113870 221.393415
37 207.997712 58.113870
38 -205.053293 207.997712
39 -266.042517 -205.053293
40 -562.584163 -266.042517
41 344.022848 -562.584163
42 280.985154 344.022848
43 132.001607 280.985154
44 -67.235988 132.001607
45 -317.875101 -67.235988
46 135.619683 -317.875101
47 379.738240 135.619683
48 -213.760245 379.738240
49 -52.554552 -213.760245
50 139.891956 -52.554552
51 94.411717 139.891956
52 -106.497752 94.411717
53 57.845472 -106.497752
54 -385.600995 57.845472
55 234.169037 -385.600995
56 74.229232 234.169037
57 66.685672 74.229232
58 -144.290189 66.685672
59 47.932220 -144.290189
60 21.869541 47.932220
61 -67.255519 21.869541
62 243.737181 -67.255519
63 -142.675260 243.737181
64 416.127218 -142.675260
65 118.820220 416.127218
66 -229.958448 118.820220
67 48.485281 -229.958448
68 372.556187 48.485281
69 375.203290 372.556187
70 46.432767 375.203290
71 -593.228979 46.432767
72 NA -593.228979
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -41.570369 220.483660
[2,] 209.027561 -41.570369
[3,] 341.470647 209.027561
[4,] 608.052220 341.470647
[5,] -30.404112 608.052220
[6,] -43.206374 -30.404112
[7,] -8.423032 -43.206374
[8,] -319.617723 -8.423032
[9,] 139.308730 -319.617723
[10,] 223.729950 139.308730
[11,] -67.876924 223.729950
[12,] -104.407719 -67.876924
[13,] 45.280110 -104.407719
[14,] 66.960533 45.280110
[15,] -277.884002 66.960533
[16,] -97.190470 -277.884002
[17,] -454.886776 -97.190470
[18,] 190.870871 -454.886776
[19,] -36.414703 190.870871
[20,] -98.230188 -36.414703
[21,] 19.332619 -98.230188
[22,] -152.469136 19.332619
[23,] 12.042027 -152.469136
[24,] 17.700892 12.042027
[25,] -91.897381 17.700892
[26,] -454.563938 -91.897381
[27,] 250.719415 -454.563938
[28,] -257.907053 250.719415
[29,] -35.397651 -257.907053
[30,] 186.909792 -35.397651
[31,] -369.818189 186.909792
[32,] 38.298480 -369.818189
[33,] -282.655210 38.298480
[34,] -109.023074 -282.655210
[35,] 221.393415 -109.023074
[36,] 58.113870 221.393415
[37,] 207.997712 58.113870
[38,] -205.053293 207.997712
[39,] -266.042517 -205.053293
[40,] -562.584163 -266.042517
[41,] 344.022848 -562.584163
[42,] 280.985154 344.022848
[43,] 132.001607 280.985154
[44,] -67.235988 132.001607
[45,] -317.875101 -67.235988
[46,] 135.619683 -317.875101
[47,] 379.738240 135.619683
[48,] -213.760245 379.738240
[49,] -52.554552 -213.760245
[50,] 139.891956 -52.554552
[51,] 94.411717 139.891956
[52,] -106.497752 94.411717
[53,] 57.845472 -106.497752
[54,] -385.600995 57.845472
[55,] 234.169037 -385.600995
[56,] 74.229232 234.169037
[57,] 66.685672 74.229232
[58,] -144.290189 66.685672
[59,] 47.932220 -144.290189
[60,] 21.869541 47.932220
[61,] -67.255519 21.869541
[62,] 243.737181 -67.255519
[63,] -142.675260 243.737181
[64,] 416.127218 -142.675260
[65,] 118.820220 416.127218
[66,] -229.958448 118.820220
[67,] 48.485281 -229.958448
[68,] 372.556187 48.485281
[69,] 375.203290 372.556187
[70,] 46.432767 375.203290
[71,] -593.228979 46.432767
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -41.570369 220.483660
2 209.027561 -41.570369
3 341.470647 209.027561
4 608.052220 341.470647
5 -30.404112 608.052220
6 -43.206374 -30.404112
7 -8.423032 -43.206374
8 -319.617723 -8.423032
9 139.308730 -319.617723
10 223.729950 139.308730
11 -67.876924 223.729950
12 -104.407719 -67.876924
13 45.280110 -104.407719
14 66.960533 45.280110
15 -277.884002 66.960533
16 -97.190470 -277.884002
17 -454.886776 -97.190470
18 190.870871 -454.886776
19 -36.414703 190.870871
20 -98.230188 -36.414703
21 19.332619 -98.230188
22 -152.469136 19.332619
23 12.042027 -152.469136
24 17.700892 12.042027
25 -91.897381 17.700892
26 -454.563938 -91.897381
27 250.719415 -454.563938
28 -257.907053 250.719415
29 -35.397651 -257.907053
30 186.909792 -35.397651
31 -369.818189 186.909792
32 38.298480 -369.818189
33 -282.655210 38.298480
34 -109.023074 -282.655210
35 221.393415 -109.023074
36 58.113870 221.393415
37 207.997712 58.113870
38 -205.053293 207.997712
39 -266.042517 -205.053293
40 -562.584163 -266.042517
41 344.022848 -562.584163
42 280.985154 344.022848
43 132.001607 280.985154
44 -67.235988 132.001607
45 -317.875101 -67.235988
46 135.619683 -317.875101
47 379.738240 135.619683
48 -213.760245 379.738240
49 -52.554552 -213.760245
50 139.891956 -52.554552
51 94.411717 139.891956
52 -106.497752 94.411717
53 57.845472 -106.497752
54 -385.600995 57.845472
55 234.169037 -385.600995
56 74.229232 234.169037
57 66.685672 74.229232
58 -144.290189 66.685672
59 47.932220 -144.290189
60 21.869541 47.932220
61 -67.255519 21.869541
62 243.737181 -67.255519
63 -142.675260 243.737181
64 416.127218 -142.675260
65 118.820220 416.127218
66 -229.958448 118.820220
67 48.485281 -229.958448
68 372.556187 48.485281
69 375.203290 372.556187
70 46.432767 375.203290
71 -593.228979 46.432767
> 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/rcomp/tmp/73onh1322614337.ps",horizontal=F,onefile=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/rcomp/tmp/8qy371322614337.ps",horizontal=F,onefile=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/rcomp/tmp/905hh1322614337.ps",horizontal=F,onefile=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/rcomp/tmp/10eyyi1322614337.ps",horizontal=F,onefile=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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11m5lc1322614337.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/rcomp/tmp/121niq1322614337.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/rcomp/tmp/138nw61322614337.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/rcomp/tmp/14pptt1322614337.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/rcomp/tmp/15dhb31322614337.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/rcomp/tmp/16febf1322614337.tab")
+ }
>
> try(system("convert tmp/1h1191322614337.ps tmp/1h1191322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/2h8hh1322614337.ps tmp/2h8hh1322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/34n721322614337.ps tmp/34n721322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/4qv161322614337.ps tmp/4qv161322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/5pk551322614337.ps tmp/5pk551322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/6x2tn1322614337.ps tmp/6x2tn1322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/73onh1322614337.ps tmp/73onh1322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/8qy371322614337.ps tmp/8qy371322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/905hh1322614337.ps tmp/905hh1322614337.png",intern=TRUE))
character(0)
> try(system("convert tmp/10eyyi1322614337.ps tmp/10eyyi1322614337.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.540 0.768 5.314