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(2.057
+ ,0
+ ,2.058
+ ,2.077
+ ,2.053
+ ,2.085
+ ,2.076
+ ,0
+ ,2.057
+ ,2.058
+ ,2.077
+ ,2.053
+ ,2.07
+ ,0
+ ,2.076
+ ,2.057
+ ,2.058
+ ,2.077
+ ,2.062
+ ,0
+ ,2.07
+ ,2.076
+ ,2.057
+ ,2.058
+ ,2.073
+ ,0
+ ,2.062
+ ,2.07
+ ,2.076
+ ,2.057
+ ,2.061
+ ,0
+ ,2.073
+ ,2.062
+ ,2.07
+ ,2.076
+ ,2.094
+ ,0
+ ,2.061
+ ,2.073
+ ,2.062
+ ,2.07
+ ,2.067
+ ,0
+ ,2.094
+ ,2.061
+ ,2.073
+ ,2.062
+ ,2.086
+ ,0
+ ,2.067
+ ,2.094
+ ,2.061
+ ,2.073
+ ,2.276
+ ,0
+ ,2.086
+ ,2.067
+ ,2.094
+ ,2.061
+ ,2.326
+ ,0
+ ,2.276
+ ,2.086
+ ,2.067
+ ,2.094
+ ,2.349
+ ,0
+ ,2.326
+ ,2.276
+ ,2.086
+ ,2.067
+ ,2.52
+ ,0
+ ,2.349
+ ,2.326
+ ,2.276
+ ,2.086
+ ,2.628
+ ,0
+ ,2.52
+ ,2.349
+ ,2.326
+ ,2.276
+ ,2.577
+ ,0
+ ,2.628
+ ,2.52
+ ,2.349
+ ,2.326
+ ,2.698
+ ,0
+ ,2.577
+ ,2.628
+ ,2.52
+ ,2.349
+ ,2.814
+ ,0
+ ,2.698
+ ,2.577
+ ,2.628
+ ,2.52
+ ,2.968
+ ,0
+ ,2.814
+ ,2.698
+ ,2.577
+ ,2.628
+ ,3.041
+ ,0
+ ,2.968
+ ,2.814
+ ,2.698
+ ,2.577
+ ,3.278
+ ,0
+ ,3.041
+ ,2.968
+ ,2.814
+ ,2.698
+ ,3.328
+ ,0
+ ,3.278
+ ,3.041
+ ,2.968
+ ,2.814
+ ,3.5
+ ,0
+ ,3.328
+ ,3.278
+ ,3.041
+ ,2.968
+ ,3.563
+ ,0
+ ,3.5
+ ,3.328
+ ,3.278
+ ,3.041
+ ,3.569
+ ,0
+ ,3.563
+ ,3.5
+ ,3.328
+ ,3.278
+ ,3.69
+ ,0
+ ,3.569
+ ,3.563
+ ,3.5
+ ,3.328
+ ,3.819
+ ,0
+ ,3.69
+ ,3.569
+ ,3.563
+ ,3.5
+ ,3.79
+ ,0
+ ,3.819
+ ,3.69
+ ,3.569
+ ,3.563
+ ,3.956
+ ,0
+ ,3.79
+ ,3.819
+ ,3.69
+ ,3.569
+ ,4.063
+ ,0
+ ,3.956
+ ,3.79
+ ,3.819
+ ,3.69
+ ,4.047
+ ,0
+ ,4.063
+ ,3.956
+ ,3.79
+ ,3.819
+ ,4.029
+ ,0
+ ,4.047
+ ,4.063
+ ,3.956
+ ,3.79
+ ,3.941
+ ,0
+ ,4.029
+ ,4.047
+ ,4.063
+ ,3.956
+ ,4.022
+ ,0
+ ,3.941
+ ,4.029
+ ,4.047
+ ,4.063
+ ,3.879
+ ,0
+ ,4.022
+ ,3.941
+ ,4.029
+ ,4.047
+ ,4.022
+ ,0
+ ,3.879
+ ,4.022
+ ,3.941
+ ,4.029
+ ,4.028
+ ,0
+ ,4.022
+ ,3.879
+ ,4.022
+ ,3.941
+ ,4.091
+ ,0
+ ,4.028
+ ,4.022
+ ,3.879
+ ,4.022
+ ,3.987
+ ,0
+ ,4.091
+ ,4.028
+ ,4.022
+ ,3.879
+ ,4.01
+ ,0
+ ,3.987
+ ,4.091
+ ,4.028
+ ,4.022
+ ,4.007
+ ,0
+ ,4.01
+ ,3.987
+ ,4.091
+ ,4.028
+ ,4.191
+ ,0
+ ,4.007
+ ,4.01
+ ,3.987
+ ,4.091
+ ,4.299
+ ,0
+ ,4.191
+ ,4.007
+ ,4.01
+ ,3.987
+ ,4.273
+ ,0
+ ,4.299
+ ,4.191
+ ,4.007
+ ,4.01
+ ,3.82
+ ,0
+ ,4.273
+ ,4.299
+ ,4.191
+ ,4.007
+ ,3.15
+ ,1
+ ,3.82
+ ,4.273
+ ,4.299
+ ,4.191
+ ,2.486
+ ,1
+ ,3.15
+ ,3.82
+ ,4.273
+ ,4.299
+ ,1.812
+ ,1
+ ,2.486
+ ,3.15
+ ,3.82
+ ,4.273
+ ,1.257
+ ,1
+ ,1.812
+ ,2.486
+ ,3.15
+ ,3.82
+ ,1.062
+ ,1
+ ,1.257
+ ,1.812
+ ,2.486
+ ,3.15
+ ,0.842
+ ,1
+ ,1.062
+ ,1.257
+ ,1.812
+ ,2.486
+ ,0.782
+ ,1
+ ,0.842
+ ,1.062
+ ,1.257
+ ,1.812
+ ,0.698
+ ,1
+ ,0.782
+ ,0.842
+ ,1.062
+ ,1.257
+ ,0.358
+ ,1
+ ,0.698
+ ,0.782
+ ,0.842
+ ,1.062
+ ,0.347
+ ,1
+ ,0.358
+ ,0.698
+ ,0.782
+ ,0.842
+ ,0.363
+ ,1
+ ,0.347
+ ,0.358
+ ,0.698
+ ,0.782
+ ,0.359
+ ,1
+ ,0.363
+ ,0.347
+ ,0.358
+ ,0.698
+ ,0.355
+ ,1
+ ,0.359
+ ,0.363
+ ,0.347
+ ,0.358)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('intb'
+ ,'X'
+ ,'Yt-1'
+ ,'Yt-2'
+ ,'Yt-3'
+ ,'Yt-4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('intb','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 = 'No Linear Trend'
> par2 = 'Do not include Seasonal 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
intb X Yt-1 Yt-2 Yt-3 Yt-4
1 2.057 0 2.058 2.077 2.053 2.085
2 2.076 0 2.057 2.058 2.077 2.053
3 2.070 0 2.076 2.057 2.058 2.077
4 2.062 0 2.070 2.076 2.057 2.058
5 2.073 0 2.062 2.070 2.076 2.057
6 2.061 0 2.073 2.062 2.070 2.076
7 2.094 0 2.061 2.073 2.062 2.070
8 2.067 0 2.094 2.061 2.073 2.062
9 2.086 0 2.067 2.094 2.061 2.073
10 2.276 0 2.086 2.067 2.094 2.061
11 2.326 0 2.276 2.086 2.067 2.094
12 2.349 0 2.326 2.276 2.086 2.067
13 2.520 0 2.349 2.326 2.276 2.086
14 2.628 0 2.520 2.349 2.326 2.276
15 2.577 0 2.628 2.520 2.349 2.326
16 2.698 0 2.577 2.628 2.520 2.349
17 2.814 0 2.698 2.577 2.628 2.520
18 2.968 0 2.814 2.698 2.577 2.628
19 3.041 0 2.968 2.814 2.698 2.577
20 3.278 0 3.041 2.968 2.814 2.698
21 3.328 0 3.278 3.041 2.968 2.814
22 3.500 0 3.328 3.278 3.041 2.968
23 3.563 0 3.500 3.328 3.278 3.041
24 3.569 0 3.563 3.500 3.328 3.278
25 3.690 0 3.569 3.563 3.500 3.328
26 3.819 0 3.690 3.569 3.563 3.500
27 3.790 0 3.819 3.690 3.569 3.563
28 3.956 0 3.790 3.819 3.690 3.569
29 4.063 0 3.956 3.790 3.819 3.690
30 4.047 0 4.063 3.956 3.790 3.819
31 4.029 0 4.047 4.063 3.956 3.790
32 3.941 0 4.029 4.047 4.063 3.956
33 4.022 0 3.941 4.029 4.047 4.063
34 3.879 0 4.022 3.941 4.029 4.047
35 4.022 0 3.879 4.022 3.941 4.029
36 4.028 0 4.022 3.879 4.022 3.941
37 4.091 0 4.028 4.022 3.879 4.022
38 3.987 0 4.091 4.028 4.022 3.879
39 4.010 0 3.987 4.091 4.028 4.022
40 4.007 0 4.010 3.987 4.091 4.028
41 4.191 0 4.007 4.010 3.987 4.091
42 4.299 0 4.191 4.007 4.010 3.987
43 4.273 0 4.299 4.191 4.007 4.010
44 3.820 0 4.273 4.299 4.191 4.007
45 3.150 1 3.820 4.273 4.299 4.191
46 2.486 1 3.150 3.820 4.273 4.299
47 1.812 1 2.486 3.150 3.820 4.273
48 1.257 1 1.812 2.486 3.150 3.820
49 1.062 1 1.257 1.812 2.486 3.150
50 0.842 1 1.062 1.257 1.812 2.486
51 0.782 1 0.842 1.062 1.257 1.812
52 0.698 1 0.782 0.842 1.062 1.257
53 0.358 1 0.698 0.782 0.842 1.062
54 0.347 1 0.358 0.698 0.782 0.842
55 0.363 1 0.347 0.358 0.698 0.782
56 0.359 1 0.363 0.347 0.358 0.698
57 0.355 1 0.359 0.363 0.347 0.358
> 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`
0.2107 -0.2560 1.3942 -0.2798 -0.3449 0.1696
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.37934 -0.08599 -0.02257 0.09244 0.21546
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.21066 0.06980 3.018 0.00397 **
X -0.25603 0.08016 -3.194 0.00241 **
`Yt-1` 1.39419 0.15003 9.293 1.48e-12 ***
`Yt-2` -0.27978 0.24478 -1.143 0.25839
`Yt-3` -0.34488 0.24277 -1.421 0.16152
`Yt-4` 0.16957 0.13418 1.264 0.21209
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.1262 on 51 degrees of freedom
Multiple R-squared: 0.9905, Adjusted R-squared: 0.9896
F-statistic: 1065 on 5 and 51 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.0036601667 0.007320333 0.9963398
[2,] 0.0510923141 0.102184628 0.9489077
[3,] 0.0198462824 0.039692565 0.9801537
[4,] 0.0175675603 0.035135121 0.9824324
[5,] 0.0279969910 0.055993982 0.9720030
[6,] 0.0129068312 0.025813662 0.9870932
[7,] 0.0126125215 0.025225043 0.9873875
[8,] 0.0065098738 0.013019748 0.9934901
[9,] 0.0029184684 0.005836937 0.9970815
[10,] 0.0165622874 0.033124575 0.9834377
[11,] 0.0144926298 0.028985260 0.9855074
[12,] 0.0136885094 0.027377019 0.9863115
[13,] 0.0238407911 0.047681582 0.9761592
[14,] 0.0132665592 0.026533118 0.9867334
[15,] 0.0180411557 0.036082311 0.9819588
[16,] 0.0205701601 0.041140320 0.9794298
[17,] 0.0117667718 0.023533544 0.9882332
[18,] 0.0074157778 0.014831556 0.9925842
[19,] 0.0070972941 0.014194588 0.9929027
[20,] 0.0054273677 0.010854735 0.9945726
[21,] 0.0033948443 0.006789689 0.9966052
[22,] 0.0021061279 0.004212256 0.9978939
[23,] 0.0026926398 0.005385280 0.9973074
[24,] 0.0029752627 0.005950525 0.9970247
[25,] 0.0029174299 0.005834860 0.9970826
[26,] 0.0035727872 0.007145574 0.9964272
[27,] 0.0064827258 0.012965452 0.9935173
[28,] 0.0034572164 0.006914433 0.9965428
[29,] 0.0021382658 0.004276532 0.9978617
[30,] 0.0026021505 0.005204301 0.9973978
[31,] 0.0014557551 0.002911510 0.9985442
[32,] 0.0006933646 0.001386729 0.9993066
[33,] 0.0045486456 0.009097291 0.9954514
[34,] 0.0123871498 0.024774300 0.9876129
[35,] 0.0843416647 0.168683329 0.9156583
[36,] 0.3073556140 0.614711228 0.6926444
[37,] 0.2946413040 0.589282608 0.7053587
[38,] 0.3915469895 0.783093979 0.6084530
[39,] 0.3840121232 0.768024246 0.6159879
[40,] 0.2551337984 0.510267597 0.7448662
> postscript(file="/var/www/html/rcomp/tmp/1qifq1258619688.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/2b76s1258619688.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/3mtwz1258619688.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/45wqm1258619688.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/56gxf1258619688.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
-0.0873171079 -0.0585355409 -0.1019271272 -0.0933693453 -0.0661722971
6 7 8 9 10
-0.1010376012 -0.0499714022 -0.1211867715 -0.0613147855 0.1080573544
11 12 13 14 15
-0.1164299634 -0.0988507729 0.1163763937 -0.0225687393 -0.1768453406
16 17 18 19 20
0.1005479184 0.0418332388 0.0320586118 -0.0268143502 0.1709836502
21 22 23 24 25
-0.0555740425 0.1120864390 0.0186321469 -0.0380234922 0.1430776520
26 27 28 29 30
0.0976212949 -0.0859893681 0.1972459135 0.0886685798 -0.0619420095
31 32 33 34 35
0.0344679644 -0.0241594072 0.1508315363 -0.1332127945 0.2045211874
36 37 38 39 40
0.0140009344 0.0455918226 -0.0709981277 0.0924446518 0.0489912739
41 42 43 44 45
0.1970589459 0.0732560521 -0.0567719219 -0.3793412534 -0.1629695090
46 47 48 49 50
-0.0468824674 -0.1344122533 -0.0897546626 0.1850619437 -0.0382018505
51 52 53 54 55
0.0768447233 0.0418036383 -0.2406784015 0.2154563541 0.1328726064
56 57
0.0004738653 0.0603860133
> postscript(file="/var/www/html/rcomp/tmp/6h55m1258619688.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 -0.0873171079 NA
1 -0.0585355409 -0.0873171079
2 -0.1019271272 -0.0585355409
3 -0.0933693453 -0.1019271272
4 -0.0661722971 -0.0933693453
5 -0.1010376012 -0.0661722971
6 -0.0499714022 -0.1010376012
7 -0.1211867715 -0.0499714022
8 -0.0613147855 -0.1211867715
9 0.1080573544 -0.0613147855
10 -0.1164299634 0.1080573544
11 -0.0988507729 -0.1164299634
12 0.1163763937 -0.0988507729
13 -0.0225687393 0.1163763937
14 -0.1768453406 -0.0225687393
15 0.1005479184 -0.1768453406
16 0.0418332388 0.1005479184
17 0.0320586118 0.0418332388
18 -0.0268143502 0.0320586118
19 0.1709836502 -0.0268143502
20 -0.0555740425 0.1709836502
21 0.1120864390 -0.0555740425
22 0.0186321469 0.1120864390
23 -0.0380234922 0.0186321469
24 0.1430776520 -0.0380234922
25 0.0976212949 0.1430776520
26 -0.0859893681 0.0976212949
27 0.1972459135 -0.0859893681
28 0.0886685798 0.1972459135
29 -0.0619420095 0.0886685798
30 0.0344679644 -0.0619420095
31 -0.0241594072 0.0344679644
32 0.1508315363 -0.0241594072
33 -0.1332127945 0.1508315363
34 0.2045211874 -0.1332127945
35 0.0140009344 0.2045211874
36 0.0455918226 0.0140009344
37 -0.0709981277 0.0455918226
38 0.0924446518 -0.0709981277
39 0.0489912739 0.0924446518
40 0.1970589459 0.0489912739
41 0.0732560521 0.1970589459
42 -0.0567719219 0.0732560521
43 -0.3793412534 -0.0567719219
44 -0.1629695090 -0.3793412534
45 -0.0468824674 -0.1629695090
46 -0.1344122533 -0.0468824674
47 -0.0897546626 -0.1344122533
48 0.1850619437 -0.0897546626
49 -0.0382018505 0.1850619437
50 0.0768447233 -0.0382018505
51 0.0418036383 0.0768447233
52 -0.2406784015 0.0418036383
53 0.2154563541 -0.2406784015
54 0.1328726064 0.2154563541
55 0.0004738653 0.1328726064
56 0.0603860133 0.0004738653
57 NA 0.0603860133
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.0585355409 -0.0873171079
[2,] -0.1019271272 -0.0585355409
[3,] -0.0933693453 -0.1019271272
[4,] -0.0661722971 -0.0933693453
[5,] -0.1010376012 -0.0661722971
[6,] -0.0499714022 -0.1010376012
[7,] -0.1211867715 -0.0499714022
[8,] -0.0613147855 -0.1211867715
[9,] 0.1080573544 -0.0613147855
[10,] -0.1164299634 0.1080573544
[11,] -0.0988507729 -0.1164299634
[12,] 0.1163763937 -0.0988507729
[13,] -0.0225687393 0.1163763937
[14,] -0.1768453406 -0.0225687393
[15,] 0.1005479184 -0.1768453406
[16,] 0.0418332388 0.1005479184
[17,] 0.0320586118 0.0418332388
[18,] -0.0268143502 0.0320586118
[19,] 0.1709836502 -0.0268143502
[20,] -0.0555740425 0.1709836502
[21,] 0.1120864390 -0.0555740425
[22,] 0.0186321469 0.1120864390
[23,] -0.0380234922 0.0186321469
[24,] 0.1430776520 -0.0380234922
[25,] 0.0976212949 0.1430776520
[26,] -0.0859893681 0.0976212949
[27,] 0.1972459135 -0.0859893681
[28,] 0.0886685798 0.1972459135
[29,] -0.0619420095 0.0886685798
[30,] 0.0344679644 -0.0619420095
[31,] -0.0241594072 0.0344679644
[32,] 0.1508315363 -0.0241594072
[33,] -0.1332127945 0.1508315363
[34,] 0.2045211874 -0.1332127945
[35,] 0.0140009344 0.2045211874
[36,] 0.0455918226 0.0140009344
[37,] -0.0709981277 0.0455918226
[38,] 0.0924446518 -0.0709981277
[39,] 0.0489912739 0.0924446518
[40,] 0.1970589459 0.0489912739
[41,] 0.0732560521 0.1970589459
[42,] -0.0567719219 0.0732560521
[43,] -0.3793412534 -0.0567719219
[44,] -0.1629695090 -0.3793412534
[45,] -0.0468824674 -0.1629695090
[46,] -0.1344122533 -0.0468824674
[47,] -0.0897546626 -0.1344122533
[48,] 0.1850619437 -0.0897546626
[49,] -0.0382018505 0.1850619437
[50,] 0.0768447233 -0.0382018505
[51,] 0.0418036383 0.0768447233
[52,] -0.2406784015 0.0418036383
[53,] 0.2154563541 -0.2406784015
[54,] 0.1328726064 0.2154563541
[55,] 0.0004738653 0.1328726064
[56,] 0.0603860133 0.0004738653
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.0585355409 -0.0873171079
2 -0.1019271272 -0.0585355409
3 -0.0933693453 -0.1019271272
4 -0.0661722971 -0.0933693453
5 -0.1010376012 -0.0661722971
6 -0.0499714022 -0.1010376012
7 -0.1211867715 -0.0499714022
8 -0.0613147855 -0.1211867715
9 0.1080573544 -0.0613147855
10 -0.1164299634 0.1080573544
11 -0.0988507729 -0.1164299634
12 0.1163763937 -0.0988507729
13 -0.0225687393 0.1163763937
14 -0.1768453406 -0.0225687393
15 0.1005479184 -0.1768453406
16 0.0418332388 0.1005479184
17 0.0320586118 0.0418332388
18 -0.0268143502 0.0320586118
19 0.1709836502 -0.0268143502
20 -0.0555740425 0.1709836502
21 0.1120864390 -0.0555740425
22 0.0186321469 0.1120864390
23 -0.0380234922 0.0186321469
24 0.1430776520 -0.0380234922
25 0.0976212949 0.1430776520
26 -0.0859893681 0.0976212949
27 0.1972459135 -0.0859893681
28 0.0886685798 0.1972459135
29 -0.0619420095 0.0886685798
30 0.0344679644 -0.0619420095
31 -0.0241594072 0.0344679644
32 0.1508315363 -0.0241594072
33 -0.1332127945 0.1508315363
34 0.2045211874 -0.1332127945
35 0.0140009344 0.2045211874
36 0.0455918226 0.0140009344
37 -0.0709981277 0.0455918226
38 0.0924446518 -0.0709981277
39 0.0489912739 0.0924446518
40 0.1970589459 0.0489912739
41 0.0732560521 0.1970589459
42 -0.0567719219 0.0732560521
43 -0.3793412534 -0.0567719219
44 -0.1629695090 -0.3793412534
45 -0.0468824674 -0.1629695090
46 -0.1344122533 -0.0468824674
47 -0.0897546626 -0.1344122533
48 0.1850619437 -0.0897546626
49 -0.0382018505 0.1850619437
50 0.0768447233 -0.0382018505
51 0.0418036383 0.0768447233
52 -0.2406784015 0.0418036383
53 0.2154563541 -0.2406784015
54 0.1328726064 0.2154563541
55 0.0004738653 0.1328726064
56 0.0603860133 0.0004738653
> 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/7oc3g1258619688.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/8glm51258619688.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/9i8vz1258619688.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/10o1ma1258619688.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/11f5mn1258619688.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/126jpb1258619688.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/13y6gw1258619689.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/141i671258619689.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/15t3v81258619689.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/1673581258619689.tab")
+ }
>
> system("convert tmp/1qifq1258619688.ps tmp/1qifq1258619688.png")
> system("convert tmp/2b76s1258619688.ps tmp/2b76s1258619688.png")
> system("convert tmp/3mtwz1258619688.ps tmp/3mtwz1258619688.png")
> system("convert tmp/45wqm1258619688.ps tmp/45wqm1258619688.png")
> system("convert tmp/56gxf1258619688.ps tmp/56gxf1258619688.png")
> system("convert tmp/6h55m1258619688.ps tmp/6h55m1258619688.png")
> system("convert tmp/7oc3g1258619688.ps tmp/7oc3g1258619688.png")
> system("convert tmp/8glm51258619688.ps tmp/8glm51258619688.png")
> system("convert tmp/9i8vz1258619688.ps tmp/9i8vz1258619688.png")
> system("convert tmp/10o1ma1258619688.ps tmp/10o1ma1258619688.png")
>
>
> proc.time()
user system elapsed
2.413 1.580 9.049