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(2.16
+ ,196.2
+ ,2.04
+ ,2.26
+ ,1.95
+ ,1.79
+ ,2.75
+ ,196.2
+ ,2.16
+ ,2.04
+ ,2.26
+ ,1.95
+ ,2.79
+ ,196.2
+ ,2.75
+ ,2.16
+ ,2.04
+ ,2.26
+ ,2.88
+ ,197
+ ,2.79
+ ,2.75
+ ,2.16
+ ,2.04
+ ,3.36
+ ,197.7
+ ,2.88
+ ,2.79
+ ,2.75
+ ,2.16
+ ,2.97
+ ,198
+ ,3.36
+ ,2.88
+ ,2.79
+ ,2.75
+ ,3.1
+ ,198.2
+ ,2.97
+ ,3.36
+ ,2.88
+ ,2.79
+ ,2.49
+ ,198.5
+ ,3.1
+ ,2.97
+ ,3.36
+ ,2.88
+ ,2.2
+ ,198.6
+ ,2.49
+ ,3.1
+ ,2.97
+ ,3.36
+ ,2.25
+ ,199.5
+ ,2.2
+ ,2.49
+ ,3.1
+ ,2.97
+ ,2.09
+ ,200
+ ,2.25
+ ,2.2
+ ,2.49
+ ,3.1
+ ,2.79
+ ,201.3
+ ,2.09
+ ,2.25
+ ,2.2
+ ,2.49
+ ,3.14
+ ,202.2
+ ,2.79
+ ,2.09
+ ,2.25
+ ,2.2
+ ,2.93
+ ,202.9
+ ,3.14
+ ,2.79
+ ,2.09
+ ,2.25
+ ,2.65
+ ,203.5
+ ,2.93
+ ,3.14
+ ,2.79
+ ,2.09
+ ,2.67
+ ,203.5
+ ,2.65
+ ,2.93
+ ,3.14
+ ,2.79
+ ,2.26
+ ,204
+ ,2.67
+ ,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+ ,2.57
+ ,2.26
+ ,2.27
+ ,2.51
+ ,220.9
+ ,2.76
+ ,3.07
+ ,2.57
+ ,2.26
+ ,2.87
+ ,221
+ ,2.51
+ ,2.76
+ ,3.07
+ ,2.57
+ ,3.14
+ ,221.8
+ ,2.87
+ ,2.51
+ ,2.76
+ ,3.07
+ ,3.11
+ ,222
+ ,3.14
+ ,2.87
+ ,2.51
+ ,2.76
+ ,3.16
+ ,222.2
+ ,3.11
+ ,3.14
+ ,2.87
+ ,2.51
+ ,2.47
+ ,222.5
+ ,3.16
+ ,3.11
+ ,3.14
+ ,2.87
+ ,2.57
+ ,222.9
+ ,2.47
+ ,3.16
+ ,3.11
+ ,3.14
+ ,2.89
+ ,223.1
+ ,2.57
+ ,2.47
+ ,3.16
+ ,3.11)
+ ,dim=c(6
+ ,68)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:68))
> y <- array(NA,dim=c(6,68),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:68))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 2.16 196.2 2.04 2.26 1.95 1.79 1 0 0 0 0 0 0 0 0 0 0 1
2 2.75 196.2 2.16 2.04 2.26 1.95 0 1 0 0 0 0 0 0 0 0 0 2
3 2.79 196.2 2.75 2.16 2.04 2.26 0 0 1 0 0 0 0 0 0 0 0 3
4 2.88 197.0 2.79 2.75 2.16 2.04 0 0 0 1 0 0 0 0 0 0 0 4
5 3.36 197.7 2.88 2.79 2.75 2.16 0 0 0 0 1 0 0 0 0 0 0 5
6 2.97 198.0 3.36 2.88 2.79 2.75 0 0 0 0 0 1 0 0 0 0 0 6
7 3.10 198.2 2.97 3.36 2.88 2.79 0 0 0 0 0 0 1 0 0 0 0 7
8 2.49 198.5 3.10 2.97 3.36 2.88 0 0 0 0 0 0 0 1 0 0 0 8
9 2.20 198.6 2.49 3.10 2.97 3.36 0 0 0 0 0 0 0 0 1 0 0 9
10 2.25 199.5 2.20 2.49 3.10 2.97 0 0 0 0 0 0 0 0 0 1 0 10
11 2.09 200.0 2.25 2.20 2.49 3.10 0 0 0 0 0 0 0 0 0 0 1 11
12 2.79 201.3 2.09 2.25 2.20 2.49 0 0 0 0 0 0 0 0 0 0 0 12
13 3.14 202.2 2.79 2.09 2.25 2.20 1 0 0 0 0 0 0 0 0 0 0 13
14 2.93 202.9 3.14 2.79 2.09 2.25 0 1 0 0 0 0 0 0 0 0 0 14
15 2.65 203.5 2.93 3.14 2.79 2.09 0 0 1 0 0 0 0 0 0 0 0 15
16 2.67 203.5 2.65 2.93 3.14 2.79 0 0 0 1 0 0 0 0 0 0 0 16
17 2.26 204.0 2.67 2.65 2.93 3.14 0 0 0 0 1 0 0 0 0 0 0 17
18 2.35 204.1 2.26 2.67 2.65 2.93 0 0 0 0 0 1 0 0 0 0 0 18
19 2.13 204.3 2.35 2.26 2.67 2.65 0 0 0 0 0 0 1 0 0 0 0 19
20 2.18 204.5 2.13 2.35 2.26 2.67 0 0 0 0 0 0 0 1 0 0 0 20
21 2.90 204.8 2.18 2.13 2.35 2.26 0 0 0 0 0 0 0 0 1 0 0 21
22 2.63 205.1 2.90 2.18 2.13 2.35 0 0 0 0 0 0 0 0 0 1 0 22
23 2.67 205.7 2.63 2.90 2.18 2.13 0 0 0 0 0 0 0 0 0 0 1 23
24 1.81 206.5 2.67 2.63 2.90 2.18 0 0 0 0 0 0 0 0 0 0 0 24
25 1.33 206.9 1.81 2.67 2.63 2.90 1 0 0 0 0 0 0 0 0 0 0 25
26 0.88 207.1 1.33 1.81 2.67 2.63 0 1 0 0 0 0 0 0 0 0 0 26
27 1.28 207.8 0.88 1.33 1.81 2.67 0 0 1 0 0 0 0 0 0 0 0 27
28 1.26 208.0 1.28 0.88 1.33 1.81 0 0 0 1 0 0 0 0 0 0 0 28
29 1.26 208.5 1.26 1.28 0.88 1.33 0 0 0 0 1 0 0 0 0 0 0 29
30 1.29 208.6 1.26 1.26 1.28 0.88 0 0 0 0 0 1 0 0 0 0 0 30
31 1.10 209.0 1.29 1.26 1.26 1.28 0 0 0 0 0 0 1 0 0 0 0 31
32 1.37 209.1 1.10 1.29 1.26 1.26 0 0 0 0 0 0 0 1 0 0 0 32
33 1.21 209.7 1.37 1.10 1.29 1.26 0 0 0 0 0 0 0 0 1 0 0 33
34 1.74 209.8 1.21 1.37 1.10 1.29 0 0 0 0 0 0 0 0 0 1 0 34
35 1.76 209.9 1.74 1.21 1.37 1.10 0 0 0 0 0 0 0 0 0 0 1 35
36 1.48 210.0 1.76 1.74 1.21 1.37 0 0 0 0 0 0 0 0 0 0 0 36
37 1.04 210.8 1.48 1.76 1.74 1.21 1 0 0 0 0 0 0 0 0 0 0 37
38 1.62 211.4 1.04 1.48 1.76 1.74 0 1 0 0 0 0 0 0 0 0 0 38
39 1.49 211.7 1.62 1.04 1.48 1.76 0 0 1 0 0 0 0 0 0 0 0 39
40 1.79 212.0 1.49 1.62 1.04 1.48 0 0 0 1 0 0 0 0 0 0 0 40
41 1.80 212.2 1.79 1.49 1.62 1.04 0 0 0 0 1 0 0 0 0 0 0 41
42 1.58 212.4 1.80 1.79 1.49 1.62 0 0 0 0 0 1 0 0 0 0 0 42
43 1.86 212.9 1.58 1.80 1.79 1.49 0 0 0 0 0 0 1 0 0 0 0 43
44 1.74 213.4 1.86 1.58 1.80 1.79 0 0 0 0 0 0 0 1 0 0 0 44
45 1.59 213.7 1.74 1.86 1.58 1.80 0 0 0 0 0 0 0 0 1 0 0 45
46 1.26 214.0 1.59 1.74 1.86 1.58 0 0 0 0 0 0 0 0 0 1 0 46
47 1.13 214.3 1.26 1.59 1.74 1.86 0 0 0 0 0 0 0 0 0 0 1 47
48 1.92 214.8 1.13 1.26 1.59 1.74 0 0 0 0 0 0 0 0 0 0 0 48
49 2.61 215.0 1.92 1.13 1.26 1.59 1 0 0 0 0 0 0 0 0 0 0 49
50 2.26 215.9 2.61 1.92 1.13 1.26 0 1 0 0 0 0 0 0 0 0 0 50
51 2.41 216.4 2.26 2.61 1.92 1.13 0 0 1 0 0 0 0 0 0 0 0 51
52 2.26 216.9 2.41 2.26 2.61 1.92 0 0 0 1 0 0 0 0 0 0 0 52
53 2.03 217.2 2.26 2.41 2.26 2.61 0 0 0 0 1 0 0 0 0 0 0 53
54 2.86 217.5 2.03 2.26 2.41 2.26 0 0 0 0 0 1 0 0 0 0 0 54
55 2.55 217.9 2.86 2.03 2.26 2.41 0 0 0 0 0 0 1 0 0 0 0 55
56 2.27 218.1 2.55 2.86 2.03 2.26 0 0 0 0 0 0 0 1 0 0 0 56
57 2.26 218.6 2.27 2.55 2.86 2.03 0 0 0 0 0 0 0 0 1 0 0 57
58 2.57 218.9 2.26 2.27 2.55 2.86 0 0 0 0 0 0 0 0 0 1 0 58
59 3.07 219.3 2.57 2.26 2.27 2.55 0 0 0 0 0 0 0 0 0 0 1 59
60 2.76 220.4 3.07 2.57 2.26 2.27 0 0 0 0 0 0 0 0 0 0 0 60
61 2.51 220.9 2.76 3.07 2.57 2.26 1 0 0 0 0 0 0 0 0 0 0 61
62 2.87 221.0 2.51 2.76 3.07 2.57 0 1 0 0 0 0 0 0 0 0 0 62
63 3.14 221.8 2.87 2.51 2.76 3.07 0 0 1 0 0 0 0 0 0 0 0 63
64 3.11 222.0 3.14 2.87 2.51 2.76 0 0 0 1 0 0 0 0 0 0 0 64
65 3.16 222.2 3.11 3.14 2.87 2.51 0 0 0 0 1 0 0 0 0 0 0 65
66 2.47 222.5 3.16 3.11 3.14 2.87 0 0 0 0 0 1 0 0 0 0 0 66
67 2.57 222.9 2.47 3.16 3.11 3.14 0 0 0 0 0 0 1 0 0 0 0 67
68 2.89 223.1 2.57 2.47 3.16 3.11 0 0 0 0 0 0 0 1 0 0 0 68
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
23.84658 -0.12020 0.84850 -0.04941 -0.03722 0.11176
M1 M2 M3 M4 M5 M6
0.00712 0.09025 0.08904 0.05928 0.01935 -0.05273
M7 M8 M9 M10 M11 t
-0.05283 -0.11093 -0.04797 -0.02845 -0.02388 0.04877
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.66400 -0.24290 -0.02164 0.20726 0.80359
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 23.84658 18.02241 1.323 0.192
X -0.12021 0.09185 -1.309 0.197
Y1 0.84850 0.14085 6.024 2.01e-07 ***
Y2 -0.04941 0.18400 -0.269 0.789
Y3 -0.03722 0.18741 -0.199 0.843
Y4 0.11176 0.14569 0.767 0.447
M1 0.00712 0.24132 0.030 0.977
M2 0.09025 0.24142 0.374 0.710
M3 0.08904 0.24148 0.369 0.714
M4 0.05928 0.24109 0.246 0.807
M5 0.01935 0.24128 0.080 0.936
M6 -0.05273 0.24159 -0.218 0.828
M7 -0.05283 0.24244 -0.218 0.828
M8 -0.11093 0.24409 -0.454 0.651
M9 -0.04797 0.25558 -0.188 0.852
M10 -0.02846 0.25561 -0.111 0.912
M11 -0.02388 0.25479 -0.094 0.926
t 0.04877 0.03673 1.328 0.190
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.3972 on 50 degrees of freedom
Multiple R-squared: 0.7238, Adjusted R-squared: 0.6299
F-statistic: 7.707 on 17 and 50 DF, p-value: 7.37e-09
> 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.23930552 0.4786110 0.7606945
[2,] 0.70999594 0.5800081 0.2900041
[3,] 0.74570857 0.5085829 0.2542914
[4,] 0.90536329 0.1892734 0.0946367
[5,] 0.88432929 0.2313414 0.1156707
[6,] 0.82494877 0.3501025 0.1750512
[7,] 0.76748580 0.4650284 0.2325142
[8,] 0.76127915 0.4774417 0.2387209
[9,] 0.74160910 0.5167818 0.2583909
[10,] 0.65189599 0.6962080 0.3481040
[11,] 0.59225274 0.8154945 0.4077473
[12,] 0.53184954 0.9363009 0.4681505
[13,] 0.48827687 0.9765537 0.5117231
[14,] 0.54749106 0.9050179 0.4525089
[15,] 0.56581458 0.8683708 0.4341854
[16,] 0.48587639 0.9717528 0.5141236
[17,] 0.40901895 0.8180379 0.5909811
[18,] 0.52915276 0.9416945 0.4708472
[19,] 0.48186194 0.9637239 0.5181381
[20,] 0.42142388 0.8428478 0.5785761
[21,] 0.33152172 0.6630434 0.6684783
[22,] 0.24242604 0.4848521 0.7575740
[23,] 0.23898408 0.4779682 0.7610159
[24,] 0.17632319 0.3526464 0.8236768
[25,] 0.10487485 0.2097497 0.8951251
[26,] 0.06589685 0.1317937 0.9341031
[27,] 0.16052617 0.3210523 0.8394738
> postscript(file="/var/www/html/rcomp/tmp/1i3gb1291474387.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/html/rcomp/tmp/2i3gb1291474387.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/html/rcomp/tmp/3i3gb1291474387.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/html/rcomp/tmp/4bdgw1291474387.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/html/rcomp/tmp/5bdgw1291474387.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 = 68
Frequency = 1
1 2 3 4 5
0.0949615130 0.4340265405 -0.1110535422 0.0803723414 0.5698378434
6 7 8 9 10
-0.2280720591 0.2308169405 -0.4555603602 -0.3894149935 -0.0351666359
11 12 13 14 15
-0.2823940214 0.6968400935 0.5315504227 -0.0001359892 -0.0161608063
16 17 18 19 20
0.1468338769 -0.2896352258 0.1976213118 -0.1115895969 0.1454075385
21 22 23 24 25
0.7856171046 -0.1433038010 0.2065940876 -0.6559599586 -0.5025908937
26 27 28 29 30
-0.6639981937 0.0942183454 -0.2041312214 -0.0792317724 0.0502909035
31 32 33 34 35
-0.2111950826 0.2450905532 -0.1918810331 0.4205323746 -0.0271221693
36 37 38 39 40
-0.3946570197 -0.5182053119 0.3030361336 -0.3649907027 0.1059489988
41 42 43 44 45
-0.0590604405 -0.2950270060 0.2092688251 -0.1229037936 -0.2422186650
46 47 48 49 50
-0.4480886832 -0.3585365027 0.5207503448 0.5066461340 -0.3814582818
51 52 53 54 55
0.1560834224 -0.1599984640 -0.3182243805 0.8035916147 -0.2449596784
56 57 58 59 60
-0.1793347667 0.0378975870 0.2060267455 0.4614586057 -0.1669734599
61 62 63 64 65
-0.1123618642 0.3085297906 0.2419032835 0.0309744683 0.1763139758
66 67 68
-0.5284047649 0.1276585924 0.3673008288
> postscript(file="/var/www/html/rcomp/tmp/6bdgw1291474387.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 = 68
Frequency = 1
lag(myerror, k = 1) myerror
0 0.0949615130 NA
1 0.4340265405 0.0949615130
2 -0.1110535422 0.4340265405
3 0.0803723414 -0.1110535422
4 0.5698378434 0.0803723414
5 -0.2280720591 0.5698378434
6 0.2308169405 -0.2280720591
7 -0.4555603602 0.2308169405
8 -0.3894149935 -0.4555603602
9 -0.0351666359 -0.3894149935
10 -0.2823940214 -0.0351666359
11 0.6968400935 -0.2823940214
12 0.5315504227 0.6968400935
13 -0.0001359892 0.5315504227
14 -0.0161608063 -0.0001359892
15 0.1468338769 -0.0161608063
16 -0.2896352258 0.1468338769
17 0.1976213118 -0.2896352258
18 -0.1115895969 0.1976213118
19 0.1454075385 -0.1115895969
20 0.7856171046 0.1454075385
21 -0.1433038010 0.7856171046
22 0.2065940876 -0.1433038010
23 -0.6559599586 0.2065940876
24 -0.5025908937 -0.6559599586
25 -0.6639981937 -0.5025908937
26 0.0942183454 -0.6639981937
27 -0.2041312214 0.0942183454
28 -0.0792317724 -0.2041312214
29 0.0502909035 -0.0792317724
30 -0.2111950826 0.0502909035
31 0.2450905532 -0.2111950826
32 -0.1918810331 0.2450905532
33 0.4205323746 -0.1918810331
34 -0.0271221693 0.4205323746
35 -0.3946570197 -0.0271221693
36 -0.5182053119 -0.3946570197
37 0.3030361336 -0.5182053119
38 -0.3649907027 0.3030361336
39 0.1059489988 -0.3649907027
40 -0.0590604405 0.1059489988
41 -0.2950270060 -0.0590604405
42 0.2092688251 -0.2950270060
43 -0.1229037936 0.2092688251
44 -0.2422186650 -0.1229037936
45 -0.4480886832 -0.2422186650
46 -0.3585365027 -0.4480886832
47 0.5207503448 -0.3585365027
48 0.5066461340 0.5207503448
49 -0.3814582818 0.5066461340
50 0.1560834224 -0.3814582818
51 -0.1599984640 0.1560834224
52 -0.3182243805 -0.1599984640
53 0.8035916147 -0.3182243805
54 -0.2449596784 0.8035916147
55 -0.1793347667 -0.2449596784
56 0.0378975870 -0.1793347667
57 0.2060267455 0.0378975870
58 0.4614586057 0.2060267455
59 -0.1669734599 0.4614586057
60 -0.1123618642 -0.1669734599
61 0.3085297906 -0.1123618642
62 0.2419032835 0.3085297906
63 0.0309744683 0.2419032835
64 0.1763139758 0.0309744683
65 -0.5284047649 0.1763139758
66 0.1276585924 -0.5284047649
67 0.3673008288 0.1276585924
68 NA 0.3673008288
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.4340265405 0.0949615130
[2,] -0.1110535422 0.4340265405
[3,] 0.0803723414 -0.1110535422
[4,] 0.5698378434 0.0803723414
[5,] -0.2280720591 0.5698378434
[6,] 0.2308169405 -0.2280720591
[7,] -0.4555603602 0.2308169405
[8,] -0.3894149935 -0.4555603602
[9,] -0.0351666359 -0.3894149935
[10,] -0.2823940214 -0.0351666359
[11,] 0.6968400935 -0.2823940214
[12,] 0.5315504227 0.6968400935
[13,] -0.0001359892 0.5315504227
[14,] -0.0161608063 -0.0001359892
[15,] 0.1468338769 -0.0161608063
[16,] -0.2896352258 0.1468338769
[17,] 0.1976213118 -0.2896352258
[18,] -0.1115895969 0.1976213118
[19,] 0.1454075385 -0.1115895969
[20,] 0.7856171046 0.1454075385
[21,] -0.1433038010 0.7856171046
[22,] 0.2065940876 -0.1433038010
[23,] -0.6559599586 0.2065940876
[24,] -0.5025908937 -0.6559599586
[25,] -0.6639981937 -0.5025908937
[26,] 0.0942183454 -0.6639981937
[27,] -0.2041312214 0.0942183454
[28,] -0.0792317724 -0.2041312214
[29,] 0.0502909035 -0.0792317724
[30,] -0.2111950826 0.0502909035
[31,] 0.2450905532 -0.2111950826
[32,] -0.1918810331 0.2450905532
[33,] 0.4205323746 -0.1918810331
[34,] -0.0271221693 0.4205323746
[35,] -0.3946570197 -0.0271221693
[36,] -0.5182053119 -0.3946570197
[37,] 0.3030361336 -0.5182053119
[38,] -0.3649907027 0.3030361336
[39,] 0.1059489988 -0.3649907027
[40,] -0.0590604405 0.1059489988
[41,] -0.2950270060 -0.0590604405
[42,] 0.2092688251 -0.2950270060
[43,] -0.1229037936 0.2092688251
[44,] -0.2422186650 -0.1229037936
[45,] -0.4480886832 -0.2422186650
[46,] -0.3585365027 -0.4480886832
[47,] 0.5207503448 -0.3585365027
[48,] 0.5066461340 0.5207503448
[49,] -0.3814582818 0.5066461340
[50,] 0.1560834224 -0.3814582818
[51,] -0.1599984640 0.1560834224
[52,] -0.3182243805 -0.1599984640
[53,] 0.8035916147 -0.3182243805
[54,] -0.2449596784 0.8035916147
[55,] -0.1793347667 -0.2449596784
[56,] 0.0378975870 -0.1793347667
[57,] 0.2060267455 0.0378975870
[58,] 0.4614586057 0.2060267455
[59,] -0.1669734599 0.4614586057
[60,] -0.1123618642 -0.1669734599
[61,] 0.3085297906 -0.1123618642
[62,] 0.2419032835 0.3085297906
[63,] 0.0309744683 0.2419032835
[64,] 0.1763139758 0.0309744683
[65,] -0.5284047649 0.1763139758
[66,] 0.1276585924 -0.5284047649
[67,] 0.3673008288 0.1276585924
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.4340265405 0.0949615130
2 -0.1110535422 0.4340265405
3 0.0803723414 -0.1110535422
4 0.5698378434 0.0803723414
5 -0.2280720591 0.5698378434
6 0.2308169405 -0.2280720591
7 -0.4555603602 0.2308169405
8 -0.3894149935 -0.4555603602
9 -0.0351666359 -0.3894149935
10 -0.2823940214 -0.0351666359
11 0.6968400935 -0.2823940214
12 0.5315504227 0.6968400935
13 -0.0001359892 0.5315504227
14 -0.0161608063 -0.0001359892
15 0.1468338769 -0.0161608063
16 -0.2896352258 0.1468338769
17 0.1976213118 -0.2896352258
18 -0.1115895969 0.1976213118
19 0.1454075385 -0.1115895969
20 0.7856171046 0.1454075385
21 -0.1433038010 0.7856171046
22 0.2065940876 -0.1433038010
23 -0.6559599586 0.2065940876
24 -0.5025908937 -0.6559599586
25 -0.6639981937 -0.5025908937
26 0.0942183454 -0.6639981937
27 -0.2041312214 0.0942183454
28 -0.0792317724 -0.2041312214
29 0.0502909035 -0.0792317724
30 -0.2111950826 0.0502909035
31 0.2450905532 -0.2111950826
32 -0.1918810331 0.2450905532
33 0.4205323746 -0.1918810331
34 -0.0271221693 0.4205323746
35 -0.3946570197 -0.0271221693
36 -0.5182053119 -0.3946570197
37 0.3030361336 -0.5182053119
38 -0.3649907027 0.3030361336
39 0.1059489988 -0.3649907027
40 -0.0590604405 0.1059489988
41 -0.2950270060 -0.0590604405
42 0.2092688251 -0.2950270060
43 -0.1229037936 0.2092688251
44 -0.2422186650 -0.1229037936
45 -0.4480886832 -0.2422186650
46 -0.3585365027 -0.4480886832
47 0.5207503448 -0.3585365027
48 0.5066461340 0.5207503448
49 -0.3814582818 0.5066461340
50 0.1560834224 -0.3814582818
51 -0.1599984640 0.1560834224
52 -0.3182243805 -0.1599984640
53 0.8035916147 -0.3182243805
54 -0.2449596784 0.8035916147
55 -0.1793347667 -0.2449596784
56 0.0378975870 -0.1793347667
57 0.2060267455 0.0378975870
58 0.4614586057 0.2060267455
59 -0.1669734599 0.4614586057
60 -0.1123618642 -0.1669734599
61 0.3085297906 -0.1123618642
62 0.2419032835 0.3085297906
63 0.0309744683 0.2419032835
64 0.1763139758 0.0309744683
65 -0.5284047649 0.1763139758
66 0.1276585924 -0.5284047649
67 0.3673008288 0.1276585924
> 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/744fh1291474387.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/html/rcomp/tmp/8fdwk1291474387.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/html/rcomp/tmp/9fdwk1291474387.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/html/rcomp/tmp/10fdwk1291474387.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/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/11iwv71291474387.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/123wtd1291474387.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/13afqp1291474387.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/14367s1291474387.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/15o7og1291474387.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/162h4p1291474387.tab")
+ }
>
> try(system("convert tmp/1i3gb1291474387.ps tmp/1i3gb1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/2i3gb1291474387.ps tmp/2i3gb1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/3i3gb1291474387.ps tmp/3i3gb1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/4bdgw1291474387.ps tmp/4bdgw1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/5bdgw1291474387.ps tmp/5bdgw1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/6bdgw1291474387.ps tmp/6bdgw1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/744fh1291474387.ps tmp/744fh1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/8fdwk1291474387.ps tmp/8fdwk1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/9fdwk1291474387.ps tmp/9fdwk1291474387.png",intern=TRUE))
character(0)
> try(system("convert tmp/10fdwk1291474387.ps tmp/10fdwk1291474387.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.539 1.693 9.239