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(4634
+ ,611
+ ,4138
+ ,3759
+ ,3922
+ ,5560
+ ,3996
+ ,594
+ ,4634
+ ,4138
+ ,3759
+ ,3922
+ ,4308
+ ,595
+ ,3996
+ ,4634
+ ,4138
+ ,3759
+ ,4143
+ ,591
+ ,4308
+ ,3996
+ ,4634
+ ,4138
+ ,4429
+ ,589
+ ,4143
+ ,4308
+ ,3996
+ ,4634
+ ,5219
+ ,584
+ ,4429
+ ,4143
+ ,4308
+ ,3996
+ ,4929
+ ,573
+ ,5219
+ ,4429
+ ,4143
+ ,4308
+ ,5755
+ ,567
+ ,4929
+ ,5219
+ ,4429
+ ,4143
+ ,5592
+ ,569
+ ,5755
+ ,4929
+ ,5219
+ ,4429
+ ,4163
+ ,621
+ ,5592
+ ,5755
+ ,4929
+ ,5219
+ ,4962
+ ,629
+ ,4163
+ ,5592
+ ,5755
+ ,4929
+ ,5208
+ ,628
+ ,4962
+ ,4163
+ ,5592
+ ,5755
+ ,4755
+ ,612
+ ,5208
+ ,4962
+ ,4163
+ ,5592
+ ,4491
+ ,595
+ ,4755
+ ,5208
+ ,4962
+ ,4163
+ ,5732
+ ,597
+ ,4491
+ ,4755
+ ,5208
+ ,4962
+ ,5731
+ ,593
+ ,5732
+ ,4491
+ ,4755
+ ,5208
+ ,5040
+ ,590
+ ,5731
+ ,5732
+ ,4491
+ ,4755
+ ,6102
+ ,580
+ ,5040
+ ,5731
+ ,5732
+ ,4491
+ ,4904
+ ,574
+ ,6102
+ ,5040
+ ,5731
+ ,5732
+ ,5369
+ ,573
+ ,4904
+ ,6102
+ ,5040
+ ,5731
+ ,5578
+ ,573
+ ,5369
+ ,4904
+ ,6102
+ ,5040
+ ,4619
+ ,620
+ ,5578
+ ,5369
+ ,4904
+ ,6102
+ ,4731
+ ,626
+ ,4619
+ ,5578
+ ,5369
+ ,4904
+ ,5011
+ ,620
+ ,4731
+ ,4619
+ ,5578
+ ,5369
+ ,5299
+ ,588
+ ,5011
+ ,4731
+ ,4619
+ ,5578
+ ,4146
+ ,566
+ ,5299
+ ,5011
+ ,4731
+ ,4619
+ ,4625
+ ,557
+ ,4146
+ ,5299
+ ,5011
+ ,4731
+ ,4736
+ ,561
+ ,4625
+ ,4146
+ ,5299
+ ,5011
+ ,4219
+ ,549
+ ,4736
+ ,4625
+ ,4146
+ ,5299
+ ,5116
+ ,532
+ ,4219
+ ,4736
+ ,4625
+ ,4146
+ ,4205
+ ,526
+ ,5116
+ ,4219
+ ,4736
+ ,4625
+ ,4121
+ ,511
+ ,4205
+ ,5116
+ ,4219
+ ,4736
+ ,5103
+ ,499
+ ,4121
+ ,4205
+ ,5116
+ ,4219
+ ,4300
+ ,555
+ ,5103
+ ,4121
+ ,4205
+ ,5116
+ ,4578
+ ,565
+ ,4300
+ ,5103
+ ,4121
+ ,4205
+ ,3809
+ ,542
+ ,4578
+ ,4300
+ ,5103
+ ,4121
+ ,5526
+ ,527
+ ,3809
+ ,4578
+ ,4300
+ ,5103
+ ,4247
+ ,510
+ ,5526
+ ,3809
+ ,4578
+ ,4300
+ ,3830
+ ,514
+ ,4247
+ ,5526
+ ,3809
+ ,4578
+ ,4394
+ ,517
+ ,3830
+ ,4247
+ ,5526
+ ,3809
+ ,4826
+ ,508
+ ,4394
+ ,3830
+ ,4247
+ ,5526
+ ,4409
+ ,493
+ ,4826
+ ,4394
+ ,3830
+ ,4247
+ ,4569
+ ,490
+ ,4409
+ ,4826
+ ,4394
+ ,3830
+ ,4106
+ ,469
+ ,4569
+ ,4409
+ ,4826
+ ,4394
+ ,4794
+ ,478
+ ,4106
+ ,4569
+ ,4409
+ ,4826
+ ,3914
+ ,528
+ ,4794
+ ,4106
+ ,4569
+ ,4409
+ ,3793
+ ,534
+ ,3914
+ ,4794
+ ,4106
+ ,4569
+ ,4405
+ ,518
+ ,3793
+ ,3914
+ ,4794
+ ,4106
+ ,4022
+ ,506
+ ,4405
+ ,3793
+ ,3914
+ ,4794
+ ,4100
+ ,502
+ ,4022
+ ,4405
+ ,3793
+ ,3914
+ ,4788
+ ,516
+ ,4100
+ ,4022
+ ,4405
+ ,3793
+ ,3163
+ ,528
+ ,4788
+ ,4100
+ ,4022
+ ,4405
+ ,3585
+ ,533
+ ,3163
+ ,4788
+ ,4100
+ ,4022
+ ,3903
+ ,536
+ ,3585
+ ,3163
+ ,4788
+ ,4100
+ ,4178
+ ,537
+ ,3903
+ ,3585
+ ,3163
+ ,4788
+ ,3863
+ ,524
+ ,4178
+ ,3903
+ ,3585
+ ,3163
+ ,4187
+ ,536
+ ,3863
+ ,4178
+ ,3903
+ ,3585)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'yt-1'
+ ,'yt-2'
+ ,'yt-3'
+ ,'yt-4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','yt-1','yt-2','yt-3','yt-4'),1:57))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> 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 yt-1 yt-2 yt-3 yt-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 4634 611 4138 3759 3922 5560 1 0 0 0 0 0 0 0 0 0 0 1
2 3996 594 4634 4138 3759 3922 0 1 0 0 0 0 0 0 0 0 0 2
3 4308 595 3996 4634 4138 3759 0 0 1 0 0 0 0 0 0 0 0 3
4 4143 591 4308 3996 4634 4138 0 0 0 1 0 0 0 0 0 0 0 4
5 4429 589 4143 4308 3996 4634 0 0 0 0 1 0 0 0 0 0 0 5
6 5219 584 4429 4143 4308 3996 0 0 0 0 0 1 0 0 0 0 0 6
7 4929 573 5219 4429 4143 4308 0 0 0 0 0 0 1 0 0 0 0 7
8 5755 567 4929 5219 4429 4143 0 0 0 0 0 0 0 1 0 0 0 8
9 5592 569 5755 4929 5219 4429 0 0 0 0 0 0 0 0 1 0 0 9
10 4163 621 5592 5755 4929 5219 0 0 0 0 0 0 0 0 0 1 0 10
11 4962 629 4163 5592 5755 4929 0 0 0 0 0 0 0 0 0 0 1 11
12 5208 628 4962 4163 5592 5755 0 0 0 0 0 0 0 0 0 0 0 12
13 4755 612 5208 4962 4163 5592 1 0 0 0 0 0 0 0 0 0 0 13
14 4491 595 4755 5208 4962 4163 0 1 0 0 0 0 0 0 0 0 0 14
15 5732 597 4491 4755 5208 4962 0 0 1 0 0 0 0 0 0 0 0 15
16 5731 593 5732 4491 4755 5208 0 0 0 1 0 0 0 0 0 0 0 16
17 5040 590 5731 5732 4491 4755 0 0 0 0 1 0 0 0 0 0 0 17
18 6102 580 5040 5731 5732 4491 0 0 0 0 0 1 0 0 0 0 0 18
19 4904 574 6102 5040 5731 5732 0 0 0 0 0 0 1 0 0 0 0 19
20 5369 573 4904 6102 5040 5731 0 0 0 0 0 0 0 1 0 0 0 20
21 5578 573 5369 4904 6102 5040 0 0 0 0 0 0 0 0 1 0 0 21
22 4619 620 5578 5369 4904 6102 0 0 0 0 0 0 0 0 0 1 0 22
23 4731 626 4619 5578 5369 4904 0 0 0 0 0 0 0 0 0 0 1 23
24 5011 620 4731 4619 5578 5369 0 0 0 0 0 0 0 0 0 0 0 24
25 5299 588 5011 4731 4619 5578 1 0 0 0 0 0 0 0 0 0 0 25
26 4146 566 5299 5011 4731 4619 0 1 0 0 0 0 0 0 0 0 0 26
27 4625 557 4146 5299 5011 4731 0 0 1 0 0 0 0 0 0 0 0 27
28 4736 561 4625 4146 5299 5011 0 0 0 1 0 0 0 0 0 0 0 28
29 4219 549 4736 4625 4146 5299 0 0 0 0 1 0 0 0 0 0 0 29
30 5116 532 4219 4736 4625 4146 0 0 0 0 0 1 0 0 0 0 0 30
31 4205 526 5116 4219 4736 4625 0 0 0 0 0 0 1 0 0 0 0 31
32 4121 511 4205 5116 4219 4736 0 0 0 0 0 0 0 1 0 0 0 32
33 5103 499 4121 4205 5116 4219 0 0 0 0 0 0 0 0 1 0 0 33
34 4300 555 5103 4121 4205 5116 0 0 0 0 0 0 0 0 0 1 0 34
35 4578 565 4300 5103 4121 4205 0 0 0 0 0 0 0 0 0 0 1 35
36 3809 542 4578 4300 5103 4121 0 0 0 0 0 0 0 0 0 0 0 36
37 5526 527 3809 4578 4300 5103 1 0 0 0 0 0 0 0 0 0 0 37
38 4247 510 5526 3809 4578 4300 0 1 0 0 0 0 0 0 0 0 0 38
39 3830 514 4247 5526 3809 4578 0 0 1 0 0 0 0 0 0 0 0 39
40 4394 517 3830 4247 5526 3809 0 0 0 1 0 0 0 0 0 0 0 40
41 4826 508 4394 3830 4247 5526 0 0 0 0 1 0 0 0 0 0 0 41
42 4409 493 4826 4394 3830 4247 0 0 0 0 0 1 0 0 0 0 0 42
43 4569 490 4409 4826 4394 3830 0 0 0 0 0 0 1 0 0 0 0 43
44 4106 469 4569 4409 4826 4394 0 0 0 0 0 0 0 1 0 0 0 44
45 4794 478 4106 4569 4409 4826 0 0 0 0 0 0 0 0 1 0 0 45
46 3914 528 4794 4106 4569 4409 0 0 0 0 0 0 0 0 0 1 0 46
47 3793 534 3914 4794 4106 4569 0 0 0 0 0 0 0 0 0 0 1 47
48 4405 518 3793 3914 4794 4106 0 0 0 0 0 0 0 0 0 0 0 48
49 4022 506 4405 3793 3914 4794 1 0 0 0 0 0 0 0 0 0 0 49
50 4100 502 4022 4405 3793 3914 0 1 0 0 0 0 0 0 0 0 0 50
51 4788 516 4100 4022 4405 3793 0 0 1 0 0 0 0 0 0 0 0 51
52 3163 528 4788 4100 4022 4405 0 0 0 1 0 0 0 0 0 0 0 52
53 3585 533 3163 4788 4100 4022 0 0 0 0 1 0 0 0 0 0 0 53
54 3903 536 3585 3163 4788 4100 0 0 0 0 0 1 0 0 0 0 0 54
55 4178 537 3903 3585 3163 4788 0 0 0 0 0 0 1 0 0 0 0 55
56 3863 524 4178 3903 3585 3163 0 0 0 0 0 0 0 1 0 0 0 56
57 4187 536 3863 4178 3903 3585 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X `yt-1` `yt-2` `yt-3` `yt-4`
1781.33974 0.05380 0.11950 0.06359 0.31107 0.14067
M1 M2 M3 M4 M5 M6
445.12023 -139.14888 317.06461 -33.42535 117.40686 623.11818
M7 M8 M9 M10 M11 t
183.84898 330.21445 600.95957 -370.07406 22.84315 -11.09487
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-740.05 -311.48 31.28 197.13 946.39
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1781.33974 2001.20223 0.890 0.3789
X 0.05380 3.06788 0.018 0.9861
`yt-1` 0.11950 0.15504 0.771 0.4455
`yt-2` 0.06359 0.14591 0.436 0.6654
`yt-3` 0.31107 0.14583 2.133 0.0393 *
`yt-4` 0.14067 0.15335 0.917 0.3646
M1 445.12023 379.27994 1.174 0.2477
M2 -139.14888 371.69011 -0.374 0.7102
M3 317.06461 366.79403 0.864 0.3926
M4 -33.42535 331.08877 -0.101 0.9201
M5 117.40686 374.37762 0.314 0.7555
M6 623.11818 348.47641 1.788 0.0815 .
M7 183.84898 365.71780 0.503 0.6180
M8 330.21445 389.67266 0.847 0.4019
M9 600.95957 351.31289 1.711 0.0951 .
M10 -370.07406 377.36543 -0.981 0.3328
M11 22.84315 382.79981 0.060 0.9527
t -11.09487 7.20870 -1.539 0.1319
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 471.7 on 39 degrees of freedom
Multiple R-squared: 0.6016, Adjusted R-squared: 0.428
F-statistic: 3.465 on 17 and 39 DF, p-value: 0.0006624
> 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.6629650 0.6740701 0.3370350
[2,] 0.7331302 0.5337395 0.2668698
[3,] 0.7366756 0.5266487 0.2633244
[4,] 0.6820708 0.6358584 0.3179292
[5,] 0.6345365 0.7309270 0.3654635
[6,] 0.6024663 0.7950673 0.3975337
[7,] 0.4747143 0.9494287 0.5252857
[8,] 0.4080805 0.8161610 0.5919195
[9,] 0.2978484 0.5956968 0.7021516
[10,] 0.2483677 0.4967353 0.7516323
[11,] 0.1914488 0.3828976 0.8085512
[12,] 0.1477997 0.2955993 0.8522003
[13,] 0.3458900 0.6917800 0.6541100
[14,] 0.2531524 0.5063048 0.7468476
[15,] 0.1667521 0.3335042 0.8332479
[16,] 0.1468943 0.2937885 0.8531057
> postscript(file="/var/www/html/rcomp/tmp/19qq91261332839.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/2xzi11261332839.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/3ysd91261332839.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/4voqq1261332839.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/5nqvw1261332839.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 57
Frequency = 1
1 2 3 4 5 6 7
-349.90800 -193.87790 -377.31353 -384.83587 -109.89585 154.76460 210.56588
8 9 10 11 12 13 14
820.28492 31.28020 -472.35148 -90.62198 119.26280 -379.65406 -56.41067
15 16 17 18 19 20 21
610.79647 946.39173 182.87177 484.53018 -520.01744 100.49162 -162.70518
22 23 24 25 26 27 28
26.62236 -118.33448 113.09526 197.12663 -311.48303 -260.49972 98.96681
29 30 31 32 33 34 35
-282.69523 188.51765 -448.02493 -469.44956 115.20662 336.51696 419.95628
36 37 38 39 40 41 42
-589.68599 879.96721 67.43964 -551.12113 79.52740 487.71904 -200.94292
43 44 45 46 47 48 49
315.16114 -488.30578 53.66231 109.21216 -210.99982 357.32793 -347.53178
50 51 52 53 54 55 56
494.33197 578.13792 -740.05007 -277.99973 -626.86951 442.31534 36.97881
57
-37.44395
> postscript(file="/var/www/html/rcomp/tmp/6v1kt1261332839.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -349.90800 NA
1 -193.87790 -349.90800
2 -377.31353 -193.87790
3 -384.83587 -377.31353
4 -109.89585 -384.83587
5 154.76460 -109.89585
6 210.56588 154.76460
7 820.28492 210.56588
8 31.28020 820.28492
9 -472.35148 31.28020
10 -90.62198 -472.35148
11 119.26280 -90.62198
12 -379.65406 119.26280
13 -56.41067 -379.65406
14 610.79647 -56.41067
15 946.39173 610.79647
16 182.87177 946.39173
17 484.53018 182.87177
18 -520.01744 484.53018
19 100.49162 -520.01744
20 -162.70518 100.49162
21 26.62236 -162.70518
22 -118.33448 26.62236
23 113.09526 -118.33448
24 197.12663 113.09526
25 -311.48303 197.12663
26 -260.49972 -311.48303
27 98.96681 -260.49972
28 -282.69523 98.96681
29 188.51765 -282.69523
30 -448.02493 188.51765
31 -469.44956 -448.02493
32 115.20662 -469.44956
33 336.51696 115.20662
34 419.95628 336.51696
35 -589.68599 419.95628
36 879.96721 -589.68599
37 67.43964 879.96721
38 -551.12113 67.43964
39 79.52740 -551.12113
40 487.71904 79.52740
41 -200.94292 487.71904
42 315.16114 -200.94292
43 -488.30578 315.16114
44 53.66231 -488.30578
45 109.21216 53.66231
46 -210.99982 109.21216
47 357.32793 -210.99982
48 -347.53178 357.32793
49 494.33197 -347.53178
50 578.13792 494.33197
51 -740.05007 578.13792
52 -277.99973 -740.05007
53 -626.86951 -277.99973
54 442.31534 -626.86951
55 36.97881 442.31534
56 -37.44395 36.97881
57 NA -37.44395
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -193.87790 -349.90800
[2,] -377.31353 -193.87790
[3,] -384.83587 -377.31353
[4,] -109.89585 -384.83587
[5,] 154.76460 -109.89585
[6,] 210.56588 154.76460
[7,] 820.28492 210.56588
[8,] 31.28020 820.28492
[9,] -472.35148 31.28020
[10,] -90.62198 -472.35148
[11,] 119.26280 -90.62198
[12,] -379.65406 119.26280
[13,] -56.41067 -379.65406
[14,] 610.79647 -56.41067
[15,] 946.39173 610.79647
[16,] 182.87177 946.39173
[17,] 484.53018 182.87177
[18,] -520.01744 484.53018
[19,] 100.49162 -520.01744
[20,] -162.70518 100.49162
[21,] 26.62236 -162.70518
[22,] -118.33448 26.62236
[23,] 113.09526 -118.33448
[24,] 197.12663 113.09526
[25,] -311.48303 197.12663
[26,] -260.49972 -311.48303
[27,] 98.96681 -260.49972
[28,] -282.69523 98.96681
[29,] 188.51765 -282.69523
[30,] -448.02493 188.51765
[31,] -469.44956 -448.02493
[32,] 115.20662 -469.44956
[33,] 336.51696 115.20662
[34,] 419.95628 336.51696
[35,] -589.68599 419.95628
[36,] 879.96721 -589.68599
[37,] 67.43964 879.96721
[38,] -551.12113 67.43964
[39,] 79.52740 -551.12113
[40,] 487.71904 79.52740
[41,] -200.94292 487.71904
[42,] 315.16114 -200.94292
[43,] -488.30578 315.16114
[44,] 53.66231 -488.30578
[45,] 109.21216 53.66231
[46,] -210.99982 109.21216
[47,] 357.32793 -210.99982
[48,] -347.53178 357.32793
[49,] 494.33197 -347.53178
[50,] 578.13792 494.33197
[51,] -740.05007 578.13792
[52,] -277.99973 -740.05007
[53,] -626.86951 -277.99973
[54,] 442.31534 -626.86951
[55,] 36.97881 442.31534
[56,] -37.44395 36.97881
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -193.87790 -349.90800
2 -377.31353 -193.87790
3 -384.83587 -377.31353
4 -109.89585 -384.83587
5 154.76460 -109.89585
6 210.56588 154.76460
7 820.28492 210.56588
8 31.28020 820.28492
9 -472.35148 31.28020
10 -90.62198 -472.35148
11 119.26280 -90.62198
12 -379.65406 119.26280
13 -56.41067 -379.65406
14 610.79647 -56.41067
15 946.39173 610.79647
16 182.87177 946.39173
17 484.53018 182.87177
18 -520.01744 484.53018
19 100.49162 -520.01744
20 -162.70518 100.49162
21 26.62236 -162.70518
22 -118.33448 26.62236
23 113.09526 -118.33448
24 197.12663 113.09526
25 -311.48303 197.12663
26 -260.49972 -311.48303
27 98.96681 -260.49972
28 -282.69523 98.96681
29 188.51765 -282.69523
30 -448.02493 188.51765
31 -469.44956 -448.02493
32 115.20662 -469.44956
33 336.51696 115.20662
34 419.95628 336.51696
35 -589.68599 419.95628
36 879.96721 -589.68599
37 67.43964 879.96721
38 -551.12113 67.43964
39 79.52740 -551.12113
40 487.71904 79.52740
41 -200.94292 487.71904
42 315.16114 -200.94292
43 -488.30578 315.16114
44 53.66231 -488.30578
45 109.21216 53.66231
46 -210.99982 109.21216
47 357.32793 -210.99982
48 -347.53178 357.32793
49 494.33197 -347.53178
50 578.13792 494.33197
51 -740.05007 578.13792
52 -277.99973 -740.05007
53 -626.86951 -277.99973
54 442.31534 -626.86951
55 36.97881 442.31534
56 -37.44395 36.97881
> 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/7x62j1261332839.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/8u71c1261332839.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/9oenq1261332839.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/10bs0m1261332839.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/11r70x1261332839.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/12n5fp1261332839.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/13g1tq1261332839.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/14szhm1261332839.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/15wzkz1261332839.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/16a7911261332839.tab")
+ }
>
> try(system("convert tmp/19qq91261332839.ps tmp/19qq91261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/2xzi11261332839.ps tmp/2xzi11261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/3ysd91261332839.ps tmp/3ysd91261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/4voqq1261332839.ps tmp/4voqq1261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/5nqvw1261332839.ps tmp/5nqvw1261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/6v1kt1261332839.ps tmp/6v1kt1261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/7x62j1261332839.ps tmp/7x62j1261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/8u71c1261332839.ps tmp/8u71c1261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/9oenq1261332839.ps tmp/9oenq1261332839.png",intern=TRUE))
character(0)
> try(system("convert tmp/10bs0m1261332839.ps tmp/10bs0m1261332839.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.300 1.541 4.300