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(547344
+ ,0
+ ,565464
+ ,577992
+ ,554788
+ ,0
+ ,547344
+ ,565464
+ ,562325
+ ,0
+ ,554788
+ ,547344
+ ,560854
+ ,0
+ ,562325
+ ,554788
+ ,555332
+ ,0
+ ,560854
+ ,562325
+ ,543599
+ ,0
+ ,555332
+ ,560854
+ ,536662
+ ,0
+ ,543599
+ ,555332
+ ,542722
+ ,0
+ ,536662
+ ,543599
+ ,593530
+ ,1
+ ,542722
+ ,536662
+ ,610763
+ ,1
+ ,593530
+ ,542722
+ ,612613
+ ,1
+ ,610763
+ ,593530
+ ,611324
+ ,1
+ ,612613
+ ,610763
+ ,594167
+ ,1
+ ,611324
+ ,612613
+ ,595454
+ ,1
+ ,594167
+ ,611324
+ ,590865
+ ,1
+ ,595454
+ ,594167
+ ,589379
+ ,1
+ ,590865
+ ,595454
+ ,584428
+ ,1
+ ,589379
+ ,590865
+ ,573100
+ ,1
+ ,584428
+ ,589379
+ ,567456
+ ,1
+ ,573100
+ ,584428
+ ,569028
+ ,1
+ ,567456
+ ,573100
+ ,620735
+ ,1
+ ,569028
+ ,567456
+ ,628884
+ ,1
+ ,620735
+ ,569028
+ ,628232
+ ,1
+ ,628884
+ ,620735
+ ,612117
+ ,1
+ ,628232
+ ,628884
+ ,595404
+ ,1
+ ,612117
+ ,628232
+ ,597141
+ ,1
+ ,595404
+ ,612117
+ ,593408
+ ,1
+ ,597141
+ ,595404
+ ,590072
+ ,1
+ ,593408
+ ,597141
+ ,579799
+ ,1
+ ,590072
+ ,593408
+ ,574205
+ ,1
+ ,579799
+ ,590072
+ ,572775
+ ,1
+ ,574205
+ ,579799
+ ,572942
+ ,1
+ ,572775
+ ,574205
+ ,619567
+ ,1
+ ,572942
+ ,572775
+ ,625809
+ ,1
+ ,619567
+ ,572942
+ ,619916
+ ,1
+ ,625809
+ ,619567
+ ,587625
+ ,1
+ ,619916
+ ,625809
+ ,565742
+ ,1
+ ,587625
+ ,619916
+ ,557274
+ ,1
+ ,565742
+ ,587625
+ ,560576
+ ,1
+ ,557274
+ ,565742
+ ,548854
+ ,1
+ ,560576
+ ,557274
+ ,531673
+ ,1
+ ,548854
+ ,560576
+ ,525919
+ ,1
+ ,531673
+ ,548854
+ ,511038
+ ,1
+ ,525919
+ ,531673
+ ,498662
+ ,1
+ ,511038
+ ,525919
+ ,555362
+ ,1
+ ,498662
+ ,511038
+ ,564591
+ ,1
+ ,555362
+ ,498662
+ ,541657
+ ,1
+ ,564591
+ ,555362
+ ,527070
+ ,1
+ ,541657
+ ,564591
+ ,509846
+ ,1
+ ,527070
+ ,541657
+ ,514258
+ ,1
+ ,509846
+ ,527070
+ ,516922
+ ,1
+ ,514258
+ ,509846
+ ,507561
+ ,1
+ ,516922
+ ,514258
+ ,492622
+ ,1
+ ,507561
+ ,516922
+ ,490243
+ ,1
+ ,492622
+ ,507561
+ ,469357
+ ,1
+ ,490243
+ ,492622
+ ,477580
+ ,1
+ ,469357
+ ,490243
+ ,528379
+ ,1
+ ,477580
+ ,469357
+ ,533590
+ ,1
+ ,528379
+ ,477580
+ ,517945
+ ,1
+ ,533590
+ ,528379
+ ,506174
+ ,1
+ ,517945
+ ,533590
+ ,501866
+ ,1
+ ,506174
+ ,517945
+ ,516141
+ ,1
+ ,501866
+ ,506174
+ ,528222
+ ,1
+ ,516141
+ ,501866
+ ,532638
+ ,1
+ ,528222
+ ,516141
+ ,536322
+ ,1
+ ,532638
+ ,528222
+ ,536535
+ ,1
+ ,536322
+ ,532638
+ ,523597
+ ,1
+ ,536535
+ ,536322
+ ,536214
+ ,1
+ ,523597
+ ,536535
+ ,586570
+ ,1
+ ,536214
+ ,523597
+ ,596594
+ ,1
+ ,586570
+ ,536214
+ ,580523
+ ,1
+ ,596594
+ ,586570)
+ ,dim=c(4
+ ,71)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2')
+ ,1:71))
> y <- array(NA,dim=c(4,71),dimnames=list(c('Y','X','Y1','Y2'),1:71))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 547344 0 565464 577992 1 0 0 0 0 0 0 0 0 0 0 1
2 554788 0 547344 565464 0 1 0 0 0 0 0 0 0 0 0 2
3 562325 0 554788 547344 0 0 1 0 0 0 0 0 0 0 0 3
4 560854 0 562325 554788 0 0 0 1 0 0 0 0 0 0 0 4
5 555332 0 560854 562325 0 0 0 0 1 0 0 0 0 0 0 5
6 543599 0 555332 560854 0 0 0 0 0 1 0 0 0 0 0 6
7 536662 0 543599 555332 0 0 0 0 0 0 1 0 0 0 0 7
8 542722 0 536662 543599 0 0 0 0 0 0 0 1 0 0 0 8
9 593530 1 542722 536662 0 0 0 0 0 0 0 0 1 0 0 9
10 610763 1 593530 542722 0 0 0 0 0 0 0 0 0 1 0 10
11 612613 1 610763 593530 0 0 0 0 0 0 0 0 0 0 1 11
12 611324 1 612613 610763 0 0 0 0 0 0 0 0 0 0 0 12
13 594167 1 611324 612613 1 0 0 0 0 0 0 0 0 0 0 13
14 595454 1 594167 611324 0 1 0 0 0 0 0 0 0 0 0 14
15 590865 1 595454 594167 0 0 1 0 0 0 0 0 0 0 0 15
16 589379 1 590865 595454 0 0 0 1 0 0 0 0 0 0 0 16
17 584428 1 589379 590865 0 0 0 0 1 0 0 0 0 0 0 17
18 573100 1 584428 589379 0 0 0 0 0 1 0 0 0 0 0 18
19 567456 1 573100 584428 0 0 0 0 0 0 1 0 0 0 0 19
20 569028 1 567456 573100 0 0 0 0 0 0 0 1 0 0 0 20
21 620735 1 569028 567456 0 0 0 0 0 0 0 0 1 0 0 21
22 628884 1 620735 569028 0 0 0 0 0 0 0 0 0 1 0 22
23 628232 1 628884 620735 0 0 0 0 0 0 0 0 0 0 1 23
24 612117 1 628232 628884 0 0 0 0 0 0 0 0 0 0 0 24
25 595404 1 612117 628232 1 0 0 0 0 0 0 0 0 0 0 25
26 597141 1 595404 612117 0 1 0 0 0 0 0 0 0 0 0 26
27 593408 1 597141 595404 0 0 1 0 0 0 0 0 0 0 0 27
28 590072 1 593408 597141 0 0 0 1 0 0 0 0 0 0 0 28
29 579799 1 590072 593408 0 0 0 0 1 0 0 0 0 0 0 29
30 574205 1 579799 590072 0 0 0 0 0 1 0 0 0 0 0 30
31 572775 1 574205 579799 0 0 0 0 0 0 1 0 0 0 0 31
32 572942 1 572775 574205 0 0 0 0 0 0 0 1 0 0 0 32
33 619567 1 572942 572775 0 0 0 0 0 0 0 0 1 0 0 33
34 625809 1 619567 572942 0 0 0 0 0 0 0 0 0 1 0 34
35 619916 1 625809 619567 0 0 0 0 0 0 0 0 0 0 1 35
36 587625 1 619916 625809 0 0 0 0 0 0 0 0 0 0 0 36
37 565742 1 587625 619916 1 0 0 0 0 0 0 0 0 0 0 37
38 557274 1 565742 587625 0 1 0 0 0 0 0 0 0 0 0 38
39 560576 1 557274 565742 0 0 1 0 0 0 0 0 0 0 0 39
40 548854 1 560576 557274 0 0 0 1 0 0 0 0 0 0 0 40
41 531673 1 548854 560576 0 0 0 0 1 0 0 0 0 0 0 41
42 525919 1 531673 548854 0 0 0 0 0 1 0 0 0 0 0 42
43 511038 1 525919 531673 0 0 0 0 0 0 1 0 0 0 0 43
44 498662 1 511038 525919 0 0 0 0 0 0 0 1 0 0 0 44
45 555362 1 498662 511038 0 0 0 0 0 0 0 0 1 0 0 45
46 564591 1 555362 498662 0 0 0 0 0 0 0 0 0 1 0 46
47 541657 1 564591 555362 0 0 0 0 0 0 0 0 0 0 1 47
48 527070 1 541657 564591 0 0 0 0 0 0 0 0 0 0 0 48
49 509846 1 527070 541657 1 0 0 0 0 0 0 0 0 0 0 49
50 514258 1 509846 527070 0 1 0 0 0 0 0 0 0 0 0 50
51 516922 1 514258 509846 0 0 1 0 0 0 0 0 0 0 0 51
52 507561 1 516922 514258 0 0 0 1 0 0 0 0 0 0 0 52
53 492622 1 507561 516922 0 0 0 0 1 0 0 0 0 0 0 53
54 490243 1 492622 507561 0 0 0 0 0 1 0 0 0 0 0 54
55 469357 1 490243 492622 0 0 0 0 0 0 1 0 0 0 0 55
56 477580 1 469357 490243 0 0 0 0 0 0 0 1 0 0 0 56
57 528379 1 477580 469357 0 0 0 0 0 0 0 0 1 0 0 57
58 533590 1 528379 477580 0 0 0 0 0 0 0 0 0 1 0 58
59 517945 1 533590 528379 0 0 0 0 0 0 0 0 0 0 1 59
60 506174 1 517945 533590 0 0 0 0 0 0 0 0 0 0 0 60
61 501866 1 506174 517945 1 0 0 0 0 0 0 0 0 0 0 61
62 516141 1 501866 506174 0 1 0 0 0 0 0 0 0 0 0 62
63 528222 1 516141 501866 0 0 1 0 0 0 0 0 0 0 0 63
64 532638 1 528222 516141 0 0 0 1 0 0 0 0 0 0 0 64
65 536322 1 532638 528222 0 0 0 0 1 0 0 0 0 0 0 65
66 536535 1 536322 532638 0 0 0 0 0 1 0 0 0 0 0 66
67 523597 1 536535 536322 0 0 0 0 0 0 1 0 0 0 0 67
68 536214 1 523597 536535 0 0 0 0 0 0 0 1 0 0 0 68
69 586570 1 536214 523597 0 0 0 0 0 0 0 0 1 0 0 69
70 596594 1 586570 536214 0 0 0 0 0 0 0 0 0 1 0 70
71 580523 1 596594 586570 0 0 0 0 0 0 0 0 0 0 1 71
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 M1 M2
15281.0180 639.0318 1.2133 -0.2589 -30.8518 18948.0579
M3 M4 M5 M6 M7 M8
13586.0496 7223.2825 4475.8673 7396.1983 2278.6742 16154.5211
M9 M10 M11 t
61280.2391 9312.7749 1391.1670 -61.7258
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-16159.04 -4122.48 -13.69 3919.07 11996.26
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 15281.0180 22689.4053 0.673 0.503458
X 639.0318 3843.7320 0.166 0.868568
Y1 1.2133 0.1310 9.259 8.18e-13 ***
Y2 -0.2589 0.1329 -1.948 0.056468 .
M1 -30.8518 4396.5805 -0.007 0.994427
M2 18948.0579 4502.9652 4.208 9.60e-05 ***
M3 13586.0496 4723.0137 2.877 0.005711 **
M4 7223.2825 4657.3651 1.551 0.126652
M5 4475.8673 4445.3509 1.007 0.318409
M6 7396.1983 4442.4069 1.665 0.101618
M7 2278.6742 4514.8401 0.505 0.615780
M8 16154.5211 4589.9362 3.520 0.000876 ***
M9 61280.2391 4964.2762 12.344 < 2e-16 ***
M10 9312.7749 8984.8579 1.036 0.304506
M11 1391.1670 4880.9731 0.285 0.776701
t -61.7258 75.9126 -0.813 0.419657
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7058 on 55 degrees of freedom
Multiple R-squared: 0.9754, Adjusted R-squared: 0.9687
F-statistic: 145.2 on 15 and 55 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.070442645 0.140885289 0.92955736
[2,] 0.046913687 0.093827374 0.95308631
[3,] 0.015908134 0.031816268 0.98409187
[4,] 0.026035870 0.052071740 0.97396413
[5,] 0.015531001 0.031062001 0.98446900
[6,] 0.055942473 0.111884947 0.94405753
[7,] 0.038324394 0.076648788 0.96167561
[8,] 0.019577362 0.039154724 0.98042264
[9,] 0.011183433 0.022366866 0.98881657
[10,] 0.005735498 0.011470997 0.99426450
[11,] 0.003210322 0.006420645 0.99678968
[12,] 0.002853904 0.005707809 0.99714610
[13,] 0.006281001 0.012562002 0.99371900
[14,] 0.003854971 0.007709941 0.99614503
[15,] 0.001843161 0.003686322 0.99815684
[16,] 0.001227582 0.002455164 0.99877242
[17,] 0.015918845 0.031837691 0.98408115
[18,] 0.228540009 0.457080018 0.77145999
[19,] 0.167330897 0.334661794 0.83266910
[20,] 0.195246545 0.390493090 0.80475346
[21,] 0.185484585 0.370969170 0.81451541
[22,] 0.151885856 0.303771713 0.84811414
[23,] 0.123555268 0.247110535 0.87644473
[24,] 0.107754519 0.215509039 0.89224548
[25,] 0.136235214 0.272470427 0.86376479
[26,] 0.301452464 0.602904928 0.69854754
[27,] 0.815967030 0.368065940 0.18403297
[28,] 0.832800001 0.334399999 0.16720000
[29,] 0.843694592 0.312610816 0.15630541
[30,] 0.913033409 0.173933181 0.08696659
[31,] 0.865268135 0.269463730 0.13473186
[32,] 0.847845655 0.304308690 0.15215435
[33,] 0.899644031 0.200711938 0.10035597
[34,] 0.974054844 0.051890313 0.02594516
> postscript(file="/var/www/html/rcomp/tmp/1z24h1260654332.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/2o3hc1260654332.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/3nw0s1260654332.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/4qd4q1260654332.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/5fmzr1260654332.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 = 71
Frequency = 1
1 2 3 4 5
-4246.582861 3020.960720 2257.794275 -5.673605 1017.919017
6 7 8 9 10
-7254.804599 3793.077550 1417.309504 -2626.591443 6559.914867
11 12 13 14 15
8641.283921 11023.058069 -3998.375621 -1145.902334 -6315.464857
16 17 18 19 20
4524.090362 2996.865026 -5567.532287 6429.826758 -1897.852821
21 22 23 24 25
1376.351673 -774.054857 10059.649656 -1701.214843 1061.720799
26 27 28 29 30
-13.687374 -4758.257660 3309.247132 -1073.728423 2073.955822
31 32 33 34 35
9950.173936 -3410.501716 -2422.410939 -677.693507 5912.778382
36 37 38 39 40
-16159.041274 -297.054456 -9493.506833 3839.795774 -7656.781309
41 42 43 44 45
-6951.386933 2246.167610 -4923.308326 -14548.431591 8249.849787
46 47 48 49 50
-2490.343982 -13956.061231 3125.301021 -2246.577630 368.680458
51 52 53 54 55
-1356.767661 -6382.999766 -6465.396226 3998.337659 -12690.433179
56 57 58 59 60
6443.212505 -3207.087776 -5471.554841 -6301.325663 3711.897026
61 62 63 64 65
9726.869769 7263.455363 6332.900129 6212.117186 10475.727538
66 67 68 69 70
4503.875794 -2559.336739 11996.264119 -1370.111302 2853.732320
71
-4356.325064
> postscript(file="/var/www/html/rcomp/tmp/6zp8w1260654332.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 = 71
Frequency = 1
lag(myerror, k = 1) myerror
0 -4246.582861 NA
1 3020.960720 -4246.582861
2 2257.794275 3020.960720
3 -5.673605 2257.794275
4 1017.919017 -5.673605
5 -7254.804599 1017.919017
6 3793.077550 -7254.804599
7 1417.309504 3793.077550
8 -2626.591443 1417.309504
9 6559.914867 -2626.591443
10 8641.283921 6559.914867
11 11023.058069 8641.283921
12 -3998.375621 11023.058069
13 -1145.902334 -3998.375621
14 -6315.464857 -1145.902334
15 4524.090362 -6315.464857
16 2996.865026 4524.090362
17 -5567.532287 2996.865026
18 6429.826758 -5567.532287
19 -1897.852821 6429.826758
20 1376.351673 -1897.852821
21 -774.054857 1376.351673
22 10059.649656 -774.054857
23 -1701.214843 10059.649656
24 1061.720799 -1701.214843
25 -13.687374 1061.720799
26 -4758.257660 -13.687374
27 3309.247132 -4758.257660
28 -1073.728423 3309.247132
29 2073.955822 -1073.728423
30 9950.173936 2073.955822
31 -3410.501716 9950.173936
32 -2422.410939 -3410.501716
33 -677.693507 -2422.410939
34 5912.778382 -677.693507
35 -16159.041274 5912.778382
36 -297.054456 -16159.041274
37 -9493.506833 -297.054456
38 3839.795774 -9493.506833
39 -7656.781309 3839.795774
40 -6951.386933 -7656.781309
41 2246.167610 -6951.386933
42 -4923.308326 2246.167610
43 -14548.431591 -4923.308326
44 8249.849787 -14548.431591
45 -2490.343982 8249.849787
46 -13956.061231 -2490.343982
47 3125.301021 -13956.061231
48 -2246.577630 3125.301021
49 368.680458 -2246.577630
50 -1356.767661 368.680458
51 -6382.999766 -1356.767661
52 -6465.396226 -6382.999766
53 3998.337659 -6465.396226
54 -12690.433179 3998.337659
55 6443.212505 -12690.433179
56 -3207.087776 6443.212505
57 -5471.554841 -3207.087776
58 -6301.325663 -5471.554841
59 3711.897026 -6301.325663
60 9726.869769 3711.897026
61 7263.455363 9726.869769
62 6332.900129 7263.455363
63 6212.117186 6332.900129
64 10475.727538 6212.117186
65 4503.875794 10475.727538
66 -2559.336739 4503.875794
67 11996.264119 -2559.336739
68 -1370.111302 11996.264119
69 2853.732320 -1370.111302
70 -4356.325064 2853.732320
71 NA -4356.325064
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3020.960720 -4246.582861
[2,] 2257.794275 3020.960720
[3,] -5.673605 2257.794275
[4,] 1017.919017 -5.673605
[5,] -7254.804599 1017.919017
[6,] 3793.077550 -7254.804599
[7,] 1417.309504 3793.077550
[8,] -2626.591443 1417.309504
[9,] 6559.914867 -2626.591443
[10,] 8641.283921 6559.914867
[11,] 11023.058069 8641.283921
[12,] -3998.375621 11023.058069
[13,] -1145.902334 -3998.375621
[14,] -6315.464857 -1145.902334
[15,] 4524.090362 -6315.464857
[16,] 2996.865026 4524.090362
[17,] -5567.532287 2996.865026
[18,] 6429.826758 -5567.532287
[19,] -1897.852821 6429.826758
[20,] 1376.351673 -1897.852821
[21,] -774.054857 1376.351673
[22,] 10059.649656 -774.054857
[23,] -1701.214843 10059.649656
[24,] 1061.720799 -1701.214843
[25,] -13.687374 1061.720799
[26,] -4758.257660 -13.687374
[27,] 3309.247132 -4758.257660
[28,] -1073.728423 3309.247132
[29,] 2073.955822 -1073.728423
[30,] 9950.173936 2073.955822
[31,] -3410.501716 9950.173936
[32,] -2422.410939 -3410.501716
[33,] -677.693507 -2422.410939
[34,] 5912.778382 -677.693507
[35,] -16159.041274 5912.778382
[36,] -297.054456 -16159.041274
[37,] -9493.506833 -297.054456
[38,] 3839.795774 -9493.506833
[39,] -7656.781309 3839.795774
[40,] -6951.386933 -7656.781309
[41,] 2246.167610 -6951.386933
[42,] -4923.308326 2246.167610
[43,] -14548.431591 -4923.308326
[44,] 8249.849787 -14548.431591
[45,] -2490.343982 8249.849787
[46,] -13956.061231 -2490.343982
[47,] 3125.301021 -13956.061231
[48,] -2246.577630 3125.301021
[49,] 368.680458 -2246.577630
[50,] -1356.767661 368.680458
[51,] -6382.999766 -1356.767661
[52,] -6465.396226 -6382.999766
[53,] 3998.337659 -6465.396226
[54,] -12690.433179 3998.337659
[55,] 6443.212505 -12690.433179
[56,] -3207.087776 6443.212505
[57,] -5471.554841 -3207.087776
[58,] -6301.325663 -5471.554841
[59,] 3711.897026 -6301.325663
[60,] 9726.869769 3711.897026
[61,] 7263.455363 9726.869769
[62,] 6332.900129 7263.455363
[63,] 6212.117186 6332.900129
[64,] 10475.727538 6212.117186
[65,] 4503.875794 10475.727538
[66,] -2559.336739 4503.875794
[67,] 11996.264119 -2559.336739
[68,] -1370.111302 11996.264119
[69,] 2853.732320 -1370.111302
[70,] -4356.325064 2853.732320
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3020.960720 -4246.582861
2 2257.794275 3020.960720
3 -5.673605 2257.794275
4 1017.919017 -5.673605
5 -7254.804599 1017.919017
6 3793.077550 -7254.804599
7 1417.309504 3793.077550
8 -2626.591443 1417.309504
9 6559.914867 -2626.591443
10 8641.283921 6559.914867
11 11023.058069 8641.283921
12 -3998.375621 11023.058069
13 -1145.902334 -3998.375621
14 -6315.464857 -1145.902334
15 4524.090362 -6315.464857
16 2996.865026 4524.090362
17 -5567.532287 2996.865026
18 6429.826758 -5567.532287
19 -1897.852821 6429.826758
20 1376.351673 -1897.852821
21 -774.054857 1376.351673
22 10059.649656 -774.054857
23 -1701.214843 10059.649656
24 1061.720799 -1701.214843
25 -13.687374 1061.720799
26 -4758.257660 -13.687374
27 3309.247132 -4758.257660
28 -1073.728423 3309.247132
29 2073.955822 -1073.728423
30 9950.173936 2073.955822
31 -3410.501716 9950.173936
32 -2422.410939 -3410.501716
33 -677.693507 -2422.410939
34 5912.778382 -677.693507
35 -16159.041274 5912.778382
36 -297.054456 -16159.041274
37 -9493.506833 -297.054456
38 3839.795774 -9493.506833
39 -7656.781309 3839.795774
40 -6951.386933 -7656.781309
41 2246.167610 -6951.386933
42 -4923.308326 2246.167610
43 -14548.431591 -4923.308326
44 8249.849787 -14548.431591
45 -2490.343982 8249.849787
46 -13956.061231 -2490.343982
47 3125.301021 -13956.061231
48 -2246.577630 3125.301021
49 368.680458 -2246.577630
50 -1356.767661 368.680458
51 -6382.999766 -1356.767661
52 -6465.396226 -6382.999766
53 3998.337659 -6465.396226
54 -12690.433179 3998.337659
55 6443.212505 -12690.433179
56 -3207.087776 6443.212505
57 -5471.554841 -3207.087776
58 -6301.325663 -5471.554841
59 3711.897026 -6301.325663
60 9726.869769 3711.897026
61 7263.455363 9726.869769
62 6332.900129 7263.455363
63 6212.117186 6332.900129
64 10475.727538 6212.117186
65 4503.875794 10475.727538
66 -2559.336739 4503.875794
67 11996.264119 -2559.336739
68 -1370.111302 11996.264119
69 2853.732320 -1370.111302
70 -4356.325064 2853.732320
> 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/7ucmy1260654332.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/8f7au1260654332.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/9traq1260654332.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/10rxpx1260654332.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/1143y61260654332.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/12h2sf1260654332.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/13s2nq1260654332.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/14q36e1260654332.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/15g94x1260654333.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/165tl61260654333.tab")
+ }
> try(system("convert tmp/1z24h1260654332.ps tmp/1z24h1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/2o3hc1260654332.ps tmp/2o3hc1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/3nw0s1260654332.ps tmp/3nw0s1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/4qd4q1260654332.ps tmp/4qd4q1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/5fmzr1260654332.ps tmp/5fmzr1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/6zp8w1260654332.ps tmp/6zp8w1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ucmy1260654332.ps tmp/7ucmy1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/8f7au1260654332.ps tmp/8f7au1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/9traq1260654332.ps tmp/9traq1260654332.png",intern=TRUE))
character(0)
> try(system("convert tmp/10rxpx1260654332.ps tmp/10rxpx1260654332.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.536 1.573 3.197