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(267413
+ ,0
+ ,262813
+ ,269645
+ ,267366
+ ,0
+ ,267413
+ ,267037
+ ,264777
+ ,0
+ ,267366
+ ,258113
+ ,258863
+ ,0
+ ,264777
+ ,262813
+ ,254844
+ ,0
+ ,258863
+ ,267413
+ ,254868
+ ,0
+ ,254844
+ ,267366
+ ,277267
+ ,0
+ ,254868
+ ,264777
+ ,285351
+ ,0
+ ,277267
+ ,258863
+ ,286602
+ ,0
+ ,285351
+ ,254844
+ ,283042
+ ,0
+ ,286602
+ ,254868
+ ,276687
+ ,0
+ ,283042
+ ,277267
+ ,277915
+ ,0
+ ,276687
+ ,285351
+ ,277128
+ ,0
+ ,277915
+ ,286602
+ ,277103
+ ,0
+ ,277128
+ ,283042
+ ,275037
+ ,0
+ ,277103
+ ,276687
+ ,270150
+ ,0
+ ,275037
+ ,277915
+ ,267140
+ ,0
+ ,270150
+ ,277128
+ ,264993
+ ,0
+ ,267140
+ ,277103
+ ,287259
+ ,0
+ ,264993
+ ,275037
+ ,291186
+ ,0
+ ,287259
+ ,270150
+ ,292300
+ ,0
+ ,291186
+ ,267140
+ ,288186
+ ,0
+ ,292300
+ ,264993
+ ,281477
+ ,0
+ ,288186
+ ,287259
+ ,282656
+ ,0
+ ,281477
+ ,291186
+ ,280190
+ ,0
+ ,282656
+ ,292300
+ ,280408
+ ,0
+ ,280190
+ ,288186
+ ,276836
+ ,0
+ ,280408
+ ,281477
+ ,275216
+ ,0
+ ,276836
+ ,282656
+ ,274352
+ ,0
+ ,275216
+ ,280190
+ ,271311
+ ,0
+ ,274352
+ ,280408
+ ,289802
+ ,0
+ ,271311
+ ,276836
+ ,290726
+ ,0
+ ,289802
+ ,275216
+ ,292300
+ ,0
+ ,290726
+ ,274352
+ ,278506
+ ,0
+ ,292300
+ ,271311
+ ,269826
+ ,0
+ ,278506
+ ,289802
+ ,265861
+ ,0
+ ,269826
+ ,290726
+ ,269034
+ ,0
+ ,265861
+ ,292300
+ ,264176
+ ,0
+ ,269034
+ ,278506
+ ,255198
+ ,0
+ ,264176
+ ,269826
+ ,253353
+ ,0
+ ,255198
+ ,265861
+ ,246057
+ ,0
+ ,253353
+ ,269034
+ ,235372
+ ,0
+ ,246057
+ ,264176
+ ,258556
+ ,0
+ ,235372
+ ,255198
+ ,260993
+ ,0
+ ,258556
+ ,253353
+ ,254663
+ ,0
+ ,260993
+ ,246057
+ ,250643
+ ,0
+ ,254663
+ ,235372
+ ,243422
+ ,0
+ ,250643
+ ,258556
+ ,247105
+ ,0
+ ,243422
+ ,260993
+ ,248541
+ ,0
+ ,247105
+ ,254663
+ ,245039
+ ,0
+ ,248541
+ ,250643
+ ,237080
+ ,0
+ ,245039
+ ,243422
+ ,237085
+ ,0
+ ,237080
+ ,247105
+ ,225554
+ ,0
+ ,237085
+ ,248541
+ ,226839
+ ,0
+ ,225554
+ ,245039
+ ,247934
+ ,0
+ ,226839
+ ,237080
+ ,248333
+ ,1
+ ,247934
+ ,237085
+ ,246969
+ ,1
+ ,248333
+ ,225554
+ ,245098
+ ,1
+ ,246969
+ ,226839
+ ,246263
+ ,1
+ ,245098
+ ,247934
+ ,255765
+ ,1
+ ,246263
+ ,248333
+ ,264319
+ ,1
+ ,255765
+ ,246969
+ ,268347
+ ,1
+ ,264319
+ ,245098
+ ,273046
+ ,1
+ ,268347
+ ,246263
+ ,273963
+ ,1
+ ,273046
+ ,255765
+ ,267430
+ ,1
+ ,273963
+ ,264319
+ ,271993
+ ,1
+ ,267430
+ ,268347
+ ,292710
+ ,1
+ ,271993
+ ,273046
+ ,295881
+ ,1
+ ,292710
+ ,273963)
+ ,dim=c(4
+ ,68)
+ ,dimnames=list(c('y'
+ ,'x'
+ ,'y1'
+ ,'y4')
+ ,1:68))
> y <- array(NA,dim=c(4,68),dimnames=list(c('y','x','y1','y4'),1:68))
> 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 y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 267413 0 262813 269645 1 0 0 0 0 0 0 0 0 0 0 1
2 267366 0 267413 267037 0 1 0 0 0 0 0 0 0 0 0 2
3 264777 0 267366 258113 0 0 1 0 0 0 0 0 0 0 0 3
4 258863 0 264777 262813 0 0 0 1 0 0 0 0 0 0 0 4
5 254844 0 258863 267413 0 0 0 0 1 0 0 0 0 0 0 5
6 254868 0 254844 267366 0 0 0 0 0 1 0 0 0 0 0 6
7 277267 0 254868 264777 0 0 0 0 0 0 1 0 0 0 0 7
8 285351 0 277267 258863 0 0 0 0 0 0 0 1 0 0 0 8
9 286602 0 285351 254844 0 0 0 0 0 0 0 0 1 0 0 9
10 283042 0 286602 254868 0 0 0 0 0 0 0 0 0 1 0 10
11 276687 0 283042 277267 0 0 0 0 0 0 0 0 0 0 1 11
12 277915 0 276687 285351 0 0 0 0 0 0 0 0 0 0 0 12
13 277128 0 277915 286602 1 0 0 0 0 0 0 0 0 0 0 13
14 277103 0 277128 283042 0 1 0 0 0 0 0 0 0 0 0 14
15 275037 0 277103 276687 0 0 1 0 0 0 0 0 0 0 0 15
16 270150 0 275037 277915 0 0 0 1 0 0 0 0 0 0 0 16
17 267140 0 270150 277128 0 0 0 0 1 0 0 0 0 0 0 17
18 264993 0 267140 277103 0 0 0 0 0 1 0 0 0 0 0 18
19 287259 0 264993 275037 0 0 0 0 0 0 1 0 0 0 0 19
20 291186 0 287259 270150 0 0 0 0 0 0 0 1 0 0 0 20
21 292300 0 291186 267140 0 0 0 0 0 0 0 0 1 0 0 21
22 288186 0 292300 264993 0 0 0 0 0 0 0 0 0 1 0 22
23 281477 0 288186 287259 0 0 0 0 0 0 0 0 0 0 1 23
24 282656 0 281477 291186 0 0 0 0 0 0 0 0 0 0 0 24
25 280190 0 282656 292300 1 0 0 0 0 0 0 0 0 0 0 25
26 280408 0 280190 288186 0 1 0 0 0 0 0 0 0 0 0 26
27 276836 0 280408 281477 0 0 1 0 0 0 0 0 0 0 0 27
28 275216 0 276836 282656 0 0 0 1 0 0 0 0 0 0 0 28
29 274352 0 275216 280190 0 0 0 0 1 0 0 0 0 0 0 29
30 271311 0 274352 280408 0 0 0 0 0 1 0 0 0 0 0 30
31 289802 0 271311 276836 0 0 0 0 0 0 1 0 0 0 0 31
32 290726 0 289802 275216 0 0 0 0 0 0 0 1 0 0 0 32
33 292300 0 290726 274352 0 0 0 0 0 0 0 0 1 0 0 33
34 278506 0 292300 271311 0 0 0 0 0 0 0 0 0 1 0 34
35 269826 0 278506 289802 0 0 0 0 0 0 0 0 0 0 1 35
36 265861 0 269826 290726 0 0 0 0 0 0 0 0 0 0 0 36
37 269034 0 265861 292300 1 0 0 0 0 0 0 0 0 0 0 37
38 264176 0 269034 278506 0 1 0 0 0 0 0 0 0 0 0 38
39 255198 0 264176 269826 0 0 1 0 0 0 0 0 0 0 0 39
40 253353 0 255198 265861 0 0 0 1 0 0 0 0 0 0 0 40
41 246057 0 253353 269034 0 0 0 0 1 0 0 0 0 0 0 41
42 235372 0 246057 264176 0 0 0 0 0 1 0 0 0 0 0 42
43 258556 0 235372 255198 0 0 0 0 0 0 1 0 0 0 0 43
44 260993 0 258556 253353 0 0 0 0 0 0 0 1 0 0 0 44
45 254663 0 260993 246057 0 0 0 0 0 0 0 0 1 0 0 45
46 250643 0 254663 235372 0 0 0 0 0 0 0 0 0 1 0 46
47 243422 0 250643 258556 0 0 0 0 0 0 0 0 0 0 1 47
48 247105 0 243422 260993 0 0 0 0 0 0 0 0 0 0 0 48
49 248541 0 247105 254663 1 0 0 0 0 0 0 0 0 0 0 49
50 245039 0 248541 250643 0 1 0 0 0 0 0 0 0 0 0 50
51 237080 0 245039 243422 0 0 1 0 0 0 0 0 0 0 0 51
52 237085 0 237080 247105 0 0 0 1 0 0 0 0 0 0 0 52
53 225554 0 237085 248541 0 0 0 0 1 0 0 0 0 0 0 53
54 226839 0 225554 245039 0 0 0 0 0 1 0 0 0 0 0 54
55 247934 0 226839 237080 0 0 0 0 0 0 1 0 0 0 0 55
56 248333 1 247934 237085 0 0 0 0 0 0 0 1 0 0 0 56
57 246969 1 248333 225554 0 0 0 0 0 0 0 0 1 0 0 57
58 245098 1 246969 226839 0 0 0 0 0 0 0 0 0 1 0 58
59 246263 1 245098 247934 0 0 0 0 0 0 0 0 0 0 1 59
60 255765 1 246263 248333 0 0 0 0 0 0 0 0 0 0 0 60
61 264319 1 255765 246969 1 0 0 0 0 0 0 0 0 0 0 61
62 268347 1 264319 245098 0 1 0 0 0 0 0 0 0 0 0 62
63 273046 1 268347 246263 0 0 1 0 0 0 0 0 0 0 0 63
64 273963 1 273046 255765 0 0 0 1 0 0 0 0 0 0 0 64
65 267430 1 273963 264319 0 0 0 0 1 0 0 0 0 0 0 65
66 271993 1 267430 268347 0 0 0 0 0 1 0 0 0 0 0 66
67 292710 1 271993 273046 0 0 0 0 0 0 1 0 0 0 0 67
68 295881 1 292710 273963 0 0 0 0 0 0 0 1 0 0 0 68
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x y1 y4 M1 M2
2.018e+04 4.420e+03 1.073e+00 -1.289e-01 -4.313e+02 -4.300e+03
M3 M4 M5 M6 M7 M8
-7.684e+03 -5.831e+03 -8.608e+03 -4.352e+03 1.842e+04 -2.290e+03
M9 M10 M11 t
-6.938e+03 -1.191e+04 -8.764e+03 -6.733e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-7534.8 -1861.4 194.7 2203.3 5609.5
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.018e+04 9.546e+03 2.114 0.039305 *
x 4.420e+03 1.933e+03 2.287 0.026325 *
y1 1.073e+00 7.385e-02 14.526 < 2e-16 ***
y4 -1.289e-01 7.856e-02 -1.641 0.106752
M1 -4.313e+02 2.018e+03 -0.214 0.831607
M2 -4.300e+03 2.160e+03 -1.991 0.051735 .
M3 -7.684e+03 2.360e+03 -3.256 0.001992 **
M4 -5.831e+03 2.161e+03 -2.699 0.009363 **
M5 -8.608e+03 2.060e+03 -4.179 0.000112 ***
M6 -4.352e+03 2.021e+03 -2.154 0.035933 *
M7 1.842e+04 2.047e+03 9.001 3.46e-12 ***
M8 -2.290e+03 2.685e+03 -0.853 0.397553
M9 -6.938e+03 3.252e+03 -2.134 0.037620 *
M10 -1.191e+04 3.395e+03 -3.508 0.000939 ***
M11 -8.764e+03 2.183e+03 -4.015 0.000192 ***
t -6.733e+01 3.372e+01 -1.997 0.051123 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3303 on 52 degrees of freedom
Multiple R-squared: 0.9714, Adjusted R-squared: 0.9632
F-statistic: 118 on 15 and 52 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.0170914527 0.034182905 0.9829085
[2,] 0.0706844224 0.141368845 0.9293156
[3,] 0.0429904511 0.085980902 0.9570095
[4,] 0.0207952244 0.041590449 0.9792048
[5,] 0.0084376895 0.016875379 0.9915623
[6,] 0.0029494850 0.005898970 0.9970505
[7,] 0.0033375655 0.006675131 0.9966624
[8,] 0.0013727360 0.002745472 0.9986273
[9,] 0.0005403427 0.001080685 0.9994597
[10,] 0.0008561388 0.001712278 0.9991439
[11,] 0.0021914946 0.004382989 0.9978085
[12,] 0.0009640584 0.001928117 0.9990359
[13,] 0.0008160634 0.001632127 0.9991839
[14,] 0.0026752020 0.005350404 0.9973248
[15,] 0.0070985144 0.014197029 0.9929015
[16,] 0.0938021357 0.187604271 0.9061979
[17,] 0.0593867116 0.118773423 0.9406133
[18,] 0.0591410940 0.118282188 0.9408589
[19,] 0.0850138360 0.170027672 0.9149862
[20,] 0.0573687826 0.114737565 0.9426312
[21,] 0.0428196121 0.085639224 0.9571804
[22,] 0.0514371928 0.102874386 0.9485628
[23,] 0.0716367205 0.143273441 0.9283633
[24,] 0.3757749022 0.751549804 0.6242251
[25,] 0.4902087695 0.980417539 0.5097912
[26,] 0.6692124215 0.661575157 0.3307876
[27,] 0.6217423694 0.756515261 0.3782576
[28,] 0.6875288309 0.624942338 0.3124712
[29,] 0.5599213350 0.880157330 0.4400787
[30,] 0.5459842994 0.908031401 0.4540157
[31,] 0.5092960138 0.981407972 0.4907040
> postscript(file="/var/www/html/rcomp/tmp/1s2un1258727924.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/2dxsc1258727924.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/3wycc1258727924.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/4dt4v1258727924.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/5ikqj1258727924.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 = 68
Frequency = 1
1 2 3 4 5 6 7
554.3944 -827.6785 -1065.3387 -5381.8344 381.2190 521.9198 -145.6791
8 9 10 11 12 13 14
3926.2127 701.5945 844.3555 -1884.0002 -1492.8768 -2937.3389 1358.9300
15 16 17 18 19 20 21
1951.9209 -2346.3287 2629.3627 -480.5401 1115.3147 1305.3105 2533.3636
22 23 24 25 26 27 28
1989.1628 -516.0192 -330.1423 -3418.7029 2850.3385 1630.9971 2209.0440
29 30 31 32 33 34 35
5609.4519 -665.3154 -2079.5774 -421.5629 4764.7745 -6068.1818 -646.5583
36 37 38 39 40 41 42
-3877.4348 4250.7258 -1853.8294 -3287.8574 2201.3886 138.2780 -7534.8444
43 44 45 46 47 48 49
3247.2035 1354.6244 -3815.5184 2619.1868 -380.4681 2666.5510 -166.1095
50 51 52 53 54 55 56
-1790.9559 -3472.5542 3759.6732 -4747.0629 4267.9063 251.1057 -5620.3379
57 58 59 60 61 62 63
-4184.2142 615.4766 3427.0458 3033.9029 1717.0311 263.1953 4242.8323
64 65 66 67 68
-441.9427 -4011.2487 3890.8738 -2388.3674 -544.2468
> postscript(file="/var/www/html/rcomp/tmp/659bz1258727924.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 = 68
Frequency = 1
lag(myerror, k = 1) myerror
0 554.3944 NA
1 -827.6785 554.3944
2 -1065.3387 -827.6785
3 -5381.8344 -1065.3387
4 381.2190 -5381.8344
5 521.9198 381.2190
6 -145.6791 521.9198
7 3926.2127 -145.6791
8 701.5945 3926.2127
9 844.3555 701.5945
10 -1884.0002 844.3555
11 -1492.8768 -1884.0002
12 -2937.3389 -1492.8768
13 1358.9300 -2937.3389
14 1951.9209 1358.9300
15 -2346.3287 1951.9209
16 2629.3627 -2346.3287
17 -480.5401 2629.3627
18 1115.3147 -480.5401
19 1305.3105 1115.3147
20 2533.3636 1305.3105
21 1989.1628 2533.3636
22 -516.0192 1989.1628
23 -330.1423 -516.0192
24 -3418.7029 -330.1423
25 2850.3385 -3418.7029
26 1630.9971 2850.3385
27 2209.0440 1630.9971
28 5609.4519 2209.0440
29 -665.3154 5609.4519
30 -2079.5774 -665.3154
31 -421.5629 -2079.5774
32 4764.7745 -421.5629
33 -6068.1818 4764.7745
34 -646.5583 -6068.1818
35 -3877.4348 -646.5583
36 4250.7258 -3877.4348
37 -1853.8294 4250.7258
38 -3287.8574 -1853.8294
39 2201.3886 -3287.8574
40 138.2780 2201.3886
41 -7534.8444 138.2780
42 3247.2035 -7534.8444
43 1354.6244 3247.2035
44 -3815.5184 1354.6244
45 2619.1868 -3815.5184
46 -380.4681 2619.1868
47 2666.5510 -380.4681
48 -166.1095 2666.5510
49 -1790.9559 -166.1095
50 -3472.5542 -1790.9559
51 3759.6732 -3472.5542
52 -4747.0629 3759.6732
53 4267.9063 -4747.0629
54 251.1057 4267.9063
55 -5620.3379 251.1057
56 -4184.2142 -5620.3379
57 615.4766 -4184.2142
58 3427.0458 615.4766
59 3033.9029 3427.0458
60 1717.0311 3033.9029
61 263.1953 1717.0311
62 4242.8323 263.1953
63 -441.9427 4242.8323
64 -4011.2487 -441.9427
65 3890.8738 -4011.2487
66 -2388.3674 3890.8738
67 -544.2468 -2388.3674
68 NA -544.2468
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -827.6785 554.3944
[2,] -1065.3387 -827.6785
[3,] -5381.8344 -1065.3387
[4,] 381.2190 -5381.8344
[5,] 521.9198 381.2190
[6,] -145.6791 521.9198
[7,] 3926.2127 -145.6791
[8,] 701.5945 3926.2127
[9,] 844.3555 701.5945
[10,] -1884.0002 844.3555
[11,] -1492.8768 -1884.0002
[12,] -2937.3389 -1492.8768
[13,] 1358.9300 -2937.3389
[14,] 1951.9209 1358.9300
[15,] -2346.3287 1951.9209
[16,] 2629.3627 -2346.3287
[17,] -480.5401 2629.3627
[18,] 1115.3147 -480.5401
[19,] 1305.3105 1115.3147
[20,] 2533.3636 1305.3105
[21,] 1989.1628 2533.3636
[22,] -516.0192 1989.1628
[23,] -330.1423 -516.0192
[24,] -3418.7029 -330.1423
[25,] 2850.3385 -3418.7029
[26,] 1630.9971 2850.3385
[27,] 2209.0440 1630.9971
[28,] 5609.4519 2209.0440
[29,] -665.3154 5609.4519
[30,] -2079.5774 -665.3154
[31,] -421.5629 -2079.5774
[32,] 4764.7745 -421.5629
[33,] -6068.1818 4764.7745
[34,] -646.5583 -6068.1818
[35,] -3877.4348 -646.5583
[36,] 4250.7258 -3877.4348
[37,] -1853.8294 4250.7258
[38,] -3287.8574 -1853.8294
[39,] 2201.3886 -3287.8574
[40,] 138.2780 2201.3886
[41,] -7534.8444 138.2780
[42,] 3247.2035 -7534.8444
[43,] 1354.6244 3247.2035
[44,] -3815.5184 1354.6244
[45,] 2619.1868 -3815.5184
[46,] -380.4681 2619.1868
[47,] 2666.5510 -380.4681
[48,] -166.1095 2666.5510
[49,] -1790.9559 -166.1095
[50,] -3472.5542 -1790.9559
[51,] 3759.6732 -3472.5542
[52,] -4747.0629 3759.6732
[53,] 4267.9063 -4747.0629
[54,] 251.1057 4267.9063
[55,] -5620.3379 251.1057
[56,] -4184.2142 -5620.3379
[57,] 615.4766 -4184.2142
[58,] 3427.0458 615.4766
[59,] 3033.9029 3427.0458
[60,] 1717.0311 3033.9029
[61,] 263.1953 1717.0311
[62,] 4242.8323 263.1953
[63,] -441.9427 4242.8323
[64,] -4011.2487 -441.9427
[65,] 3890.8738 -4011.2487
[66,] -2388.3674 3890.8738
[67,] -544.2468 -2388.3674
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -827.6785 554.3944
2 -1065.3387 -827.6785
3 -5381.8344 -1065.3387
4 381.2190 -5381.8344
5 521.9198 381.2190
6 -145.6791 521.9198
7 3926.2127 -145.6791
8 701.5945 3926.2127
9 844.3555 701.5945
10 -1884.0002 844.3555
11 -1492.8768 -1884.0002
12 -2937.3389 -1492.8768
13 1358.9300 -2937.3389
14 1951.9209 1358.9300
15 -2346.3287 1951.9209
16 2629.3627 -2346.3287
17 -480.5401 2629.3627
18 1115.3147 -480.5401
19 1305.3105 1115.3147
20 2533.3636 1305.3105
21 1989.1628 2533.3636
22 -516.0192 1989.1628
23 -330.1423 -516.0192
24 -3418.7029 -330.1423
25 2850.3385 -3418.7029
26 1630.9971 2850.3385
27 2209.0440 1630.9971
28 5609.4519 2209.0440
29 -665.3154 5609.4519
30 -2079.5774 -665.3154
31 -421.5629 -2079.5774
32 4764.7745 -421.5629
33 -6068.1818 4764.7745
34 -646.5583 -6068.1818
35 -3877.4348 -646.5583
36 4250.7258 -3877.4348
37 -1853.8294 4250.7258
38 -3287.8574 -1853.8294
39 2201.3886 -3287.8574
40 138.2780 2201.3886
41 -7534.8444 138.2780
42 3247.2035 -7534.8444
43 1354.6244 3247.2035
44 -3815.5184 1354.6244
45 2619.1868 -3815.5184
46 -380.4681 2619.1868
47 2666.5510 -380.4681
48 -166.1095 2666.5510
49 -1790.9559 -166.1095
50 -3472.5542 -1790.9559
51 3759.6732 -3472.5542
52 -4747.0629 3759.6732
53 4267.9063 -4747.0629
54 251.1057 4267.9063
55 -5620.3379 251.1057
56 -4184.2142 -5620.3379
57 615.4766 -4184.2142
58 3427.0458 615.4766
59 3033.9029 3427.0458
60 1717.0311 3033.9029
61 263.1953 1717.0311
62 4242.8323 263.1953
63 -441.9427 4242.8323
64 -4011.2487 -441.9427
65 3890.8738 -4011.2487
66 -2388.3674 3890.8738
67 -544.2468 -2388.3674
> 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/7iigx1258727924.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/8wghs1258727924.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/9ydvb1258727924.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/10pvfy1258727924.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/11xe1d1258727924.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/12igjy1258727924.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/13gshn1258727924.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/14rw6f1258727924.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/153dax1258727924.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/165fdy1258727924.tab")
+ }
>
> system("convert tmp/1s2un1258727924.ps tmp/1s2un1258727924.png")
> system("convert tmp/2dxsc1258727924.ps tmp/2dxsc1258727924.png")
> system("convert tmp/3wycc1258727924.ps tmp/3wycc1258727924.png")
> system("convert tmp/4dt4v1258727924.ps tmp/4dt4v1258727924.png")
> system("convert tmp/5ikqj1258727924.ps tmp/5ikqj1258727924.png")
> system("convert tmp/659bz1258727924.ps tmp/659bz1258727924.png")
> system("convert tmp/7iigx1258727924.ps tmp/7iigx1258727924.png")
> system("convert tmp/8wghs1258727924.ps tmp/8wghs1258727924.png")
> system("convert tmp/9ydvb1258727924.ps tmp/9ydvb1258727924.png")
> system("convert tmp/10pvfy1258727924.ps tmp/10pvfy1258727924.png")
>
>
> proc.time()
user system elapsed
2.619 1.650 3.764