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(282965,1,276610,1,277838,1,277051,1,277026,1,274960,1,270073,1,267063,1,264916,1,287182,1,291109,1,292223,1,288109,1,281400,1,282579,1,280113,1,280331,1,276759,1,275139,1,274275,1,271234,1,289725,1,290649,1,292223,1,278429,0,269749,0,265784,0,268957,0,264099,0,255121,0,253276,0,245980,0,235295,0,258479,0,260916,0,254586,0,250566,0,243345,0,247028,0,248464,0,244962,0,237003,0,237008,0,225477,0,226762,0,247857,0,248256,0,246892,0,245021,0,246186,0,255688,0,264242,0,268270,0,272969,0,273886,0,267353,0,271916,0,292633,0,295804,0,293222,0),dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 282965 1 1 0 0 0 0 0 0 0 0 0 0
2 276610 1 0 1 0 0 0 0 0 0 0 0 0
3 277838 1 0 0 1 0 0 0 0 0 0 0 0
4 277051 1 0 0 0 1 0 0 0 0 0 0 0
5 277026 1 0 0 0 0 1 0 0 0 0 0 0
6 274960 1 0 0 0 0 0 1 0 0 0 0 0
7 270073 1 0 0 0 0 0 0 1 0 0 0 0
8 267063 1 0 0 0 0 0 0 0 1 0 0 0
9 264916 1 0 0 0 0 0 0 0 0 1 0 0
10 287182 1 0 0 0 0 0 0 0 0 0 1 0
11 291109 1 0 0 0 0 0 0 0 0 0 0 1
12 292223 1 0 0 0 0 0 0 0 0 0 0 0
13 288109 1 1 0 0 0 0 0 0 0 0 0 0
14 281400 1 0 1 0 0 0 0 0 0 0 0 0
15 282579 1 0 0 1 0 0 0 0 0 0 0 0
16 280113 1 0 0 0 1 0 0 0 0 0 0 0
17 280331 1 0 0 0 0 1 0 0 0 0 0 0
18 276759 1 0 0 0 0 0 1 0 0 0 0 0
19 275139 1 0 0 0 0 0 0 1 0 0 0 0
20 274275 1 0 0 0 0 0 0 0 1 0 0 0
21 271234 1 0 0 0 0 0 0 0 0 1 0 0
22 289725 1 0 0 0 0 0 0 0 0 0 1 0
23 290649 1 0 0 0 0 0 0 0 0 0 0 1
24 292223 1 0 0 0 0 0 0 0 0 0 0 0
25 278429 0 1 0 0 0 0 0 0 0 0 0 0
26 269749 0 0 1 0 0 0 0 0 0 0 0 0
27 265784 0 0 0 1 0 0 0 0 0 0 0 0
28 268957 0 0 0 0 1 0 0 0 0 0 0 0
29 264099 0 0 0 0 0 1 0 0 0 0 0 0
30 255121 0 0 0 0 0 0 1 0 0 0 0 0
31 253276 0 0 0 0 0 0 0 1 0 0 0 0
32 245980 0 0 0 0 0 0 0 0 1 0 0 0
33 235295 0 0 0 0 0 0 0 0 0 1 0 0
34 258479 0 0 0 0 0 0 0 0 0 0 1 0
35 260916 0 0 0 0 0 0 0 0 0 0 0 1
36 254586 0 0 0 0 0 0 0 0 0 0 0 0
37 250566 0 1 0 0 0 0 0 0 0 0 0 0
38 243345 0 0 1 0 0 0 0 0 0 0 0 0
39 247028 0 0 0 1 0 0 0 0 0 0 0 0
40 248464 0 0 0 0 1 0 0 0 0 0 0 0
41 244962 0 0 0 0 0 1 0 0 0 0 0 0
42 237003 0 0 0 0 0 0 1 0 0 0 0 0
43 237008 0 0 0 0 0 0 0 1 0 0 0 0
44 225477 0 0 0 0 0 0 0 0 1 0 0 0
45 226762 0 0 0 0 0 0 0 0 0 1 0 0
46 247857 0 0 0 0 0 0 0 0 0 0 1 0
47 248256 0 0 0 0 0 0 0 0 0 0 0 1
48 246892 0 0 0 0 0 0 0 0 0 0 0 0
49 245021 0 1 0 0 0 0 0 0 0 0 0 0
50 246186 0 0 1 0 0 0 0 0 0 0 0 0
51 255688 0 0 0 1 0 0 0 0 0 0 0 0
52 264242 0 0 0 0 1 0 0 0 0 0 0 0
53 268270 0 0 0 0 0 1 0 0 0 0 0 0
54 272969 0 0 0 0 0 0 1 0 0 0 0 0
55 273886 0 0 0 0 0 0 0 1 0 0 0 0
56 267353 0 0 0 0 0 0 0 0 1 0 0 0
57 271916 0 0 0 0 0 0 0 0 0 1 0 0
58 292633 0 0 0 0 0 0 0 0 0 0 1 0
59 295804 0 0 0 0 0 0 0 0 0 0 0 1
60 293222 0 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
266709 22801 -6811 -12371 -10046 -8064
M5 M6 M7 M8 M9 M10
-8892 -12467 -13953 -19800 -21805 -654
M11
1518
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-21432.1 -8446.5 -473.5 4776.0 27577.7
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 266709 6332 42.118 < 2e-16 ***
X 22801 3632 6.278 1.02e-07 ***
M1 -6811 8716 -0.781 0.4385
M2 -12371 8716 -1.419 0.1624
M3 -10046 8716 -1.153 0.2549
M4 -8064 8716 -0.925 0.3596
M5 -8892 8716 -1.020 0.3129
M6 -12467 8716 -1.430 0.1593
M7 -13953 8716 -1.601 0.1161
M8 -19800 8716 -2.272 0.0277 *
M9 -21805 8716 -2.502 0.0159 *
M10 -654 8716 -0.075 0.9405
M11 1518 8716 0.174 0.8625
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 13780 on 47 degrees of freedom
Multiple R-squared: 0.5395, Adjusted R-squared: 0.4219
F-statistic: 4.588 on 12 and 47 DF, p-value: 7.237e-05
> 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,] 1.425566e-02 2.851131e-02 0.9857443
[2,] 3.161675e-03 6.323351e-03 0.9968383
[3,] 5.665885e-04 1.133177e-03 0.9994334
[4,] 1.731266e-04 3.462532e-04 0.9998269
[5,] 9.103848e-05 1.820770e-04 0.9999090
[6,] 3.488377e-05 6.976754e-05 0.9999651
[7,] 7.033542e-06 1.406708e-05 0.9999930
[8,] 1.190097e-06 2.380194e-06 0.9999988
[9,] 1.867327e-07 3.734653e-07 0.9999998
[10,] 4.246441e-08 8.492882e-08 1.0000000
[11,] 9.296870e-09 1.859374e-08 1.0000000
[12,] 3.913141e-09 7.826282e-09 1.0000000
[13,] 6.268298e-10 1.253660e-09 1.0000000
[14,] 1.637922e-10 3.275844e-10 1.0000000
[15,] 2.993247e-10 5.986494e-10 1.0000000
[16,] 1.303471e-10 2.606942e-10 1.0000000
[17,] 2.512264e-10 5.024529e-10 1.0000000
[18,] 4.838540e-09 9.677080e-09 1.0000000
[19,] 6.608179e-09 1.321636e-08 1.0000000
[20,] 5.547399e-09 1.109480e-08 1.0000000
[21,] 2.087726e-08 4.175452e-08 1.0000000
[22,] 6.053101e-08 1.210620e-07 0.9999999
[23,] 9.450772e-08 1.890154e-07 0.9999999
[24,] 5.738999e-08 1.147800e-07 0.9999999
[25,] 2.912022e-08 5.824045e-08 1.0000000
[26,] 2.089584e-08 4.179167e-08 1.0000000
[27,] 3.784695e-08 7.569391e-08 1.0000000
[28,] 5.103420e-08 1.020684e-07 0.9999999
[29,] 2.586464e-07 5.172928e-07 0.9999997
> postscript(file="/var/www/html/rcomp/tmp/1lhfv1259332381.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/2g6za1259332381.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/3avqq1259332381.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/4bmsk1259332381.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/57vxv1259332381.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 = 60
Frequency = 1
1 2 3 4 5 6
266.21667 -528.78333 -1626.18333 -4395.18333 -3592.38333 -2083.18333
7 8 9 10 11 12
-5484.18333 -2647.38333 -2789.38333 -1673.98333 81.41667 2713.01667
13 14 15 16 17 18
5410.21667 4261.21667 3114.81667 -1333.18333 -287.38333 -284.18333
19 20 21 22 23 24
-418.18333 4564.61667 3528.61667 869.01667 -378.58333 2713.01667
25 26 27 28 29 30
18531.52222 15411.52222 9121.12222 10312.12222 6281.92222 879.12222
31 32 33 34 35 36
520.12222 -929.07778 -9609.07778 -7575.67778 -7310.27778 -12122.67778
37 38 39 40 41 42
-9331.47778 -10992.47778 -9634.87778 -10180.87778 -12855.07778 -17238.87778
43 44 45 46 47 48
-15747.87778 -21432.07778 -18142.07778 -18197.67778 -19970.27778 -19816.67778
49 50 51 52 53 54
-14876.47778 -8151.47778 -974.87778 5597.12222 10452.92222 18727.12222
55 56 57 58 59 60
21130.12222 20443.92222 27011.92222 26578.32222 27577.72222 26513.32222
> postscript(file="/var/www/html/rcomp/tmp/6vypc1259332381.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 266.21667 NA
1 -528.78333 266.21667
2 -1626.18333 -528.78333
3 -4395.18333 -1626.18333
4 -3592.38333 -4395.18333
5 -2083.18333 -3592.38333
6 -5484.18333 -2083.18333
7 -2647.38333 -5484.18333
8 -2789.38333 -2647.38333
9 -1673.98333 -2789.38333
10 81.41667 -1673.98333
11 2713.01667 81.41667
12 5410.21667 2713.01667
13 4261.21667 5410.21667
14 3114.81667 4261.21667
15 -1333.18333 3114.81667
16 -287.38333 -1333.18333
17 -284.18333 -287.38333
18 -418.18333 -284.18333
19 4564.61667 -418.18333
20 3528.61667 4564.61667
21 869.01667 3528.61667
22 -378.58333 869.01667
23 2713.01667 -378.58333
24 18531.52222 2713.01667
25 15411.52222 18531.52222
26 9121.12222 15411.52222
27 10312.12222 9121.12222
28 6281.92222 10312.12222
29 879.12222 6281.92222
30 520.12222 879.12222
31 -929.07778 520.12222
32 -9609.07778 -929.07778
33 -7575.67778 -9609.07778
34 -7310.27778 -7575.67778
35 -12122.67778 -7310.27778
36 -9331.47778 -12122.67778
37 -10992.47778 -9331.47778
38 -9634.87778 -10992.47778
39 -10180.87778 -9634.87778
40 -12855.07778 -10180.87778
41 -17238.87778 -12855.07778
42 -15747.87778 -17238.87778
43 -21432.07778 -15747.87778
44 -18142.07778 -21432.07778
45 -18197.67778 -18142.07778
46 -19970.27778 -18197.67778
47 -19816.67778 -19970.27778
48 -14876.47778 -19816.67778
49 -8151.47778 -14876.47778
50 -974.87778 -8151.47778
51 5597.12222 -974.87778
52 10452.92222 5597.12222
53 18727.12222 10452.92222
54 21130.12222 18727.12222
55 20443.92222 21130.12222
56 27011.92222 20443.92222
57 26578.32222 27011.92222
58 27577.72222 26578.32222
59 26513.32222 27577.72222
60 NA 26513.32222
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -528.78333 266.21667
[2,] -1626.18333 -528.78333
[3,] -4395.18333 -1626.18333
[4,] -3592.38333 -4395.18333
[5,] -2083.18333 -3592.38333
[6,] -5484.18333 -2083.18333
[7,] -2647.38333 -5484.18333
[8,] -2789.38333 -2647.38333
[9,] -1673.98333 -2789.38333
[10,] 81.41667 -1673.98333
[11,] 2713.01667 81.41667
[12,] 5410.21667 2713.01667
[13,] 4261.21667 5410.21667
[14,] 3114.81667 4261.21667
[15,] -1333.18333 3114.81667
[16,] -287.38333 -1333.18333
[17,] -284.18333 -287.38333
[18,] -418.18333 -284.18333
[19,] 4564.61667 -418.18333
[20,] 3528.61667 4564.61667
[21,] 869.01667 3528.61667
[22,] -378.58333 869.01667
[23,] 2713.01667 -378.58333
[24,] 18531.52222 2713.01667
[25,] 15411.52222 18531.52222
[26,] 9121.12222 15411.52222
[27,] 10312.12222 9121.12222
[28,] 6281.92222 10312.12222
[29,] 879.12222 6281.92222
[30,] 520.12222 879.12222
[31,] -929.07778 520.12222
[32,] -9609.07778 -929.07778
[33,] -7575.67778 -9609.07778
[34,] -7310.27778 -7575.67778
[35,] -12122.67778 -7310.27778
[36,] -9331.47778 -12122.67778
[37,] -10992.47778 -9331.47778
[38,] -9634.87778 -10992.47778
[39,] -10180.87778 -9634.87778
[40,] -12855.07778 -10180.87778
[41,] -17238.87778 -12855.07778
[42,] -15747.87778 -17238.87778
[43,] -21432.07778 -15747.87778
[44,] -18142.07778 -21432.07778
[45,] -18197.67778 -18142.07778
[46,] -19970.27778 -18197.67778
[47,] -19816.67778 -19970.27778
[48,] -14876.47778 -19816.67778
[49,] -8151.47778 -14876.47778
[50,] -974.87778 -8151.47778
[51,] 5597.12222 -974.87778
[52,] 10452.92222 5597.12222
[53,] 18727.12222 10452.92222
[54,] 21130.12222 18727.12222
[55,] 20443.92222 21130.12222
[56,] 27011.92222 20443.92222
[57,] 26578.32222 27011.92222
[58,] 27577.72222 26578.32222
[59,] 26513.32222 27577.72222
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -528.78333 266.21667
2 -1626.18333 -528.78333
3 -4395.18333 -1626.18333
4 -3592.38333 -4395.18333
5 -2083.18333 -3592.38333
6 -5484.18333 -2083.18333
7 -2647.38333 -5484.18333
8 -2789.38333 -2647.38333
9 -1673.98333 -2789.38333
10 81.41667 -1673.98333
11 2713.01667 81.41667
12 5410.21667 2713.01667
13 4261.21667 5410.21667
14 3114.81667 4261.21667
15 -1333.18333 3114.81667
16 -287.38333 -1333.18333
17 -284.18333 -287.38333
18 -418.18333 -284.18333
19 4564.61667 -418.18333
20 3528.61667 4564.61667
21 869.01667 3528.61667
22 -378.58333 869.01667
23 2713.01667 -378.58333
24 18531.52222 2713.01667
25 15411.52222 18531.52222
26 9121.12222 15411.52222
27 10312.12222 9121.12222
28 6281.92222 10312.12222
29 879.12222 6281.92222
30 520.12222 879.12222
31 -929.07778 520.12222
32 -9609.07778 -929.07778
33 -7575.67778 -9609.07778
34 -7310.27778 -7575.67778
35 -12122.67778 -7310.27778
36 -9331.47778 -12122.67778
37 -10992.47778 -9331.47778
38 -9634.87778 -10992.47778
39 -10180.87778 -9634.87778
40 -12855.07778 -10180.87778
41 -17238.87778 -12855.07778
42 -15747.87778 -17238.87778
43 -21432.07778 -15747.87778
44 -18142.07778 -21432.07778
45 -18197.67778 -18142.07778
46 -19970.27778 -18197.67778
47 -19816.67778 -19970.27778
48 -14876.47778 -19816.67778
49 -8151.47778 -14876.47778
50 -974.87778 -8151.47778
51 5597.12222 -974.87778
52 10452.92222 5597.12222
53 18727.12222 10452.92222
54 21130.12222 18727.12222
55 20443.92222 21130.12222
56 27011.92222 20443.92222
57 26578.32222 27011.92222
58 27577.72222 26578.32222
59 26513.32222 27577.72222
> 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/7xsv21259332381.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/8swr81259332381.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/9iolf1259332381.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/10wkhz1259332381.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/11bo081259332381.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/12gfy81259332381.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/13dqjm1259332381.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/14sfqs1259332381.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/1562ry1259332381.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/16ckoz1259332381.tab")
+ }
> system("convert tmp/1lhfv1259332381.ps tmp/1lhfv1259332381.png")
> system("convert tmp/2g6za1259332381.ps tmp/2g6za1259332381.png")
> system("convert tmp/3avqq1259332381.ps tmp/3avqq1259332381.png")
> system("convert tmp/4bmsk1259332381.ps tmp/4bmsk1259332381.png")
> system("convert tmp/57vxv1259332381.ps tmp/57vxv1259332381.png")
> system("convert tmp/6vypc1259332381.ps tmp/6vypc1259332381.png")
> system("convert tmp/7xsv21259332381.ps tmp/7xsv21259332381.png")
> system("convert tmp/8swr81259332381.ps tmp/8swr81259332381.png")
> system("convert tmp/9iolf1259332381.ps tmp/9iolf1259332381.png")
> system("convert tmp/10wkhz1259332381.ps tmp/10wkhz1259332381.png")
>
>
> proc.time()
user system elapsed
2.412 1.581 2.851