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(819.3
+ ,31.3
+ ,785.8
+ ,849.4
+ ,30
+ ,819.3
+ ,880.4
+ ,31.3
+ ,849.4
+ ,900.1
+ ,33
+ ,880.4
+ ,937.2
+ ,31.3
+ ,900.1
+ ,948.9
+ ,29
+ ,937.2
+ ,952.6
+ ,28.7
+ ,948.9
+ ,947.3
+ ,28
+ ,952.6
+ ,974.2
+ ,29.7
+ ,947.3
+ ,1000.8
+ ,30.7
+ ,974.2
+ ,1032.8
+ ,24
+ ,1000.8
+ ,1050.7
+ ,29
+ ,1032.8
+ ,1057.3
+ ,33
+ ,1050.7
+ ,1075.4
+ ,28
+ ,1057.3
+ ,1118.4
+ ,28.7
+ ,1075.4
+ ,1179.8
+ ,31.7
+ ,1118.4
+ ,1227
+ ,34
+ ,1179.8
+ ,1257.8
+ ,35.3
+ ,1227
+ ,1251.5
+ ,27
+ ,1257.8
+ ,1236.3
+ ,31.3
+ ,1251.5
+ ,1170.6
+ ,38.7
+ ,1236.3
+ ,1213.1
+ ,37.3
+ ,1170.6
+ ,1265.5
+ ,37.3
+ ,1213.1
+ ,1300.8
+ ,37.7
+ ,1265.5
+ ,1348.4
+ ,34.7
+ ,1300.8
+ ,1371.9
+ ,34.7
+ ,1348.4
+ ,1403.3
+ ,33.7
+ ,1371.9
+ ,1451.8
+ ,38.3
+ ,1403.3
+ ,1474.2
+ ,38
+ ,1451.8
+ ,1438.2
+ ,38.3
+ ,1474.2
+ ,1513.6
+ ,42.7
+ ,1438.2
+ ,1562.2
+ ,41.7
+ ,1513.6
+ ,1546.2
+ ,39.7
+ ,1562.2
+ ,1527.5
+ ,39.3
+ ,1546.2
+ ,1418.7
+ ,39.3
+ ,1527.5
+ ,1448.5
+ ,37.7
+ ,1418.7
+ ,1492.1
+ ,38.3
+ ,1448.5
+ ,1395.4
+ ,37.7
+ ,1492.1
+ ,1403.7
+ ,37
+ ,1395.4
+ ,1316.6
+ ,34.3
+ ,1403.7
+ ,1274.5
+ ,29.7
+ ,1316.6
+ ,1264.4
+ ,34.7
+ ,1274.5
+ ,1323.9
+ ,32
+ ,1264.4
+ ,1332.1
+ ,30.3
+ ,1323.9
+ ,1250.2
+ ,28.3
+ ,1332.1
+ ,1096.7
+ ,31.3
+ ,1250.2
+ ,1080.8
+ ,17.7
+ ,1096.7
+ ,1039.2
+ ,15.7
+ ,1080.8
+ ,792
+ ,14.3
+ ,1039.2
+ ,746.6
+ ,13.3
+ ,792
+ ,688.8
+ ,11
+ ,746.6
+ ,715.8
+ ,2.7
+ ,688.8
+ ,672.9
+ ,3.3
+ ,715.8
+ ,629.5
+ ,3.7
+ ,672.9
+ ,681.2
+ ,1.4
+ ,629.5
+ ,755.4
+ ,7.1
+ ,681.2
+ ,760.6
+ ,8.1
+ ,755.4
+ ,765.9
+ ,12.4
+ ,760.6
+ ,836.8
+ ,12.4
+ ,765.9
+ ,904.9
+ ,9.2
+ ,836.8)
+ ,dim=c(3
+ ,60)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1')
+ ,1:60))
> y <- array(NA,dim=c(3,60),dimnames=list(c('Y','X','Y1'),1:60))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 819.3 31.3 785.8 1 0 0 0 0 0 0 0 0 0 0 1
2 849.4 30.0 819.3 0 1 0 0 0 0 0 0 0 0 0 2
3 880.4 31.3 849.4 0 0 1 0 0 0 0 0 0 0 0 3
4 900.1 33.0 880.4 0 0 0 1 0 0 0 0 0 0 0 4
5 937.2 31.3 900.1 0 0 0 0 1 0 0 0 0 0 0 5
6 948.9 29.0 937.2 0 0 0 0 0 1 0 0 0 0 0 6
7 952.6 28.7 948.9 0 0 0 0 0 0 1 0 0 0 0 7
8 947.3 28.0 952.6 0 0 0 0 0 0 0 1 0 0 0 8
9 974.2 29.7 947.3 0 0 0 0 0 0 0 0 1 0 0 9
10 1000.8 30.7 974.2 0 0 0 0 0 0 0 0 0 1 0 10
11 1032.8 24.0 1000.8 0 0 0 0 0 0 0 0 0 0 1 11
12 1050.7 29.0 1032.8 0 0 0 0 0 0 0 0 0 0 0 12
13 1057.3 33.0 1050.7 1 0 0 0 0 0 0 0 0 0 0 13
14 1075.4 28.0 1057.3 0 1 0 0 0 0 0 0 0 0 0 14
15 1118.4 28.7 1075.4 0 0 1 0 0 0 0 0 0 0 0 15
16 1179.8 31.7 1118.4 0 0 0 1 0 0 0 0 0 0 0 16
17 1227.0 34.0 1179.8 0 0 0 0 1 0 0 0 0 0 0 17
18 1257.8 35.3 1227.0 0 0 0 0 0 1 0 0 0 0 0 18
19 1251.5 27.0 1257.8 0 0 0 0 0 0 1 0 0 0 0 19
20 1236.3 31.3 1251.5 0 0 0 0 0 0 0 1 0 0 0 20
21 1170.6 38.7 1236.3 0 0 0 0 0 0 0 0 1 0 0 21
22 1213.1 37.3 1170.6 0 0 0 0 0 0 0 0 0 1 0 22
23 1265.5 37.3 1213.1 0 0 0 0 0 0 0 0 0 0 1 23
24 1300.8 37.7 1265.5 0 0 0 0 0 0 0 0 0 0 0 24
25 1348.4 34.7 1300.8 1 0 0 0 0 0 0 0 0 0 0 25
26 1371.9 34.7 1348.4 0 1 0 0 0 0 0 0 0 0 0 26
27 1403.3 33.7 1371.9 0 0 1 0 0 0 0 0 0 0 0 27
28 1451.8 38.3 1403.3 0 0 0 1 0 0 0 0 0 0 0 28
29 1474.2 38.0 1451.8 0 0 0 0 1 0 0 0 0 0 0 29
30 1438.2 38.3 1474.2 0 0 0 0 0 1 0 0 0 0 0 30
31 1513.6 42.7 1438.2 0 0 0 0 0 0 1 0 0 0 0 31
32 1562.2 41.7 1513.6 0 0 0 0 0 0 0 1 0 0 0 32
33 1546.2 39.7 1562.2 0 0 0 0 0 0 0 0 1 0 0 33
34 1527.5 39.3 1546.2 0 0 0 0 0 0 0 0 0 1 0 34
35 1418.7 39.3 1527.5 0 0 0 0 0 0 0 0 0 0 1 35
36 1448.5 37.7 1418.7 0 0 0 0 0 0 0 0 0 0 0 36
37 1492.1 38.3 1448.5 1 0 0 0 0 0 0 0 0 0 0 37
38 1395.4 37.7 1492.1 0 1 0 0 0 0 0 0 0 0 0 38
39 1403.7 37.0 1395.4 0 0 1 0 0 0 0 0 0 0 0 39
40 1316.6 34.3 1403.7 0 0 0 1 0 0 0 0 0 0 0 40
41 1274.5 29.7 1316.6 0 0 0 0 1 0 0 0 0 0 0 41
42 1264.4 34.7 1274.5 0 0 0 0 0 1 0 0 0 0 0 42
43 1323.9 32.0 1264.4 0 0 0 0 0 0 1 0 0 0 0 43
44 1332.1 30.3 1323.9 0 0 0 0 0 0 0 1 0 0 0 44
45 1250.2 28.3 1332.1 0 0 0 0 0 0 0 0 1 0 0 45
46 1096.7 31.3 1250.2 0 0 0 0 0 0 0 0 0 1 0 46
47 1080.8 17.7 1096.7 0 0 0 0 0 0 0 0 0 0 1 47
48 1039.2 15.7 1080.8 0 0 0 0 0 0 0 0 0 0 0 48
49 792.0 14.3 1039.2 1 0 0 0 0 0 0 0 0 0 0 49
50 746.6 13.3 792.0 0 1 0 0 0 0 0 0 0 0 0 50
51 688.8 11.0 746.6 0 0 1 0 0 0 0 0 0 0 0 51
52 715.8 2.7 688.8 0 0 0 1 0 0 0 0 0 0 0 52
53 672.9 3.3 715.8 0 0 0 0 1 0 0 0 0 0 0 53
54 629.5 3.7 672.9 0 0 0 0 0 1 0 0 0 0 0 54
55 681.2 1.4 629.5 0 0 0 0 0 0 1 0 0 0 0 55
56 755.4 7.1 681.2 0 0 0 0 0 0 0 1 0 0 0 56
57 760.6 8.1 755.4 0 0 0 0 0 0 0 0 1 0 0 57
58 765.9 12.4 760.6 0 0 0 0 0 0 0 0 0 1 0 58
59 836.8 12.4 765.9 0 0 0 0 0 0 0 0 0 0 1 59
60 904.9 9.2 836.8 0 0 0 0 0 0 0 0 0 0 0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 M1 M2 M3
92.4076 5.4171 0.7905 -61.8370 -49.7448 -25.9780
M4 M5 M6 M7 M8 M9
-19.7830 -23.1313 -41.7636 11.7246 -3.1244 -54.2119
M10 M11 t
-60.7349 -17.8696 0.7096
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-172.247 -25.600 7.185 34.853 83.891
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 92.40762 43.53886 2.122 0.0393 *
X 5.41715 2.35575 2.300 0.0262 *
Y1 0.79045 0.08017 9.860 8.07e-13 ***
M1 -61.83703 35.59197 -1.737 0.0892 .
M2 -49.74482 35.50060 -1.401 0.1680
M3 -25.97798 35.49970 -0.732 0.4681
M4 -19.78305 35.40988 -0.559 0.5791
M5 -23.13129 35.36389 -0.654 0.5164
M6 -41.76360 35.34880 -1.181 0.2436
M7 11.72461 35.31017 0.332 0.7414
M8 -3.12436 35.25917 -0.089 0.9298
M9 -54.21193 35.30048 -1.536 0.1316
M10 -60.73489 36.05169 -1.685 0.0990 .
M11 -17.86960 35.22174 -0.507 0.6144
t 0.70962 0.88340 0.803 0.4260
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 55.68 on 45 degrees of freedom
Multiple R-squared: 0.9671, Adjusted R-squared: 0.9568
F-statistic: 94.34 on 14 and 45 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,] 3.876260e-02 7.752519e-02 0.9612374
[2,] 1.202271e-02 2.404542e-02 0.9879773
[3,] 3.256051e-03 6.512102e-03 0.9967439
[4,] 1.717152e-02 3.434304e-02 0.9828285
[5,] 7.521156e-03 1.504231e-02 0.9924788
[6,] 3.942941e-03 7.885883e-03 0.9960571
[7,] 3.084689e-03 6.169378e-03 0.9969153
[8,] 1.373003e-03 2.746007e-03 0.9986270
[9,] 5.035591e-04 1.007118e-03 0.9994964
[10,] 1.906342e-04 3.812684e-04 0.9998094
[11,] 6.387676e-05 1.277535e-04 0.9999361
[12,] 2.109372e-05 4.218743e-05 0.9999789
[13,] 4.198655e-05 8.397310e-05 0.9999580
[14,] 6.949072e-05 1.389814e-04 0.9999305
[15,] 1.163434e-04 2.326868e-04 0.9998837
[16,] 5.603509e-05 1.120702e-04 0.9999440
[17,] 1.541462e-04 3.082925e-04 0.9998459
[18,] 8.008855e-03 1.601771e-02 0.9919911
[19,] 8.407522e-03 1.681504e-02 0.9915925
[20,] 1.480922e-01 2.961843e-01 0.8519078
[21,] 2.386776e-01 4.773552e-01 0.7613224
[22,] 4.412881e-01 8.825763e-01 0.5587119
[23,] 6.132978e-01 7.734045e-01 0.3867022
[24,] 4.991357e-01 9.982713e-01 0.5008643
[25,] 4.251112e-01 8.502223e-01 0.5748888
> postscript(file="/var/www/html/rcomp/tmp/146xn1258557416.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/20mi21258557416.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/3krre1258557416.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/4hj5v1258557416.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/5fuxp1258557416.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 = 60
Frequency = 1
1 2 3 4 5 6
-2.6759197 -4.8156723 -29.1270944 -50.0448790 -16.6690530 -3.9127807
7 8 9 10 11 12
-62.0337734 -52.3270982 19.9311199 25.6640936 29.3579898 -23.7015042
13 14 15 16 17 18
8.2081907 35.3751034 35.7994214 40.0538938 28.8991864 33.2701409
19 20 21 22 23 24
-6.6113537 -25.9858701 -69.3798919 38.4503055 13.6810932 -13.1847931
25 26 27 28 29 30
83.8910252 56.9635756 50.7285901 42.5848975 30.9116331 -6.4969981
31 32 33 34 35 36
19.3260900 27.8823339 34.6785074 36.6059776 -100.9874298 4.9022157
37 38 39 40 41 42
82.8238038 -57.8915403 6.1609404 -79.7780843 -25.4720097 -11.4569273
43 44 45 46 47 48
16.4551371 0.9716076 -26.1978640 -125.3977531 10.1352818 -26.6414211
49 50 51 52 53 54
-172.2471000 -29.6314663 -63.5618575 47.1841720 -17.6697567 -11.4034348
55 56 57 58 59 60
32.8639000 49.4590268 40.9681286 24.6773763 47.8130650 58.6255027
> postscript(file="/var/www/html/rcomp/tmp/629f71258557416.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 -2.6759197 NA
1 -4.8156723 -2.6759197
2 -29.1270944 -4.8156723
3 -50.0448790 -29.1270944
4 -16.6690530 -50.0448790
5 -3.9127807 -16.6690530
6 -62.0337734 -3.9127807
7 -52.3270982 -62.0337734
8 19.9311199 -52.3270982
9 25.6640936 19.9311199
10 29.3579898 25.6640936
11 -23.7015042 29.3579898
12 8.2081907 -23.7015042
13 35.3751034 8.2081907
14 35.7994214 35.3751034
15 40.0538938 35.7994214
16 28.8991864 40.0538938
17 33.2701409 28.8991864
18 -6.6113537 33.2701409
19 -25.9858701 -6.6113537
20 -69.3798919 -25.9858701
21 38.4503055 -69.3798919
22 13.6810932 38.4503055
23 -13.1847931 13.6810932
24 83.8910252 -13.1847931
25 56.9635756 83.8910252
26 50.7285901 56.9635756
27 42.5848975 50.7285901
28 30.9116331 42.5848975
29 -6.4969981 30.9116331
30 19.3260900 -6.4969981
31 27.8823339 19.3260900
32 34.6785074 27.8823339
33 36.6059776 34.6785074
34 -100.9874298 36.6059776
35 4.9022157 -100.9874298
36 82.8238038 4.9022157
37 -57.8915403 82.8238038
38 6.1609404 -57.8915403
39 -79.7780843 6.1609404
40 -25.4720097 -79.7780843
41 -11.4569273 -25.4720097
42 16.4551371 -11.4569273
43 0.9716076 16.4551371
44 -26.1978640 0.9716076
45 -125.3977531 -26.1978640
46 10.1352818 -125.3977531
47 -26.6414211 10.1352818
48 -172.2471000 -26.6414211
49 -29.6314663 -172.2471000
50 -63.5618575 -29.6314663
51 47.1841720 -63.5618575
52 -17.6697567 47.1841720
53 -11.4034348 -17.6697567
54 32.8639000 -11.4034348
55 49.4590268 32.8639000
56 40.9681286 49.4590268
57 24.6773763 40.9681286
58 47.8130650 24.6773763
59 58.6255027 47.8130650
60 NA 58.6255027
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.8156723 -2.6759197
[2,] -29.1270944 -4.8156723
[3,] -50.0448790 -29.1270944
[4,] -16.6690530 -50.0448790
[5,] -3.9127807 -16.6690530
[6,] -62.0337734 -3.9127807
[7,] -52.3270982 -62.0337734
[8,] 19.9311199 -52.3270982
[9,] 25.6640936 19.9311199
[10,] 29.3579898 25.6640936
[11,] -23.7015042 29.3579898
[12,] 8.2081907 -23.7015042
[13,] 35.3751034 8.2081907
[14,] 35.7994214 35.3751034
[15,] 40.0538938 35.7994214
[16,] 28.8991864 40.0538938
[17,] 33.2701409 28.8991864
[18,] -6.6113537 33.2701409
[19,] -25.9858701 -6.6113537
[20,] -69.3798919 -25.9858701
[21,] 38.4503055 -69.3798919
[22,] 13.6810932 38.4503055
[23,] -13.1847931 13.6810932
[24,] 83.8910252 -13.1847931
[25,] 56.9635756 83.8910252
[26,] 50.7285901 56.9635756
[27,] 42.5848975 50.7285901
[28,] 30.9116331 42.5848975
[29,] -6.4969981 30.9116331
[30,] 19.3260900 -6.4969981
[31,] 27.8823339 19.3260900
[32,] 34.6785074 27.8823339
[33,] 36.6059776 34.6785074
[34,] -100.9874298 36.6059776
[35,] 4.9022157 -100.9874298
[36,] 82.8238038 4.9022157
[37,] -57.8915403 82.8238038
[38,] 6.1609404 -57.8915403
[39,] -79.7780843 6.1609404
[40,] -25.4720097 -79.7780843
[41,] -11.4569273 -25.4720097
[42,] 16.4551371 -11.4569273
[43,] 0.9716076 16.4551371
[44,] -26.1978640 0.9716076
[45,] -125.3977531 -26.1978640
[46,] 10.1352818 -125.3977531
[47,] -26.6414211 10.1352818
[48,] -172.2471000 -26.6414211
[49,] -29.6314663 -172.2471000
[50,] -63.5618575 -29.6314663
[51,] 47.1841720 -63.5618575
[52,] -17.6697567 47.1841720
[53,] -11.4034348 -17.6697567
[54,] 32.8639000 -11.4034348
[55,] 49.4590268 32.8639000
[56,] 40.9681286 49.4590268
[57,] 24.6773763 40.9681286
[58,] 47.8130650 24.6773763
[59,] 58.6255027 47.8130650
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.8156723 -2.6759197
2 -29.1270944 -4.8156723
3 -50.0448790 -29.1270944
4 -16.6690530 -50.0448790
5 -3.9127807 -16.6690530
6 -62.0337734 -3.9127807
7 -52.3270982 -62.0337734
8 19.9311199 -52.3270982
9 25.6640936 19.9311199
10 29.3579898 25.6640936
11 -23.7015042 29.3579898
12 8.2081907 -23.7015042
13 35.3751034 8.2081907
14 35.7994214 35.3751034
15 40.0538938 35.7994214
16 28.8991864 40.0538938
17 33.2701409 28.8991864
18 -6.6113537 33.2701409
19 -25.9858701 -6.6113537
20 -69.3798919 -25.9858701
21 38.4503055 -69.3798919
22 13.6810932 38.4503055
23 -13.1847931 13.6810932
24 83.8910252 -13.1847931
25 56.9635756 83.8910252
26 50.7285901 56.9635756
27 42.5848975 50.7285901
28 30.9116331 42.5848975
29 -6.4969981 30.9116331
30 19.3260900 -6.4969981
31 27.8823339 19.3260900
32 34.6785074 27.8823339
33 36.6059776 34.6785074
34 -100.9874298 36.6059776
35 4.9022157 -100.9874298
36 82.8238038 4.9022157
37 -57.8915403 82.8238038
38 6.1609404 -57.8915403
39 -79.7780843 6.1609404
40 -25.4720097 -79.7780843
41 -11.4569273 -25.4720097
42 16.4551371 -11.4569273
43 0.9716076 16.4551371
44 -26.1978640 0.9716076
45 -125.3977531 -26.1978640
46 10.1352818 -125.3977531
47 -26.6414211 10.1352818
48 -172.2471000 -26.6414211
49 -29.6314663 -172.2471000
50 -63.5618575 -29.6314663
51 47.1841720 -63.5618575
52 -17.6697567 47.1841720
53 -11.4034348 -17.6697567
54 32.8639000 -11.4034348
55 49.4590268 32.8639000
56 40.9681286 49.4590268
57 24.6773763 40.9681286
58 47.8130650 24.6773763
59 58.6255027 47.8130650
> 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/76hk61258557416.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/8erhn1258557416.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/94z381258557416.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/10ff2y1258557416.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/11ie6w1258557416.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/12l8na1258557416.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/1366q91258557416.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/1400ss1258557416.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/15novu1258557416.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/16gfbk1258557416.tab")
+ }
>
> system("convert tmp/146xn1258557416.ps tmp/146xn1258557416.png")
> system("convert tmp/20mi21258557416.ps tmp/20mi21258557416.png")
> system("convert tmp/3krre1258557416.ps tmp/3krre1258557416.png")
> system("convert tmp/4hj5v1258557416.ps tmp/4hj5v1258557416.png")
> system("convert tmp/5fuxp1258557416.ps tmp/5fuxp1258557416.png")
> system("convert tmp/629f71258557416.ps tmp/629f71258557416.png")
> system("convert tmp/76hk61258557416.ps tmp/76hk61258557416.png")
> system("convert tmp/8erhn1258557416.ps tmp/8erhn1258557416.png")
> system("convert tmp/94z381258557416.ps tmp/94z381258557416.png")
> system("convert tmp/10ff2y1258557416.ps tmp/10ff2y1258557416.png")
>
>
> proc.time()
user system elapsed
2.372 1.588 3.512