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(656
+ ,677
+ ,825
+ ,696
+ ,627
+ ,0
+ ,785
+ ,656
+ ,677
+ ,825
+ ,696
+ ,0
+ ,412
+ ,785
+ ,656
+ ,677
+ ,825
+ ,0
+ ,352
+ ,412
+ ,785
+ ,656
+ ,677
+ ,0
+ ,839
+ ,352
+ ,412
+ ,785
+ ,656
+ ,0
+ ,729
+ ,839
+ ,352
+ ,412
+ ,785
+ ,0
+ ,696
+ ,729
+ ,839
+ ,352
+ ,412
+ ,0
+ ,641
+ ,696
+ ,729
+ ,839
+ ,352
+ ,0
+ ,695
+ ,641
+ ,696
+ ,729
+ ,839
+ ,0
+ ,638
+ ,695
+ ,641
+ ,696
+ ,729
+ ,0
+ ,762
+ ,638
+ ,695
+ ,641
+ ,696
+ ,0
+ ,635
+ ,762
+ ,638
+ ,695
+ ,641
+ ,0
+ ,721
+ ,635
+ ,762
+ ,638
+ ,695
+ ,0
+ ,854
+ ,721
+ ,635
+ ,762
+ ,638
+ ,0
+ ,418
+ ,854
+ ,721
+ ,635
+ ,762
+ ,0
+ ,367
+ ,418
+ ,854
+ ,721
+ ,635
+ ,0
+ ,824
+ ,367
+ ,418
+ ,854
+ ,721
+ ,0
+ ,687
+ ,824
+ ,367
+ ,418
+ ,854
+ ,0
+ ,601
+ ,687
+ ,824
+ ,367
+ ,418
+ ,0
+ ,676
+ ,601
+ ,687
+ ,824
+ ,367
+ ,0
+ ,740
+ ,676
+ ,601
+ ,687
+ ,824
+ ,0
+ ,691
+ ,740
+ ,676
+ ,601
+ ,687
+ ,0
+ ,683
+ ,691
+ ,740
+ ,676
+ ,601
+ ,0
+ ,594
+ ,683
+ ,691
+ ,740
+ ,676
+ ,0
+ ,729
+ ,594
+ ,683
+ ,691
+ ,740
+ ,0
+ ,731
+ ,729
+ ,594
+ ,683
+ ,691
+ ,0
+ ,386
+ ,731
+ ,729
+ ,594
+ ,683
+ ,0
+ ,331
+ ,386
+ ,731
+ ,729
+ ,594
+ ,0
+ ,707
+ ,331
+ ,386
+ ,731
+ ,729
+ ,0
+ ,715
+ ,707
+ ,331
+ ,386
+ ,731
+ ,0
+ ,657
+ ,715
+ ,707
+ ,331
+ ,386
+ ,0
+ ,653
+ ,657
+ ,715
+ ,707
+ ,331
+ ,0
+ ,642
+ ,653
+ ,657
+ ,715
+ ,707
+ ,0
+ ,643
+ ,642
+ ,653
+ ,657
+ ,715
+ ,0
+ ,718
+ ,643
+ ,642
+ ,653
+ ,657
+ ,0
+ ,654
+ ,718
+ ,643
+ ,642
+ ,653
+ ,0
+ ,632
+ ,654
+ ,718
+ ,643
+ ,642
+ ,0
+ ,731
+ ,632
+ ,654
+ ,718
+ ,643
+ ,0
+ ,392
+ ,731
+ ,632
+ ,654
+ ,718
+ ,0
+ ,344
+ ,392
+ ,731
+ ,632
+ ,654
+ ,0
+ ,792
+ ,344
+ ,392
+ ,731
+ ,632
+ ,0
+ ,852
+ ,792
+ ,344
+ ,392
+ ,731
+ ,0
+ ,649
+ ,852
+ ,792
+ ,344
+ ,392
+ ,0
+ ,629
+ ,649
+ ,852
+ ,792
+ ,344
+ ,0
+ ,685
+ ,629
+ ,649
+ ,852
+ ,792
+ ,1
+ ,617
+ ,685
+ ,629
+ ,649
+ ,852
+ ,1
+ ,715
+ ,617
+ ,685
+ ,629
+ ,649
+ ,1
+ ,715
+ ,715
+ ,617
+ ,685
+ ,629
+ ,1
+ ,629
+ ,715
+ ,715
+ ,617
+ ,685
+ ,1
+ ,916
+ ,629
+ ,715
+ ,715
+ ,617
+ ,1
+ ,531
+ ,916
+ ,629
+ ,715
+ ,715
+ ,1
+ ,357
+ ,531
+ ,916
+ ,629
+ ,715
+ ,1
+ ,917
+ ,357
+ ,531
+ ,916
+ ,629
+ ,1
+ ,828
+ ,917
+ ,357
+ ,531
+ ,916
+ ,1
+ ,708
+ ,828
+ ,917
+ ,357
+ ,531
+ ,1
+ ,858
+ ,708
+ ,828
+ ,917
+ ,357
+ ,1)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Y(t)'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)'
+ ,'X')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Y(t)','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)','X'),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(t) Y(t-1) Y(t-2) Y(t-3) Y(t-4) X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 656 677 825 696 627 0 1 0 0 0 0 0 0 0 0 0 0 1
2 785 656 677 825 696 0 0 1 0 0 0 0 0 0 0 0 0 2
3 412 785 656 677 825 0 0 0 1 0 0 0 0 0 0 0 0 3
4 352 412 785 656 677 0 0 0 0 1 0 0 0 0 0 0 0 4
5 839 352 412 785 656 0 0 0 0 0 1 0 0 0 0 0 0 5
6 729 839 352 412 785 0 0 0 0 0 0 1 0 0 0 0 0 6
7 696 729 839 352 412 0 0 0 0 0 0 0 1 0 0 0 0 7
8 641 696 729 839 352 0 0 0 0 0 0 0 0 1 0 0 0 8
9 695 641 696 729 839 0 0 0 0 0 0 0 0 0 1 0 0 9
10 638 695 641 696 729 0 0 0 0 0 0 0 0 0 0 1 0 10
11 762 638 695 641 696 0 0 0 0 0 0 0 0 0 0 0 1 11
12 635 762 638 695 641 0 0 0 0 0 0 0 0 0 0 0 0 12
13 721 635 762 638 695 0 1 0 0 0 0 0 0 0 0 0 0 13
14 854 721 635 762 638 0 0 1 0 0 0 0 0 0 0 0 0 14
15 418 854 721 635 762 0 0 0 1 0 0 0 0 0 0 0 0 15
16 367 418 854 721 635 0 0 0 0 1 0 0 0 0 0 0 0 16
17 824 367 418 854 721 0 0 0 0 0 1 0 0 0 0 0 0 17
18 687 824 367 418 854 0 0 0 0 0 0 1 0 0 0 0 0 18
19 601 687 824 367 418 0 0 0 0 0 0 0 1 0 0 0 0 19
20 676 601 687 824 367 0 0 0 0 0 0 0 0 1 0 0 0 20
21 740 676 601 687 824 0 0 0 0 0 0 0 0 0 1 0 0 21
22 691 740 676 601 687 0 0 0 0 0 0 0 0 0 0 1 0 22
23 683 691 740 676 601 0 0 0 0 0 0 0 0 0 0 0 1 23
24 594 683 691 740 676 0 0 0 0 0 0 0 0 0 0 0 0 24
25 729 594 683 691 740 0 1 0 0 0 0 0 0 0 0 0 0 25
26 731 729 594 683 691 0 0 1 0 0 0 0 0 0 0 0 0 26
27 386 731 729 594 683 0 0 0 1 0 0 0 0 0 0 0 0 27
28 331 386 731 729 594 0 0 0 0 1 0 0 0 0 0 0 0 28
29 707 331 386 731 729 0 0 0 0 0 1 0 0 0 0 0 0 29
30 715 707 331 386 731 0 0 0 0 0 0 1 0 0 0 0 0 30
31 657 715 707 331 386 0 0 0 0 0 0 0 1 0 0 0 0 31
32 653 657 715 707 331 0 0 0 0 0 0 0 0 1 0 0 0 32
33 642 653 657 715 707 0 0 0 0 0 0 0 0 0 1 0 0 33
34 643 642 653 657 715 0 0 0 0 0 0 0 0 0 0 1 0 34
35 718 643 642 653 657 0 0 0 0 0 0 0 0 0 0 0 1 35
36 654 718 643 642 653 0 0 0 0 0 0 0 0 0 0 0 0 36
37 632 654 718 643 642 0 1 0 0 0 0 0 0 0 0 0 0 37
38 731 632 654 718 643 0 0 1 0 0 0 0 0 0 0 0 0 38
39 392 731 632 654 718 0 0 0 1 0 0 0 0 0 0 0 0 39
40 344 392 731 632 654 0 0 0 0 1 0 0 0 0 0 0 0 40
41 792 344 392 731 632 0 0 0 0 0 1 0 0 0 0 0 0 41
42 852 792 344 392 731 0 0 0 0 0 0 1 0 0 0 0 0 42
43 649 852 792 344 392 0 0 0 0 0 0 0 1 0 0 0 0 43
44 629 649 852 792 344 0 0 0 0 0 0 0 0 1 0 0 0 44
45 685 629 649 852 792 1 0 0 0 0 0 0 0 0 1 0 0 45
46 617 685 629 649 852 1 0 0 0 0 0 0 0 0 0 1 0 46
47 715 617 685 629 649 1 0 0 0 0 0 0 0 0 0 0 1 47
48 715 715 617 685 629 1 0 0 0 0 0 0 0 0 0 0 0 48
49 629 715 715 617 685 1 1 0 0 0 0 0 0 0 0 0 0 49
50 916 629 715 715 617 1 0 1 0 0 0 0 0 0 0 0 0 50
51 531 916 629 715 715 1 0 0 1 0 0 0 0 0 0 0 0 51
52 357 531 916 629 715 1 0 0 0 1 0 0 0 0 0 0 0 52
53 917 357 531 916 629 1 0 0 0 0 1 0 0 0 0 0 0 53
54 828 917 357 531 916 1 0 0 0 0 0 1 0 0 0 0 0 54
55 708 828 917 357 531 1 0 0 0 0 0 0 1 0 0 0 0 55
56 858 708 828 917 357 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) `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)` X
498.42786 0.13078 0.01629 0.26399 -0.21993 59.72240
M1 M2 M3 M4 M5 M6
47.49892 150.10550 -201.54901 -255.56490 196.29361 211.07491
M7 M8 M9 M10 M11 t
48.64181 -47.92600 65.64612 32.58338 89.45931 -0.26298
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-81.153 -35.936 2.142 25.669 101.642
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 498.42786 216.52412 2.302 0.026911 *
`Y(t-1)` 0.13078 0.16660 0.785 0.437315
`Y(t-2)` 0.01629 0.15915 0.102 0.919004
`Y(t-3)` 0.26399 0.16790 1.572 0.124158
`Y(t-4)` -0.21993 0.17130 -1.284 0.206939
X 59.72240 31.47561 1.897 0.065391 .
M1 47.49892 41.65450 1.140 0.261295
M2 150.10550 37.21285 4.034 0.000255 ***
M3 -201.54901 40.93596 -4.924 1.69e-05 ***
M4 -255.56490 67.71682 -3.774 0.000549 ***
M5 196.29361 78.48862 2.501 0.016816 *
M6 211.07491 75.45300 2.797 0.008041 **
M7 48.64181 82.44685 0.590 0.558698
M8 -47.92600 65.65475 -0.730 0.469885
M9 65.64612 47.53388 1.381 0.175335
M10 32.58338 41.87441 0.778 0.441316
M11 89.45931 40.88025 2.188 0.034864 *
t -0.26298 0.70917 -0.371 0.712819
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 52.81 on 38 degrees of freedom
Multiple R-squared: 0.9122, Adjusted R-squared: 0.8729
F-statistic: 23.21 on 17 and 38 DF, p-value: 5.411e-15
> 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.47190586 0.9438117 0.5280941
[2,] 0.34021703 0.6804341 0.6597830
[3,] 0.28039289 0.5607858 0.7196071
[4,] 0.18592145 0.3718429 0.8140786
[5,] 0.31777903 0.6355581 0.6822210
[6,] 0.62915339 0.7416932 0.3708466
[7,] 0.52846715 0.9430657 0.4715329
[8,] 0.43062190 0.8612438 0.5693781
[9,] 0.49504870 0.9900974 0.5049513
[10,] 0.46594442 0.9318888 0.5340556
[11,] 0.33885907 0.6777181 0.6611409
[12,] 0.22876622 0.4575324 0.7712338
[13,] 0.16988986 0.3397797 0.8301101
[14,] 0.09161011 0.1832202 0.9083899
[15,] 0.08158879 0.1631776 0.9184112
> postscript(file="/var/www/html/rcomp/tmp/1qk0c1259779022.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/2ch6g1259779022.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/3cfza1259779022.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/4d0ow1259779022.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/5mnpb1259779022.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
-37.4877855 -24.5536445 5.2772173 19.2310354 29.8855069 -30.5063374
7 8 9 10 11 12
39.4468132 -54.3755849 30.1926952 -15.1287170 66.0952332 -12.8231663
13 14 15 16 17 18
67.4544564 43.6609393 1.5819218 9.0812213 12.0618295 -54.0417259
19 20 21 22 23 24
-49.3003526 4.1479389 83.1075070 50.4138534 -47.5470801 -45.3808965
25 26 27 28 29 30
81.1647633 -44.0495865 -17.8569897 -28.7031855 -62.3220174 -25.6015086
31 32 33 34 35 36
10.5655443 -0.5066127 -42.7649295 10.1357270 16.8710833 34.7924272
37 38 39 40 41 42
-29.9784043 -48.9817102 -15.2628997 25.4713303 2.7023655 101.6418422
43 44 45 46 47 48
-15.6932704 -42.1168468 -70.5352728 -45.4208634 -35.4192364 23.4116356
49 50 51 52 53 54
-81.1530300 73.9240020 26.2607504 -25.0804015 17.6723154 8.5077297
55 56
14.9812655 92.8511054
> postscript(file="/var/www/html/rcomp/tmp/6b1a01259779022.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 -37.4877855 NA
1 -24.5536445 -37.4877855
2 5.2772173 -24.5536445
3 19.2310354 5.2772173
4 29.8855069 19.2310354
5 -30.5063374 29.8855069
6 39.4468132 -30.5063374
7 -54.3755849 39.4468132
8 30.1926952 -54.3755849
9 -15.1287170 30.1926952
10 66.0952332 -15.1287170
11 -12.8231663 66.0952332
12 67.4544564 -12.8231663
13 43.6609393 67.4544564
14 1.5819218 43.6609393
15 9.0812213 1.5819218
16 12.0618295 9.0812213
17 -54.0417259 12.0618295
18 -49.3003526 -54.0417259
19 4.1479389 -49.3003526
20 83.1075070 4.1479389
21 50.4138534 83.1075070
22 -47.5470801 50.4138534
23 -45.3808965 -47.5470801
24 81.1647633 -45.3808965
25 -44.0495865 81.1647633
26 -17.8569897 -44.0495865
27 -28.7031855 -17.8569897
28 -62.3220174 -28.7031855
29 -25.6015086 -62.3220174
30 10.5655443 -25.6015086
31 -0.5066127 10.5655443
32 -42.7649295 -0.5066127
33 10.1357270 -42.7649295
34 16.8710833 10.1357270
35 34.7924272 16.8710833
36 -29.9784043 34.7924272
37 -48.9817102 -29.9784043
38 -15.2628997 -48.9817102
39 25.4713303 -15.2628997
40 2.7023655 25.4713303
41 101.6418422 2.7023655
42 -15.6932704 101.6418422
43 -42.1168468 -15.6932704
44 -70.5352728 -42.1168468
45 -45.4208634 -70.5352728
46 -35.4192364 -45.4208634
47 23.4116356 -35.4192364
48 -81.1530300 23.4116356
49 73.9240020 -81.1530300
50 26.2607504 73.9240020
51 -25.0804015 26.2607504
52 17.6723154 -25.0804015
53 8.5077297 17.6723154
54 14.9812655 8.5077297
55 92.8511054 14.9812655
56 NA 92.8511054
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -24.5536445 -37.4877855
[2,] 5.2772173 -24.5536445
[3,] 19.2310354 5.2772173
[4,] 29.8855069 19.2310354
[5,] -30.5063374 29.8855069
[6,] 39.4468132 -30.5063374
[7,] -54.3755849 39.4468132
[8,] 30.1926952 -54.3755849
[9,] -15.1287170 30.1926952
[10,] 66.0952332 -15.1287170
[11,] -12.8231663 66.0952332
[12,] 67.4544564 -12.8231663
[13,] 43.6609393 67.4544564
[14,] 1.5819218 43.6609393
[15,] 9.0812213 1.5819218
[16,] 12.0618295 9.0812213
[17,] -54.0417259 12.0618295
[18,] -49.3003526 -54.0417259
[19,] 4.1479389 -49.3003526
[20,] 83.1075070 4.1479389
[21,] 50.4138534 83.1075070
[22,] -47.5470801 50.4138534
[23,] -45.3808965 -47.5470801
[24,] 81.1647633 -45.3808965
[25,] -44.0495865 81.1647633
[26,] -17.8569897 -44.0495865
[27,] -28.7031855 -17.8569897
[28,] -62.3220174 -28.7031855
[29,] -25.6015086 -62.3220174
[30,] 10.5655443 -25.6015086
[31,] -0.5066127 10.5655443
[32,] -42.7649295 -0.5066127
[33,] 10.1357270 -42.7649295
[34,] 16.8710833 10.1357270
[35,] 34.7924272 16.8710833
[36,] -29.9784043 34.7924272
[37,] -48.9817102 -29.9784043
[38,] -15.2628997 -48.9817102
[39,] 25.4713303 -15.2628997
[40,] 2.7023655 25.4713303
[41,] 101.6418422 2.7023655
[42,] -15.6932704 101.6418422
[43,] -42.1168468 -15.6932704
[44,] -70.5352728 -42.1168468
[45,] -45.4208634 -70.5352728
[46,] -35.4192364 -45.4208634
[47,] 23.4116356 -35.4192364
[48,] -81.1530300 23.4116356
[49,] 73.9240020 -81.1530300
[50,] 26.2607504 73.9240020
[51,] -25.0804015 26.2607504
[52,] 17.6723154 -25.0804015
[53,] 8.5077297 17.6723154
[54,] 14.9812655 8.5077297
[55,] 92.8511054 14.9812655
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -24.5536445 -37.4877855
2 5.2772173 -24.5536445
3 19.2310354 5.2772173
4 29.8855069 19.2310354
5 -30.5063374 29.8855069
6 39.4468132 -30.5063374
7 -54.3755849 39.4468132
8 30.1926952 -54.3755849
9 -15.1287170 30.1926952
10 66.0952332 -15.1287170
11 -12.8231663 66.0952332
12 67.4544564 -12.8231663
13 43.6609393 67.4544564
14 1.5819218 43.6609393
15 9.0812213 1.5819218
16 12.0618295 9.0812213
17 -54.0417259 12.0618295
18 -49.3003526 -54.0417259
19 4.1479389 -49.3003526
20 83.1075070 4.1479389
21 50.4138534 83.1075070
22 -47.5470801 50.4138534
23 -45.3808965 -47.5470801
24 81.1647633 -45.3808965
25 -44.0495865 81.1647633
26 -17.8569897 -44.0495865
27 -28.7031855 -17.8569897
28 -62.3220174 -28.7031855
29 -25.6015086 -62.3220174
30 10.5655443 -25.6015086
31 -0.5066127 10.5655443
32 -42.7649295 -0.5066127
33 10.1357270 -42.7649295
34 16.8710833 10.1357270
35 34.7924272 16.8710833
36 -29.9784043 34.7924272
37 -48.9817102 -29.9784043
38 -15.2628997 -48.9817102
39 25.4713303 -15.2628997
40 2.7023655 25.4713303
41 101.6418422 2.7023655
42 -15.6932704 101.6418422
43 -42.1168468 -15.6932704
44 -70.5352728 -42.1168468
45 -45.4208634 -70.5352728
46 -35.4192364 -45.4208634
47 23.4116356 -35.4192364
48 -81.1530300 23.4116356
49 73.9240020 -81.1530300
50 26.2607504 73.9240020
51 -25.0804015 26.2607504
52 17.6723154 -25.0804015
53 8.5077297 17.6723154
54 14.9812655 8.5077297
55 92.8511054 14.9812655
> 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/7w5x21259779022.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/8cwnh1259779022.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/9yp4a1259779022.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/10htn31259779022.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/11l82l1259779023.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/121ge01259779023.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/138pn71259779023.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/14kun51259779023.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/15rci01259779023.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/16ptpj1259779023.tab")
+ }
> system("convert tmp/1qk0c1259779022.ps tmp/1qk0c1259779022.png")
> system("convert tmp/2ch6g1259779022.ps tmp/2ch6g1259779022.png")
> system("convert tmp/3cfza1259779022.ps tmp/3cfza1259779022.png")
> system("convert tmp/4d0ow1259779022.ps tmp/4d0ow1259779022.png")
> system("convert tmp/5mnpb1259779022.ps tmp/5mnpb1259779022.png")
> system("convert tmp/6b1a01259779022.ps tmp/6b1a01259779022.png")
> system("convert tmp/7w5x21259779022.ps tmp/7w5x21259779022.png")
> system("convert tmp/8cwnh1259779022.ps tmp/8cwnh1259779022.png")
> system("convert tmp/9yp4a1259779022.ps tmp/9yp4a1259779022.png")
> system("convert tmp/10htn31259779022.ps tmp/10htn31259779022.png")
>
>
> proc.time()
user system elapsed
2.331 1.582 3.471