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(13807
+ ,0
+ ,19169
+ ,22782
+ ,20366
+ ,29743
+ ,0
+ ,13807
+ ,19169
+ ,22782
+ ,25591
+ ,0
+ ,29743
+ ,13807
+ ,19169
+ ,29096
+ ,0
+ ,25591
+ ,29743
+ ,13807
+ ,26482
+ ,0
+ ,29096
+ ,25591
+ ,29743
+ ,22405
+ ,0
+ ,26482
+ ,29096
+ ,25591
+ ,27044
+ ,0
+ ,22405
+ ,26482
+ ,29096
+ ,17970
+ ,0
+ ,27044
+ ,22405
+ ,26482
+ ,18730
+ ,0
+ ,17970
+ ,27044
+ ,22405
+ ,19684
+ ,0
+ ,18730
+ ,17970
+ ,27044
+ ,19785
+ ,0
+ ,19684
+ ,18730
+ ,17970
+ ,18479
+ ,0
+ ,19785
+ ,19684
+ ,18730
+ ,10698
+ ,0
+ ,18479
+ ,19785
+ ,19684
+ ,31956
+ ,0
+ ,10698
+ ,18479
+ ,19785
+ ,29506
+ ,0
+ ,31956
+ ,10698
+ ,18479
+ ,34506
+ ,0
+ ,29506
+ ,31956
+ ,10698
+ ,27165
+ ,0
+ ,34506
+ ,29506
+ ,31956
+ ,26736
+ ,0
+ ,27165
+ ,34506
+ ,29506
+ ,23691
+ ,0
+ ,26736
+ ,27165
+ ,34506
+ ,18157
+ ,0
+ ,23691
+ ,26736
+ ,27165
+ ,17328
+ ,0
+ ,18157
+ ,23691
+ ,26736
+ ,18205
+ ,0
+ ,17328
+ ,18157
+ ,23691
+ ,20995
+ ,0
+ ,18205
+ ,17328
+ ,18157
+ ,17382
+ ,0
+ ,20995
+ ,18205
+ ,17328
+ ,9367
+ ,0
+ ,17382
+ ,20995
+ ,18205
+ ,31124
+ ,0
+ ,9367
+ ,17382
+ ,20995
+ ,26551
+ ,0
+ ,31124
+ ,9367
+ ,17382
+ ,30651
+ ,0
+ ,26551
+ ,31124
+ ,9367
+ ,25859
+ ,0
+ ,30651
+ ,26551
+ ,31124
+ ,25100
+ ,0
+ ,25859
+ ,30651
+ ,26551
+ ,25778
+ ,0
+ ,25100
+ ,25859
+ ,30651
+ ,20418
+ ,0
+ ,25778
+ ,25100
+ ,25859
+ ,18688
+ ,0
+ ,20418
+ ,25778
+ ,25100
+ ,20424
+ ,0
+ ,18688
+ ,20418
+ ,25778
+ ,24776
+ ,0
+ ,20424
+ ,18688
+ ,20418
+ ,19814
+ ,0
+ ,24776
+ ,20424
+ ,18688
+ ,12738
+ ,0
+ ,19814
+ ,24776
+ ,20424
+ ,31566
+ ,0
+ ,12738
+ ,19814
+ ,24776
+ ,30111
+ ,0
+ ,31566
+ ,12738
+ ,19814
+ ,30019
+ ,0
+ ,30111
+ ,31566
+ ,12738
+ ,31934
+ ,1
+ ,30019
+ ,30111
+ ,31566
+ ,25826
+ ,1
+ ,31934
+ ,30019
+ ,30111
+ ,26835
+ ,1
+ ,25826
+ ,31934
+ ,30019
+ ,20205
+ ,1
+ ,26835
+ ,25826
+ ,31934
+ ,17789
+ ,1
+ ,20205
+ ,26835
+ ,25826
+ ,20520
+ ,1
+ ,17789
+ ,20205
+ ,26835
+ ,22518
+ ,1
+ ,20520
+ ,17789
+ ,20205
+ ,15572
+ ,1
+ ,22518
+ ,20520
+ ,17789
+ ,11509
+ ,1
+ ,15572
+ ,22518
+ ,20520
+ ,25447
+ ,1
+ ,11509
+ ,15572
+ ,22518
+ ,24090
+ ,1
+ ,25447
+ ,11509
+ ,15572
+ ,27786
+ ,1
+ ,24090
+ ,25447
+ ,11509
+ ,26195
+ ,1
+ ,27786
+ ,24090
+ ,25447
+ ,20516
+ ,1
+ ,26195
+ ,27786
+ ,24090
+ ,22759
+ ,1
+ ,20516
+ ,26195
+ ,27786
+ ,19028
+ ,1
+ ,22759
+ ,20516
+ ,26195
+ ,16971
+ ,1
+ ,19028
+ ,22759
+ ,20516
+ ,20036
+ ,1
+ ,16971
+ ,19028
+ ,22759)
+ ,dim=c(5
+ ,58)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3')
+ ,1:58))
> y <- array(NA,dim=c(5,58),dimnames=list(c('Y','X','Y1','Y2','Y3'),1:58))
> 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 Y3 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 13807 0 19169 22782 20366 1 0 0 0 0 0 0 0 0 0 0 1
2 29743 0 13807 19169 22782 0 1 0 0 0 0 0 0 0 0 0 2
3 25591 0 29743 13807 19169 0 0 1 0 0 0 0 0 0 0 0 3
4 29096 0 25591 29743 13807 0 0 0 1 0 0 0 0 0 0 0 4
5 26482 0 29096 25591 29743 0 0 0 0 1 0 0 0 0 0 0 5
6 22405 0 26482 29096 25591 0 0 0 0 0 1 0 0 0 0 0 6
7 27044 0 22405 26482 29096 0 0 0 0 0 0 1 0 0 0 0 7
8 17970 0 27044 22405 26482 0 0 0 0 0 0 0 1 0 0 0 8
9 18730 0 17970 27044 22405 0 0 0 0 0 0 0 0 1 0 0 9
10 19684 0 18730 17970 27044 0 0 0 0 0 0 0 0 0 1 0 10
11 19785 0 19684 18730 17970 0 0 0 0 0 0 0 0 0 0 1 11
12 18479 0 19785 19684 18730 0 0 0 0 0 0 0 0 0 0 0 12
13 10698 0 18479 19785 19684 1 0 0 0 0 0 0 0 0 0 0 13
14 31956 0 10698 18479 19785 0 1 0 0 0 0 0 0 0 0 0 14
15 29506 0 31956 10698 18479 0 0 1 0 0 0 0 0 0 0 0 15
16 34506 0 29506 31956 10698 0 0 0 1 0 0 0 0 0 0 0 16
17 27165 0 34506 29506 31956 0 0 0 0 1 0 0 0 0 0 0 17
18 26736 0 27165 34506 29506 0 0 0 0 0 1 0 0 0 0 0 18
19 23691 0 26736 27165 34506 0 0 0 0 0 0 1 0 0 0 0 19
20 18157 0 23691 26736 27165 0 0 0 0 0 0 0 1 0 0 0 20
21 17328 0 18157 23691 26736 0 0 0 0 0 0 0 0 1 0 0 21
22 18205 0 17328 18157 23691 0 0 0 0 0 0 0 0 0 1 0 22
23 20995 0 18205 17328 18157 0 0 0 0 0 0 0 0 0 0 1 23
24 17382 0 20995 18205 17328 0 0 0 0 0 0 0 0 0 0 0 24
25 9367 0 17382 20995 18205 1 0 0 0 0 0 0 0 0 0 0 25
26 31124 0 9367 17382 20995 0 1 0 0 0 0 0 0 0 0 0 26
27 26551 0 31124 9367 17382 0 0 1 0 0 0 0 0 0 0 0 27
28 30651 0 26551 31124 9367 0 0 0 1 0 0 0 0 0 0 0 28
29 25859 0 30651 26551 31124 0 0 0 0 1 0 0 0 0 0 0 29
30 25100 0 25859 30651 26551 0 0 0 0 0 1 0 0 0 0 0 30
31 25778 0 25100 25859 30651 0 0 0 0 0 0 1 0 0 0 0 31
32 20418 0 25778 25100 25859 0 0 0 0 0 0 0 1 0 0 0 32
33 18688 0 20418 25778 25100 0 0 0 0 0 0 0 0 1 0 0 33
34 20424 0 18688 20418 25778 0 0 0 0 0 0 0 0 0 1 0 34
35 24776 0 20424 18688 20418 0 0 0 0 0 0 0 0 0 0 1 35
36 19814 0 24776 20424 18688 0 0 0 0 0 0 0 0 0 0 0 36
37 12738 0 19814 24776 20424 1 0 0 0 0 0 0 0 0 0 0 37
38 31566 0 12738 19814 24776 0 1 0 0 0 0 0 0 0 0 0 38
39 30111 0 31566 12738 19814 0 0 1 0 0 0 0 0 0 0 0 39
40 30019 0 30111 31566 12738 0 0 0 1 0 0 0 0 0 0 0 40
41 31934 1 30019 30111 31566 0 0 0 0 1 0 0 0 0 0 0 41
42 25826 1 31934 30019 30111 0 0 0 0 0 1 0 0 0 0 0 42
43 26835 1 25826 31934 30019 0 0 0 0 0 0 1 0 0 0 0 43
44 20205 1 26835 25826 31934 0 0 0 0 0 0 0 1 0 0 0 44
45 17789 1 20205 26835 25826 0 0 0 0 0 0 0 0 1 0 0 45
46 20520 1 17789 20205 26835 0 0 0 0 0 0 0 0 0 1 0 46
47 22518 1 20520 17789 20205 0 0 0 0 0 0 0 0 0 0 1 47
48 15572 1 22518 20520 17789 0 0 0 0 0 0 0 0 0 0 0 48
49 11509 1 15572 22518 20520 1 0 0 0 0 0 0 0 0 0 0 49
50 25447 1 11509 15572 22518 0 1 0 0 0 0 0 0 0 0 0 50
51 24090 1 25447 11509 15572 0 0 1 0 0 0 0 0 0 0 0 51
52 27786 1 24090 25447 11509 0 0 0 1 0 0 0 0 0 0 0 52
53 26195 1 27786 24090 25447 0 0 0 0 1 0 0 0 0 0 0 53
54 20516 1 26195 27786 24090 0 0 0 0 0 1 0 0 0 0 0 54
55 22759 1 20516 26195 27786 0 0 0 0 0 0 1 0 0 0 0 55
56 19028 1 22759 20516 26195 0 0 0 0 0 0 0 1 0 0 0 56
57 16971 1 19028 22759 20516 0 0 0 0 0 0 0 0 1 0 0 57
58 20036 1 16971 19028 22759 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 M1
4.746e+03 -8.668e+02 1.570e-01 4.423e-01 3.647e-02 -6.691e+03
M2 M3 M4 M5 M6 M7
1.438e+04 1.169e+04 7.477e+03 4.810e+03 5.062e+02 3.289e+03
M8 M9 M10 M11 t
-1.351e+03 -2.033e+03 2.665e+03 5.242e+03 1.489e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3068.0 -894.5 138.0 807.6 3450.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.746e+03 3.544e+03 1.339 0.187877
X -8.668e+02 8.797e+02 -0.985 0.330254
Y1 1.570e-01 1.578e-01 0.995 0.325580
Y2 4.423e-01 1.417e-01 3.121 0.003295 **
Y3 3.647e-02 1.555e-01 0.235 0.815719
M1 -6.691e+03 1.476e+03 -4.534 4.95e-05 ***
M2 1.438e+04 2.320e+03 6.195 2.28e-07 ***
M3 1.169e+04 2.215e+03 5.277 4.58e-06 ***
M4 7.477e+03 2.474e+03 3.022 0.004315 **
M5 4.810e+03 2.006e+03 2.398 0.021100 *
M6 5.062e+02 1.962e+03 0.258 0.797741
M7 3.289e+03 2.169e+03 1.516 0.137088
M8 -1.351e+03 1.727e+03 -0.782 0.438528
M9 -2.033e+03 1.812e+03 -1.122 0.268585
M10 2.665e+03 1.925e+03 1.384 0.173759
M11 5.242e+03 1.345e+03 3.897 0.000352 ***
t 1.489e+01 2.378e+01 0.626 0.534743
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1769 on 41 degrees of freedom
Multiple R-squared: 0.934, Adjusted R-squared: 0.9082
F-statistic: 36.26 on 16 and 41 DF, p-value: < 2.2e-16
> 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.9155763 0.1688474 0.08442372
[2,] 0.8688119 0.2623762 0.13118810
[3,] 0.8839555 0.2320890 0.11604451
[4,] 0.8393052 0.3213896 0.16069480
[5,] 0.7796587 0.4406826 0.22034128
[6,] 0.8071508 0.3856985 0.19284923
[7,] 0.8012797 0.3974405 0.19872026
[8,] 0.7112649 0.5774703 0.28873514
[9,] 0.6730420 0.6539160 0.32695799
[10,] 0.8528161 0.2943678 0.14718388
[11,] 0.8058908 0.3882184 0.19410921
[12,] 0.7144086 0.5711828 0.28559139
[13,] 0.6920721 0.6158557 0.30792786
[14,] 0.5774784 0.8450432 0.42252158
[15,] 0.5006154 0.9987692 0.49938459
[16,] 0.4822599 0.9645197 0.51774015
[17,] 0.3843269 0.7686538 0.61567308
[18,] 0.2740267 0.5480534 0.72597329
[19,] 0.3293345 0.6586690 0.67066548
> postscript(file="/var/www/html/rcomp/tmp/1jnji1259246800.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/255o51259246800.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/3owa81259246800.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/4uzd41259246800.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/5r48y1259246800.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 = 58
Frequency = 1
1 2 3 4 5 6
1907.341714 -885.533152 -2364.911958 -864.228795 -121.328913 -897.422541
7 8 9 10 11 12
2612.138167 -665.932536 281.801690 248.634103 -2397.720125 1058.176323
13 14 15 16 17 18
78.518255 2051.417371 2424.339518 2887.013989 -2278.741780 611.930574
19 20 21 22 23 24
-2098.902847 -2071.796935 -3.086348 -1149.337052 -520.873369 297.879784
25 26 27 28 29 30
-1740.184296 1690.807481 50.038763 -266.169482 -1820.781993 815.234255
31 32 33 34 35 36
784.558902 454.164716 -40.167945 -398.724238 2049.065681 926.501795
37 38 39 40 41 42
-683.013445 211.278457 1782.212651 -1954.196442 3450.770624 1425.304697
43 44 45 46 47 48
-248.352714 220.631053 -711.624502 582.193035 869.527813 -2282.557902
49 50 51 52 53 54
437.337772 -3067.970158 -1891.678975 197.580730 770.082062 -1955.046984
55 56 57 58
-1049.441509 2062.933701 473.077105 717.234152
> postscript(file="/var/www/html/rcomp/tmp/6qrn21259246800.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 1907.341714 NA
1 -885.533152 1907.341714
2 -2364.911958 -885.533152
3 -864.228795 -2364.911958
4 -121.328913 -864.228795
5 -897.422541 -121.328913
6 2612.138167 -897.422541
7 -665.932536 2612.138167
8 281.801690 -665.932536
9 248.634103 281.801690
10 -2397.720125 248.634103
11 1058.176323 -2397.720125
12 78.518255 1058.176323
13 2051.417371 78.518255
14 2424.339518 2051.417371
15 2887.013989 2424.339518
16 -2278.741780 2887.013989
17 611.930574 -2278.741780
18 -2098.902847 611.930574
19 -2071.796935 -2098.902847
20 -3.086348 -2071.796935
21 -1149.337052 -3.086348
22 -520.873369 -1149.337052
23 297.879784 -520.873369
24 -1740.184296 297.879784
25 1690.807481 -1740.184296
26 50.038763 1690.807481
27 -266.169482 50.038763
28 -1820.781993 -266.169482
29 815.234255 -1820.781993
30 784.558902 815.234255
31 454.164716 784.558902
32 -40.167945 454.164716
33 -398.724238 -40.167945
34 2049.065681 -398.724238
35 926.501795 2049.065681
36 -683.013445 926.501795
37 211.278457 -683.013445
38 1782.212651 211.278457
39 -1954.196442 1782.212651
40 3450.770624 -1954.196442
41 1425.304697 3450.770624
42 -248.352714 1425.304697
43 220.631053 -248.352714
44 -711.624502 220.631053
45 582.193035 -711.624502
46 869.527813 582.193035
47 -2282.557902 869.527813
48 437.337772 -2282.557902
49 -3067.970158 437.337772
50 -1891.678975 -3067.970158
51 197.580730 -1891.678975
52 770.082062 197.580730
53 -1955.046984 770.082062
54 -1049.441509 -1955.046984
55 2062.933701 -1049.441509
56 473.077105 2062.933701
57 717.234152 473.077105
58 NA 717.234152
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -885.533152 1907.341714
[2,] -2364.911958 -885.533152
[3,] -864.228795 -2364.911958
[4,] -121.328913 -864.228795
[5,] -897.422541 -121.328913
[6,] 2612.138167 -897.422541
[7,] -665.932536 2612.138167
[8,] 281.801690 -665.932536
[9,] 248.634103 281.801690
[10,] -2397.720125 248.634103
[11,] 1058.176323 -2397.720125
[12,] 78.518255 1058.176323
[13,] 2051.417371 78.518255
[14,] 2424.339518 2051.417371
[15,] 2887.013989 2424.339518
[16,] -2278.741780 2887.013989
[17,] 611.930574 -2278.741780
[18,] -2098.902847 611.930574
[19,] -2071.796935 -2098.902847
[20,] -3.086348 -2071.796935
[21,] -1149.337052 -3.086348
[22,] -520.873369 -1149.337052
[23,] 297.879784 -520.873369
[24,] -1740.184296 297.879784
[25,] 1690.807481 -1740.184296
[26,] 50.038763 1690.807481
[27,] -266.169482 50.038763
[28,] -1820.781993 -266.169482
[29,] 815.234255 -1820.781993
[30,] 784.558902 815.234255
[31,] 454.164716 784.558902
[32,] -40.167945 454.164716
[33,] -398.724238 -40.167945
[34,] 2049.065681 -398.724238
[35,] 926.501795 2049.065681
[36,] -683.013445 926.501795
[37,] 211.278457 -683.013445
[38,] 1782.212651 211.278457
[39,] -1954.196442 1782.212651
[40,] 3450.770624 -1954.196442
[41,] 1425.304697 3450.770624
[42,] -248.352714 1425.304697
[43,] 220.631053 -248.352714
[44,] -711.624502 220.631053
[45,] 582.193035 -711.624502
[46,] 869.527813 582.193035
[47,] -2282.557902 869.527813
[48,] 437.337772 -2282.557902
[49,] -3067.970158 437.337772
[50,] -1891.678975 -3067.970158
[51,] 197.580730 -1891.678975
[52,] 770.082062 197.580730
[53,] -1955.046984 770.082062
[54,] -1049.441509 -1955.046984
[55,] 2062.933701 -1049.441509
[56,] 473.077105 2062.933701
[57,] 717.234152 473.077105
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -885.533152 1907.341714
2 -2364.911958 -885.533152
3 -864.228795 -2364.911958
4 -121.328913 -864.228795
5 -897.422541 -121.328913
6 2612.138167 -897.422541
7 -665.932536 2612.138167
8 281.801690 -665.932536
9 248.634103 281.801690
10 -2397.720125 248.634103
11 1058.176323 -2397.720125
12 78.518255 1058.176323
13 2051.417371 78.518255
14 2424.339518 2051.417371
15 2887.013989 2424.339518
16 -2278.741780 2887.013989
17 611.930574 -2278.741780
18 -2098.902847 611.930574
19 -2071.796935 -2098.902847
20 -3.086348 -2071.796935
21 -1149.337052 -3.086348
22 -520.873369 -1149.337052
23 297.879784 -520.873369
24 -1740.184296 297.879784
25 1690.807481 -1740.184296
26 50.038763 1690.807481
27 -266.169482 50.038763
28 -1820.781993 -266.169482
29 815.234255 -1820.781993
30 784.558902 815.234255
31 454.164716 784.558902
32 -40.167945 454.164716
33 -398.724238 -40.167945
34 2049.065681 -398.724238
35 926.501795 2049.065681
36 -683.013445 926.501795
37 211.278457 -683.013445
38 1782.212651 211.278457
39 -1954.196442 1782.212651
40 3450.770624 -1954.196442
41 1425.304697 3450.770624
42 -248.352714 1425.304697
43 220.631053 -248.352714
44 -711.624502 220.631053
45 582.193035 -711.624502
46 869.527813 582.193035
47 -2282.557902 869.527813
48 437.337772 -2282.557902
49 -3067.970158 437.337772
50 -1891.678975 -3067.970158
51 197.580730 -1891.678975
52 770.082062 197.580730
53 -1955.046984 770.082062
54 -1049.441509 -1955.046984
55 2062.933701 -1049.441509
56 473.077105 2062.933701
57 717.234152 473.077105
> 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/71zh51259246800.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/8tfww1259246800.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/93bvp1259246800.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/10qdtx1259246801.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/11rv1j1259246801.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/12le9e1259246801.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/131lt41259246801.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/14sdt41259246801.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/157ybm1259246801.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/16gx271259246801.tab")
+ }
> system("convert tmp/1jnji1259246800.ps tmp/1jnji1259246800.png")
> system("convert tmp/255o51259246800.ps tmp/255o51259246800.png")
> system("convert tmp/3owa81259246800.ps tmp/3owa81259246800.png")
> system("convert tmp/4uzd41259246800.ps tmp/4uzd41259246800.png")
> system("convert tmp/5r48y1259246800.ps tmp/5r48y1259246800.png")
> system("convert tmp/6qrn21259246800.ps tmp/6qrn21259246800.png")
> system("convert tmp/71zh51259246800.ps tmp/71zh51259246800.png")
> system("convert tmp/8tfww1259246800.ps tmp/8tfww1259246800.png")
> system("convert tmp/93bvp1259246800.ps tmp/93bvp1259246800.png")
> system("convert tmp/10qdtx1259246801.ps tmp/10qdtx1259246801.png")
>
>
> proc.time()
user system elapsed
2.400 1.571 4.258