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(111.6,0,104.6,0,91.6,0,98.3,0,97.7,0,106.3,0,102.3,0,106.6,0,108.1,0,93.8,0,88.2,0,108.9,0,114.2,0,102.5,0,94.2,0,97.4,0,98.5,0,106.5,0,102.9,0,97.1,0,103.7,0,93.4,0,85.8,0,108.6,0,110.2,0,101.2,0,101.2,0,96.9,0,99.4,0,118.7,0,108.0,0,101.2,0,119.9,0,94.8,0,95.3,0,118.0,0,115.9,0,111.4,0,108.2,0,108.8,0,109.5,0,124.8,0,115.3,0,109.5,0,124.2,0,92.9,0,98.4,0,120.9,0,111.7,0,116.1,0,109.4,0,111.7,0,114.3,0,133.7,0,114.3,0,126.5,0,131.0,0,104.0,0,108.9,0,128.5,0,132.4,0,128.0,0,116.4,0,120.9,0,118.6,0,133.1,0,121.1,0,127.6,0,135.4,0,114.9,0,114.3,0,128.9,0,138.9,0,129.4,0,115.0,0,128.0,0,127.0,0,128.8,0,137.9,0,128.4,0,135.9,0,122.2,0,113.1,0,136.2,1,138.0,1,115.2,1,111.0,1,99.2,1,102.4,1,112.7,1,105.5,1,98.3,1,116.4,1,97.4,1,93.3,1,117.4,1),dim=c(2,96),dimnames=list(c('y','dummy'),1:96))
> y <- array(NA,dim=c(2,96),dimnames=list(c('y','dummy'),1:96))
> 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 dummy M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 111.6 0 1 0 0 0 0 0 0 0 0 0 0 1
2 104.6 0 0 1 0 0 0 0 0 0 0 0 0 2
3 91.6 0 0 0 1 0 0 0 0 0 0 0 0 3
4 98.3 0 0 0 0 1 0 0 0 0 0 0 0 4
5 97.7 0 0 0 0 0 1 0 0 0 0 0 0 5
6 106.3 0 0 0 0 0 0 1 0 0 0 0 0 6
7 102.3 0 0 0 0 0 0 0 1 0 0 0 0 7
8 106.6 0 0 0 0 0 0 0 0 1 0 0 0 8
9 108.1 0 0 0 0 0 0 0 0 0 1 0 0 9
10 93.8 0 0 0 0 0 0 0 0 0 0 1 0 10
11 88.2 0 0 0 0 0 0 0 0 0 0 0 1 11
12 108.9 0 0 0 0 0 0 0 0 0 0 0 0 12
13 114.2 0 1 0 0 0 0 0 0 0 0 0 0 13
14 102.5 0 0 1 0 0 0 0 0 0 0 0 0 14
15 94.2 0 0 0 1 0 0 0 0 0 0 0 0 15
16 97.4 0 0 0 0 1 0 0 0 0 0 0 0 16
17 98.5 0 0 0 0 0 1 0 0 0 0 0 0 17
18 106.5 0 0 0 0 0 0 1 0 0 0 0 0 18
19 102.9 0 0 0 0 0 0 0 1 0 0 0 0 19
20 97.1 0 0 0 0 0 0 0 0 1 0 0 0 20
21 103.7 0 0 0 0 0 0 0 0 0 1 0 0 21
22 93.4 0 0 0 0 0 0 0 0 0 0 1 0 22
23 85.8 0 0 0 0 0 0 0 0 0 0 0 1 23
24 108.6 0 0 0 0 0 0 0 0 0 0 0 0 24
25 110.2 0 1 0 0 0 0 0 0 0 0 0 0 25
26 101.2 0 0 1 0 0 0 0 0 0 0 0 0 26
27 101.2 0 0 0 1 0 0 0 0 0 0 0 0 27
28 96.9 0 0 0 0 1 0 0 0 0 0 0 0 28
29 99.4 0 0 0 0 0 1 0 0 0 0 0 0 29
30 118.7 0 0 0 0 0 0 1 0 0 0 0 0 30
31 108.0 0 0 0 0 0 0 0 1 0 0 0 0 31
32 101.2 0 0 0 0 0 0 0 0 1 0 0 0 32
33 119.9 0 0 0 0 0 0 0 0 0 1 0 0 33
34 94.8 0 0 0 0 0 0 0 0 0 0 1 0 34
35 95.3 0 0 0 0 0 0 0 0 0 0 0 1 35
36 118.0 0 0 0 0 0 0 0 0 0 0 0 0 36
37 115.9 0 1 0 0 0 0 0 0 0 0 0 0 37
38 111.4 0 0 1 0 0 0 0 0 0 0 0 0 38
39 108.2 0 0 0 1 0 0 0 0 0 0 0 0 39
40 108.8 0 0 0 0 1 0 0 0 0 0 0 0 40
41 109.5 0 0 0 0 0 1 0 0 0 0 0 0 41
42 124.8 0 0 0 0 0 0 1 0 0 0 0 0 42
43 115.3 0 0 0 0 0 0 0 1 0 0 0 0 43
44 109.5 0 0 0 0 0 0 0 0 1 0 0 0 44
45 124.2 0 0 0 0 0 0 0 0 0 1 0 0 45
46 92.9 0 0 0 0 0 0 0 0 0 0 1 0 46
47 98.4 0 0 0 0 0 0 0 0 0 0 0 1 47
48 120.9 0 0 0 0 0 0 0 0 0 0 0 0 48
49 111.7 0 1 0 0 0 0 0 0 0 0 0 0 49
50 116.1 0 0 1 0 0 0 0 0 0 0 0 0 50
51 109.4 0 0 0 1 0 0 0 0 0 0 0 0 51
52 111.7 0 0 0 0 1 0 0 0 0 0 0 0 52
53 114.3 0 0 0 0 0 1 0 0 0 0 0 0 53
54 133.7 0 0 0 0 0 0 1 0 0 0 0 0 54
55 114.3 0 0 0 0 0 0 0 1 0 0 0 0 55
56 126.5 0 0 0 0 0 0 0 0 1 0 0 0 56
57 131.0 0 0 0 0 0 0 0 0 0 1 0 0 57
58 104.0 0 0 0 0 0 0 0 0 0 0 1 0 58
59 108.9 0 0 0 0 0 0 0 0 0 0 0 1 59
60 128.5 0 0 0 0 0 0 0 0 0 0 0 0 60
61 132.4 0 1 0 0 0 0 0 0 0 0 0 0 61
62 128.0 0 0 1 0 0 0 0 0 0 0 0 0 62
63 116.4 0 0 0 1 0 0 0 0 0 0 0 0 63
64 120.9 0 0 0 0 1 0 0 0 0 0 0 0 64
65 118.6 0 0 0 0 0 1 0 0 0 0 0 0 65
66 133.1 0 0 0 0 0 0 1 0 0 0 0 0 66
67 121.1 0 0 0 0 0 0 0 1 0 0 0 0 67
68 127.6 0 0 0 0 0 0 0 0 1 0 0 0 68
69 135.4 0 0 0 0 0 0 0 0 0 1 0 0 69
70 114.9 0 0 0 0 0 0 0 0 0 0 1 0 70
71 114.3 0 0 0 0 0 0 0 0 0 0 0 1 71
72 128.9 0 0 0 0 0 0 0 0 0 0 0 0 72
73 138.9 0 1 0 0 0 0 0 0 0 0 0 0 73
74 129.4 0 0 1 0 0 0 0 0 0 0 0 0 74
75 115.0 0 0 0 1 0 0 0 0 0 0 0 0 75
76 128.0 0 0 0 0 1 0 0 0 0 0 0 0 76
77 127.0 0 0 0 0 0 1 0 0 0 0 0 0 77
78 128.8 0 0 0 0 0 0 1 0 0 0 0 0 78
79 137.9 0 0 0 0 0 0 0 1 0 0 0 0 79
80 128.4 0 0 0 0 0 0 0 0 1 0 0 0 80
81 135.9 0 0 0 0 0 0 0 0 0 1 0 0 81
82 122.2 0 0 0 0 0 0 0 0 0 0 1 0 82
83 113.1 0 0 0 0 0 0 0 0 0 0 0 1 83
84 136.2 1 0 0 0 0 0 0 0 0 0 0 0 84
85 138.0 1 1 0 0 0 0 0 0 0 0 0 0 85
86 115.2 1 0 1 0 0 0 0 0 0 0 0 0 86
87 111.0 1 0 0 1 0 0 0 0 0 0 0 0 87
88 99.2 1 0 0 0 1 0 0 0 0 0 0 0 88
89 102.4 1 0 0 0 0 1 0 0 0 0 0 0 89
90 112.7 1 0 0 0 0 0 1 0 0 0 0 0 90
91 105.5 1 0 0 0 0 0 0 1 0 0 0 0 91
92 98.3 1 0 0 0 0 0 0 0 1 0 0 0 92
93 116.4 1 0 0 0 0 0 0 0 0 1 0 0 93
94 97.4 1 0 0 0 0 0 0 0 0 0 1 0 94
95 93.3 1 0 0 0 0 0 0 0 0 0 0 1 95
96 117.4 1 0 0 0 0 0 0 0 0 0 0 0 96
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) dummy M1 M2 M3 M4
104.0279 -22.2017 2.4849 -5.9933 -14.0840 -12.7246
M5 M6 M7 M8 M9 M10
-12.3653 -0.6310 -8.2092 -10.1374 -0.6281 -21.1938
M11 t
-23.6220 0.4157
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-15.18188 -3.60772 -0.02521 3.24544 19.45541
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 104.02788 2.37571 43.788 < 2e-16 ***
dummy -22.20169 2.15946 -10.281 < 2e-16 ***
M1 2.48494 2.90759 0.855 0.395242
M2 -5.99326 2.90649 -2.062 0.042372 *
M3 -14.08395 2.90563 -4.847 5.85e-06 ***
M4 -12.72465 2.90501 -4.380 3.48e-05 ***
M5 -12.36534 2.90464 -4.257 5.48e-05 ***
M6 -0.63104 2.90452 -0.217 0.828544
M7 -8.20923 2.90464 -2.826 0.005914 **
M8 -10.13743 2.90501 -3.490 0.000781 ***
M9 -0.62813 2.90563 -0.216 0.829388
M10 -21.19382 2.90649 -7.292 1.73e-10 ***
M11 -23.62202 2.90759 -8.124 3.96e-12 ***
t 0.41570 0.02674 15.548 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.793 on 82 degrees of freedom
Multiple R-squared: 0.8313, Adjusted R-squared: 0.8045
F-statistic: 31.08 on 13 and 82 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.0311181134 0.0622362269 0.9688819
[2,] 0.0072937962 0.0145875924 0.9927062
[3,] 0.0015289604 0.0030579208 0.9984710
[4,] 0.0387800719 0.0775601438 0.9612199
[5,] 0.0236179622 0.0472359243 0.9763820
[6,] 0.0104565724 0.0209131448 0.9895434
[7,] 0.0044152471 0.0088304943 0.9955848
[8,] 0.0017706817 0.0035413634 0.9982293
[9,] 0.0007019638 0.0014039276 0.9992980
[10,] 0.0002713399 0.0005426798 0.9997287
[11,] 0.0035656682 0.0071313363 0.9964343
[12,] 0.0016969517 0.0033939033 0.9983030
[13,] 0.0008311016 0.0016622032 0.9991689
[14,] 0.0103844198 0.0207688397 0.9896156
[15,] 0.0075547060 0.0151094119 0.9924453
[16,] 0.0045512227 0.0091024454 0.9954488
[17,] 0.0204497910 0.0408995821 0.9795502
[18,] 0.0122844723 0.0245689446 0.9877155
[19,] 0.0109163477 0.0218326954 0.9890837
[20,] 0.0102923979 0.0205847958 0.9897076
[21,] 0.0067249662 0.0134499325 0.9932750
[22,] 0.0051639722 0.0103279445 0.9948360
[23,] 0.0063661419 0.0127322838 0.9936339
[24,] 0.0055525704 0.0111051409 0.9944474
[25,] 0.0043649804 0.0087299608 0.9956350
[26,] 0.0055085993 0.0110171985 0.9944914
[27,] 0.0040203413 0.0080406825 0.9959797
[28,] 0.0023762179 0.0047524358 0.9976238
[29,] 0.0021709517 0.0043419033 0.9978290
[30,] 0.0032127450 0.0064254899 0.9967873
[31,] 0.0019169540 0.0038339081 0.9980830
[32,] 0.0012707504 0.0025415008 0.9987292
[33,] 0.0137770118 0.0275540237 0.9862230
[34,] 0.0118801435 0.0237602871 0.9881199
[35,] 0.0085721408 0.0171442817 0.9914279
[36,] 0.0062745216 0.0125490432 0.9937255
[37,] 0.0046011762 0.0092023525 0.9953988
[38,] 0.0091624376 0.0183248752 0.9908376
[39,] 0.0078260478 0.0156520956 0.9921740
[40,] 0.0203014818 0.0406029636 0.9796985
[41,] 0.0173971074 0.0347942148 0.9826029
[42,] 0.0149513249 0.0299026497 0.9850487
[43,] 0.0120588681 0.0241177362 0.9879411
[44,] 0.0106316169 0.0212632338 0.9893684
[45,] 0.0190140982 0.0380281964 0.9809859
[46,] 0.0163602144 0.0327204288 0.9836398
[47,] 0.0116796763 0.0233593526 0.9883203
[48,] 0.0079346653 0.0158693305 0.9920653
[49,] 0.0054372848 0.0108745696 0.9945627
[50,] 0.0032940947 0.0065881894 0.9967059
[51,] 0.0036389229 0.0072778459 0.9963611
[52,] 0.0025597724 0.0051195448 0.9974402
[53,] 0.0014819025 0.0029638050 0.9985181
[54,] 0.0011560801 0.0023121602 0.9988439
[55,] 0.0006771141 0.0013542282 0.9993229
[56,] 0.0159823436 0.0319646872 0.9840177
[57,] 0.1042390744 0.2084781489 0.8957609
[58,] 0.0959266296 0.1918532592 0.9040734
[59,] 0.6098181262 0.7803637477 0.3901819
[60,] 0.5569164381 0.8861671238 0.4430836
[61,] 0.4289824836 0.8579649672 0.5710175
[62,] 0.5357638374 0.9284723252 0.4642362
[63,] 0.6499284700 0.7001430600 0.3500715
> postscript(file="/var/www/html/rcomp/tmp/103ip1262013848.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/2wayx1262013848.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/3phzj1262013848.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/4p54o1262013848.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/5kxjo1262013848.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 = 96
Frequency = 1
1 2 3 4 5 6
4.67149135 5.73399135 0.40899135 5.33399135 3.95899135 0.40899135
7 8 9 10 11 12
3.57149135 9.38399135 0.95899135 6.80899135 3.22149135 -0.11621976
13 14 15 16 17 18
2.28314779 -1.35435221 -1.97935221 -0.55435221 -0.22935221 -4.37935221
19 20 21 22 23 24
-0.81685221 -5.10435221 -8.42935221 1.42064779 -4.16685221 -5.40456331
25 26 27 28 29 30
-6.70519577 -7.64269577 0.03230423 -6.04269577 -4.31769577 2.83230423
31 32 33 34 35 36
-0.70519577 -5.99269577 2.78230423 -2.16769577 0.34480423 -0.99290687
37 38 39 40 41 42
-5.99353933 -2.43103933 2.04396067 0.86896067 0.79396067 3.94396067
43 44 45 46 47 48
1.60646067 -2.68103933 2.09396067 -9.05603933 -1.54353933 -3.08125043
49 50 51 52 53 54
-15.18188288 -2.71938288 -1.74438288 -1.21938288 0.60561712 7.85561712
55 56 57 58 59 60
-4.38188288 9.33061712 3.90561712 -2.94438288 3.96811712 -0.46959399
61 62 63 64 65 66
0.52977356 4.19227356 0.26727356 2.99227356 -0.08272644 2.26727356
67 68 69 70 71 72
-2.57022644 5.44227356 3.31727356 2.96727356 4.37977356 -5.05793755
73 74 75 76 77 78
2.04143000 0.60393000 -6.12107000 5.10393000 3.32893000 -7.02107000
79 80 81 82 83 84
9.24143000 1.25393000 -1.17107000 5.27893000 -1.80857000 19.45540773
85 86 87 88 89 90
18.35477528 3.61727528 7.09227528 -6.48272472 -4.05772472 -5.90772472
91 92 93 94 95 96
-5.94522472 -11.63272472 -3.45772472 -2.30772472 -4.39522472 -4.33293582
> postscript(file="/var/www/html/rcomp/tmp/6uz1r1262013848.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 = 96
Frequency = 1
lag(myerror, k = 1) myerror
0 4.67149135 NA
1 5.73399135 4.67149135
2 0.40899135 5.73399135
3 5.33399135 0.40899135
4 3.95899135 5.33399135
5 0.40899135 3.95899135
6 3.57149135 0.40899135
7 9.38399135 3.57149135
8 0.95899135 9.38399135
9 6.80899135 0.95899135
10 3.22149135 6.80899135
11 -0.11621976 3.22149135
12 2.28314779 -0.11621976
13 -1.35435221 2.28314779
14 -1.97935221 -1.35435221
15 -0.55435221 -1.97935221
16 -0.22935221 -0.55435221
17 -4.37935221 -0.22935221
18 -0.81685221 -4.37935221
19 -5.10435221 -0.81685221
20 -8.42935221 -5.10435221
21 1.42064779 -8.42935221
22 -4.16685221 1.42064779
23 -5.40456331 -4.16685221
24 -6.70519577 -5.40456331
25 -7.64269577 -6.70519577
26 0.03230423 -7.64269577
27 -6.04269577 0.03230423
28 -4.31769577 -6.04269577
29 2.83230423 -4.31769577
30 -0.70519577 2.83230423
31 -5.99269577 -0.70519577
32 2.78230423 -5.99269577
33 -2.16769577 2.78230423
34 0.34480423 -2.16769577
35 -0.99290687 0.34480423
36 -5.99353933 -0.99290687
37 -2.43103933 -5.99353933
38 2.04396067 -2.43103933
39 0.86896067 2.04396067
40 0.79396067 0.86896067
41 3.94396067 0.79396067
42 1.60646067 3.94396067
43 -2.68103933 1.60646067
44 2.09396067 -2.68103933
45 -9.05603933 2.09396067
46 -1.54353933 -9.05603933
47 -3.08125043 -1.54353933
48 -15.18188288 -3.08125043
49 -2.71938288 -15.18188288
50 -1.74438288 -2.71938288
51 -1.21938288 -1.74438288
52 0.60561712 -1.21938288
53 7.85561712 0.60561712
54 -4.38188288 7.85561712
55 9.33061712 -4.38188288
56 3.90561712 9.33061712
57 -2.94438288 3.90561712
58 3.96811712 -2.94438288
59 -0.46959399 3.96811712
60 0.52977356 -0.46959399
61 4.19227356 0.52977356
62 0.26727356 4.19227356
63 2.99227356 0.26727356
64 -0.08272644 2.99227356
65 2.26727356 -0.08272644
66 -2.57022644 2.26727356
67 5.44227356 -2.57022644
68 3.31727356 5.44227356
69 2.96727356 3.31727356
70 4.37977356 2.96727356
71 -5.05793755 4.37977356
72 2.04143000 -5.05793755
73 0.60393000 2.04143000
74 -6.12107000 0.60393000
75 5.10393000 -6.12107000
76 3.32893000 5.10393000
77 -7.02107000 3.32893000
78 9.24143000 -7.02107000
79 1.25393000 9.24143000
80 -1.17107000 1.25393000
81 5.27893000 -1.17107000
82 -1.80857000 5.27893000
83 19.45540773 -1.80857000
84 18.35477528 19.45540773
85 3.61727528 18.35477528
86 7.09227528 3.61727528
87 -6.48272472 7.09227528
88 -4.05772472 -6.48272472
89 -5.90772472 -4.05772472
90 -5.94522472 -5.90772472
91 -11.63272472 -5.94522472
92 -3.45772472 -11.63272472
93 -2.30772472 -3.45772472
94 -4.39522472 -2.30772472
95 -4.33293582 -4.39522472
96 NA -4.33293582
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 5.73399135 4.67149135
[2,] 0.40899135 5.73399135
[3,] 5.33399135 0.40899135
[4,] 3.95899135 5.33399135
[5,] 0.40899135 3.95899135
[6,] 3.57149135 0.40899135
[7,] 9.38399135 3.57149135
[8,] 0.95899135 9.38399135
[9,] 6.80899135 0.95899135
[10,] 3.22149135 6.80899135
[11,] -0.11621976 3.22149135
[12,] 2.28314779 -0.11621976
[13,] -1.35435221 2.28314779
[14,] -1.97935221 -1.35435221
[15,] -0.55435221 -1.97935221
[16,] -0.22935221 -0.55435221
[17,] -4.37935221 -0.22935221
[18,] -0.81685221 -4.37935221
[19,] -5.10435221 -0.81685221
[20,] -8.42935221 -5.10435221
[21,] 1.42064779 -8.42935221
[22,] -4.16685221 1.42064779
[23,] -5.40456331 -4.16685221
[24,] -6.70519577 -5.40456331
[25,] -7.64269577 -6.70519577
[26,] 0.03230423 -7.64269577
[27,] -6.04269577 0.03230423
[28,] -4.31769577 -6.04269577
[29,] 2.83230423 -4.31769577
[30,] -0.70519577 2.83230423
[31,] -5.99269577 -0.70519577
[32,] 2.78230423 -5.99269577
[33,] -2.16769577 2.78230423
[34,] 0.34480423 -2.16769577
[35,] -0.99290687 0.34480423
[36,] -5.99353933 -0.99290687
[37,] -2.43103933 -5.99353933
[38,] 2.04396067 -2.43103933
[39,] 0.86896067 2.04396067
[40,] 0.79396067 0.86896067
[41,] 3.94396067 0.79396067
[42,] 1.60646067 3.94396067
[43,] -2.68103933 1.60646067
[44,] 2.09396067 -2.68103933
[45,] -9.05603933 2.09396067
[46,] -1.54353933 -9.05603933
[47,] -3.08125043 -1.54353933
[48,] -15.18188288 -3.08125043
[49,] -2.71938288 -15.18188288
[50,] -1.74438288 -2.71938288
[51,] -1.21938288 -1.74438288
[52,] 0.60561712 -1.21938288
[53,] 7.85561712 0.60561712
[54,] -4.38188288 7.85561712
[55,] 9.33061712 -4.38188288
[56,] 3.90561712 9.33061712
[57,] -2.94438288 3.90561712
[58,] 3.96811712 -2.94438288
[59,] -0.46959399 3.96811712
[60,] 0.52977356 -0.46959399
[61,] 4.19227356 0.52977356
[62,] 0.26727356 4.19227356
[63,] 2.99227356 0.26727356
[64,] -0.08272644 2.99227356
[65,] 2.26727356 -0.08272644
[66,] -2.57022644 2.26727356
[67,] 5.44227356 -2.57022644
[68,] 3.31727356 5.44227356
[69,] 2.96727356 3.31727356
[70,] 4.37977356 2.96727356
[71,] -5.05793755 4.37977356
[72,] 2.04143000 -5.05793755
[73,] 0.60393000 2.04143000
[74,] -6.12107000 0.60393000
[75,] 5.10393000 -6.12107000
[76,] 3.32893000 5.10393000
[77,] -7.02107000 3.32893000
[78,] 9.24143000 -7.02107000
[79,] 1.25393000 9.24143000
[80,] -1.17107000 1.25393000
[81,] 5.27893000 -1.17107000
[82,] -1.80857000 5.27893000
[83,] 19.45540773 -1.80857000
[84,] 18.35477528 19.45540773
[85,] 3.61727528 18.35477528
[86,] 7.09227528 3.61727528
[87,] -6.48272472 7.09227528
[88,] -4.05772472 -6.48272472
[89,] -5.90772472 -4.05772472
[90,] -5.94522472 -5.90772472
[91,] -11.63272472 -5.94522472
[92,] -3.45772472 -11.63272472
[93,] -2.30772472 -3.45772472
[94,] -4.39522472 -2.30772472
[95,] -4.33293582 -4.39522472
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 5.73399135 4.67149135
2 0.40899135 5.73399135
3 5.33399135 0.40899135
4 3.95899135 5.33399135
5 0.40899135 3.95899135
6 3.57149135 0.40899135
7 9.38399135 3.57149135
8 0.95899135 9.38399135
9 6.80899135 0.95899135
10 3.22149135 6.80899135
11 -0.11621976 3.22149135
12 2.28314779 -0.11621976
13 -1.35435221 2.28314779
14 -1.97935221 -1.35435221
15 -0.55435221 -1.97935221
16 -0.22935221 -0.55435221
17 -4.37935221 -0.22935221
18 -0.81685221 -4.37935221
19 -5.10435221 -0.81685221
20 -8.42935221 -5.10435221
21 1.42064779 -8.42935221
22 -4.16685221 1.42064779
23 -5.40456331 -4.16685221
24 -6.70519577 -5.40456331
25 -7.64269577 -6.70519577
26 0.03230423 -7.64269577
27 -6.04269577 0.03230423
28 -4.31769577 -6.04269577
29 2.83230423 -4.31769577
30 -0.70519577 2.83230423
31 -5.99269577 -0.70519577
32 2.78230423 -5.99269577
33 -2.16769577 2.78230423
34 0.34480423 -2.16769577
35 -0.99290687 0.34480423
36 -5.99353933 -0.99290687
37 -2.43103933 -5.99353933
38 2.04396067 -2.43103933
39 0.86896067 2.04396067
40 0.79396067 0.86896067
41 3.94396067 0.79396067
42 1.60646067 3.94396067
43 -2.68103933 1.60646067
44 2.09396067 -2.68103933
45 -9.05603933 2.09396067
46 -1.54353933 -9.05603933
47 -3.08125043 -1.54353933
48 -15.18188288 -3.08125043
49 -2.71938288 -15.18188288
50 -1.74438288 -2.71938288
51 -1.21938288 -1.74438288
52 0.60561712 -1.21938288
53 7.85561712 0.60561712
54 -4.38188288 7.85561712
55 9.33061712 -4.38188288
56 3.90561712 9.33061712
57 -2.94438288 3.90561712
58 3.96811712 -2.94438288
59 -0.46959399 3.96811712
60 0.52977356 -0.46959399
61 4.19227356 0.52977356
62 0.26727356 4.19227356
63 2.99227356 0.26727356
64 -0.08272644 2.99227356
65 2.26727356 -0.08272644
66 -2.57022644 2.26727356
67 5.44227356 -2.57022644
68 3.31727356 5.44227356
69 2.96727356 3.31727356
70 4.37977356 2.96727356
71 -5.05793755 4.37977356
72 2.04143000 -5.05793755
73 0.60393000 2.04143000
74 -6.12107000 0.60393000
75 5.10393000 -6.12107000
76 3.32893000 5.10393000
77 -7.02107000 3.32893000
78 9.24143000 -7.02107000
79 1.25393000 9.24143000
80 -1.17107000 1.25393000
81 5.27893000 -1.17107000
82 -1.80857000 5.27893000
83 19.45540773 -1.80857000
84 18.35477528 19.45540773
85 3.61727528 18.35477528
86 7.09227528 3.61727528
87 -6.48272472 7.09227528
88 -4.05772472 -6.48272472
89 -5.90772472 -4.05772472
90 -5.94522472 -5.90772472
91 -11.63272472 -5.94522472
92 -3.45772472 -11.63272472
93 -2.30772472 -3.45772472
94 -4.39522472 -2.30772472
95 -4.33293582 -4.39522472
> 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/7rzqc1262013848.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/8tcrp1262013848.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/93j4s1262013848.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/10volh1262013849.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/117q0e1262013849.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/12i82j1262013849.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/13v30u1262013849.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/14tyde1262013849.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/15pmui1262013849.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/16pjiq1262013849.tab")
+ }
>
> try(system("convert tmp/103ip1262013848.ps tmp/103ip1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/2wayx1262013848.ps tmp/2wayx1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/3phzj1262013848.ps tmp/3phzj1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/4p54o1262013848.ps tmp/4p54o1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/5kxjo1262013848.ps tmp/5kxjo1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/6uz1r1262013848.ps tmp/6uz1r1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/7rzqc1262013848.ps tmp/7rzqc1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/8tcrp1262013848.ps tmp/8tcrp1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/93j4s1262013848.ps tmp/93j4s1262013848.png",intern=TRUE))
character(0)
> try(system("convert tmp/10volh1262013849.ps tmp/10volh1262013849.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.032 1.694 5.207