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(9605
+ ,3024
+ ,9487
+ ,8640
+ ,1887
+ ,8700
+ ,9214
+ ,2070
+ ,9627
+ ,9567
+ ,1351
+ ,8947
+ ,8547
+ ,2218
+ ,9283
+ ,9185
+ ,2461
+ ,8829
+ ,9470
+ ,3028
+ ,9947
+ ,9123
+ ,4784
+ ,9628
+ ,9278
+ ,4975
+ ,9318
+ ,10170
+ ,4607
+ ,9605
+ ,9434
+ ,6249
+ ,8640
+ ,9655
+ ,4809
+ ,9214
+ ,9429
+ ,3157
+ ,9567
+ ,8739
+ ,1910
+ ,8547
+ ,9552
+ ,2228
+ ,9185
+ ,9784
+ ,1594
+ ,9470
+ ,9089
+ ,2467
+ ,9123
+ ,9763
+ ,2222
+ ,9278
+ ,9330
+ ,3607
+ ,10170
+ ,9144
+ ,4685
+ ,9434
+ ,9895
+ ,4962
+ ,9655
+ ,10404
+ ,5770
+ ,9429
+ ,10195
+ ,5480
+ ,8739
+ ,9987
+ ,5000
+ ,9552
+ ,9789
+ ,3228
+ ,9784
+ ,9437
+ ,1993
+ ,9089
+ ,10096
+ ,2288
+ ,9763
+ ,9776
+ ,1580
+ ,9330
+ ,9106
+ ,2111
+ ,9144
+ ,10258
+ ,2192
+ ,9895
+ ,9766
+ ,3601
+ ,10404
+ ,9826
+ ,4665
+ ,10195
+ ,9957
+ ,4876
+ ,9987
+ ,10036
+ ,5813
+ ,9789
+ ,10508
+ ,5589
+ ,9437
+ ,10146
+ ,5331
+ ,10096
+ ,10166
+ ,3075
+ ,9776
+ ,9365
+ ,2002
+ ,9106
+ ,9968
+ ,2306
+ ,10258
+ ,10123
+ ,1507
+ ,9766
+ ,9144
+ ,1992
+ ,9826
+ ,10447
+ ,2487
+ ,9957
+ ,9699
+ ,3490
+ ,10036
+ ,10451
+ ,4647
+ ,10508
+ ,10192
+ ,5594
+ ,10146
+ ,10404
+ ,5611
+ ,10166
+ ,10597
+ ,5788
+ ,9365
+ ,10633
+ ,6204
+ ,9968
+ ,10727
+ ,3013
+ ,10123
+ ,9784
+ ,1931
+ ,9144
+ ,9667
+ ,2549
+ ,10447
+ ,10297
+ ,1504
+ ,9699
+ ,9426
+ ,2090
+ ,10451
+ ,10274
+ ,2702
+ ,10192
+ ,9598
+ ,2939
+ ,10404
+ ,10400
+ ,4500
+ ,10597
+ ,9985
+ ,6208
+ ,10633
+ ,10761
+ ,6415
+ ,10727
+ ,11081
+ ,5657
+ ,9784
+ ,10297
+ ,5964
+ ,9667
+ ,10751
+ ,3163
+ ,10297
+ ,9760
+ ,1997
+ ,9426
+ ,10133
+ ,2422
+ ,10274
+ ,10806
+ ,1376
+ ,9598
+ ,9734
+ ,2202
+ ,10400
+ ,10083
+ ,2683
+ ,9985
+ ,10691
+ ,3303
+ ,10761
+ ,10446
+ ,5202
+ ,11081
+ ,10517
+ ,5231
+ ,10297
+ ,11353
+ ,4880
+ ,10751
+ ,10436
+ ,7998
+ ,9760
+ ,10721
+ ,4977
+ ,10133
+ ,10701
+ ,3531
+ ,10806
+ ,9793
+ ,2025
+ ,9734
+ ,10142
+ ,2205
+ ,10083)
+ ,dim=c(3
+ ,75)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y9')
+ ,1:75))
> y <- array(NA,dim=c(3,75),dimnames=list(c('Y','X','Y9'),1:75))
> 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 Y9 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 9605 3024 9487 1 0 0 0 0 0 0 0 0 0 0 1
2 8640 1887 8700 0 1 0 0 0 0 0 0 0 0 0 2
3 9214 2070 9627 0 0 1 0 0 0 0 0 0 0 0 3
4 9567 1351 8947 0 0 0 1 0 0 0 0 0 0 0 4
5 8547 2218 9283 0 0 0 0 1 0 0 0 0 0 0 5
6 9185 2461 8829 0 0 0 0 0 1 0 0 0 0 0 6
7 9470 3028 9947 0 0 0 0 0 0 1 0 0 0 0 7
8 9123 4784 9628 0 0 0 0 0 0 0 1 0 0 0 8
9 9278 4975 9318 0 0 0 0 0 0 0 0 1 0 0 9
10 10170 4607 9605 0 0 0 0 0 0 0 0 0 1 0 10
11 9434 6249 8640 0 0 0 0 0 0 0 0 0 0 1 11
12 9655 4809 9214 0 0 0 0 0 0 0 0 0 0 0 12
13 9429 3157 9567 1 0 0 0 0 0 0 0 0 0 0 13
14 8739 1910 8547 0 1 0 0 0 0 0 0 0 0 0 14
15 9552 2228 9185 0 0 1 0 0 0 0 0 0 0 0 15
16 9784 1594 9470 0 0 0 1 0 0 0 0 0 0 0 16
17 9089 2467 9123 0 0 0 0 1 0 0 0 0 0 0 17
18 9763 2222 9278 0 0 0 0 0 1 0 0 0 0 0 18
19 9330 3607 10170 0 0 0 0 0 0 1 0 0 0 0 19
20 9144 4685 9434 0 0 0 0 0 0 0 1 0 0 0 20
21 9895 4962 9655 0 0 0 0 0 0 0 0 1 0 0 21
22 10404 5770 9429 0 0 0 0 0 0 0 0 0 1 0 22
23 10195 5480 8739 0 0 0 0 0 0 0 0 0 0 1 23
24 9987 5000 9552 0 0 0 0 0 0 0 0 0 0 0 24
25 9789 3228 9784 1 0 0 0 0 0 0 0 0 0 0 25
26 9437 1993 9089 0 1 0 0 0 0 0 0 0 0 0 26
27 10096 2288 9763 0 0 1 0 0 0 0 0 0 0 0 27
28 9776 1580 9330 0 0 0 1 0 0 0 0 0 0 0 28
29 9106 2111 9144 0 0 0 0 1 0 0 0 0 0 0 29
30 10258 2192 9895 0 0 0 0 0 1 0 0 0 0 0 30
31 9766 3601 10404 0 0 0 0 0 0 1 0 0 0 0 31
32 9826 4665 10195 0 0 0 0 0 0 0 1 0 0 0 32
33 9957 4876 9987 0 0 0 0 0 0 0 0 1 0 0 33
34 10036 5813 9789 0 0 0 0 0 0 0 0 0 1 0 34
35 10508 5589 9437 0 0 0 0 0 0 0 0 0 0 1 35
36 10146 5331 10096 0 0 0 0 0 0 0 0 0 0 0 36
37 10166 3075 9776 1 0 0 0 0 0 0 0 0 0 0 37
38 9365 2002 9106 0 1 0 0 0 0 0 0 0 0 0 38
39 9968 2306 10258 0 0 1 0 0 0 0 0 0 0 0 39
40 10123 1507 9766 0 0 0 1 0 0 0 0 0 0 0 40
41 9144 1992 9826 0 0 0 0 1 0 0 0 0 0 0 41
42 10447 2487 9957 0 0 0 0 0 1 0 0 0 0 0 42
43 9699 3490 10036 0 0 0 0 0 0 1 0 0 0 0 43
44 10451 4647 10508 0 0 0 0 0 0 0 1 0 0 0 44
45 10192 5594 10146 0 0 0 0 0 0 0 0 1 0 0 45
46 10404 5611 10166 0 0 0 0 0 0 0 0 0 1 0 46
47 10597 5788 9365 0 0 0 0 0 0 0 0 0 0 1 47
48 10633 6204 9968 0 0 0 0 0 0 0 0 0 0 0 48
49 10727 3013 10123 1 0 0 0 0 0 0 0 0 0 0 49
50 9784 1931 9144 0 1 0 0 0 0 0 0 0 0 0 50
51 9667 2549 10447 0 0 1 0 0 0 0 0 0 0 0 51
52 10297 1504 9699 0 0 0 1 0 0 0 0 0 0 0 52
53 9426 2090 10451 0 0 0 0 1 0 0 0 0 0 0 53
54 10274 2702 10192 0 0 0 0 0 1 0 0 0 0 0 54
55 9598 2939 10404 0 0 0 0 0 0 1 0 0 0 0 55
56 10400 4500 10597 0 0 0 0 0 0 0 1 0 0 0 56
57 9985 6208 10633 0 0 0 0 0 0 0 0 1 0 0 57
58 10761 6415 10727 0 0 0 0 0 0 0 0 0 1 0 58
59 11081 5657 9784 0 0 0 0 0 0 0 0 0 0 1 59
60 10297 5964 9667 0 0 0 0 0 0 0 0 0 0 0 60
61 10751 3163 10297 1 0 0 0 0 0 0 0 0 0 0 61
62 9760 1997 9426 0 1 0 0 0 0 0 0 0 0 0 62
63 10133 2422 10274 0 0 1 0 0 0 0 0 0 0 0 63
64 10806 1376 9598 0 0 0 1 0 0 0 0 0 0 0 64
65 9734 2202 10400 0 0 0 0 1 0 0 0 0 0 0 65
66 10083 2683 9985 0 0 0 0 0 1 0 0 0 0 0 66
67 10691 3303 10761 0 0 0 0 0 0 1 0 0 0 0 67
68 10446 5202 11081 0 0 0 0 0 0 0 1 0 0 0 68
69 10517 5231 10297 0 0 0 0 0 0 0 0 1 0 0 69
70 11353 4880 10751 0 0 0 0 0 0 0 0 0 1 0 70
71 10436 7998 9760 0 0 0 0 0 0 0 0 0 0 1 71
72 10721 4977 10133 0 0 0 0 0 0 0 0 0 0 0 72
73 10701 3531 10806 1 0 0 0 0 0 0 0 0 0 0 73
74 9793 2025 9734 0 1 0 0 0 0 0 0 0 0 0 74
75 10142 2205 10083 0 0 1 0 0 0 0 0 0 0 0 75
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y9 M1 M2 M3
8102.0780 -0.2421 0.2941 -601.1665 -1457.9024 -1173.6911
M4 M5 M6 M7 M8 M9
-926.9832 -1726.2450 -840.6790 -1061.9305 -578.8196 -315.3129
M10 M11 t
251.1737 471.8318 13.4945
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-532.49 -141.69 -13.76 131.42 486.01
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8102.0780 1127.4729 7.186 1.20e-09 ***
X -0.2421 0.0725 -3.339 0.001447 **
Y9 0.2941 0.1196 2.460 0.016790 *
M1 -601.1665 208.8002 -2.879 0.005519 **
M2 -1457.9024 283.0811 -5.150 3.05e-06 ***
M3 -1173.6911 260.0354 -4.514 3.03e-05 ***
M4 -926.9832 309.3545 -2.997 0.003967 **
M5 -1726.2450 266.0222 -6.489 1.85e-08 ***
M6 -840.6790 248.8439 -3.378 0.001286 **
M7 -1061.9305 214.3825 -4.953 6.27e-06 ***
M8 -578.8196 156.0190 -3.710 0.000455 ***
M9 -315.3129 138.1179 -2.283 0.025992 *
M10 251.1737 139.9335 1.795 0.077699 .
M11 471.8318 155.9473 3.026 0.003651 **
t 13.4945 2.4167 5.584 6.01e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 231.5 on 60 degrees of freedom
Multiple R-squared: 0.8705, Adjusted R-squared: 0.8403
F-statistic: 28.81 on 14 and 60 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.63434157 0.73131686 0.36565843
[2,] 0.48476055 0.96952109 0.51523945
[3,] 0.50284809 0.99430382 0.49715191
[4,] 0.47643857 0.95287713 0.52356143
[5,] 0.48369405 0.96738811 0.51630595
[6,] 0.43623798 0.87247596 0.56376202
[7,] 0.33712691 0.67425382 0.66287309
[8,] 0.30029485 0.60058969 0.69970515
[9,] 0.28469029 0.56938058 0.71530971
[10,] 0.33252547 0.66505094 0.66747453
[11,] 0.38758502 0.77517005 0.61241498
[12,] 0.35393256 0.70786511 0.64606744
[13,] 0.29100738 0.58201476 0.70899262
[14,] 0.22790599 0.45581198 0.77209401
[15,] 0.17607676 0.35215351 0.82392324
[16,] 0.14821631 0.29643262 0.85178369
[17,] 0.26926343 0.53852686 0.73073657
[18,] 0.20543196 0.41086391 0.79456804
[19,] 0.18146016 0.36292032 0.81853984
[20,] 0.14041880 0.28083760 0.85958120
[21,] 0.10632534 0.21265068 0.89367466
[22,] 0.10290591 0.20581183 0.89709409
[23,] 0.09306445 0.18612890 0.90693555
[24,] 0.12588996 0.25177992 0.87411004
[25,] 0.14072828 0.28145656 0.85927172
[26,] 0.10775434 0.21550867 0.89224566
[27,] 0.13699058 0.27398116 0.86300942
[28,] 0.10597477 0.21194954 0.89402523
[29,] 0.12219617 0.24439235 0.87780383
[30,] 0.08998300 0.17996600 0.91001700
[31,] 0.19875676 0.39751352 0.80124324
[32,] 0.18001299 0.36002597 0.81998701
[33,] 0.18255261 0.36510523 0.81744739
[34,] 0.25801600 0.51603200 0.74198400
[35,] 0.22935170 0.45870341 0.77064830
[36,] 0.19295376 0.38590751 0.80704624
[37,] 0.15819064 0.31638127 0.84180936
[38,] 0.98736216 0.02527568 0.01263784
[39,] 0.98655879 0.02688243 0.01344121
[40,] 0.98733744 0.02532513 0.01266256
> postscript(file="/var/www/html/rcomp/tmp/1xm0i1261261513.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/2hqvd1261261513.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/33lsu1261261513.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/499vc1261261513.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/5jew91261261513.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 = 75
Frequency = 1
1 2 3 4 5 6
32.706495 -132.884126 -84.905029 33.795617 -89.340467 -158.050790
7 8 9 10 11 12
143.190761 -181.451709 -166.041511 -27.523626 -316.331687 -154.442979
13 14 15 16 17 18
-296.553308 -145.253208 259.403027 -6.113841 398.066328 68.104580
19 20 21 22 23 24
-84.142114 -289.300723 186.769204 377.878713 67.436036 -37.535566
25 26 27 28 29 30
-145.114390 251.511747 486.012168 -138.264229 160.765220 212.454150
31 32 33 34 35 36
119.654670 2.120981 -31.623784 -247.516390 39.617830 -120.315087
37 38 39 40 41 42
35.261794 14.757773 54.862100 -99.095142 -192.549013 292.710067
43 44 45 46 47 48
-27.927995 368.779301 168.518639 -201.228394 36.039105 453.758529
49 50 51 52 53 54
317.268134 243.458968 -404.821243 -68.050883 -232.561866 -59.280551
55 56 57 58 59 60
-532.490174 94.081409 -194.980129 23.511390 203.165245 -13.760588
61 62 63 64 65 66
164.479754 -9.428532 -80.625278 277.728478 -44.380203 -355.937456
67 68 69 70 71 72
381.714852 5.770741 37.357581 74.878307 -29.926529 -127.704308
73 74 75
-108.048478 -222.162622 -229.925744
> postscript(file="/var/www/html/rcomp/tmp/6gafc1261261513.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 = 75
Frequency = 1
lag(myerror, k = 1) myerror
0 32.706495 NA
1 -132.884126 32.706495
2 -84.905029 -132.884126
3 33.795617 -84.905029
4 -89.340467 33.795617
5 -158.050790 -89.340467
6 143.190761 -158.050790
7 -181.451709 143.190761
8 -166.041511 -181.451709
9 -27.523626 -166.041511
10 -316.331687 -27.523626
11 -154.442979 -316.331687
12 -296.553308 -154.442979
13 -145.253208 -296.553308
14 259.403027 -145.253208
15 -6.113841 259.403027
16 398.066328 -6.113841
17 68.104580 398.066328
18 -84.142114 68.104580
19 -289.300723 -84.142114
20 186.769204 -289.300723
21 377.878713 186.769204
22 67.436036 377.878713
23 -37.535566 67.436036
24 -145.114390 -37.535566
25 251.511747 -145.114390
26 486.012168 251.511747
27 -138.264229 486.012168
28 160.765220 -138.264229
29 212.454150 160.765220
30 119.654670 212.454150
31 2.120981 119.654670
32 -31.623784 2.120981
33 -247.516390 -31.623784
34 39.617830 -247.516390
35 -120.315087 39.617830
36 35.261794 -120.315087
37 14.757773 35.261794
38 54.862100 14.757773
39 -99.095142 54.862100
40 -192.549013 -99.095142
41 292.710067 -192.549013
42 -27.927995 292.710067
43 368.779301 -27.927995
44 168.518639 368.779301
45 -201.228394 168.518639
46 36.039105 -201.228394
47 453.758529 36.039105
48 317.268134 453.758529
49 243.458968 317.268134
50 -404.821243 243.458968
51 -68.050883 -404.821243
52 -232.561866 -68.050883
53 -59.280551 -232.561866
54 -532.490174 -59.280551
55 94.081409 -532.490174
56 -194.980129 94.081409
57 23.511390 -194.980129
58 203.165245 23.511390
59 -13.760588 203.165245
60 164.479754 -13.760588
61 -9.428532 164.479754
62 -80.625278 -9.428532
63 277.728478 -80.625278
64 -44.380203 277.728478
65 -355.937456 -44.380203
66 381.714852 -355.937456
67 5.770741 381.714852
68 37.357581 5.770741
69 74.878307 37.357581
70 -29.926529 74.878307
71 -127.704308 -29.926529
72 -108.048478 -127.704308
73 -222.162622 -108.048478
74 -229.925744 -222.162622
75 NA -229.925744
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -132.884126 32.706495
[2,] -84.905029 -132.884126
[3,] 33.795617 -84.905029
[4,] -89.340467 33.795617
[5,] -158.050790 -89.340467
[6,] 143.190761 -158.050790
[7,] -181.451709 143.190761
[8,] -166.041511 -181.451709
[9,] -27.523626 -166.041511
[10,] -316.331687 -27.523626
[11,] -154.442979 -316.331687
[12,] -296.553308 -154.442979
[13,] -145.253208 -296.553308
[14,] 259.403027 -145.253208
[15,] -6.113841 259.403027
[16,] 398.066328 -6.113841
[17,] 68.104580 398.066328
[18,] -84.142114 68.104580
[19,] -289.300723 -84.142114
[20,] 186.769204 -289.300723
[21,] 377.878713 186.769204
[22,] 67.436036 377.878713
[23,] -37.535566 67.436036
[24,] -145.114390 -37.535566
[25,] 251.511747 -145.114390
[26,] 486.012168 251.511747
[27,] -138.264229 486.012168
[28,] 160.765220 -138.264229
[29,] 212.454150 160.765220
[30,] 119.654670 212.454150
[31,] 2.120981 119.654670
[32,] -31.623784 2.120981
[33,] -247.516390 -31.623784
[34,] 39.617830 -247.516390
[35,] -120.315087 39.617830
[36,] 35.261794 -120.315087
[37,] 14.757773 35.261794
[38,] 54.862100 14.757773
[39,] -99.095142 54.862100
[40,] -192.549013 -99.095142
[41,] 292.710067 -192.549013
[42,] -27.927995 292.710067
[43,] 368.779301 -27.927995
[44,] 168.518639 368.779301
[45,] -201.228394 168.518639
[46,] 36.039105 -201.228394
[47,] 453.758529 36.039105
[48,] 317.268134 453.758529
[49,] 243.458968 317.268134
[50,] -404.821243 243.458968
[51,] -68.050883 -404.821243
[52,] -232.561866 -68.050883
[53,] -59.280551 -232.561866
[54,] -532.490174 -59.280551
[55,] 94.081409 -532.490174
[56,] -194.980129 94.081409
[57,] 23.511390 -194.980129
[58,] 203.165245 23.511390
[59,] -13.760588 203.165245
[60,] 164.479754 -13.760588
[61,] -9.428532 164.479754
[62,] -80.625278 -9.428532
[63,] 277.728478 -80.625278
[64,] -44.380203 277.728478
[65,] -355.937456 -44.380203
[66,] 381.714852 -355.937456
[67,] 5.770741 381.714852
[68,] 37.357581 5.770741
[69,] 74.878307 37.357581
[70,] -29.926529 74.878307
[71,] -127.704308 -29.926529
[72,] -108.048478 -127.704308
[73,] -222.162622 -108.048478
[74,] -229.925744 -222.162622
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -132.884126 32.706495
2 -84.905029 -132.884126
3 33.795617 -84.905029
4 -89.340467 33.795617
5 -158.050790 -89.340467
6 143.190761 -158.050790
7 -181.451709 143.190761
8 -166.041511 -181.451709
9 -27.523626 -166.041511
10 -316.331687 -27.523626
11 -154.442979 -316.331687
12 -296.553308 -154.442979
13 -145.253208 -296.553308
14 259.403027 -145.253208
15 -6.113841 259.403027
16 398.066328 -6.113841
17 68.104580 398.066328
18 -84.142114 68.104580
19 -289.300723 -84.142114
20 186.769204 -289.300723
21 377.878713 186.769204
22 67.436036 377.878713
23 -37.535566 67.436036
24 -145.114390 -37.535566
25 251.511747 -145.114390
26 486.012168 251.511747
27 -138.264229 486.012168
28 160.765220 -138.264229
29 212.454150 160.765220
30 119.654670 212.454150
31 2.120981 119.654670
32 -31.623784 2.120981
33 -247.516390 -31.623784
34 39.617830 -247.516390
35 -120.315087 39.617830
36 35.261794 -120.315087
37 14.757773 35.261794
38 54.862100 14.757773
39 -99.095142 54.862100
40 -192.549013 -99.095142
41 292.710067 -192.549013
42 -27.927995 292.710067
43 368.779301 -27.927995
44 168.518639 368.779301
45 -201.228394 168.518639
46 36.039105 -201.228394
47 453.758529 36.039105
48 317.268134 453.758529
49 243.458968 317.268134
50 -404.821243 243.458968
51 -68.050883 -404.821243
52 -232.561866 -68.050883
53 -59.280551 -232.561866
54 -532.490174 -59.280551
55 94.081409 -532.490174
56 -194.980129 94.081409
57 23.511390 -194.980129
58 203.165245 23.511390
59 -13.760588 203.165245
60 164.479754 -13.760588
61 -9.428532 164.479754
62 -80.625278 -9.428532
63 277.728478 -80.625278
64 -44.380203 277.728478
65 -355.937456 -44.380203
66 381.714852 -355.937456
67 5.770741 381.714852
68 37.357581 5.770741
69 74.878307 37.357581
70 -29.926529 74.878307
71 -127.704308 -29.926529
72 -108.048478 -127.704308
73 -222.162622 -108.048478
74 -229.925744 -222.162622
> 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/72udy1261261513.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/82x2k1261261513.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/95q5m1261261513.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/10bew21261261513.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/1129xi1261261513.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/123e961261261513.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/13atot1261261513.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/14taji1261261513.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/15mqf11261261513.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/16ppcg1261261513.tab")
+ }
>
> try(system("convert tmp/1xm0i1261261513.ps tmp/1xm0i1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/2hqvd1261261513.ps tmp/2hqvd1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/33lsu1261261513.ps tmp/33lsu1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/499vc1261261513.ps tmp/499vc1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/5jew91261261513.ps tmp/5jew91261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/6gafc1261261513.ps tmp/6gafc1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/72udy1261261513.ps tmp/72udy1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/82x2k1261261513.ps tmp/82x2k1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/95q5m1261261513.ps tmp/95q5m1261261513.png",intern=TRUE))
character(0)
> try(system("convert tmp/10bew21261261513.ps tmp/10bew21261261513.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.606 1.607 3.949