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(1318
+ ,1427
+ ,1081
+ ,831
+ ,557
+ ,280
+ ,1578
+ ,934
+ ,1318
+ ,1081
+ ,831
+ ,557
+ ,1859
+ ,709
+ ,1578
+ ,1318
+ ,1081
+ ,831
+ ,2141
+ ,1186
+ ,1859
+ ,1578
+ ,1318
+ ,1081
+ ,2428
+ ,986
+ ,2141
+ ,1859
+ ,1578
+ ,1318
+ ,2715
+ ,1033
+ ,2428
+ ,2141
+ ,1859
+ ,1578
+ ,3004
+ ,1257
+ ,2715
+ ,2428
+ ,2141
+ ,1859
+ ,3309
+ ,1105
+ ,3004
+ ,2715
+ ,2428
+ ,2141
+ ,269
+ ,1179
+ ,3309
+ ,3004
+ ,2715
+ ,2428
+ ,537
+ ,1092
+ ,269
+ ,3309
+ ,3004
+ ,2715
+ ,813
+ ,1092
+ ,537
+ ,269
+ ,3309
+ ,3004
+ ,1068
+ ,1087
+ ,813
+ ,537
+ ,269
+ ,3309
+ ,1411
+ ,2028
+ ,1068
+ ,813
+ ,537
+ ,269
+ ,1675
+ ,2039
+ ,1411
+ ,1068
+ ,813
+ ,537
+ ,1958
+ ,2010
+ ,1675
+ ,1411
+ ,1068
+ ,813
+ ,2242
+ ,754
+ ,1958
+ ,1675
+ ,1411
+ ,1068
+ ,2524
+ ,760
+ ,2242
+ ,1958
+ ,1675
+ ,1411
+ ,2836
+ ,715
+ ,2524
+ ,2242
+ ,1958
+ ,1675
+ ,3143
+ ,855
+ ,2836
+ ,2524
+ ,2242
+ ,1958
+ ,3522
+ ,971
+ ,3143
+ ,2836
+ ,2524
+ ,2242
+ ,285
+ ,815
+ ,3522
+ ,3143
+ ,2836
+ ,2524
+ ,574
+ ,915
+ ,285
+ ,3522
+ ,3143
+ ,2836
+ ,865
+ ,843
+ ,574
+ ,285
+ ,3522
+ ,3143
+ ,1147
+ ,761
+ ,865
+ ,574
+ ,285
+ ,3522
+ ,1516
+ ,1858
+ ,1147
+ ,865
+ ,574
+ ,285
+ ,1789
+ ,2968
+ ,1516
+ ,1147
+ ,865
+ ,574
+ ,2087
+ ,4061
+ ,1789
+ ,1516
+ ,1147
+ ,865
+ ,2372
+ ,3661
+ ,2087
+ ,1789
+ ,1516
+ ,1147
+ ,2669
+ ,3269
+ ,2372
+ ,2087
+ ,1789
+ ,1516
+ ,2966
+ ,2857
+ ,2669
+ ,2372
+ ,2087
+ ,1789
+ ,3270
+ ,2568
+ ,2966
+ ,2669
+ ,2372
+ ,2087
+ ,3652
+ ,2274
+ ,3270
+ ,2966
+ ,2669
+ ,2372
+ ,329
+ ,1987
+ ,3652
+ ,3270
+ ,2966
+ ,2669
+ ,658
+ ,683
+ ,329
+ ,3652
+ ,3270
+ ,2966
+ ,988
+ ,381
+ ,658
+ ,329
+ ,3652
+ ,3270
+ ,1303
+ ,71
+ ,988
+ ,658
+ ,329
+ ,3652
+ ,1603
+ ,1772
+ ,1303
+ ,988
+ ,658
+ ,329
+ ,1929
+ ,3485
+ ,1603
+ ,1303
+ ,988
+ ,658
+ ,2235
+ ,5181
+ ,1929
+ ,1603
+ ,1303
+ ,988
+ ,2544
+ ,4479
+ ,2235
+ ,1929
+ ,1603
+ ,1303
+ ,2872
+ ,3782
+ ,2544
+ ,2235
+ ,1929
+ ,1603
+ ,3198
+ ,3067
+ ,2872
+ ,2544
+ ,2235
+ ,1929
+ ,3544
+ ,2489
+ ,3198
+ ,2872
+ ,2544
+ ,2235
+ ,3903
+ ,1903
+ ,3544
+ ,3198
+ ,2872
+ ,2544
+ ,332
+ ,1330
+ ,3903
+ ,3544
+ ,3198
+ ,2872
+ ,665
+ ,736
+ ,332
+ ,3903
+ ,3544
+ ,3198
+ ,1001
+ ,483
+ ,665
+ ,332
+ ,3903
+ ,3544
+ ,1329
+ ,242
+ ,1001
+ ,665
+ ,332
+ ,3903
+ ,1639
+ ,1334
+ ,1329
+ ,1001
+ ,665
+ ,332
+ ,1975
+ ,2423
+ ,1639
+ ,1329
+ ,1001
+ ,665
+ ,2304
+ ,3523
+ ,1975
+ ,1639
+ ,1329
+ ,1001
+ ,2640
+ ,2986
+ ,2304
+ ,1975
+ ,1639
+ ,1329
+ ,2992
+ ,2462
+ ,2640
+ ,2304
+ ,1975
+ ,1639
+ ,3330
+ ,1908
+ ,2992
+ ,2640
+ ,2304
+ ,1975
+ ,3690
+ ,1575
+ ,3330
+ ,2992
+ ,2640
+ ,2304
+ ,4063
+ ,1237
+ ,3690
+ ,3330
+ ,2992
+ ,2640)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),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 X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 1318 1427 1081 831 557 280 1 0 0 0 0 0 0 0 0 0 0 1
2 1578 934 1318 1081 831 557 0 1 0 0 0 0 0 0 0 0 0 2
3 1859 709 1578 1318 1081 831 0 0 1 0 0 0 0 0 0 0 0 3
4 2141 1186 1859 1578 1318 1081 0 0 0 1 0 0 0 0 0 0 0 4
5 2428 986 2141 1859 1578 1318 0 0 0 0 1 0 0 0 0 0 0 5
6 2715 1033 2428 2141 1859 1578 0 0 0 0 0 1 0 0 0 0 0 6
7 3004 1257 2715 2428 2141 1859 0 0 0 0 0 0 1 0 0 0 0 7
8 3309 1105 3004 2715 2428 2141 0 0 0 0 0 0 0 1 0 0 0 8
9 269 1179 3309 3004 2715 2428 0 0 0 0 0 0 0 0 1 0 0 9
10 537 1092 269 3309 3004 2715 0 0 0 0 0 0 0 0 0 1 0 10
11 813 1092 537 269 3309 3004 0 0 0 0 0 0 0 0 0 0 1 11
12 1068 1087 813 537 269 3309 0 0 0 0 0 0 0 0 0 0 0 12
13 1411 2028 1068 813 537 269 1 0 0 0 0 0 0 0 0 0 0 13
14 1675 2039 1411 1068 813 537 0 1 0 0 0 0 0 0 0 0 0 14
15 1958 2010 1675 1411 1068 813 0 0 1 0 0 0 0 0 0 0 0 15
16 2242 754 1958 1675 1411 1068 0 0 0 1 0 0 0 0 0 0 0 16
17 2524 760 2242 1958 1675 1411 0 0 0 0 1 0 0 0 0 0 0 17
18 2836 715 2524 2242 1958 1675 0 0 0 0 0 1 0 0 0 0 0 18
19 3143 855 2836 2524 2242 1958 0 0 0 0 0 0 1 0 0 0 0 19
20 3522 971 3143 2836 2524 2242 0 0 0 0 0 0 0 1 0 0 0 20
21 285 815 3522 3143 2836 2524 0 0 0 0 0 0 0 0 1 0 0 21
22 574 915 285 3522 3143 2836 0 0 0 0 0 0 0 0 0 1 0 22
23 865 843 574 285 3522 3143 0 0 0 0 0 0 0 0 0 0 1 23
24 1147 761 865 574 285 3522 0 0 0 0 0 0 0 0 0 0 0 24
25 1516 1858 1147 865 574 285 1 0 0 0 0 0 0 0 0 0 0 25
26 1789 2968 1516 1147 865 574 0 1 0 0 0 0 0 0 0 0 0 26
27 2087 4061 1789 1516 1147 865 0 0 1 0 0 0 0 0 0 0 0 27
28 2372 3661 2087 1789 1516 1147 0 0 0 1 0 0 0 0 0 0 0 28
29 2669 3269 2372 2087 1789 1516 0 0 0 0 1 0 0 0 0 0 0 29
30 2966 2857 2669 2372 2087 1789 0 0 0 0 0 1 0 0 0 0 0 30
31 3270 2568 2966 2669 2372 2087 0 0 0 0 0 0 1 0 0 0 0 31
32 3652 2274 3270 2966 2669 2372 0 0 0 0 0 0 0 1 0 0 0 32
33 329 1987 3652 3270 2966 2669 0 0 0 0 0 0 0 0 1 0 0 33
34 658 683 329 3652 3270 2966 0 0 0 0 0 0 0 0 0 1 0 34
35 988 381 658 329 3652 3270 0 0 0 0 0 0 0 0 0 0 1 35
36 1303 71 988 658 329 3652 0 0 0 0 0 0 0 0 0 0 0 36
37 1603 1772 1303 988 658 329 1 0 0 0 0 0 0 0 0 0 0 37
38 1929 3485 1603 1303 988 658 0 1 0 0 0 0 0 0 0 0 0 38
39 2235 5181 1929 1603 1303 988 0 0 1 0 0 0 0 0 0 0 0 39
40 2544 4479 2235 1929 1603 1303 0 0 0 1 0 0 0 0 0 0 0 40
41 2872 3782 2544 2235 1929 1603 0 0 0 0 1 0 0 0 0 0 0 41
42 3198 3067 2872 2544 2235 1929 0 0 0 0 0 1 0 0 0 0 0 42
43 3544 2489 3198 2872 2544 2235 0 0 0 0 0 0 1 0 0 0 0 43
44 3903 1903 3544 3198 2872 2544 0 0 0 0 0 0 0 1 0 0 0 44
45 332 1330 3903 3544 3198 2872 0 0 0 0 0 0 0 0 1 0 0 45
46 665 736 332 3903 3544 3198 0 0 0 0 0 0 0 0 0 1 0 46
47 1001 483 665 332 3903 3544 0 0 0 0 0 0 0 0 0 0 1 47
48 1329 242 1001 665 332 3903 0 0 0 0 0 0 0 0 0 0 0 48
49 1639 1334 1329 1001 665 332 1 0 0 0 0 0 0 0 0 0 0 49
50 1975 2423 1639 1329 1001 665 0 1 0 0 0 0 0 0 0 0 0 50
51 2304 3523 1975 1639 1329 1001 0 0 1 0 0 0 0 0 0 0 0 51
52 2640 2986 2304 1975 1639 1329 0 0 0 1 0 0 0 0 0 0 0 52
53 2992 2462 2640 2304 1975 1639 0 0 0 0 1 0 0 0 0 0 0 53
54 3330 1908 2992 2640 2304 1975 0 0 0 0 0 1 0 0 0 0 0 54
55 3690 1575 3330 2992 2640 2304 0 0 0 0 0 0 1 0 0 0 0 55
56 4063 1237 3690 3330 2992 2640 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) X Y1 Y2 Y3 Y4
6.339e+02 6.699e-03 6.564e-01 -4.668e-02 -5.496e-02 -3.571e-02
M1 M2 M3 M4 M5 M6
3.787e+01 1.561e+02 2.953e+02 4.373e+02 5.888e+02 7.361e+02
M7 M8 M9 M10 M11 t
8.903e+02 1.078e+03 -2.425e+03 8.377e+01 6.517e+01 4.867e+00
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-222.699 -13.537 -5.647 22.293 212.820
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.339e+02 5.400e+02 1.174 0.247747
X 6.699e-03 1.108e-02 0.605 0.549036
Y1 6.564e-01 1.635e-01 4.014 0.000271 ***
Y2 -4.668e-02 1.949e-01 -0.240 0.811993
Y3 -5.496e-02 1.946e-01 -0.282 0.779128
Y4 -3.571e-02 1.586e-01 -0.225 0.823028
M1 3.787e+01 5.524e+02 0.069 0.945704
M2 1.561e+02 5.410e+02 0.289 0.774452
M3 2.953e+02 5.312e+02 0.556 0.581509
M4 4.373e+02 5.335e+02 0.820 0.417524
M5 5.888e+02 5.334e+02 1.104 0.276565
M6 7.361e+02 5.414e+02 1.360 0.181962
M7 8.903e+02 5.521e+02 1.613 0.115087
M8 1.078e+03 5.685e+02 1.897 0.065506 .
M9 -2.425e+03 5.866e+02 -4.135 0.000189 ***
M10 8.377e+01 7.060e+02 0.119 0.906180
M11 6.517e+01 7.042e+02 0.093 0.926751
t 4.867e+00 1.534e+00 3.172 0.002994 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 61.09 on 38 degrees of freedom
Multiple R-squared: 0.9977, Adjusted R-squared: 0.9966
F-statistic: 958.8 on 17 and 38 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.68820419 6.235916e-01 3.117958e-01
[2,] 0.65850972 6.829806e-01 3.414903e-01
[3,] 0.52570444 9.485911e-01 4.742956e-01
[4,] 0.46588290 9.317658e-01 5.341171e-01
[5,] 0.50341540 9.931692e-01 4.965846e-01
[6,] 0.37537135 7.507427e-01 6.246287e-01
[7,] 0.32598543 6.519709e-01 6.740146e-01
[8,] 0.22559084 4.511817e-01 7.744092e-01
[9,] 0.16177392 3.235478e-01 8.382261e-01
[10,] 0.09650170 1.930034e-01 9.034983e-01
[11,] 0.08721395 1.744279e-01 9.127860e-01
[12,] 0.26194279 5.238856e-01 7.380572e-01
[13,] 0.99998642 2.715044e-05 1.357522e-05
[14,] 0.99987236 2.552726e-04 1.276363e-04
[15,] 0.99944194 1.116119e-03 5.580597e-04
> postscript(file="/var/www/html/rcomp/tmp/1zxdm1258725607.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/2htco1258725607.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/34y561258725607.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/42krk1258725607.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/5h3nd1258725607.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
1.645111 22.862660 25.264962 6.826328 -10.442723 -26.384881
7 8 9 10 11 12
-47.434310 -84.561536 212.820217 3.302093 2.301949 -7.217616
13 14 15 16 17 18
38.414499 -9.300487 -3.542742 -3.493244 -24.356585 -11.054318
19 20 21 22 23 24
-30.003000 -5.777193 49.607677 -5.516629 -9.304112 -8.358943
25 26 27 28 29 30
39.324850 -20.984069 -10.416948 -22.134464 -23.864669 -31.757276
31 32 33 34 35 36
-39.695317 -7.593692 -39.729276 10.441565 16.982471 24.102841
37 38 39 40 41 42
-21.972824 17.082518 -3.193184 5.721061 22.103031 28.344539
43 44 45 46 47 48
48.358822 35.762461 -222.698618 -8.227029 -9.980308 -8.526281
49 50 51 52 53 54
-57.411636 -9.660622 -8.112088 13.080320 36.560947 40.851936
55 56
68.773806 62.169960
> postscript(file="/var/www/html/rcomp/tmp/64asl1258725607.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 1.645111 NA
1 22.862660 1.645111
2 25.264962 22.862660
3 6.826328 25.264962
4 -10.442723 6.826328
5 -26.384881 -10.442723
6 -47.434310 -26.384881
7 -84.561536 -47.434310
8 212.820217 -84.561536
9 3.302093 212.820217
10 2.301949 3.302093
11 -7.217616 2.301949
12 38.414499 -7.217616
13 -9.300487 38.414499
14 -3.542742 -9.300487
15 -3.493244 -3.542742
16 -24.356585 -3.493244
17 -11.054318 -24.356585
18 -30.003000 -11.054318
19 -5.777193 -30.003000
20 49.607677 -5.777193
21 -5.516629 49.607677
22 -9.304112 -5.516629
23 -8.358943 -9.304112
24 39.324850 -8.358943
25 -20.984069 39.324850
26 -10.416948 -20.984069
27 -22.134464 -10.416948
28 -23.864669 -22.134464
29 -31.757276 -23.864669
30 -39.695317 -31.757276
31 -7.593692 -39.695317
32 -39.729276 -7.593692
33 10.441565 -39.729276
34 16.982471 10.441565
35 24.102841 16.982471
36 -21.972824 24.102841
37 17.082518 -21.972824
38 -3.193184 17.082518
39 5.721061 -3.193184
40 22.103031 5.721061
41 28.344539 22.103031
42 48.358822 28.344539
43 35.762461 48.358822
44 -222.698618 35.762461
45 -8.227029 -222.698618
46 -9.980308 -8.227029
47 -8.526281 -9.980308
48 -57.411636 -8.526281
49 -9.660622 -57.411636
50 -8.112088 -9.660622
51 13.080320 -8.112088
52 36.560947 13.080320
53 40.851936 36.560947
54 68.773806 40.851936
55 62.169960 68.773806
56 NA 62.169960
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 22.862660 1.645111
[2,] 25.264962 22.862660
[3,] 6.826328 25.264962
[4,] -10.442723 6.826328
[5,] -26.384881 -10.442723
[6,] -47.434310 -26.384881
[7,] -84.561536 -47.434310
[8,] 212.820217 -84.561536
[9,] 3.302093 212.820217
[10,] 2.301949 3.302093
[11,] -7.217616 2.301949
[12,] 38.414499 -7.217616
[13,] -9.300487 38.414499
[14,] -3.542742 -9.300487
[15,] -3.493244 -3.542742
[16,] -24.356585 -3.493244
[17,] -11.054318 -24.356585
[18,] -30.003000 -11.054318
[19,] -5.777193 -30.003000
[20,] 49.607677 -5.777193
[21,] -5.516629 49.607677
[22,] -9.304112 -5.516629
[23,] -8.358943 -9.304112
[24,] 39.324850 -8.358943
[25,] -20.984069 39.324850
[26,] -10.416948 -20.984069
[27,] -22.134464 -10.416948
[28,] -23.864669 -22.134464
[29,] -31.757276 -23.864669
[30,] -39.695317 -31.757276
[31,] -7.593692 -39.695317
[32,] -39.729276 -7.593692
[33,] 10.441565 -39.729276
[34,] 16.982471 10.441565
[35,] 24.102841 16.982471
[36,] -21.972824 24.102841
[37,] 17.082518 -21.972824
[38,] -3.193184 17.082518
[39,] 5.721061 -3.193184
[40,] 22.103031 5.721061
[41,] 28.344539 22.103031
[42,] 48.358822 28.344539
[43,] 35.762461 48.358822
[44,] -222.698618 35.762461
[45,] -8.227029 -222.698618
[46,] -9.980308 -8.227029
[47,] -8.526281 -9.980308
[48,] -57.411636 -8.526281
[49,] -9.660622 -57.411636
[50,] -8.112088 -9.660622
[51,] 13.080320 -8.112088
[52,] 36.560947 13.080320
[53,] 40.851936 36.560947
[54,] 68.773806 40.851936
[55,] 62.169960 68.773806
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 22.862660 1.645111
2 25.264962 22.862660
3 6.826328 25.264962
4 -10.442723 6.826328
5 -26.384881 -10.442723
6 -47.434310 -26.384881
7 -84.561536 -47.434310
8 212.820217 -84.561536
9 3.302093 212.820217
10 2.301949 3.302093
11 -7.217616 2.301949
12 38.414499 -7.217616
13 -9.300487 38.414499
14 -3.542742 -9.300487
15 -3.493244 -3.542742
16 -24.356585 -3.493244
17 -11.054318 -24.356585
18 -30.003000 -11.054318
19 -5.777193 -30.003000
20 49.607677 -5.777193
21 -5.516629 49.607677
22 -9.304112 -5.516629
23 -8.358943 -9.304112
24 39.324850 -8.358943
25 -20.984069 39.324850
26 -10.416948 -20.984069
27 -22.134464 -10.416948
28 -23.864669 -22.134464
29 -31.757276 -23.864669
30 -39.695317 -31.757276
31 -7.593692 -39.695317
32 -39.729276 -7.593692
33 10.441565 -39.729276
34 16.982471 10.441565
35 24.102841 16.982471
36 -21.972824 24.102841
37 17.082518 -21.972824
38 -3.193184 17.082518
39 5.721061 -3.193184
40 22.103031 5.721061
41 28.344539 22.103031
42 48.358822 28.344539
43 35.762461 48.358822
44 -222.698618 35.762461
45 -8.227029 -222.698618
46 -9.980308 -8.227029
47 -8.526281 -9.980308
48 -57.411636 -8.526281
49 -9.660622 -57.411636
50 -8.112088 -9.660622
51 13.080320 -8.112088
52 36.560947 13.080320
53 40.851936 36.560947
54 68.773806 40.851936
55 62.169960 68.773806
> 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/7ejhd1258725607.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/89jx71258725607.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/9z6ta1258725607.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/10bcky1258725607.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/11uf711258725607.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/126bgc1258725607.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/13qh4m1258725607.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/14khpv1258725607.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/157jh31258725607.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/16gbsl1258725607.tab")
+ }
>
> system("convert tmp/1zxdm1258725607.ps tmp/1zxdm1258725607.png")
> system("convert tmp/2htco1258725607.ps tmp/2htco1258725607.png")
> system("convert tmp/34y561258725607.ps tmp/34y561258725607.png")
> system("convert tmp/42krk1258725607.ps tmp/42krk1258725607.png")
> system("convert tmp/5h3nd1258725607.ps tmp/5h3nd1258725607.png")
> system("convert tmp/64asl1258725607.ps tmp/64asl1258725607.png")
> system("convert tmp/7ejhd1258725607.ps tmp/7ejhd1258725607.png")
> system("convert tmp/89jx71258725607.ps tmp/89jx71258725607.png")
> system("convert tmp/9z6ta1258725607.ps tmp/9z6ta1258725607.png")
> system("convert tmp/10bcky1258725607.ps tmp/10bcky1258725607.png")
>
>
> proc.time()
user system elapsed
2.302 1.550 2.771