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(562325
+ ,0
+ ,543599
+ ,555332
+ ,560854
+ ,562325
+ ,560854
+ ,0
+ ,562325
+ ,543599
+ ,555332
+ ,560854
+ ,555332
+ ,0
+ ,560854
+ ,562325
+ ,543599
+ ,555332
+ ,543599
+ ,0
+ ,555332
+ ,560854
+ ,562325
+ ,543599
+ ,536662
+ ,0
+ ,543599
+ ,555332
+ ,560854
+ ,562325
+ ,542722
+ ,0
+ ,536662
+ ,543599
+ ,555332
+ ,560854
+ ,593530
+ ,0
+ ,542722
+ ,536662
+ ,543599
+ ,555332
+ ,610763
+ ,0
+ ,593530
+ ,542722
+ ,536662
+ ,543599
+ ,612613
+ ,0
+ ,610763
+ ,593530
+ ,542722
+ ,536662
+ ,611324
+ ,0
+ ,612613
+ ,610763
+ ,593530
+ ,542722
+ ,594167
+ ,0
+ ,611324
+ ,612613
+ ,610763
+ ,593530
+ ,595454
+ ,0
+ ,594167
+ ,611324
+ ,612613
+ ,610763
+ ,590865
+ ,0
+ ,595454
+ ,594167
+ ,611324
+ ,612613
+ ,589379
+ ,0
+ ,590865
+ ,595454
+ ,594167
+ ,611324
+ ,584428
+ ,0
+ ,589379
+ ,590865
+ ,595454
+ ,594167
+ ,573100
+ ,0
+ ,584428
+ ,589379
+ ,590865
+ ,595454
+ ,567456
+ ,0
+ ,573100
+ ,584428
+ ,589379
+ ,590865
+ ,569028
+ ,0
+ ,567456
+ ,573100
+ ,584428
+ ,589379
+ ,620735
+ ,0
+ ,569028
+ ,567456
+ ,573100
+ ,584428
+ ,628884
+ ,0
+ ,620735
+ ,569028
+ ,567456
+ ,573100
+ ,628232
+ ,0
+ ,628884
+ ,620735
+ ,569028
+ ,567456
+ ,612117
+ ,0
+ ,628232
+ ,628884
+ ,620735
+ ,569028
+ ,595404
+ ,0
+ ,612117
+ ,628232
+ ,628884
+ ,620735
+ ,597141
+ ,0
+ ,595404
+ ,612117
+ ,628232
+ ,628884
+ ,593408
+ ,0
+ ,597141
+ ,595404
+ ,612117
+ ,628232
+ ,590072
+ ,0
+ ,593408
+ ,597141
+ ,595404
+ ,612117
+ ,579799
+ ,0
+ ,590072
+ ,593408
+ ,597141
+ ,595404
+ ,574205
+ ,0
+ ,579799
+ ,590072
+ ,593408
+ ,597141
+ ,572775
+ ,0
+ ,574205
+ ,579799
+ ,590072
+ ,593408
+ ,572942
+ ,0
+ ,572775
+ ,574205
+ ,579799
+ ,590072
+ ,619567
+ ,0
+ ,572942
+ ,572775
+ ,574205
+ ,579799
+ ,625809
+ ,0
+ ,619567
+ ,572942
+ ,572775
+ ,574205
+ ,619916
+ ,0
+ ,625809
+ ,619567
+ ,572942
+ ,572775
+ ,587625
+ ,0
+ ,619916
+ ,625809
+ ,619567
+ ,572942
+ ,565742
+ ,0
+ ,587625
+ ,619916
+ ,625809
+ ,619567
+ ,557274
+ ,0
+ ,565742
+ ,587625
+ ,619916
+ ,625809
+ ,560576
+ ,0
+ ,557274
+ ,565742
+ ,587625
+ ,619916
+ ,548854
+ ,0
+ ,560576
+ ,557274
+ ,565742
+ ,587625
+ ,531673
+ ,0
+ ,548854
+ ,560576
+ ,557274
+ ,565742
+ ,525919
+ ,0
+ ,531673
+ ,548854
+ ,560576
+ ,557274
+ ,511038
+ ,0
+ ,525919
+ ,531673
+ ,548854
+ ,560576
+ ,498662
+ ,1
+ ,511038
+ ,525919
+ ,531673
+ ,548854
+ ,555362
+ ,1
+ ,498662
+ ,511038
+ ,525919
+ ,531673
+ ,564591
+ ,1
+ ,555362
+ ,498662
+ ,511038
+ ,525919
+ ,541657
+ ,1
+ ,564591
+ ,555362
+ ,498662
+ ,511038
+ ,527070
+ ,1
+ ,541657
+ ,564591
+ ,555362
+ ,498662
+ ,509846
+ ,1
+ ,527070
+ ,541657
+ ,564591
+ ,555362
+ ,514258
+ ,1
+ ,509846
+ ,527070
+ ,541657
+ ,564591
+ ,516922
+ ,1
+ ,514258
+ ,509846
+ ,527070
+ ,541657
+ ,507561
+ ,1
+ ,516922
+ ,514258
+ ,509846
+ ,527070
+ ,492622
+ ,1
+ ,507561
+ ,516922
+ ,514258
+ ,509846
+ ,490243
+ ,1
+ ,492622
+ ,507561
+ ,516922
+ ,514258
+ ,469357
+ ,1
+ ,490243
+ ,492622
+ ,507561
+ ,516922
+ ,477580
+ ,1
+ ,469357
+ ,490243
+ ,492622
+ ,507561
+ ,528379
+ ,1
+ ,477580
+ ,469357
+ ,490243
+ ,492622
+ ,533590
+ ,1
+ ,528379
+ ,477580
+ ,469357
+ ,490243
+ ,517945
+ ,1
+ ,533590
+ ,528379
+ ,477580
+ ,469357
+ ,506174
+ ,1
+ ,517945
+ ,533590
+ ,528379
+ ,477580
+ ,501866
+ ,1
+ ,506174
+ ,517945
+ ,533590
+ ,528379
+ ,516141
+ ,1
+ ,501866
+ ,506174
+ ,517945
+ ,533590
+ ,528222
+ ,1
+ ,516141
+ ,501866
+ ,506174
+ ,517945
+ ,532638
+ ,1
+ ,528222
+ ,516141
+ ,501866
+ ,506174
+ ,536322
+ ,1
+ ,532638
+ ,528222
+ ,516141
+ ,501866
+ ,536535
+ ,1
+ ,536322
+ ,532638
+ ,528222
+ ,516141
+ ,523597
+ ,1
+ ,536535
+ ,536322
+ ,532638
+ ,528222
+ ,536214
+ ,1
+ ,523597
+ ,536535
+ ,536322
+ ,532638
+ ,586570
+ ,1
+ ,536214
+ ,523597
+ ,536535
+ ,536322
+ ,596594
+ ,1
+ ,586570
+ ,536214
+ ,523597
+ ,536535
+ ,580523
+ ,1
+ ,596594
+ ,586570
+ ,536214
+ ,523597)
+ ,dim=c(6
+ ,69)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:69))
> y <- array(NA,dim=c(6,69),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:69))
> 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 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 562325 0 543599 555332 560854 562325 1 0 0 0 0 0 0 0 0 0 0 1
2 560854 0 562325 543599 555332 560854 0 1 0 0 0 0 0 0 0 0 0 2
3 555332 0 560854 562325 543599 555332 0 0 1 0 0 0 0 0 0 0 0 3
4 543599 0 555332 560854 562325 543599 0 0 0 1 0 0 0 0 0 0 0 4
5 536662 0 543599 555332 560854 562325 0 0 0 0 1 0 0 0 0 0 0 5
6 542722 0 536662 543599 555332 560854 0 0 0 0 0 1 0 0 0 0 0 6
7 593530 0 542722 536662 543599 555332 0 0 0 0 0 0 1 0 0 0 0 7
8 610763 0 593530 542722 536662 543599 0 0 0 0 0 0 0 1 0 0 0 8
9 612613 0 610763 593530 542722 536662 0 0 0 0 0 0 0 0 1 0 0 9
10 611324 0 612613 610763 593530 542722 0 0 0 0 0 0 0 0 0 1 0 10
11 594167 0 611324 612613 610763 593530 0 0 0 0 0 0 0 0 0 0 1 11
12 595454 0 594167 611324 612613 610763 0 0 0 0 0 0 0 0 0 0 0 12
13 590865 0 595454 594167 611324 612613 1 0 0 0 0 0 0 0 0 0 0 13
14 589379 0 590865 595454 594167 611324 0 1 0 0 0 0 0 0 0 0 0 14
15 584428 0 589379 590865 595454 594167 0 0 1 0 0 0 0 0 0 0 0 15
16 573100 0 584428 589379 590865 595454 0 0 0 1 0 0 0 0 0 0 0 16
17 567456 0 573100 584428 589379 590865 0 0 0 0 1 0 0 0 0 0 0 17
18 569028 0 567456 573100 584428 589379 0 0 0 0 0 1 0 0 0 0 0 18
19 620735 0 569028 567456 573100 584428 0 0 0 0 0 0 1 0 0 0 0 19
20 628884 0 620735 569028 567456 573100 0 0 0 0 0 0 0 1 0 0 0 20
21 628232 0 628884 620735 569028 567456 0 0 0 0 0 0 0 0 1 0 0 21
22 612117 0 628232 628884 620735 569028 0 0 0 0 0 0 0 0 0 1 0 22
23 595404 0 612117 628232 628884 620735 0 0 0 0 0 0 0 0 0 0 1 23
24 597141 0 595404 612117 628232 628884 0 0 0 0 0 0 0 0 0 0 0 24
25 593408 0 597141 595404 612117 628232 1 0 0 0 0 0 0 0 0 0 0 25
26 590072 0 593408 597141 595404 612117 0 1 0 0 0 0 0 0 0 0 0 26
27 579799 0 590072 593408 597141 595404 0 0 1 0 0 0 0 0 0 0 0 27
28 574205 0 579799 590072 593408 597141 0 0 0 1 0 0 0 0 0 0 0 28
29 572775 0 574205 579799 590072 593408 0 0 0 0 1 0 0 0 0 0 0 29
30 572942 0 572775 574205 579799 590072 0 0 0 0 0 1 0 0 0 0 0 30
31 619567 0 572942 572775 574205 579799 0 0 0 0 0 0 1 0 0 0 0 31
32 625809 0 619567 572942 572775 574205 0 0 0 0 0 0 0 1 0 0 0 32
33 619916 0 625809 619567 572942 572775 0 0 0 0 0 0 0 0 1 0 0 33
34 587625 0 619916 625809 619567 572942 0 0 0 0 0 0 0 0 0 1 0 34
35 565742 0 587625 619916 625809 619567 0 0 0 0 0 0 0 0 0 0 1 35
36 557274 0 565742 587625 619916 625809 0 0 0 0 0 0 0 0 0 0 0 36
37 560576 0 557274 565742 587625 619916 1 0 0 0 0 0 0 0 0 0 0 37
38 548854 0 560576 557274 565742 587625 0 1 0 0 0 0 0 0 0 0 0 38
39 531673 0 548854 560576 557274 565742 0 0 1 0 0 0 0 0 0 0 0 39
40 525919 0 531673 548854 560576 557274 0 0 0 1 0 0 0 0 0 0 0 40
41 511038 0 525919 531673 548854 560576 0 0 0 0 1 0 0 0 0 0 0 41
42 498662 1 511038 525919 531673 548854 0 0 0 0 0 1 0 0 0 0 0 42
43 555362 1 498662 511038 525919 531673 0 0 0 0 0 0 1 0 0 0 0 43
44 564591 1 555362 498662 511038 525919 0 0 0 0 0 0 0 1 0 0 0 44
45 541657 1 564591 555362 498662 511038 0 0 0 0 0 0 0 0 1 0 0 45
46 527070 1 541657 564591 555362 498662 0 0 0 0 0 0 0 0 0 1 0 46
47 509846 1 527070 541657 564591 555362 0 0 0 0 0 0 0 0 0 0 1 47
48 514258 1 509846 527070 541657 564591 0 0 0 0 0 0 0 0 0 0 0 48
49 516922 1 514258 509846 527070 541657 1 0 0 0 0 0 0 0 0 0 0 49
50 507561 1 516922 514258 509846 527070 0 1 0 0 0 0 0 0 0 0 0 50
51 492622 1 507561 516922 514258 509846 0 0 1 0 0 0 0 0 0 0 0 51
52 490243 1 492622 507561 516922 514258 0 0 0 1 0 0 0 0 0 0 0 52
53 469357 1 490243 492622 507561 516922 0 0 0 0 1 0 0 0 0 0 0 53
54 477580 1 469357 490243 492622 507561 0 0 0 0 0 1 0 0 0 0 0 54
55 528379 1 477580 469357 490243 492622 0 0 0 0 0 0 1 0 0 0 0 55
56 533590 1 528379 477580 469357 490243 0 0 0 0 0 0 0 1 0 0 0 56
57 517945 1 533590 528379 477580 469357 0 0 0 0 0 0 0 0 1 0 0 57
58 506174 1 517945 533590 528379 477580 0 0 0 0 0 0 0 0 0 1 0 58
59 501866 1 506174 517945 533590 528379 0 0 0 0 0 0 0 0 0 0 1 59
60 516141 1 501866 506174 517945 533590 0 0 0 0 0 0 0 0 0 0 0 60
61 528222 1 516141 501866 506174 517945 1 0 0 0 0 0 0 0 0 0 0 61
62 532638 1 528222 516141 501866 506174 0 1 0 0 0 0 0 0 0 0 0 62
63 536322 1 532638 528222 516141 501866 0 0 1 0 0 0 0 0 0 0 0 63
64 536535 1 536322 532638 528222 516141 0 0 0 1 0 0 0 0 0 0 0 64
65 523597 1 536535 536322 532638 528222 0 0 0 0 1 0 0 0 0 0 0 65
66 536214 1 523597 536535 536322 532638 0 0 0 0 0 1 0 0 0 0 0 66
67 586570 1 536214 523597 536535 536322 0 0 0 0 0 0 1 0 0 0 0 67
68 596594 1 586570 536214 523597 536535 0 0 0 0 0 0 0 1 0 0 0 68
69 580523 1 596594 586570 536214 523597 0 0 0 0 0 0 0 0 1 0 0 69
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
7.574e+04 -4.889e+03 1.045e+00 1.207e-01 -3.039e-02 -2.459e-01
M1 M2 M3 M4 M5 M6
-1.551e+02 -1.253e+04 -2.064e+04 -1.746e+04 -1.946e+04 -5.421e+03
M7 M8 M9 M10 M11 t
4.201e+04 -4.236e+03 -3.252e+04 -3.712e+04 -2.269e+04 -4.013e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13540.0 -4458.5 478.1 4237.7 11228.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.574e+04 3.217e+04 2.355 0.022435 *
X -4.889e+03 5.382e+03 -0.908 0.367909
Y1 1.045e+00 1.272e-01 8.222 6.54e-11 ***
Y2 1.207e-01 1.838e-01 0.657 0.514229
Y3 -3.039e-02 1.840e-01 -0.165 0.869489
Y4 -2.459e-01 1.265e-01 -1.944 0.057470 .
M1 -1.551e+02 4.807e+03 -0.032 0.974382
M2 -1.253e+04 5.469e+03 -2.290 0.026163 *
M3 -2.064e+04 5.346e+03 -3.861 0.000320 ***
M4 -1.746e+04 5.056e+03 -3.454 0.001122 **
M5 -1.946e+04 4.816e+03 -4.041 0.000180 ***
M6 -5.421e+03 4.651e+03 -1.166 0.249160
M7 4.201e+04 5.090e+03 8.253 5.86e-11 ***
M8 -4.236e+03 9.585e+03 -0.442 0.660353
M9 -3.252e+04 9.534e+03 -3.411 0.001273 **
M10 -3.712e+04 8.805e+03 -4.216 0.000102 ***
M11 -2.269e+04 4.973e+03 -4.562 3.21e-05 ***
t -4.013e+01 8.642e+01 -0.464 0.644387
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7037 on 51 degrees of freedom
Multiple R-squared: 0.9773, Adjusted R-squared: 0.9697
F-statistic: 129 on 17 and 51 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.34972251 0.6994450 0.65027749
[2,] 0.58341932 0.8331614 0.41658068
[3,] 0.44153622 0.8830724 0.55846378
[4,] 0.31704062 0.6340812 0.68295938
[5,] 0.22152872 0.4430574 0.77847128
[6,] 0.14821366 0.2964273 0.85178634
[7,] 0.09232372 0.1846474 0.90767628
[8,] 0.08534799 0.1706960 0.91465201
[9,] 0.17664014 0.3532803 0.82335986
[10,] 0.12090077 0.2418015 0.87909923
[11,] 0.08380145 0.1676029 0.91619855
[12,] 0.06162957 0.1232591 0.93837043
[13,] 0.24711996 0.4942399 0.75288004
[14,] 0.64080168 0.7183966 0.35919832
[15,] 0.57689381 0.8462124 0.42310619
[16,] 0.67061000 0.6587800 0.32939000
[17,] 0.66267870 0.6746426 0.33732130
[18,] 0.58170646 0.8365871 0.41829354
[19,] 0.51178041 0.9764392 0.48821959
[20,] 0.54264263 0.9147147 0.45735737
[21,] 0.44317178 0.8863436 0.55682822
[22,] 0.55306394 0.8938721 0.44693606
[23,] 0.87799140 0.2440172 0.12200860
[24,] 0.92466330 0.1506734 0.07533670
[25,] 0.93428465 0.1314307 0.06571535
[26,] 0.90851114 0.1829777 0.09148886
[27,] 0.82212116 0.3557577 0.17787884
[28,] 0.75701791 0.4859642 0.24298209
> postscript(file="/var/www/html/rcomp/tmp/1ygtw1259004008.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/2tdlf1259004008.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/3vvv81259004008.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/4gia41259004008.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/5os181259004008.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 = 69
Frequency = 1
1 2 3 4 5 6
6768.8469 -981.3308 -785.1162 -12025.7915 571.2865 771.5449
7 8 9 10 11 12
-3025.8633 3549.3687 8056.3121 10423.6913 -6983.0044 -5956.0474
13 14 15 16 17 18
-9208.5180 5520.9528 6652.2940 -2284.9123 5378.3123 -296.4418
19 20 21 22 23 24
1493.8694 -1274.1427 10300.9229 478.1099 -737.4317 -245.1965
25 26 27 28 29 30
-4231.5953 4065.8435 1828.8446 4549.6061 11228.8320 -1565.3669
31 32 33 34 35 36
-5031.4740 -2685.5615 7249.3330 -13539.9760 -3689.2294 -6672.6417
37 38 39 40 41 42
5888.4809 -4458.5348 -7267.0372 1232.0367 -3063.2751 -11702.0738
43 44 45 46 47 48
7939.9357 3805.6962 -11328.6233 262.6699 889.0417 3994.5736
49 50 51 52 53 54
-1763.3399 -6141.3786 -7561.9889 4831.4609 -9353.0894 4237.6709
55 56 57 58 59 60
-2178.0918 -5999.9150 -9783.1506 2375.5050 10520.6239 8879.3120
61 62 63 64 65 66
2546.1254 1994.4479 7133.0037 3697.6000 -4762.0663 8554.6667
67 68 69
801.6241 2604.5542 -4494.7941
> postscript(file="/var/www/html/rcomp/tmp/62j7o1259004008.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 = 69
Frequency = 1
lag(myerror, k = 1) myerror
0 6768.8469 NA
1 -981.3308 6768.8469
2 -785.1162 -981.3308
3 -12025.7915 -785.1162
4 571.2865 -12025.7915
5 771.5449 571.2865
6 -3025.8633 771.5449
7 3549.3687 -3025.8633
8 8056.3121 3549.3687
9 10423.6913 8056.3121
10 -6983.0044 10423.6913
11 -5956.0474 -6983.0044
12 -9208.5180 -5956.0474
13 5520.9528 -9208.5180
14 6652.2940 5520.9528
15 -2284.9123 6652.2940
16 5378.3123 -2284.9123
17 -296.4418 5378.3123
18 1493.8694 -296.4418
19 -1274.1427 1493.8694
20 10300.9229 -1274.1427
21 478.1099 10300.9229
22 -737.4317 478.1099
23 -245.1965 -737.4317
24 -4231.5953 -245.1965
25 4065.8435 -4231.5953
26 1828.8446 4065.8435
27 4549.6061 1828.8446
28 11228.8320 4549.6061
29 -1565.3669 11228.8320
30 -5031.4740 -1565.3669
31 -2685.5615 -5031.4740
32 7249.3330 -2685.5615
33 -13539.9760 7249.3330
34 -3689.2294 -13539.9760
35 -6672.6417 -3689.2294
36 5888.4809 -6672.6417
37 -4458.5348 5888.4809
38 -7267.0372 -4458.5348
39 1232.0367 -7267.0372
40 -3063.2751 1232.0367
41 -11702.0738 -3063.2751
42 7939.9357 -11702.0738
43 3805.6962 7939.9357
44 -11328.6233 3805.6962
45 262.6699 -11328.6233
46 889.0417 262.6699
47 3994.5736 889.0417
48 -1763.3399 3994.5736
49 -6141.3786 -1763.3399
50 -7561.9889 -6141.3786
51 4831.4609 -7561.9889
52 -9353.0894 4831.4609
53 4237.6709 -9353.0894
54 -2178.0918 4237.6709
55 -5999.9150 -2178.0918
56 -9783.1506 -5999.9150
57 2375.5050 -9783.1506
58 10520.6239 2375.5050
59 8879.3120 10520.6239
60 2546.1254 8879.3120
61 1994.4479 2546.1254
62 7133.0037 1994.4479
63 3697.6000 7133.0037
64 -4762.0663 3697.6000
65 8554.6667 -4762.0663
66 801.6241 8554.6667
67 2604.5542 801.6241
68 -4494.7941 2604.5542
69 NA -4494.7941
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -981.3308 6768.8469
[2,] -785.1162 -981.3308
[3,] -12025.7915 -785.1162
[4,] 571.2865 -12025.7915
[5,] 771.5449 571.2865
[6,] -3025.8633 771.5449
[7,] 3549.3687 -3025.8633
[8,] 8056.3121 3549.3687
[9,] 10423.6913 8056.3121
[10,] -6983.0044 10423.6913
[11,] -5956.0474 -6983.0044
[12,] -9208.5180 -5956.0474
[13,] 5520.9528 -9208.5180
[14,] 6652.2940 5520.9528
[15,] -2284.9123 6652.2940
[16,] 5378.3123 -2284.9123
[17,] -296.4418 5378.3123
[18,] 1493.8694 -296.4418
[19,] -1274.1427 1493.8694
[20,] 10300.9229 -1274.1427
[21,] 478.1099 10300.9229
[22,] -737.4317 478.1099
[23,] -245.1965 -737.4317
[24,] -4231.5953 -245.1965
[25,] 4065.8435 -4231.5953
[26,] 1828.8446 4065.8435
[27,] 4549.6061 1828.8446
[28,] 11228.8320 4549.6061
[29,] -1565.3669 11228.8320
[30,] -5031.4740 -1565.3669
[31,] -2685.5615 -5031.4740
[32,] 7249.3330 -2685.5615
[33,] -13539.9760 7249.3330
[34,] -3689.2294 -13539.9760
[35,] -6672.6417 -3689.2294
[36,] 5888.4809 -6672.6417
[37,] -4458.5348 5888.4809
[38,] -7267.0372 -4458.5348
[39,] 1232.0367 -7267.0372
[40,] -3063.2751 1232.0367
[41,] -11702.0738 -3063.2751
[42,] 7939.9357 -11702.0738
[43,] 3805.6962 7939.9357
[44,] -11328.6233 3805.6962
[45,] 262.6699 -11328.6233
[46,] 889.0417 262.6699
[47,] 3994.5736 889.0417
[48,] -1763.3399 3994.5736
[49,] -6141.3786 -1763.3399
[50,] -7561.9889 -6141.3786
[51,] 4831.4609 -7561.9889
[52,] -9353.0894 4831.4609
[53,] 4237.6709 -9353.0894
[54,] -2178.0918 4237.6709
[55,] -5999.9150 -2178.0918
[56,] -9783.1506 -5999.9150
[57,] 2375.5050 -9783.1506
[58,] 10520.6239 2375.5050
[59,] 8879.3120 10520.6239
[60,] 2546.1254 8879.3120
[61,] 1994.4479 2546.1254
[62,] 7133.0037 1994.4479
[63,] 3697.6000 7133.0037
[64,] -4762.0663 3697.6000
[65,] 8554.6667 -4762.0663
[66,] 801.6241 8554.6667
[67,] 2604.5542 801.6241
[68,] -4494.7941 2604.5542
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -981.3308 6768.8469
2 -785.1162 -981.3308
3 -12025.7915 -785.1162
4 571.2865 -12025.7915
5 771.5449 571.2865
6 -3025.8633 771.5449
7 3549.3687 -3025.8633
8 8056.3121 3549.3687
9 10423.6913 8056.3121
10 -6983.0044 10423.6913
11 -5956.0474 -6983.0044
12 -9208.5180 -5956.0474
13 5520.9528 -9208.5180
14 6652.2940 5520.9528
15 -2284.9123 6652.2940
16 5378.3123 -2284.9123
17 -296.4418 5378.3123
18 1493.8694 -296.4418
19 -1274.1427 1493.8694
20 10300.9229 -1274.1427
21 478.1099 10300.9229
22 -737.4317 478.1099
23 -245.1965 -737.4317
24 -4231.5953 -245.1965
25 4065.8435 -4231.5953
26 1828.8446 4065.8435
27 4549.6061 1828.8446
28 11228.8320 4549.6061
29 -1565.3669 11228.8320
30 -5031.4740 -1565.3669
31 -2685.5615 -5031.4740
32 7249.3330 -2685.5615
33 -13539.9760 7249.3330
34 -3689.2294 -13539.9760
35 -6672.6417 -3689.2294
36 5888.4809 -6672.6417
37 -4458.5348 5888.4809
38 -7267.0372 -4458.5348
39 1232.0367 -7267.0372
40 -3063.2751 1232.0367
41 -11702.0738 -3063.2751
42 7939.9357 -11702.0738
43 3805.6962 7939.9357
44 -11328.6233 3805.6962
45 262.6699 -11328.6233
46 889.0417 262.6699
47 3994.5736 889.0417
48 -1763.3399 3994.5736
49 -6141.3786 -1763.3399
50 -7561.9889 -6141.3786
51 4831.4609 -7561.9889
52 -9353.0894 4831.4609
53 4237.6709 -9353.0894
54 -2178.0918 4237.6709
55 -5999.9150 -2178.0918
56 -9783.1506 -5999.9150
57 2375.5050 -9783.1506
58 10520.6239 2375.5050
59 8879.3120 10520.6239
60 2546.1254 8879.3120
61 1994.4479 2546.1254
62 7133.0037 1994.4479
63 3697.6000 7133.0037
64 -4762.0663 3697.6000
65 8554.6667 -4762.0663
66 801.6241 8554.6667
67 2604.5542 801.6241
68 -4494.7941 2604.5542
> 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/7dvk51259004008.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/8aj5l1259004008.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/993x31259004008.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/10kzbb1259004008.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/11czmm1259004008.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/12mucq1259004008.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/13d6da1259004008.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/14o4xr1259004008.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/15fzlz1259004008.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/16uk7d1259004008.tab")
+ }
>
> system("convert tmp/1ygtw1259004008.ps tmp/1ygtw1259004008.png")
> system("convert tmp/2tdlf1259004008.ps tmp/2tdlf1259004008.png")
> system("convert tmp/3vvv81259004008.ps tmp/3vvv81259004008.png")
> system("convert tmp/4gia41259004008.ps tmp/4gia41259004008.png")
> system("convert tmp/5os181259004008.ps tmp/5os181259004008.png")
> system("convert tmp/62j7o1259004008.ps tmp/62j7o1259004008.png")
> system("convert tmp/7dvk51259004008.ps tmp/7dvk51259004008.png")
> system("convert tmp/8aj5l1259004008.ps tmp/8aj5l1259004008.png")
> system("convert tmp/993x31259004008.ps tmp/993x31259004008.png")
> system("convert tmp/10kzbb1259004008.ps tmp/10kzbb1259004008.png")
>
>
> proc.time()
user system elapsed
2.499 1.563 2.959