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(243324
+ ,612613
+ ,260307
+ ,241476
+ ,213587
+ ,216234
+ ,244460
+ ,611324
+ ,243324
+ ,260307
+ ,209465
+ ,213587
+ ,233575
+ ,594167
+ ,244460
+ ,243324
+ ,204045
+ ,209465
+ ,237217
+ ,595454
+ ,233575
+ ,244460
+ ,200237
+ ,204045
+ ,235243
+ ,590865
+ ,237217
+ ,233575
+ ,203666
+ ,200237
+ ,230354
+ ,589379
+ ,235243
+ ,237217
+ ,241476
+ ,203666
+ ,227184
+ ,584428
+ ,230354
+ ,235243
+ ,260307
+ ,241476
+ ,221678
+ ,573100
+ ,227184
+ ,230354
+ ,243324
+ ,260307
+ ,217142
+ ,567456
+ ,221678
+ ,227184
+ ,244460
+ ,243324
+ ,219452
+ ,569028
+ ,217142
+ ,221678
+ ,233575
+ ,244460
+ ,256446
+ ,620735
+ ,219452
+ ,217142
+ ,237217
+ ,233575
+ ,265845
+ ,628884
+ ,256446
+ ,219452
+ ,235243
+ ,237217
+ ,248624
+ ,628232
+ ,265845
+ ,256446
+ ,230354
+ ,235243
+ ,241114
+ ,612117
+ ,248624
+ ,265845
+ ,227184
+ ,230354
+ ,229245
+ ,595404
+ ,241114
+ ,248624
+ ,221678
+ ,227184
+ ,231805
+ ,597141
+ ,229245
+ ,241114
+ ,217142
+ ,221678
+ ,219277
+ ,593408
+ ,231805
+ ,229245
+ ,219452
+ ,217142
+ ,219313
+ ,590072
+ ,219277
+ ,231805
+ ,256446
+ ,219452
+ ,212610
+ ,579799
+ ,219313
+ ,219277
+ ,265845
+ ,256446
+ ,214771
+ ,574205
+ ,212610
+ ,219313
+ ,248624
+ ,265845
+ ,211142
+ ,572775
+ ,214771
+ ,212610
+ ,241114
+ ,248624
+ ,211457
+ ,572942
+ ,211142
+ ,214771
+ ,229245
+ ,241114
+ ,240048
+ ,619567
+ ,211457
+ ,211142
+ ,231805
+ ,229245
+ ,240636
+ ,625809
+ ,240048
+ ,211457
+ ,219277
+ ,231805
+ ,230580
+ ,619916
+ ,240636
+ ,240048
+ ,219313
+ ,219277
+ ,208795
+ ,587625
+ ,230580
+ ,240636
+ ,212610
+ ,219313
+ ,197922
+ ,565742
+ ,208795
+ ,230580
+ ,214771
+ ,212610
+ ,194596
+ ,557274
+ ,197922
+ ,208795
+ ,211142
+ ,214771
+ ,194581
+ ,560576
+ ,194596
+ ,197922
+ ,211457
+ ,211142
+ ,185686
+ ,548854
+ ,194581
+ ,194596
+ ,240048
+ ,211457
+ ,178106
+ ,531673
+ ,185686
+ ,194581
+ ,240636
+ ,240048
+ ,172608
+ ,525919
+ ,178106
+ ,185686
+ ,230580
+ ,240636
+ ,167302
+ ,511038
+ ,172608
+ ,178106
+ ,208795
+ ,230580
+ ,168053
+ ,498662
+ ,167302
+ ,172608
+ ,197922
+ ,208795
+ ,202300
+ ,555362
+ ,168053
+ ,167302
+ ,194596
+ ,197922
+ ,202388
+ ,564591
+ ,202300
+ ,168053
+ ,194581
+ ,194596
+ ,182516
+ ,541657
+ ,202388
+ ,202300
+ ,185686
+ ,194581
+ ,173476
+ ,527070
+ ,182516
+ ,202388
+ ,178106
+ ,185686
+ ,166444
+ ,509846
+ ,173476
+ ,182516
+ ,172608
+ ,178106
+ ,171297
+ ,514258
+ ,166444
+ ,173476
+ ,167302
+ ,172608
+ ,169701
+ ,516922
+ ,171297
+ ,166444
+ ,168053
+ ,167302
+ ,164182
+ ,507561
+ ,169701
+ ,171297
+ ,202300
+ ,168053
+ ,161914
+ ,492622
+ ,164182
+ ,169701
+ ,202388
+ ,202300
+ ,159612
+ ,490243
+ ,161914
+ ,164182
+ ,182516
+ ,202388
+ ,151001
+ ,469357
+ ,159612
+ ,161914
+ ,173476
+ ,182516
+ ,158114
+ ,477580
+ ,151001
+ ,159612
+ ,166444
+ ,173476
+ ,186530
+ ,528379
+ ,158114
+ ,151001
+ ,171297
+ ,166444
+ ,187069
+ ,533590
+ ,186530
+ ,158114
+ ,169701
+ ,171297
+ ,174330
+ ,517945
+ ,187069
+ ,186530
+ ,164182
+ ,169701
+ ,169362
+ ,506174
+ ,174330
+ ,187069
+ ,161914
+ ,164182
+ ,166827
+ ,501866
+ ,169362
+ ,174330
+ ,159612
+ ,161914
+ ,178037
+ ,516141
+ ,166827
+ ,169362
+ ,151001
+ ,159612
+ ,186412
+ ,528222
+ ,178037
+ ,166827
+ ,158114
+ ,151001
+ ,189226
+ ,532638
+ ,186412
+ ,178037
+ ,186530
+ ,158114
+ ,191563
+ ,536322
+ ,189226
+ ,186412
+ ,187069
+ ,186530
+ ,188906
+ ,536535
+ ,191563
+ ,189226
+ ,174330
+ ,187069
+ ,186005
+ ,523597
+ ,188906
+ ,191563
+ ,169362
+ ,174330
+ ,195309
+ ,536214
+ ,186005
+ ,188906
+ ,166827
+ ,169362
+ ,223532
+ ,586570
+ ,195309
+ ,186005
+ ,178037
+ ,166827
+ ,226899
+ ,596594
+ ,223532
+ ,195309
+ ,186412
+ ,178037
+ ,214126
+ ,580523
+ ,226899
+ ,223532
+ ,189226
+ ,186412)
+ ,dim=c(6
+ ,61)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'y-1'
+ ,'y-2'
+ ,'y-7'
+ ,'y-8')
+ ,1:61))
> y <- array(NA,dim=c(6,61),dimnames=list(c('Y','X','y-1','y-2','y-7','y-8'),1:61))
> 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 y-1 y-2 y-7 y-8 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 243324 612613 260307 241476 213587 216234 1 0 0 0 0 0 0 0 0 0 0
2 244460 611324 243324 260307 209465 213587 0 1 0 0 0 0 0 0 0 0 0
3 233575 594167 244460 243324 204045 209465 0 0 1 0 0 0 0 0 0 0 0
4 237217 595454 233575 244460 200237 204045 0 0 0 1 0 0 0 0 0 0 0
5 235243 590865 237217 233575 203666 200237 0 0 0 0 1 0 0 0 0 0 0
6 230354 589379 235243 237217 241476 203666 0 0 0 0 0 1 0 0 0 0 0
7 227184 584428 230354 235243 260307 241476 0 0 0 0 0 0 1 0 0 0 0
8 221678 573100 227184 230354 243324 260307 0 0 0 0 0 0 0 1 0 0 0
9 217142 567456 221678 227184 244460 243324 0 0 0 0 0 0 0 0 1 0 0
10 219452 569028 217142 221678 233575 244460 0 0 0 0 0 0 0 0 0 1 0
11 256446 620735 219452 217142 237217 233575 0 0 0 0 0 0 0 0 0 0 1
12 265845 628884 256446 219452 235243 237217 0 0 0 0 0 0 0 0 0 0 0
13 248624 628232 265845 256446 230354 235243 1 0 0 0 0 0 0 0 0 0 0
14 241114 612117 248624 265845 227184 230354 0 1 0 0 0 0 0 0 0 0 0
15 229245 595404 241114 248624 221678 227184 0 0 1 0 0 0 0 0 0 0 0
16 231805 597141 229245 241114 217142 221678 0 0 0 1 0 0 0 0 0 0 0
17 219277 593408 231805 229245 219452 217142 0 0 0 0 1 0 0 0 0 0 0
18 219313 590072 219277 231805 256446 219452 0 0 0 0 0 1 0 0 0 0 0
19 212610 579799 219313 219277 265845 256446 0 0 0 0 0 0 1 0 0 0 0
20 214771 574205 212610 219313 248624 265845 0 0 0 0 0 0 0 1 0 0 0
21 211142 572775 214771 212610 241114 248624 0 0 0 0 0 0 0 0 1 0 0
22 211457 572942 211142 214771 229245 241114 0 0 0 0 0 0 0 0 0 1 0
23 240048 619567 211457 211142 231805 229245 0 0 0 0 0 0 0 0 0 0 1
24 240636 625809 240048 211457 219277 231805 0 0 0 0 0 0 0 0 0 0 0
25 230580 619916 240636 240048 219313 219277 1 0 0 0 0 0 0 0 0 0 0
26 208795 587625 230580 240636 212610 219313 0 1 0 0 0 0 0 0 0 0 0
27 197922 565742 208795 230580 214771 212610 0 0 1 0 0 0 0 0 0 0 0
28 194596 557274 197922 208795 211142 214771 0 0 0 1 0 0 0 0 0 0 0
29 194581 560576 194596 197922 211457 211142 0 0 0 0 1 0 0 0 0 0 0
30 185686 548854 194581 194596 240048 211457 0 0 0 0 0 1 0 0 0 0 0
31 178106 531673 185686 194581 240636 240048 0 0 0 0 0 0 1 0 0 0 0
32 172608 525919 178106 185686 230580 240636 0 0 0 0 0 0 0 1 0 0 0
33 167302 511038 172608 178106 208795 230580 0 0 0 0 0 0 0 0 1 0 0
34 168053 498662 167302 172608 197922 208795 0 0 0 0 0 0 0 0 0 1 0
35 202300 555362 168053 167302 194596 197922 0 0 0 0 0 0 0 0 0 0 1
36 202388 564591 202300 168053 194581 194596 0 0 0 0 0 0 0 0 0 0 0
37 182516 541657 202388 202300 185686 194581 1 0 0 0 0 0 0 0 0 0 0
38 173476 527070 182516 202388 178106 185686 0 1 0 0 0 0 0 0 0 0 0
39 166444 509846 173476 182516 172608 178106 0 0 1 0 0 0 0 0 0 0 0
40 171297 514258 166444 173476 167302 172608 0 0 0 1 0 0 0 0 0 0 0
41 169701 516922 171297 166444 168053 167302 0 0 0 0 1 0 0 0 0 0 0
42 164182 507561 169701 171297 202300 168053 0 0 0 0 0 1 0 0 0 0 0
43 161914 492622 164182 169701 202388 202300 0 0 0 0 0 0 1 0 0 0 0
44 159612 490243 161914 164182 182516 202388 0 0 0 0 0 0 0 1 0 0 0
45 151001 469357 159612 161914 173476 182516 0 0 0 0 0 0 0 0 1 0 0
46 158114 477580 151001 159612 166444 173476 0 0 0 0 0 0 0 0 0 1 0
47 186530 528379 158114 151001 171297 166444 0 0 0 0 0 0 0 0 0 0 1
48 187069 533590 186530 158114 169701 171297 0 0 0 0 0 0 0 0 0 0 0
49 174330 517945 187069 186530 164182 169701 1 0 0 0 0 0 0 0 0 0 0
50 169362 506174 174330 187069 161914 164182 0 1 0 0 0 0 0 0 0 0 0
51 166827 501866 169362 174330 159612 161914 0 0 1 0 0 0 0 0 0 0 0
52 178037 516141 166827 169362 151001 159612 0 0 0 1 0 0 0 0 0 0 0
53 186412 528222 178037 166827 158114 151001 0 0 0 0 1 0 0 0 0 0 0
54 189226 532638 186412 178037 186530 158114 0 0 0 0 0 1 0 0 0 0 0
55 191563 536322 189226 186412 187069 186530 0 0 0 0 0 0 1 0 0 0 0
56 188906 536535 191563 189226 174330 187069 0 0 0 0 0 0 0 1 0 0 0
57 186005 523597 188906 191563 169362 174330 0 0 0 0 0 0 0 0 1 0 0
58 195309 536214 186005 188906 166827 169362 0 0 0 0 0 0 0 0 0 1 0
59 223532 586570 195309 186005 178037 166827 0 0 0 0 0 0 0 0 0 0 1
60 226899 596594 223532 195309 186412 178037 0 0 0 0 0 0 0 0 0 0 0
61 214126 580523 226899 223532 189226 186412 1 0 0 0 0 0 0 0 0 0 0
t
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 51
52 52
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
61 61
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X `y-1` `y-2` `y-7` `y-8`
-6.072e+04 3.784e-01 5.519e-01 -2.902e-02 -3.836e-02 -1.920e-01
M1 M2 M3 M4 M5 M6
-1.136e+04 -7.126e+03 -6.522e+03 1.803e+02 -5.104e+03 -3.767e+03
M7 M8 M9 M10 M11 t
4.661e+03 6.373e+03 3.974e+03 8.115e+03 1.641e+04 -2.281e+02
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-9820.7 -2493.5 -270.6 1870.4 10712.0
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -6.072e+04 2.427e+04 -2.502 0.016224 *
X 3.784e-01 9.717e-02 3.894 0.000339 ***
`y-1` 5.519e-01 1.630e-01 3.385 0.001528 **
`y-2` -2.902e-02 1.390e-01 -0.209 0.835670
`y-7` -3.836e-02 1.401e-01 -0.274 0.785505
`y-8` -1.920e-01 1.305e-01 -1.471 0.148588
M1 -1.136e+04 5.068e+03 -2.241 0.030210 *
M2 -7.126e+03 7.279e+03 -0.979 0.333069
M3 -6.522e+03 6.404e+03 -1.018 0.314214
M4 1.803e+02 6.158e+03 0.029 0.976778
M5 -5.104e+03 4.649e+03 -1.098 0.278386
M6 -3.767e+03 6.356e+03 -0.593 0.556499
M7 4.661e+03 5.447e+03 0.856 0.396966
M8 6.373e+03 5.922e+03 1.076 0.287897
M9 3.974e+03 5.839e+03 0.681 0.499792
M10 8.115e+03 5.703e+03 1.423 0.161973
M11 1.641e+04 5.130e+03 3.198 0.002596 **
t -2.281e+02 8.526e+01 -2.675 0.010528 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4143 on 43 degrees of freedom
Multiple R-squared: 0.9854, Adjusted R-squared: 0.9797
F-statistic: 171.3 on 17 and 43 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.7882203 0.423559431 0.211779716
[2,] 0.8561162 0.287767613 0.143883806
[3,] 0.9265174 0.146965219 0.073482609
[4,] 0.9297029 0.140594217 0.070297109
[5,] 0.9435250 0.112949966 0.056474983
[6,] 0.9078982 0.184203690 0.092101845
[7,] 0.9219743 0.156051304 0.078025652
[8,] 0.9003374 0.199325175 0.099662587
[9,] 0.9448843 0.110231446 0.055115723
[10,] 0.9403459 0.119308291 0.059654145
[11,] 0.9535882 0.092823553 0.046411777
[12,] 0.9171122 0.165775569 0.082887784
[13,] 0.9898530 0.020293930 0.010146965
[14,] 0.9906365 0.018726974 0.009363487
[15,] 0.9959432 0.008113601 0.004056801
[16,] 0.9895531 0.020893728 0.010446864
[17,] 0.9724776 0.055044761 0.027522381
[18,] 0.9368101 0.126379886 0.063189943
[19,] 0.9233630 0.153274066 0.076637033
[20,] 0.9971147 0.005770604 0.002885302
> postscript(file="/var/www/html/rcomp/tmp/1hpwa1258577282.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/2s38y1258577282.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/3z1a01258577282.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/4bpwu1258577282.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/5prpf1258577282.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 = 61
Frequency = 1
1 2 3 4 5 6
-3149.642380 3720.271268 -3167.286061 -1632.376572 716.917794 -1414.150411
7 8 9 10 11 12
-289.209497 1578.746162 1536.001192 1481.606559 7490.144546 10712.031104
13 14 15 16 17 18
646.459973 3944.801769 849.433441 1379.798976 -6762.920911 2278.292307
19 20 21 22 23 24
-1658.569516 5979.541143 537.820717 -2955.392645 -2529.722944 -3430.091610
25 26 27 28 29 30
-1565.372096 -9820.678251 -2261.420212 -3212.536396 1870.402736 -2627.838783
31 32 33 34 35 36
-1486.506831 -2638.437042 362.335054 53.079548 1998.154676 -4291.250814
37 38 39 40 41 42
-3294.309322 -1849.479526 6.779633 -924.066100 -1888.361405 -2493.523691
43 44 45 46 47 48
2268.828165 -270.569458 -1307.339089 1460.723015 -2748.040928 -2153.853260
49 50 51 52 53 54
2625.645696 4005.084740 4572.493198 4389.180092 6063.961786 4257.220578
55 56 57 58 59 60
1165.457679 -4649.280805 -1128.817873 -40.016477 -4210.535350 -836.835421
61
4737.218128
> postscript(file="/var/www/html/rcomp/tmp/6d1we1258577282.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 -3149.642380 NA
1 3720.271268 -3149.642380
2 -3167.286061 3720.271268
3 -1632.376572 -3167.286061
4 716.917794 -1632.376572
5 -1414.150411 716.917794
6 -289.209497 -1414.150411
7 1578.746162 -289.209497
8 1536.001192 1578.746162
9 1481.606559 1536.001192
10 7490.144546 1481.606559
11 10712.031104 7490.144546
12 646.459973 10712.031104
13 3944.801769 646.459973
14 849.433441 3944.801769
15 1379.798976 849.433441
16 -6762.920911 1379.798976
17 2278.292307 -6762.920911
18 -1658.569516 2278.292307
19 5979.541143 -1658.569516
20 537.820717 5979.541143
21 -2955.392645 537.820717
22 -2529.722944 -2955.392645
23 -3430.091610 -2529.722944
24 -1565.372096 -3430.091610
25 -9820.678251 -1565.372096
26 -2261.420212 -9820.678251
27 -3212.536396 -2261.420212
28 1870.402736 -3212.536396
29 -2627.838783 1870.402736
30 -1486.506831 -2627.838783
31 -2638.437042 -1486.506831
32 362.335054 -2638.437042
33 53.079548 362.335054
34 1998.154676 53.079548
35 -4291.250814 1998.154676
36 -3294.309322 -4291.250814
37 -1849.479526 -3294.309322
38 6.779633 -1849.479526
39 -924.066100 6.779633
40 -1888.361405 -924.066100
41 -2493.523691 -1888.361405
42 2268.828165 -2493.523691
43 -270.569458 2268.828165
44 -1307.339089 -270.569458
45 1460.723015 -1307.339089
46 -2748.040928 1460.723015
47 -2153.853260 -2748.040928
48 2625.645696 -2153.853260
49 4005.084740 2625.645696
50 4572.493198 4005.084740
51 4389.180092 4572.493198
52 6063.961786 4389.180092
53 4257.220578 6063.961786
54 1165.457679 4257.220578
55 -4649.280805 1165.457679
56 -1128.817873 -4649.280805
57 -40.016477 -1128.817873
58 -4210.535350 -40.016477
59 -836.835421 -4210.535350
60 4737.218128 -836.835421
61 NA 4737.218128
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3720.271268 -3149.642380
[2,] -3167.286061 3720.271268
[3,] -1632.376572 -3167.286061
[4,] 716.917794 -1632.376572
[5,] -1414.150411 716.917794
[6,] -289.209497 -1414.150411
[7,] 1578.746162 -289.209497
[8,] 1536.001192 1578.746162
[9,] 1481.606559 1536.001192
[10,] 7490.144546 1481.606559
[11,] 10712.031104 7490.144546
[12,] 646.459973 10712.031104
[13,] 3944.801769 646.459973
[14,] 849.433441 3944.801769
[15,] 1379.798976 849.433441
[16,] -6762.920911 1379.798976
[17,] 2278.292307 -6762.920911
[18,] -1658.569516 2278.292307
[19,] 5979.541143 -1658.569516
[20,] 537.820717 5979.541143
[21,] -2955.392645 537.820717
[22,] -2529.722944 -2955.392645
[23,] -3430.091610 -2529.722944
[24,] -1565.372096 -3430.091610
[25,] -9820.678251 -1565.372096
[26,] -2261.420212 -9820.678251
[27,] -3212.536396 -2261.420212
[28,] 1870.402736 -3212.536396
[29,] -2627.838783 1870.402736
[30,] -1486.506831 -2627.838783
[31,] -2638.437042 -1486.506831
[32,] 362.335054 -2638.437042
[33,] 53.079548 362.335054
[34,] 1998.154676 53.079548
[35,] -4291.250814 1998.154676
[36,] -3294.309322 -4291.250814
[37,] -1849.479526 -3294.309322
[38,] 6.779633 -1849.479526
[39,] -924.066100 6.779633
[40,] -1888.361405 -924.066100
[41,] -2493.523691 -1888.361405
[42,] 2268.828165 -2493.523691
[43,] -270.569458 2268.828165
[44,] -1307.339089 -270.569458
[45,] 1460.723015 -1307.339089
[46,] -2748.040928 1460.723015
[47,] -2153.853260 -2748.040928
[48,] 2625.645696 -2153.853260
[49,] 4005.084740 2625.645696
[50,] 4572.493198 4005.084740
[51,] 4389.180092 4572.493198
[52,] 6063.961786 4389.180092
[53,] 4257.220578 6063.961786
[54,] 1165.457679 4257.220578
[55,] -4649.280805 1165.457679
[56,] -1128.817873 -4649.280805
[57,] -40.016477 -1128.817873
[58,] -4210.535350 -40.016477
[59,] -836.835421 -4210.535350
[60,] 4737.218128 -836.835421
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3720.271268 -3149.642380
2 -3167.286061 3720.271268
3 -1632.376572 -3167.286061
4 716.917794 -1632.376572
5 -1414.150411 716.917794
6 -289.209497 -1414.150411
7 1578.746162 -289.209497
8 1536.001192 1578.746162
9 1481.606559 1536.001192
10 7490.144546 1481.606559
11 10712.031104 7490.144546
12 646.459973 10712.031104
13 3944.801769 646.459973
14 849.433441 3944.801769
15 1379.798976 849.433441
16 -6762.920911 1379.798976
17 2278.292307 -6762.920911
18 -1658.569516 2278.292307
19 5979.541143 -1658.569516
20 537.820717 5979.541143
21 -2955.392645 537.820717
22 -2529.722944 -2955.392645
23 -3430.091610 -2529.722944
24 -1565.372096 -3430.091610
25 -9820.678251 -1565.372096
26 -2261.420212 -9820.678251
27 -3212.536396 -2261.420212
28 1870.402736 -3212.536396
29 -2627.838783 1870.402736
30 -1486.506831 -2627.838783
31 -2638.437042 -1486.506831
32 362.335054 -2638.437042
33 53.079548 362.335054
34 1998.154676 53.079548
35 -4291.250814 1998.154676
36 -3294.309322 -4291.250814
37 -1849.479526 -3294.309322
38 6.779633 -1849.479526
39 -924.066100 6.779633
40 -1888.361405 -924.066100
41 -2493.523691 -1888.361405
42 2268.828165 -2493.523691
43 -270.569458 2268.828165
44 -1307.339089 -270.569458
45 1460.723015 -1307.339089
46 -2748.040928 1460.723015
47 -2153.853260 -2748.040928
48 2625.645696 -2153.853260
49 4005.084740 2625.645696
50 4572.493198 4005.084740
51 4389.180092 4572.493198
52 6063.961786 4389.180092
53 4257.220578 6063.961786
54 1165.457679 4257.220578
55 -4649.280805 1165.457679
56 -1128.817873 -4649.280805
57 -40.016477 -1128.817873
58 -4210.535350 -40.016477
59 -836.835421 -4210.535350
60 4737.218128 -836.835421
> 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/7r0941258577282.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/8y0du1258577282.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/9cbwb1258577282.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/10cp011258577282.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/11lffp1258577282.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/1263sw1258577282.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/13befe1258577282.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/14i8461258577282.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/15poet1258577282.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/16nbuh1258577282.tab")
+ }
>
> system("convert tmp/1hpwa1258577282.ps tmp/1hpwa1258577282.png")
> system("convert tmp/2s38y1258577282.ps tmp/2s38y1258577282.png")
> system("convert tmp/3z1a01258577282.ps tmp/3z1a01258577282.png")
> system("convert tmp/4bpwu1258577282.ps tmp/4bpwu1258577282.png")
> system("convert tmp/5prpf1258577282.ps tmp/5prpf1258577282.png")
> system("convert tmp/6d1we1258577282.ps tmp/6d1we1258577282.png")
> system("convert tmp/7r0941258577282.ps tmp/7r0941258577282.png")
> system("convert tmp/8y0du1258577282.ps tmp/8y0du1258577282.png")
> system("convert tmp/9cbwb1258577282.ps tmp/9cbwb1258577282.png")
> system("convert tmp/10cp011258577282.ps tmp/10cp011258577282.png")
>
>
> proc.time()
user system elapsed
2.351 1.581 2.875