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(200237
+ ,536662
+ ,204045
+ ,209465
+ ,213587
+ ,216234
+ ,203666
+ ,542722
+ ,200237
+ ,204045
+ ,209465
+ ,213587
+ ,241476
+ ,593530
+ ,203666
+ ,200237
+ ,204045
+ ,209465
+ ,260307
+ ,610763
+ ,241476
+ ,203666
+ ,200237
+ ,204045
+ ,243324
+ ,612613
+ ,260307
+ ,241476
+ ,203666
+ ,200237
+ ,244460
+ ,611324
+ ,243324
+ ,260307
+ ,241476
+ ,203666
+ ,233575
+ ,594167
+ ,244460
+ ,243324
+ ,260307
+ ,241476
+ ,237217
+ ,595454
+ ,233575
+ ,244460
+ ,243324
+ ,260307
+ ,235243
+ ,590865
+ ,237217
+ ,233575
+ ,244460
+ ,243324
+ ,230354
+ ,589379
+ ,235243
+ ,237217
+ ,233575
+ ,244460
+ ,227184
+ ,584428
+ ,230354
+ ,235243
+ ,237217
+ ,233575
+ ,221678
+ ,573100
+ ,227184
+ ,230354
+ ,235243
+ ,237217
+ ,217142
+ ,567456
+ ,221678
+ ,227184
+ ,230354
+ ,235243
+ ,219452
+ ,569028
+ ,217142
+ ,221678
+ ,227184
+ ,230354
+ ,256446
+ ,620735
+ ,219452
+ ,217142
+ ,221678
+ ,227184
+ ,265845
+ ,628884
+ ,256446
+ ,219452
+ ,217142
+ ,221678
+ ,248624
+ ,628232
+ ,265845
+ ,256446
+ ,219452
+ ,217142
+ ,241114
+ ,612117
+ ,248624
+ ,265845
+ ,256446
+ ,219452
+ ,229245
+ ,595404
+ ,241114
+ ,248624
+ ,265845
+ ,256446
+ ,231805
+ ,597141
+ ,229245
+ ,241114
+ ,248624
+ ,265845
+ ,219277
+ ,593408
+ ,231805
+ ,229245
+ ,241114
+ ,248624
+ ,219313
+ ,590072
+ ,219277
+ ,231805
+ ,229245
+ ,241114
+ ,212610
+ ,579799
+ ,219313
+ ,219277
+ ,231805
+ ,229245
+ ,214771
+ ,574205
+ ,212610
+ ,219313
+ ,219277
+ ,231805
+ ,211142
+ ,572775
+ ,214771
+ ,212610
+ ,219313
+ ,219277
+ ,211457
+ ,572942
+ ,211142
+ ,214771
+ ,212610
+ ,219313
+ ,240048
+ ,619567
+ ,211457
+ ,211142
+ ,214771
+ ,212610
+ ,240636
+ ,625809
+ ,240048
+ ,211457
+ ,211142
+ ,214771
+ ,230580
+ ,619916
+ ,240636
+ ,240048
+ ,211457
+ ,211142
+ ,208795
+ ,587625
+ ,230580
+ ,240636
+ ,240048
+ ,211457
+ ,197922
+ ,565742
+ ,208795
+ ,230580
+ ,240636
+ ,240048
+ ,194596
+ ,557274
+ ,197922
+ ,208795
+ ,230580
+ ,240636
+ ,194581
+ ,560576
+ ,194596
+ ,197922
+ ,208795
+ ,230580
+ ,185686
+ ,548854
+ ,194581
+ ,194596
+ ,197922
+ ,208795
+ ,178106
+ ,531673
+ ,185686
+ ,194581
+ ,194596
+ ,197922
+ ,172608
+ ,525919
+ ,178106
+ ,185686
+ ,194581
+ ,194596
+ ,167302
+ ,511038
+ ,172608
+ ,178106
+ ,185686
+ ,194581
+ ,168053
+ ,498662
+ ,167302
+ ,172608
+ ,178106
+ ,185686
+ ,202300
+ ,555362
+ ,168053
+ ,167302
+ ,172608
+ ,178106
+ ,202388
+ ,564591
+ ,202300
+ ,168053
+ ,167302
+ ,172608
+ ,182516
+ ,541657
+ ,202388
+ ,202300
+ ,168053
+ ,167302
+ ,173476
+ ,527070
+ ,182516
+ ,202388
+ ,202300
+ ,168053
+ ,166444
+ ,509846
+ ,173476
+ ,182516
+ ,202388
+ ,202300
+ ,171297
+ ,514258
+ ,166444
+ ,173476
+ ,182516
+ ,202388
+ ,169701
+ ,516922
+ ,171297
+ ,166444
+ ,173476
+ ,182516
+ ,164182
+ ,507561
+ ,169701
+ ,171297
+ ,166444
+ ,173476
+ ,161914
+ ,492622
+ ,164182
+ ,169701
+ ,171297
+ ,166444
+ ,159612
+ ,490243
+ ,161914
+ ,164182
+ ,169701
+ ,171297
+ ,151001
+ ,469357
+ ,159612
+ ,161914
+ ,164182
+ ,169701
+ ,158114
+ ,477580
+ ,151001
+ ,159612
+ ,161914
+ ,164182
+ ,186530
+ ,528379
+ ,158114
+ ,151001
+ ,159612
+ ,161914
+ ,187069
+ ,533590
+ ,186530
+ ,158114
+ ,151001
+ ,159612
+ ,174330
+ ,517945
+ ,187069
+ ,186530
+ ,158114
+ ,151001
+ ,169362
+ ,506174
+ ,174330
+ ,187069
+ ,186530
+ ,158114
+ ,166827
+ ,501866
+ ,169362
+ ,174330
+ ,187069
+ ,186530
+ ,178037
+ ,516141
+ ,166827
+ ,169362
+ ,174330
+ ,187069
+ ,186412
+ ,528222
+ ,178037
+ ,166827
+ ,169362
+ ,174330
+ ,189226
+ ,532638
+ ,186412
+ ,178037
+ ,166827
+ ,169362
+ ,191563
+ ,536322
+ ,189226
+ ,186412
+ ,178037
+ ,166827
+ ,188906
+ ,536535
+ ,191563
+ ,189226
+ ,186412
+ ,178037
+ ,186005
+ ,523597
+ ,188906
+ ,191563
+ ,189226
+ ,186412
+ ,195309
+ ,536214
+ ,186005
+ ,188906
+ ,191563
+ ,189226
+ ,223532
+ ,586570
+ ,195309
+ ,186005
+ ,188906
+ ,191563
+ ,226899
+ ,596594
+ ,223532
+ ,195309
+ ,186005
+ ,188906
+ ,214126
+ ,580523
+ ,226899
+ ,223532
+ ,195309
+ ,186005)
+ ,dim=c(6
+ ,65)
+ ,dimnames=list(c('yt'
+ ,'xt'
+ ,'yt-1'
+ ,'yt-2'
+ ,'yt-3'
+ ,'yt-4')
+ ,1:65))
> y <- array(NA,dim=c(6,65),dimnames=list(c('yt','xt','yt-1','yt-2','yt-3','yt-4'),1:65))
> 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
yt xt yt-1 yt-2 yt-3 yt-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 200237 536662 204045 209465 213587 216234 1 0 0 0 0 0 0 0 0 0 0
2 203666 542722 200237 204045 209465 213587 0 1 0 0 0 0 0 0 0 0 0
3 241476 593530 203666 200237 204045 209465 0 0 1 0 0 0 0 0 0 0 0
4 260307 610763 241476 203666 200237 204045 0 0 0 1 0 0 0 0 0 0 0
5 243324 612613 260307 241476 203666 200237 0 0 0 0 1 0 0 0 0 0 0
6 244460 611324 243324 260307 241476 203666 0 0 0 0 0 1 0 0 0 0 0
7 233575 594167 244460 243324 260307 241476 0 0 0 0 0 0 1 0 0 0 0
8 237217 595454 233575 244460 243324 260307 0 0 0 0 0 0 0 1 0 0 0
9 235243 590865 237217 233575 244460 243324 0 0 0 0 0 0 0 0 1 0 0
10 230354 589379 235243 237217 233575 244460 0 0 0 0 0 0 0 0 0 1 0
11 227184 584428 230354 235243 237217 233575 0 0 0 0 0 0 0 0 0 0 1
12 221678 573100 227184 230354 235243 237217 0 0 0 0 0 0 0 0 0 0 0
13 217142 567456 221678 227184 230354 235243 1 0 0 0 0 0 0 0 0 0 0
14 219452 569028 217142 221678 227184 230354 0 1 0 0 0 0 0 0 0 0 0
15 256446 620735 219452 217142 221678 227184 0 0 1 0 0 0 0 0 0 0 0
16 265845 628884 256446 219452 217142 221678 0 0 0 1 0 0 0 0 0 0 0
17 248624 628232 265845 256446 219452 217142 0 0 0 0 1 0 0 0 0 0 0
18 241114 612117 248624 265845 256446 219452 0 0 0 0 0 1 0 0 0 0 0
19 229245 595404 241114 248624 265845 256446 0 0 0 0 0 0 1 0 0 0 0
20 231805 597141 229245 241114 248624 265845 0 0 0 0 0 0 0 1 0 0 0
21 219277 593408 231805 229245 241114 248624 0 0 0 0 0 0 0 0 1 0 0
22 219313 590072 219277 231805 229245 241114 0 0 0 0 0 0 0 0 0 1 0
23 212610 579799 219313 219277 231805 229245 0 0 0 0 0 0 0 0 0 0 1
24 214771 574205 212610 219313 219277 231805 0 0 0 0 0 0 0 0 0 0 0
25 211142 572775 214771 212610 219313 219277 1 0 0 0 0 0 0 0 0 0 0
26 211457 572942 211142 214771 212610 219313 0 1 0 0 0 0 0 0 0 0 0
27 240048 619567 211457 211142 214771 212610 0 0 1 0 0 0 0 0 0 0 0
28 240636 625809 240048 211457 211142 214771 0 0 0 1 0 0 0 0 0 0 0
29 230580 619916 240636 240048 211457 211142 0 0 0 0 1 0 0 0 0 0 0
30 208795 587625 230580 240636 240048 211457 0 0 0 0 0 1 0 0 0 0 0
31 197922 565742 208795 230580 240636 240048 0 0 0 0 0 0 1 0 0 0 0
32 194596 557274 197922 208795 230580 240636 0 0 0 0 0 0 0 1 0 0 0
33 194581 560576 194596 197922 208795 230580 0 0 0 0 0 0 0 0 1 0 0
34 185686 548854 194581 194596 197922 208795 0 0 0 0 0 0 0 0 0 1 0
35 178106 531673 185686 194581 194596 197922 0 0 0 0 0 0 0 0 0 0 1
36 172608 525919 178106 185686 194581 194596 0 0 0 0 0 0 0 0 0 0 0
37 167302 511038 172608 178106 185686 194581 1 0 0 0 0 0 0 0 0 0 0
38 168053 498662 167302 172608 178106 185686 0 1 0 0 0 0 0 0 0 0 0
39 202300 555362 168053 167302 172608 178106 0 0 1 0 0 0 0 0 0 0 0
40 202388 564591 202300 168053 167302 172608 0 0 0 1 0 0 0 0 0 0 0
41 182516 541657 202388 202300 168053 167302 0 0 0 0 1 0 0 0 0 0 0
42 173476 527070 182516 202388 202300 168053 0 0 0 0 0 1 0 0 0 0 0
43 166444 509846 173476 182516 202388 202300 0 0 0 0 0 0 1 0 0 0 0
44 171297 514258 166444 173476 182516 202388 0 0 0 0 0 0 0 1 0 0 0
45 169701 516922 171297 166444 173476 182516 0 0 0 0 0 0 0 0 1 0 0
46 164182 507561 169701 171297 166444 173476 0 0 0 0 0 0 0 0 0 1 0
47 161914 492622 164182 169701 171297 166444 0 0 0 0 0 0 0 0 0 0 1
48 159612 490243 161914 164182 169701 171297 0 0 0 0 0 0 0 0 0 0 0
49 151001 469357 159612 161914 164182 169701 1 0 0 0 0 0 0 0 0 0 0
50 158114 477580 151001 159612 161914 164182 0 1 0 0 0 0 0 0 0 0 0
51 186530 528379 158114 151001 159612 161914 0 0 1 0 0 0 0 0 0 0 0
52 187069 533590 186530 158114 151001 159612 0 0 0 1 0 0 0 0 0 0 0
53 174330 517945 187069 186530 158114 151001 0 0 0 0 1 0 0 0 0 0 0
54 169362 506174 174330 187069 186530 158114 0 0 0 0 0 1 0 0 0 0 0
55 166827 501866 169362 174330 187069 186530 0 0 0 0 0 0 1 0 0 0 0
56 178037 516141 166827 169362 174330 187069 0 0 0 0 0 0 0 1 0 0 0
57 186412 528222 178037 166827 169362 174330 0 0 0 0 0 0 0 0 1 0 0
58 189226 532638 186412 178037 166827 169362 0 0 0 0 0 0 0 0 0 1 0
59 191563 536322 189226 186412 178037 166827 0 0 0 0 0 0 0 0 0 0 1
60 188906 536535 191563 189226 186412 178037 0 0 0 0 0 0 0 0 0 0 0
61 186005 523597 188906 191563 189226 186412 1 0 0 0 0 0 0 0 0 0 0
62 195309 536214 186005 188906 191563 189226 0 1 0 0 0 0 0 0 0 0 0
63 223532 586570 195309 186005 188906 191563 0 0 1 0 0 0 0 0 0 0 0
64 226899 596594 223532 195309 186005 188906 0 0 0 1 0 0 0 0 0 0 0
65 214126 580523 226899 223532 195309 186005 0 0 0 0 1 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
62 62
63 63
64 64
65 65
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) xt `yt-1` `yt-2` `yt-3` `yt-4`
-3.697e+04 2.252e-01 7.801e-01 2.647e-01 -2.542e-01 -2.031e-01
M1 M2 M3 M4 M5 M6
-3.480e+02 6.079e+03 2.378e+04 -8.800e+02 -2.629e+04 -1.303e+04
M7 M8 M9 M10 M11 t
8.371e+02 1.042e+04 2.635e+03 -3.259e+03 -2.451e+03 -1.331e+02
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-9173.9 -2923.7 263.6 2370.8 11180.2
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.697e+04 2.294e+04 -1.612 0.11375
xt 2.252e-01 9.014e-02 2.498 0.01603 *
`yt-1` 7.801e-01 1.655e-01 4.712 2.21e-05 ***
`yt-2` 2.647e-01 1.950e-01 1.358 0.18104
`yt-3` -2.542e-01 1.932e-01 -1.316 0.19465
`yt-4` -2.031e-01 1.483e-01 -1.369 0.17740
M1 -3.480e+02 2.867e+03 -0.121 0.90390
M2 6.079e+03 2.785e+03 2.183 0.03410 *
M3 2.378e+04 5.409e+03 4.396 6.27e-05 ***
M4 -8.800e+02 6.193e+03 -0.142 0.88761
M5 -2.629e+04 5.194e+03 -5.061 6.84e-06 ***
M6 -1.303e+04 6.464e+03 -2.015 0.04960 *
M7 8.371e+02 3.603e+03 0.232 0.81730
M8 1.042e+04 3.476e+03 2.998 0.00433 **
M9 2.635e+03 3.462e+03 0.761 0.45047
M10 -3.259e+03 3.241e+03 -1.006 0.31976
M11 -2.451e+03 2.986e+03 -0.821 0.41591
t -1.331e+02 5.795e+01 -2.297 0.02612 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4551 on 47 degrees of freedom
Multiple R-squared: 0.9824, Adjusted R-squared: 0.9761
F-statistic: 154.4 on 17 and 47 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.2985329 0.597065728 0.701467136
[2,] 0.2477837 0.495567451 0.752216275
[3,] 0.1721493 0.344298644 0.827850678
[4,] 0.8172629 0.365474125 0.182737063
[5,] 0.7515491 0.496901867 0.248450934
[6,] 0.6483692 0.703261598 0.351630799
[7,] 0.7101832 0.579633536 0.289816768
[8,] 0.9662009 0.067598206 0.033799103
[9,] 0.9791879 0.041624263 0.020812132
[10,] 0.9627891 0.074421826 0.037210913
[11,] 0.9761448 0.047710317 0.023855159
[12,] 0.9878620 0.024275910 0.012137955
[13,] 0.9914932 0.017013636 0.008506818
[14,] 0.9860476 0.027904739 0.013952369
[15,] 0.9763854 0.047229197 0.023614598
[16,] 0.9552034 0.089593134 0.044796567
[17,] 0.9817540 0.036492033 0.018246016
[18,] 0.9930430 0.013913907 0.006956954
[19,] 0.9969020 0.006196024 0.003098012
[20,] 0.9924306 0.015138754 0.007569377
[21,] 0.9801586 0.039682786 0.019841393
[22,] 0.9577855 0.084429091 0.042214546
[23,] 0.9512918 0.097416376 0.048708188
[24,] 0.9724039 0.055192265 0.027596132
> postscript(file="/var/www/html/rcomp/tmp/1jwu41259314409.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/2wmu71259314409.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/37ygy1259314409.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/4a3a21259314409.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/5jsbk1259314409.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 = 65
Frequency = 1
1 2 3 4 5 6
400.33996 -1009.07337 3910.83850 11180.21400 -5278.54939 1591.31557
7 8 9 10 11 12
-3087.44466 -1488.63829 2370.77310 1882.47023 2204.34372 936.81212
13 14 15 16 17 18
1643.70141 503.46405 5641.99300 6255.45290 -2736.31780 1074.43901
19 20 21 22 23 24
-444.03699 1052.11492 -6976.89554 4390.15367 854.72681 4512.52073
25 26 27 28 29 30
-759.37654 -6213.42712 -5785.60685 -4683.08503 3445.33607 -9173.88057
31 32 33 34 35 36
-3239.09688 -2296.42157 2757.23945 -3766.56199 -4262.76954 -3193.87280
37 38 39 40 41 42
-636.06014 -1529.96692 263.62696 -6315.65339 -5502.31249 -47.68765
43 44 45 46 47 48
2356.54183 -389.54651 -2923.68503 -3970.73387 984.16654 710.33534
49 50 51 52 53 54
-2046.65728 2550.25980 -2355.09362 -4905.14324 3537.56408 6555.81364
55 56 57 58 59 60
4414.03669 3122.49145 4772.56802 1464.67196 219.53247 -2965.79539
61 62 63 64 65
1398.05258 5698.74356 -1675.75799 -1531.78524 6534.27954
> postscript(file="/var/www/html/rcomp/tmp/6syfv1259314409.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 = 65
Frequency = 1
lag(myerror, k = 1) myerror
0 400.33996 NA
1 -1009.07337 400.33996
2 3910.83850 -1009.07337
3 11180.21400 3910.83850
4 -5278.54939 11180.21400
5 1591.31557 -5278.54939
6 -3087.44466 1591.31557
7 -1488.63829 -3087.44466
8 2370.77310 -1488.63829
9 1882.47023 2370.77310
10 2204.34372 1882.47023
11 936.81212 2204.34372
12 1643.70141 936.81212
13 503.46405 1643.70141
14 5641.99300 503.46405
15 6255.45290 5641.99300
16 -2736.31780 6255.45290
17 1074.43901 -2736.31780
18 -444.03699 1074.43901
19 1052.11492 -444.03699
20 -6976.89554 1052.11492
21 4390.15367 -6976.89554
22 854.72681 4390.15367
23 4512.52073 854.72681
24 -759.37654 4512.52073
25 -6213.42712 -759.37654
26 -5785.60685 -6213.42712
27 -4683.08503 -5785.60685
28 3445.33607 -4683.08503
29 -9173.88057 3445.33607
30 -3239.09688 -9173.88057
31 -2296.42157 -3239.09688
32 2757.23945 -2296.42157
33 -3766.56199 2757.23945
34 -4262.76954 -3766.56199
35 -3193.87280 -4262.76954
36 -636.06014 -3193.87280
37 -1529.96692 -636.06014
38 263.62696 -1529.96692
39 -6315.65339 263.62696
40 -5502.31249 -6315.65339
41 -47.68765 -5502.31249
42 2356.54183 -47.68765
43 -389.54651 2356.54183
44 -2923.68503 -389.54651
45 -3970.73387 -2923.68503
46 984.16654 -3970.73387
47 710.33534 984.16654
48 -2046.65728 710.33534
49 2550.25980 -2046.65728
50 -2355.09362 2550.25980
51 -4905.14324 -2355.09362
52 3537.56408 -4905.14324
53 6555.81364 3537.56408
54 4414.03669 6555.81364
55 3122.49145 4414.03669
56 4772.56802 3122.49145
57 1464.67196 4772.56802
58 219.53247 1464.67196
59 -2965.79539 219.53247
60 1398.05258 -2965.79539
61 5698.74356 1398.05258
62 -1675.75799 5698.74356
63 -1531.78524 -1675.75799
64 6534.27954 -1531.78524
65 NA 6534.27954
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1009.07337 400.33996
[2,] 3910.83850 -1009.07337
[3,] 11180.21400 3910.83850
[4,] -5278.54939 11180.21400
[5,] 1591.31557 -5278.54939
[6,] -3087.44466 1591.31557
[7,] -1488.63829 -3087.44466
[8,] 2370.77310 -1488.63829
[9,] 1882.47023 2370.77310
[10,] 2204.34372 1882.47023
[11,] 936.81212 2204.34372
[12,] 1643.70141 936.81212
[13,] 503.46405 1643.70141
[14,] 5641.99300 503.46405
[15,] 6255.45290 5641.99300
[16,] -2736.31780 6255.45290
[17,] 1074.43901 -2736.31780
[18,] -444.03699 1074.43901
[19,] 1052.11492 -444.03699
[20,] -6976.89554 1052.11492
[21,] 4390.15367 -6976.89554
[22,] 854.72681 4390.15367
[23,] 4512.52073 854.72681
[24,] -759.37654 4512.52073
[25,] -6213.42712 -759.37654
[26,] -5785.60685 -6213.42712
[27,] -4683.08503 -5785.60685
[28,] 3445.33607 -4683.08503
[29,] -9173.88057 3445.33607
[30,] -3239.09688 -9173.88057
[31,] -2296.42157 -3239.09688
[32,] 2757.23945 -2296.42157
[33,] -3766.56199 2757.23945
[34,] -4262.76954 -3766.56199
[35,] -3193.87280 -4262.76954
[36,] -636.06014 -3193.87280
[37,] -1529.96692 -636.06014
[38,] 263.62696 -1529.96692
[39,] -6315.65339 263.62696
[40,] -5502.31249 -6315.65339
[41,] -47.68765 -5502.31249
[42,] 2356.54183 -47.68765
[43,] -389.54651 2356.54183
[44,] -2923.68503 -389.54651
[45,] -3970.73387 -2923.68503
[46,] 984.16654 -3970.73387
[47,] 710.33534 984.16654
[48,] -2046.65728 710.33534
[49,] 2550.25980 -2046.65728
[50,] -2355.09362 2550.25980
[51,] -4905.14324 -2355.09362
[52,] 3537.56408 -4905.14324
[53,] 6555.81364 3537.56408
[54,] 4414.03669 6555.81364
[55,] 3122.49145 4414.03669
[56,] 4772.56802 3122.49145
[57,] 1464.67196 4772.56802
[58,] 219.53247 1464.67196
[59,] -2965.79539 219.53247
[60,] 1398.05258 -2965.79539
[61,] 5698.74356 1398.05258
[62,] -1675.75799 5698.74356
[63,] -1531.78524 -1675.75799
[64,] 6534.27954 -1531.78524
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1009.07337 400.33996
2 3910.83850 -1009.07337
3 11180.21400 3910.83850
4 -5278.54939 11180.21400
5 1591.31557 -5278.54939
6 -3087.44466 1591.31557
7 -1488.63829 -3087.44466
8 2370.77310 -1488.63829
9 1882.47023 2370.77310
10 2204.34372 1882.47023
11 936.81212 2204.34372
12 1643.70141 936.81212
13 503.46405 1643.70141
14 5641.99300 503.46405
15 6255.45290 5641.99300
16 -2736.31780 6255.45290
17 1074.43901 -2736.31780
18 -444.03699 1074.43901
19 1052.11492 -444.03699
20 -6976.89554 1052.11492
21 4390.15367 -6976.89554
22 854.72681 4390.15367
23 4512.52073 854.72681
24 -759.37654 4512.52073
25 -6213.42712 -759.37654
26 -5785.60685 -6213.42712
27 -4683.08503 -5785.60685
28 3445.33607 -4683.08503
29 -9173.88057 3445.33607
30 -3239.09688 -9173.88057
31 -2296.42157 -3239.09688
32 2757.23945 -2296.42157
33 -3766.56199 2757.23945
34 -4262.76954 -3766.56199
35 -3193.87280 -4262.76954
36 -636.06014 -3193.87280
37 -1529.96692 -636.06014
38 263.62696 -1529.96692
39 -6315.65339 263.62696
40 -5502.31249 -6315.65339
41 -47.68765 -5502.31249
42 2356.54183 -47.68765
43 -389.54651 2356.54183
44 -2923.68503 -389.54651
45 -3970.73387 -2923.68503
46 984.16654 -3970.73387
47 710.33534 984.16654
48 -2046.65728 710.33534
49 2550.25980 -2046.65728
50 -2355.09362 2550.25980
51 -4905.14324 -2355.09362
52 3537.56408 -4905.14324
53 6555.81364 3537.56408
54 4414.03669 6555.81364
55 3122.49145 4414.03669
56 4772.56802 3122.49145
57 1464.67196 4772.56802
58 219.53247 1464.67196
59 -2965.79539 219.53247
60 1398.05258 -2965.79539
61 5698.74356 1398.05258
62 -1675.75799 5698.74356
63 -1531.78524 -1675.75799
64 6534.27954 -1531.78524
> 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/7b8ui1259314409.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/8vf9z1259314409.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/9v4gy1259314409.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/1015k11259314409.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/1104ne1259314409.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/12cgv81259314409.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/1344cy1259314410.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/14dz331259314410.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/15jcqu1259314410.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/16ykn81259314410.tab")
+ }
>
> system("convert tmp/1jwu41259314409.ps tmp/1jwu41259314409.png")
> system("convert tmp/2wmu71259314409.ps tmp/2wmu71259314409.png")
> system("convert tmp/37ygy1259314409.ps tmp/37ygy1259314409.png")
> system("convert tmp/4a3a21259314409.ps tmp/4a3a21259314409.png")
> system("convert tmp/5jsbk1259314409.ps tmp/5jsbk1259314409.png")
> system("convert tmp/6syfv1259314409.ps tmp/6syfv1259314409.png")
> system("convert tmp/7b8ui1259314409.ps tmp/7b8ui1259314409.png")
> system("convert tmp/8vf9z1259314409.ps tmp/8vf9z1259314409.png")
> system("convert tmp/9v4gy1259314409.ps tmp/9v4gy1259314409.png")
> system("convert tmp/1015k11259314409.ps tmp/1015k11259314409.png")
>
>
> proc.time()
user system elapsed
2.409 1.552 3.996