R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(320,324,343,295,301,367,196,182,342,361,333,330,345,323,365,323,316,358,235,169,430,409,407,341,326,374,364,349,300,385,304,196,443,414,325,388,356,386,444,387,327,448,225,182,460,411,342,361,377,331,428,340,352,461,221,198,422,329,320,375,364,351,380,319,322,386,221,187,343,342,365,313,356,337,389,326,343,357,220,218,391,425,332,298,360,336,325,393,301,426,265,210,429,440,357,431,442,422,544,420,396,482,261,211,448,468,464,425),dim=c(1,108),dimnames=list(c('Vl'),1:108))
> y <- array(NA,dim=c(1,108),dimnames=list(c('Vl'),1:108))
> 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
> 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
Vl M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 320 1 0 0 0 0 0 0 0 0 0 0 1
2 324 0 1 0 0 0 0 0 0 0 0 0 2
3 343 0 0 1 0 0 0 0 0 0 0 0 3
4 295 0 0 0 1 0 0 0 0 0 0 0 4
5 301 0 0 0 0 1 0 0 0 0 0 0 5
6 367 0 0 0 0 0 1 0 0 0 0 0 6
7 196 0 0 0 0 0 0 1 0 0 0 0 7
8 182 0 0 0 0 0 0 0 1 0 0 0 8
9 342 0 0 0 0 0 0 0 0 1 0 0 9
10 361 0 0 0 0 0 0 0 0 0 1 0 10
11 333 0 0 0 0 0 0 0 0 0 0 1 11
12 330 0 0 0 0 0 0 0 0 0 0 0 12
13 345 1 0 0 0 0 0 0 0 0 0 0 13
14 323 0 1 0 0 0 0 0 0 0 0 0 14
15 365 0 0 1 0 0 0 0 0 0 0 0 15
16 323 0 0 0 1 0 0 0 0 0 0 0 16
17 316 0 0 0 0 1 0 0 0 0 0 0 17
18 358 0 0 0 0 0 1 0 0 0 0 0 18
19 235 0 0 0 0 0 0 1 0 0 0 0 19
20 169 0 0 0 0 0 0 0 1 0 0 0 20
21 430 0 0 0 0 0 0 0 0 1 0 0 21
22 409 0 0 0 0 0 0 0 0 0 1 0 22
23 407 0 0 0 0 0 0 0 0 0 0 1 23
24 341 0 0 0 0 0 0 0 0 0 0 0 24
25 326 1 0 0 0 0 0 0 0 0 0 0 25
26 374 0 1 0 0 0 0 0 0 0 0 0 26
27 364 0 0 1 0 0 0 0 0 0 0 0 27
28 349 0 0 0 1 0 0 0 0 0 0 0 28
29 300 0 0 0 0 1 0 0 0 0 0 0 29
30 385 0 0 0 0 0 1 0 0 0 0 0 30
31 304 0 0 0 0 0 0 1 0 0 0 0 31
32 196 0 0 0 0 0 0 0 1 0 0 0 32
33 443 0 0 0 0 0 0 0 0 1 0 0 33
34 414 0 0 0 0 0 0 0 0 0 1 0 34
35 325 0 0 0 0 0 0 0 0 0 0 1 35
36 388 0 0 0 0 0 0 0 0 0 0 0 36
37 356 1 0 0 0 0 0 0 0 0 0 0 37
38 386 0 1 0 0 0 0 0 0 0 0 0 38
39 444 0 0 1 0 0 0 0 0 0 0 0 39
40 387 0 0 0 1 0 0 0 0 0 0 0 40
41 327 0 0 0 0 1 0 0 0 0 0 0 41
42 448 0 0 0 0 0 1 0 0 0 0 0 42
43 225 0 0 0 0 0 0 1 0 0 0 0 43
44 182 0 0 0 0 0 0 0 1 0 0 0 44
45 460 0 0 0 0 0 0 0 0 1 0 0 45
46 411 0 0 0 0 0 0 0 0 0 1 0 46
47 342 0 0 0 0 0 0 0 0 0 0 1 47
48 361 0 0 0 0 0 0 0 0 0 0 0 48
49 377 1 0 0 0 0 0 0 0 0 0 0 49
50 331 0 1 0 0 0 0 0 0 0 0 0 50
51 428 0 0 1 0 0 0 0 0 0 0 0 51
52 340 0 0 0 1 0 0 0 0 0 0 0 52
53 352 0 0 0 0 1 0 0 0 0 0 0 53
54 461 0 0 0 0 0 1 0 0 0 0 0 54
55 221 0 0 0 0 0 0 1 0 0 0 0 55
56 198 0 0 0 0 0 0 0 1 0 0 0 56
57 422 0 0 0 0 0 0 0 0 1 0 0 57
58 329 0 0 0 0 0 0 0 0 0 1 0 58
59 320 0 0 0 0 0 0 0 0 0 0 1 59
60 375 0 0 0 0 0 0 0 0 0 0 0 60
61 364 1 0 0 0 0 0 0 0 0 0 0 61
62 351 0 1 0 0 0 0 0 0 0 0 0 62
63 380 0 0 1 0 0 0 0 0 0 0 0 63
64 319 0 0 0 1 0 0 0 0 0 0 0 64
65 322 0 0 0 0 1 0 0 0 0 0 0 65
66 386 0 0 0 0 0 1 0 0 0 0 0 66
67 221 0 0 0 0 0 0 1 0 0 0 0 67
68 187 0 0 0 0 0 0 0 1 0 0 0 68
69 343 0 0 0 0 0 0 0 0 1 0 0 69
70 342 0 0 0 0 0 0 0 0 0 1 0 70
71 365 0 0 0 0 0 0 0 0 0 0 1 71
72 313 0 0 0 0 0 0 0 0 0 0 0 72
73 356 1 0 0 0 0 0 0 0 0 0 0 73
74 337 0 1 0 0 0 0 0 0 0 0 0 74
75 389 0 0 1 0 0 0 0 0 0 0 0 75
76 326 0 0 0 1 0 0 0 0 0 0 0 76
77 343 0 0 0 0 1 0 0 0 0 0 0 77
78 357 0 0 0 0 0 1 0 0 0 0 0 78
79 220 0 0 0 0 0 0 1 0 0 0 0 79
80 218 0 0 0 0 0 0 0 1 0 0 0 80
81 391 0 0 0 0 0 0 0 0 1 0 0 81
82 425 0 0 0 0 0 0 0 0 0 1 0 82
83 332 0 0 0 0 0 0 0 0 0 0 1 83
84 298 0 0 0 0 0 0 0 0 0 0 0 84
85 360 1 0 0 0 0 0 0 0 0 0 0 85
86 336 0 1 0 0 0 0 0 0 0 0 0 86
87 325 0 0 1 0 0 0 0 0 0 0 0 87
88 393 0 0 0 1 0 0 0 0 0 0 0 88
89 301 0 0 0 0 1 0 0 0 0 0 0 89
90 426 0 0 0 0 0 1 0 0 0 0 0 90
91 265 0 0 0 0 0 0 1 0 0 0 0 91
92 210 0 0 0 0 0 0 0 1 0 0 0 92
93 429 0 0 0 0 0 0 0 0 1 0 0 93
94 440 0 0 0 0 0 0 0 0 0 1 0 94
95 357 0 0 0 0 0 0 0 0 0 0 1 95
96 431 0 0 0 0 0 0 0 0 0 0 0 96
97 442 1 0 0 0 0 0 0 0 0 0 0 97
98 422 0 1 0 0 0 0 0 0 0 0 0 98
99 544 0 0 1 0 0 0 0 0 0 0 0 99
100 420 0 0 0 1 0 0 0 0 0 0 0 100
101 396 0 0 0 0 1 0 0 0 0 0 0 101
102 482 0 0 0 0 0 1 0 0 0 0 0 102
103 261 0 0 0 0 0 0 1 0 0 0 0 103
104 211 0 0 0 0 0 0 0 1 0 0 0 104
105 448 0 0 0 0 0 0 0 0 1 0 0 105
106 468 0 0 0 0 0 0 0 0 0 1 0 106
107 464 0 0 0 0 0 0 0 0 0 0 1 107
108 425 0 0 0 0 0 0 0 0 0 0 0 108
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) M1 M2 M3 M4 M5
326.861 4.746 -2.736 40.893 -7.478 -29.626
M6 M7 M8 M9 M10 M11
48.892 -120.812 -165.294 51.335 38.631 -1.296
t
0.593
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-94.350 -21.496 -3.881 19.428 117.533
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 326.8611 14.4319 22.648 < 2e-16 ***
M1 4.7458 17.8619 0.266 0.7910
M2 -2.7361 17.8538 -0.153 0.8785
M3 40.8931 17.8464 2.291 0.0242 *
M4 -7.4778 17.8399 -0.419 0.6760
M5 -29.6264 17.8341 -1.661 0.1000 .
M6 48.8917 17.8291 2.742 0.0073 **
M7 -120.8125 17.8248 -6.778 1.02e-09 ***
M8 -165.2944 17.8213 -9.275 5.86e-15 ***
M9 51.3347 17.8186 2.881 0.0049 **
M10 38.6306 17.8167 2.168 0.0326 *
M11 -1.2958 17.8155 -0.073 0.9422
t 0.5931 0.1174 5.053 2.10e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 37.79 on 95 degrees of freedom
Multiple R-squared: 0.7794, Adjusted R-squared: 0.7516
F-statistic: 27.98 on 12 and 95 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.016363196 0.032726392 0.9836368
[2,] 0.003142254 0.006284509 0.9968577
[3,] 0.003325434 0.006650869 0.9966746
[4,] 0.002358137 0.004716274 0.9976419
[5,] 0.002073076 0.004146151 0.9979269
[6,] 0.026717496 0.053434992 0.9732825
[7,] 0.016731103 0.033462205 0.9832689
[8,] 0.022639824 0.045279648 0.9773602
[9,] 0.012612975 0.025225949 0.9873870
[10,] 0.015299094 0.030598189 0.9847009
[11,] 0.009407739 0.018815477 0.9905923
[12,] 0.006298678 0.012597356 0.9937013
[13,] 0.003232356 0.006464712 0.9967676
[14,] 0.003348718 0.006697436 0.9966513
[15,] 0.001698894 0.003397789 0.9983011
[16,] 0.005757800 0.011515601 0.9942422
[17,] 0.003320260 0.006640520 0.9966797
[18,] 0.002590333 0.005180666 0.9974097
[19,] 0.001488068 0.002976136 0.9985119
[20,] 0.006485676 0.012971353 0.9935143
[21,] 0.005097924 0.010195848 0.9949021
[22,] 0.003080295 0.006160590 0.9969197
[23,] 0.002159132 0.004318264 0.9978409
[24,] 0.003269040 0.006538081 0.9967310
[25,] 0.002757637 0.005515274 0.9972424
[26,] 0.001923936 0.003847872 0.9980761
[27,] 0.002140572 0.004281143 0.9978594
[28,] 0.004536720 0.009073440 0.9954633
[29,] 0.004348392 0.008696784 0.9956516
[30,] 0.005670640 0.011341280 0.9943294
[31,] 0.005160860 0.010321719 0.9948391
[32,] 0.006292862 0.012585724 0.9937071
[33,] 0.005461693 0.010923386 0.9945383
[34,] 0.003879246 0.007758493 0.9961208
[35,] 0.006293158 0.012586316 0.9937068
[36,] 0.005913124 0.011826249 0.9940869
[37,] 0.005339332 0.010678664 0.9946607
[38,] 0.004877175 0.009754350 0.9951228
[39,] 0.011833966 0.023667932 0.9881660
[40,] 0.017047511 0.034095022 0.9829525
[41,] 0.016427691 0.032855382 0.9835723
[42,] 0.028659315 0.057318629 0.9713407
[43,] 0.086198724 0.172397448 0.9138013
[44,] 0.093783766 0.187567533 0.9062162
[45,] 0.122855710 0.245711421 0.8771443
[46,] 0.107594001 0.215188002 0.8924060
[47,] 0.107721621 0.215443241 0.8922784
[48,] 0.098577653 0.197155307 0.9014223
[49,] 0.090802870 0.181605741 0.9091971
[50,] 0.084114516 0.168229032 0.9158855
[51,] 0.081875438 0.163750877 0.9181246
[52,] 0.084003681 0.168007362 0.9159963
[53,] 0.083399798 0.166799597 0.9166002
[54,] 0.127307396 0.254614792 0.8726926
[55,] 0.129252813 0.258505626 0.8707472
[56,] 0.138527599 0.277055198 0.8614724
[57,] 0.132058816 0.264117631 0.8679412
[58,] 0.101775708 0.203551416 0.8982243
[59,] 0.081055626 0.162111252 0.9189444
[60,] 0.060725239 0.121450478 0.9392748
[61,] 0.044717359 0.089434718 0.9552826
[62,] 0.049155570 0.098311139 0.9508444
[63,] 0.046058685 0.092117369 0.9539413
[64,] 0.034811276 0.069622551 0.9651887
[65,] 0.059949822 0.119899645 0.9400502
[66,] 0.049446834 0.098893667 0.9505532
[67,] 0.060891165 0.121782329 0.9391088
[68,] 0.043342884 0.086685768 0.9566571
[69,] 0.043197624 0.086395248 0.9568024
[70,] 0.028549337 0.057098674 0.9714507
[71,] 0.019283443 0.038566887 0.9807166
[72,] 0.587656398 0.824687204 0.4123436
[73,] 0.500322257 0.999355486 0.4996777
[74,] 0.592341947 0.815316106 0.4076581
[75,] 0.516016035 0.967967930 0.4839840
[76,] 0.433521647 0.867043293 0.5664784
[77,] 0.341246791 0.682493583 0.6587532
> postscript(file="/var/www/rcomp/tmp/1flz81292960498.ps",horizontal=F,onefile=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/rcomp/tmp/28uyb1292960498.ps",horizontal=F,onefile=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/rcomp/tmp/38uyb1292960498.ps",horizontal=F,onefile=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/rcomp/tmp/48uyb1292960498.ps",horizontal=F,onefile=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/rcomp/tmp/504gw1292960498.ps",horizontal=F,onefile=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 = 108
Frequency = 1
1 2 3 4 5 6
-12.20000000 -1.31111111 -26.53333333 -26.75555556 0.80000000 -12.31111111
7 8 9 10 11 12
-14.20000000 15.68888889 -41.53333333 -10.42222222 0.91111111 -3.97777778
13 14 15 16 17 18
5.68333333 -9.42777778 -11.65000000 -5.87222222 8.68333333 -28.42777778
19 20 21 22 23 24
17.68333333 -4.42777778 39.35000000 30.46111111 67.79444444 -0.09444444
25 26 27 28 29 30
-20.43333333 34.45555556 -19.76666667 13.01111111 -14.43333333 -8.54444444
31 32 33 34 35 36
79.56666667 15.45555556 45.23333333 28.34444444 -21.32222222 39.78888889
37 38 39 40 41 42
2.45000000 39.33888889 53.11666667 43.89444444 5.45000000 47.33888889
43 44 45 46 47 48
-6.55000000 -5.66111111 55.11666667 18.22777778 -11.43888889 5.67222222
49 50 51 52 53 54
16.33333333 -22.77777778 30.00000000 -10.22222222 23.33333333 53.22222222
55 56 57 58 59 60
-17.66666667 3.22222222 10.00000000 -70.88888889 -40.55555556 12.55555556
61 62 63 64 65 66
-3.78333333 -9.89444444 -25.11666667 -38.33888889 -13.78333333 -28.89444444
67 68 69 70 71 72
-24.78333333 -14.89444444 -76.11666667 -65.00555556 -2.67222222 -56.56111111
73 74 75 76 77 78
-18.90000000 -31.01111111 -23.23333333 -38.45555556 0.10000000 -65.01111111
79 80 81 82 83 84
-32.90000000 8.98888889 -35.23333333 10.87777778 -42.78888889 -78.67777778
85 86 87 88 89 90
-22.01666667 -39.12777778 -94.35000000 21.42777778 -49.01666667 -3.12777778
91 92 93 94 95 96
4.98333333 -6.12777778 -4.35000000 18.76111111 -24.90555556 47.20555556
97 98 99 100 101 102
52.86666667 39.75555556 117.53333333 41.31111111 38.86666667 45.75555556
103 104 105 106 107 108
-6.13333333 -12.24444444 7.53333333 39.64444444 74.97777778 34.08888889
> postscript(file="/var/www/rcomp/tmp/604gw1292960498.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 108
Frequency = 1
lag(myerror, k = 1) myerror
0 -12.20000000 NA
1 -1.31111111 -12.20000000
2 -26.53333333 -1.31111111
3 -26.75555556 -26.53333333
4 0.80000000 -26.75555556
5 -12.31111111 0.80000000
6 -14.20000000 -12.31111111
7 15.68888889 -14.20000000
8 -41.53333333 15.68888889
9 -10.42222222 -41.53333333
10 0.91111111 -10.42222222
11 -3.97777778 0.91111111
12 5.68333333 -3.97777778
13 -9.42777778 5.68333333
14 -11.65000000 -9.42777778
15 -5.87222222 -11.65000000
16 8.68333333 -5.87222222
17 -28.42777778 8.68333333
18 17.68333333 -28.42777778
19 -4.42777778 17.68333333
20 39.35000000 -4.42777778
21 30.46111111 39.35000000
22 67.79444444 30.46111111
23 -0.09444444 67.79444444
24 -20.43333333 -0.09444444
25 34.45555556 -20.43333333
26 -19.76666667 34.45555556
27 13.01111111 -19.76666667
28 -14.43333333 13.01111111
29 -8.54444444 -14.43333333
30 79.56666667 -8.54444444
31 15.45555556 79.56666667
32 45.23333333 15.45555556
33 28.34444444 45.23333333
34 -21.32222222 28.34444444
35 39.78888889 -21.32222222
36 2.45000000 39.78888889
37 39.33888889 2.45000000
38 53.11666667 39.33888889
39 43.89444444 53.11666667
40 5.45000000 43.89444444
41 47.33888889 5.45000000
42 -6.55000000 47.33888889
43 -5.66111111 -6.55000000
44 55.11666667 -5.66111111
45 18.22777778 55.11666667
46 -11.43888889 18.22777778
47 5.67222222 -11.43888889
48 16.33333333 5.67222222
49 -22.77777778 16.33333333
50 30.00000000 -22.77777778
51 -10.22222222 30.00000000
52 23.33333333 -10.22222222
53 53.22222222 23.33333333
54 -17.66666667 53.22222222
55 3.22222222 -17.66666667
56 10.00000000 3.22222222
57 -70.88888889 10.00000000
58 -40.55555556 -70.88888889
59 12.55555556 -40.55555556
60 -3.78333333 12.55555556
61 -9.89444444 -3.78333333
62 -25.11666667 -9.89444444
63 -38.33888889 -25.11666667
64 -13.78333333 -38.33888889
65 -28.89444444 -13.78333333
66 -24.78333333 -28.89444444
67 -14.89444444 -24.78333333
68 -76.11666667 -14.89444444
69 -65.00555556 -76.11666667
70 -2.67222222 -65.00555556
71 -56.56111111 -2.67222222
72 -18.90000000 -56.56111111
73 -31.01111111 -18.90000000
74 -23.23333333 -31.01111111
75 -38.45555556 -23.23333333
76 0.10000000 -38.45555556
77 -65.01111111 0.10000000
78 -32.90000000 -65.01111111
79 8.98888889 -32.90000000
80 -35.23333333 8.98888889
81 10.87777778 -35.23333333
82 -42.78888889 10.87777778
83 -78.67777778 -42.78888889
84 -22.01666667 -78.67777778
85 -39.12777778 -22.01666667
86 -94.35000000 -39.12777778
87 21.42777778 -94.35000000
88 -49.01666667 21.42777778
89 -3.12777778 -49.01666667
90 4.98333333 -3.12777778
91 -6.12777778 4.98333333
92 -4.35000000 -6.12777778
93 18.76111111 -4.35000000
94 -24.90555556 18.76111111
95 47.20555556 -24.90555556
96 52.86666667 47.20555556
97 39.75555556 52.86666667
98 117.53333333 39.75555556
99 41.31111111 117.53333333
100 38.86666667 41.31111111
101 45.75555556 38.86666667
102 -6.13333333 45.75555556
103 -12.24444444 -6.13333333
104 7.53333333 -12.24444444
105 39.64444444 7.53333333
106 74.97777778 39.64444444
107 34.08888889 74.97777778
108 NA 34.08888889
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.31111111 -12.20000000
[2,] -26.53333333 -1.31111111
[3,] -26.75555556 -26.53333333
[4,] 0.80000000 -26.75555556
[5,] -12.31111111 0.80000000
[6,] -14.20000000 -12.31111111
[7,] 15.68888889 -14.20000000
[8,] -41.53333333 15.68888889
[9,] -10.42222222 -41.53333333
[10,] 0.91111111 -10.42222222
[11,] -3.97777778 0.91111111
[12,] 5.68333333 -3.97777778
[13,] -9.42777778 5.68333333
[14,] -11.65000000 -9.42777778
[15,] -5.87222222 -11.65000000
[16,] 8.68333333 -5.87222222
[17,] -28.42777778 8.68333333
[18,] 17.68333333 -28.42777778
[19,] -4.42777778 17.68333333
[20,] 39.35000000 -4.42777778
[21,] 30.46111111 39.35000000
[22,] 67.79444444 30.46111111
[23,] -0.09444444 67.79444444
[24,] -20.43333333 -0.09444444
[25,] 34.45555556 -20.43333333
[26,] -19.76666667 34.45555556
[27,] 13.01111111 -19.76666667
[28,] -14.43333333 13.01111111
[29,] -8.54444444 -14.43333333
[30,] 79.56666667 -8.54444444
[31,] 15.45555556 79.56666667
[32,] 45.23333333 15.45555556
[33,] 28.34444444 45.23333333
[34,] -21.32222222 28.34444444
[35,] 39.78888889 -21.32222222
[36,] 2.45000000 39.78888889
[37,] 39.33888889 2.45000000
[38,] 53.11666667 39.33888889
[39,] 43.89444444 53.11666667
[40,] 5.45000000 43.89444444
[41,] 47.33888889 5.45000000
[42,] -6.55000000 47.33888889
[43,] -5.66111111 -6.55000000
[44,] 55.11666667 -5.66111111
[45,] 18.22777778 55.11666667
[46,] -11.43888889 18.22777778
[47,] 5.67222222 -11.43888889
[48,] 16.33333333 5.67222222
[49,] -22.77777778 16.33333333
[50,] 30.00000000 -22.77777778
[51,] -10.22222222 30.00000000
[52,] 23.33333333 -10.22222222
[53,] 53.22222222 23.33333333
[54,] -17.66666667 53.22222222
[55,] 3.22222222 -17.66666667
[56,] 10.00000000 3.22222222
[57,] -70.88888889 10.00000000
[58,] -40.55555556 -70.88888889
[59,] 12.55555556 -40.55555556
[60,] -3.78333333 12.55555556
[61,] -9.89444444 -3.78333333
[62,] -25.11666667 -9.89444444
[63,] -38.33888889 -25.11666667
[64,] -13.78333333 -38.33888889
[65,] -28.89444444 -13.78333333
[66,] -24.78333333 -28.89444444
[67,] -14.89444444 -24.78333333
[68,] -76.11666667 -14.89444444
[69,] -65.00555556 -76.11666667
[70,] -2.67222222 -65.00555556
[71,] -56.56111111 -2.67222222
[72,] -18.90000000 -56.56111111
[73,] -31.01111111 -18.90000000
[74,] -23.23333333 -31.01111111
[75,] -38.45555556 -23.23333333
[76,] 0.10000000 -38.45555556
[77,] -65.01111111 0.10000000
[78,] -32.90000000 -65.01111111
[79,] 8.98888889 -32.90000000
[80,] -35.23333333 8.98888889
[81,] 10.87777778 -35.23333333
[82,] -42.78888889 10.87777778
[83,] -78.67777778 -42.78888889
[84,] -22.01666667 -78.67777778
[85,] -39.12777778 -22.01666667
[86,] -94.35000000 -39.12777778
[87,] 21.42777778 -94.35000000
[88,] -49.01666667 21.42777778
[89,] -3.12777778 -49.01666667
[90,] 4.98333333 -3.12777778
[91,] -6.12777778 4.98333333
[92,] -4.35000000 -6.12777778
[93,] 18.76111111 -4.35000000
[94,] -24.90555556 18.76111111
[95,] 47.20555556 -24.90555556
[96,] 52.86666667 47.20555556
[97,] 39.75555556 52.86666667
[98,] 117.53333333 39.75555556
[99,] 41.31111111 117.53333333
[100,] 38.86666667 41.31111111
[101,] 45.75555556 38.86666667
[102,] -6.13333333 45.75555556
[103,] -12.24444444 -6.13333333
[104,] 7.53333333 -12.24444444
[105,] 39.64444444 7.53333333
[106,] 74.97777778 39.64444444
[107,] 34.08888889 74.97777778
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.31111111 -12.20000000
2 -26.53333333 -1.31111111
3 -26.75555556 -26.53333333
4 0.80000000 -26.75555556
5 -12.31111111 0.80000000
6 -14.20000000 -12.31111111
7 15.68888889 -14.20000000
8 -41.53333333 15.68888889
9 -10.42222222 -41.53333333
10 0.91111111 -10.42222222
11 -3.97777778 0.91111111
12 5.68333333 -3.97777778
13 -9.42777778 5.68333333
14 -11.65000000 -9.42777778
15 -5.87222222 -11.65000000
16 8.68333333 -5.87222222
17 -28.42777778 8.68333333
18 17.68333333 -28.42777778
19 -4.42777778 17.68333333
20 39.35000000 -4.42777778
21 30.46111111 39.35000000
22 67.79444444 30.46111111
23 -0.09444444 67.79444444
24 -20.43333333 -0.09444444
25 34.45555556 -20.43333333
26 -19.76666667 34.45555556
27 13.01111111 -19.76666667
28 -14.43333333 13.01111111
29 -8.54444444 -14.43333333
30 79.56666667 -8.54444444
31 15.45555556 79.56666667
32 45.23333333 15.45555556
33 28.34444444 45.23333333
34 -21.32222222 28.34444444
35 39.78888889 -21.32222222
36 2.45000000 39.78888889
37 39.33888889 2.45000000
38 53.11666667 39.33888889
39 43.89444444 53.11666667
40 5.45000000 43.89444444
41 47.33888889 5.45000000
42 -6.55000000 47.33888889
43 -5.66111111 -6.55000000
44 55.11666667 -5.66111111
45 18.22777778 55.11666667
46 -11.43888889 18.22777778
47 5.67222222 -11.43888889
48 16.33333333 5.67222222
49 -22.77777778 16.33333333
50 30.00000000 -22.77777778
51 -10.22222222 30.00000000
52 23.33333333 -10.22222222
53 53.22222222 23.33333333
54 -17.66666667 53.22222222
55 3.22222222 -17.66666667
56 10.00000000 3.22222222
57 -70.88888889 10.00000000
58 -40.55555556 -70.88888889
59 12.55555556 -40.55555556
60 -3.78333333 12.55555556
61 -9.89444444 -3.78333333
62 -25.11666667 -9.89444444
63 -38.33888889 -25.11666667
64 -13.78333333 -38.33888889
65 -28.89444444 -13.78333333
66 -24.78333333 -28.89444444
67 -14.89444444 -24.78333333
68 -76.11666667 -14.89444444
69 -65.00555556 -76.11666667
70 -2.67222222 -65.00555556
71 -56.56111111 -2.67222222
72 -18.90000000 -56.56111111
73 -31.01111111 -18.90000000
74 -23.23333333 -31.01111111
75 -38.45555556 -23.23333333
76 0.10000000 -38.45555556
77 -65.01111111 0.10000000
78 -32.90000000 -65.01111111
79 8.98888889 -32.90000000
80 -35.23333333 8.98888889
81 10.87777778 -35.23333333
82 -42.78888889 10.87777778
83 -78.67777778 -42.78888889
84 -22.01666667 -78.67777778
85 -39.12777778 -22.01666667
86 -94.35000000 -39.12777778
87 21.42777778 -94.35000000
88 -49.01666667 21.42777778
89 -3.12777778 -49.01666667
90 4.98333333 -3.12777778
91 -6.12777778 4.98333333
92 -4.35000000 -6.12777778
93 18.76111111 -4.35000000
94 -24.90555556 18.76111111
95 47.20555556 -24.90555556
96 52.86666667 47.20555556
97 39.75555556 52.86666667
98 117.53333333 39.75555556
99 41.31111111 117.53333333
100 38.86666667 41.31111111
101 45.75555556 38.86666667
102 -6.13333333 45.75555556
103 -12.24444444 -6.13333333
104 7.53333333 -12.24444444
105 39.64444444 7.53333333
106 74.97777778 39.64444444
107 34.08888889 74.97777778
> 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/rcomp/tmp/7tvfz1292960498.ps",horizontal=F,onefile=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/rcomp/tmp/8tvfz1292960498.ps",horizontal=F,onefile=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/rcomp/tmp/94mw21292960498.ps",horizontal=F,onefile=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/rcomp/tmp/104mw21292960498.ps",horizontal=F,onefile=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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/1175dq1292960498.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/rcomp/tmp/12t5be1292960498.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/rcomp/tmp/13ho8p1292960498.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/rcomp/tmp/14syps1292960498.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/rcomp/tmp/15vyog1292960498.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/rcomp/tmp/16aqm71292960498.tab")
+ }
>
> try(system("convert tmp/1flz81292960498.ps tmp/1flz81292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/28uyb1292960498.ps tmp/28uyb1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/38uyb1292960498.ps tmp/38uyb1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/48uyb1292960498.ps tmp/48uyb1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/504gw1292960498.ps tmp/504gw1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/604gw1292960498.ps tmp/604gw1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/7tvfz1292960498.ps tmp/7tvfz1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/8tvfz1292960498.ps tmp/8tvfz1292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/94mw21292960498.ps tmp/94mw21292960498.png",intern=TRUE))
character(0)
> try(system("convert tmp/104mw21292960498.ps tmp/104mw21292960498.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.770 0.750 4.515