R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(13,0,8,0,7,0,3,0,3,0,4,0,4,0,0,0,-4,0,-14,1,-18,1,-8,1,-1,1,1,1,2,1,0,1,1,1,0,1,-1,1,-3,1,-3,1,-3,1,-4,1,-8,1,-9,1,-13,1,-18,1,-11,1,-9,1,-10,1,-13,1,-11,1,-5,1,-15,1,-6,1,-6,1,-3,1,-1,1,-3,1,-4,1,-6,1,0,1,-4,1,-2,1,-2,1,-6,1,-7,1,-6,1,-6,1,-3,1,-2,1,-5,1,-11,1,-11,1,-11,1,-10,1,-14,1,-8,1,-9,1,-5,1,-1,1),dim=c(2,61),dimnames=list(c('X','D'),1:61))
> y <- array(NA,dim=c(2,61),dimnames=list(c('X','D'),1:61))
> 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
X D M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 13 0 1 0 0 0 0 0 0 0 0 0 0 1
2 8 0 0 1 0 0 0 0 0 0 0 0 0 2
3 7 0 0 0 1 0 0 0 0 0 0 0 0 3
4 3 0 0 0 0 1 0 0 0 0 0 0 0 4
5 3 0 0 0 0 0 1 0 0 0 0 0 0 5
6 4 0 0 0 0 0 0 1 0 0 0 0 0 6
7 4 0 0 0 0 0 0 0 1 0 0 0 0 7
8 0 0 0 0 0 0 0 0 0 1 0 0 0 8
9 -4 0 0 0 0 0 0 0 0 0 1 0 0 9
10 -14 1 0 0 0 0 0 0 0 0 0 1 0 10
11 -18 1 0 0 0 0 0 0 0 0 0 0 1 11
12 -8 1 0 0 0 0 0 0 0 0 0 0 0 12
13 -1 1 1 0 0 0 0 0 0 0 0 0 0 13
14 1 1 0 1 0 0 0 0 0 0 0 0 0 14
15 2 1 0 0 1 0 0 0 0 0 0 0 0 15
16 0 1 0 0 0 1 0 0 0 0 0 0 0 16
17 1 1 0 0 0 0 1 0 0 0 0 0 0 17
18 0 1 0 0 0 0 0 1 0 0 0 0 0 18
19 -1 1 0 0 0 0 0 0 1 0 0 0 0 19
20 -3 1 0 0 0 0 0 0 0 1 0 0 0 20
21 -3 1 0 0 0 0 0 0 0 0 1 0 0 21
22 -3 1 0 0 0 0 0 0 0 0 0 1 0 22
23 -4 1 0 0 0 0 0 0 0 0 0 0 1 23
24 -8 1 0 0 0 0 0 0 0 0 0 0 0 24
25 -9 1 1 0 0 0 0 0 0 0 0 0 0 25
26 -13 1 0 1 0 0 0 0 0 0 0 0 0 26
27 -18 1 0 0 1 0 0 0 0 0 0 0 0 27
28 -11 1 0 0 0 1 0 0 0 0 0 0 0 28
29 -9 1 0 0 0 0 1 0 0 0 0 0 0 29
30 -10 1 0 0 0 0 0 1 0 0 0 0 0 30
31 -13 1 0 0 0 0 0 0 1 0 0 0 0 31
32 -11 1 0 0 0 0 0 0 0 1 0 0 0 32
33 -5 1 0 0 0 0 0 0 0 0 1 0 0 33
34 -15 1 0 0 0 0 0 0 0 0 0 1 0 34
35 -6 1 0 0 0 0 0 0 0 0 0 0 1 35
36 -6 1 0 0 0 0 0 0 0 0 0 0 0 36
37 -3 1 1 0 0 0 0 0 0 0 0 0 0 37
38 -1 1 0 1 0 0 0 0 0 0 0 0 0 38
39 -3 1 0 0 1 0 0 0 0 0 0 0 0 39
40 -4 1 0 0 0 1 0 0 0 0 0 0 0 40
41 -6 1 0 0 0 0 1 0 0 0 0 0 0 41
42 0 1 0 0 0 0 0 1 0 0 0 0 0 42
43 -4 1 0 0 0 0 0 0 1 0 0 0 0 43
44 -2 1 0 0 0 0 0 0 0 1 0 0 0 44
45 -2 1 0 0 0 0 0 0 0 0 1 0 0 45
46 -6 1 0 0 0 0 0 0 0 0 0 1 0 46
47 -7 1 0 0 0 0 0 0 0 0 0 0 1 47
48 -6 1 0 0 0 0 0 0 0 0 0 0 0 48
49 -6 1 1 0 0 0 0 0 0 0 0 0 0 49
50 -3 1 0 1 0 0 0 0 0 0 0 0 0 50
51 -2 1 0 0 1 0 0 0 0 0 0 0 0 51
52 -5 1 0 0 0 1 0 0 0 0 0 0 0 52
53 -11 1 0 0 0 0 1 0 0 0 0 0 0 53
54 -11 1 0 0 0 0 0 1 0 0 0 0 0 54
55 -11 1 0 0 0 0 0 0 1 0 0 0 0 55
56 -10 1 0 0 0 0 0 0 0 1 0 0 0 56
57 -14 1 0 0 0 0 0 0 0 0 1 0 0 57
58 -8 1 0 0 0 0 0 0 0 0 0 1 0 58
59 -9 1 0 0 0 0 0 0 0 0 0 0 1 59
60 -5 1 0 0 0 0 0 0 0 0 0 0 0 60
61 -1 1 1 0 0 0 0 0 0 0 0 0 0 61
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) D M1 M2 M3 M4
3.3214 -8.7983 3.8110 2.9284 1.7596 1.1908
M5 M6 M7 M8 M9 M10
0.2220 1.2532 -0.3156 -0.4844 -0.8532 -2.6624
M11 t
-2.2312 -0.0312
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.440 -2.840 1.071 3.308 6.785
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.32138 2.99512 1.109 0.273103
D -8.79828 2.40589 -3.657 0.000643 ***
M1 3.81097 3.12344 1.220 0.228507
M2 2.92837 3.27293 0.895 0.375494
M3 1.75957 3.27059 0.538 0.593117
M4 1.19077 3.26894 0.364 0.717293
M5 0.22196 3.26799 0.068 0.946137
M6 1.25316 3.26774 0.383 0.703082
M7 -0.31564 3.26818 -0.097 0.923470
M8 -0.48444 3.26933 -0.148 0.882836
M9 -0.85325 3.27117 -0.261 0.795356
M10 -2.66239 3.24678 -0.820 0.416349
M11 -2.23120 3.24573 -0.687 0.495193
t -0.03120 0.04775 -0.653 0.516750
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.131 on 47 degrees of freedom
Multiple R-squared: 0.463, Adjusted R-squared: 0.3145
F-statistic: 3.117 on 13 and 47 DF, p-value: 0.002105
> 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.36957134 0.73914268 0.63042866
[2,] 0.23757542 0.47515084 0.76242458
[3,] 0.14817918 0.29635837 0.85182082
[4,] 0.09378141 0.18756281 0.90621859
[5,] 0.10585200 0.21170400 0.89414800
[6,] 0.07176876 0.14353752 0.92823124
[7,] 0.04710522 0.09421044 0.95289478
[8,] 0.13086588 0.26173176 0.86913412
[9,] 0.63276169 0.73447662 0.36723831
[10,] 0.84189874 0.31620252 0.15810126
[11,] 0.97936915 0.04126169 0.02063085
[12,] 0.97612144 0.04775712 0.02387856
[13,] 0.95857349 0.08285301 0.04142651
[14,] 0.94475465 0.11049070 0.05524535
[15,] 0.94168657 0.11662685 0.05831343
[16,] 0.93665243 0.12669514 0.06334757
[17,] 0.91844382 0.16311236 0.08155618
[18,] 0.96297993 0.07404014 0.03702007
[19,] 0.95980172 0.08039657 0.04019828
[20,] 0.95301277 0.09397446 0.04698723
[21,] 0.93803885 0.12392230 0.06196115
[22,] 0.90729703 0.18540594 0.09270297
[23,] 0.88331034 0.23337931 0.11668966
[24,] 0.82830653 0.34338694 0.17169347
[25,] 0.72725774 0.54548451 0.27274226
[26,] 0.71445574 0.57108852 0.28554426
[27,] 0.60298974 0.79402053 0.39701026
[28,] 0.51652337 0.96695327 0.48347663
> postscript(file="/var/www/html/rcomp/tmp/1tvlh1227735184.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/2v4401227735184.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/3uetp1227735184.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/4zwtn1227735184.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/5ej8p1227735184.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 = 61
Frequency = 1
1 2 3 4 5 6
5.8988506 1.8126437 2.0126437 -1.3873563 -0.3873563 -0.3873563
7 8 9 10 11 12
1.2126437 -2.5873563 -6.1873563 -5.5487356 -9.9487356 -2.1487356
13 14 15 16 17 18
1.0714943 3.9852874 6.1852874 4.7852874 6.7852874 4.7852874
19 20 21 22 23 24
5.3852874 3.5852874 3.9852874 5.8256322 4.4256322 -1.7743678
25 26 27 28 29 30
-6.5541379 -9.6403448 -13.4403448 -5.8403448 -2.8403448 -4.8403448
31 32 33 34 35 36
-6.2403448 -4.0403448 2.3596552 -5.8000000 2.8000000 0.6000000
37 38 39 40 41 42
-0.1797701 2.7340230 1.9340230 1.5340230 0.5340230 5.5340230
43 44 45 46 47 48
3.1340230 5.3340230 5.7340230 3.5743678 2.1743678 0.9743678
49 50 51 52 53 54
-2.8054023 1.1083908 3.3083908 0.9083908 -4.0916092 -5.0916092
55 56 57 58 59 60
-3.4916092 -2.2916092 -5.8916092 1.9487356 0.5487356 2.3487356
61
2.5689655
> postscript(file="/var/www/html/rcomp/tmp/6wmpj1227735184.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 5.8988506 NA
1 1.8126437 5.8988506
2 2.0126437 1.8126437
3 -1.3873563 2.0126437
4 -0.3873563 -1.3873563
5 -0.3873563 -0.3873563
6 1.2126437 -0.3873563
7 -2.5873563 1.2126437
8 -6.1873563 -2.5873563
9 -5.5487356 -6.1873563
10 -9.9487356 -5.5487356
11 -2.1487356 -9.9487356
12 1.0714943 -2.1487356
13 3.9852874 1.0714943
14 6.1852874 3.9852874
15 4.7852874 6.1852874
16 6.7852874 4.7852874
17 4.7852874 6.7852874
18 5.3852874 4.7852874
19 3.5852874 5.3852874
20 3.9852874 3.5852874
21 5.8256322 3.9852874
22 4.4256322 5.8256322
23 -1.7743678 4.4256322
24 -6.5541379 -1.7743678
25 -9.6403448 -6.5541379
26 -13.4403448 -9.6403448
27 -5.8403448 -13.4403448
28 -2.8403448 -5.8403448
29 -4.8403448 -2.8403448
30 -6.2403448 -4.8403448
31 -4.0403448 -6.2403448
32 2.3596552 -4.0403448
33 -5.8000000 2.3596552
34 2.8000000 -5.8000000
35 0.6000000 2.8000000
36 -0.1797701 0.6000000
37 2.7340230 -0.1797701
38 1.9340230 2.7340230
39 1.5340230 1.9340230
40 0.5340230 1.5340230
41 5.5340230 0.5340230
42 3.1340230 5.5340230
43 5.3340230 3.1340230
44 5.7340230 5.3340230
45 3.5743678 5.7340230
46 2.1743678 3.5743678
47 0.9743678 2.1743678
48 -2.8054023 0.9743678
49 1.1083908 -2.8054023
50 3.3083908 1.1083908
51 0.9083908 3.3083908
52 -4.0916092 0.9083908
53 -5.0916092 -4.0916092
54 -3.4916092 -5.0916092
55 -2.2916092 -3.4916092
56 -5.8916092 -2.2916092
57 1.9487356 -5.8916092
58 0.5487356 1.9487356
59 2.3487356 0.5487356
60 2.5689655 2.3487356
61 NA 2.5689655
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.8126437 5.8988506
[2,] 2.0126437 1.8126437
[3,] -1.3873563 2.0126437
[4,] -0.3873563 -1.3873563
[5,] -0.3873563 -0.3873563
[6,] 1.2126437 -0.3873563
[7,] -2.5873563 1.2126437
[8,] -6.1873563 -2.5873563
[9,] -5.5487356 -6.1873563
[10,] -9.9487356 -5.5487356
[11,] -2.1487356 -9.9487356
[12,] 1.0714943 -2.1487356
[13,] 3.9852874 1.0714943
[14,] 6.1852874 3.9852874
[15,] 4.7852874 6.1852874
[16,] 6.7852874 4.7852874
[17,] 4.7852874 6.7852874
[18,] 5.3852874 4.7852874
[19,] 3.5852874 5.3852874
[20,] 3.9852874 3.5852874
[21,] 5.8256322 3.9852874
[22,] 4.4256322 5.8256322
[23,] -1.7743678 4.4256322
[24,] -6.5541379 -1.7743678
[25,] -9.6403448 -6.5541379
[26,] -13.4403448 -9.6403448
[27,] -5.8403448 -13.4403448
[28,] -2.8403448 -5.8403448
[29,] -4.8403448 -2.8403448
[30,] -6.2403448 -4.8403448
[31,] -4.0403448 -6.2403448
[32,] 2.3596552 -4.0403448
[33,] -5.8000000 2.3596552
[34,] 2.8000000 -5.8000000
[35,] 0.6000000 2.8000000
[36,] -0.1797701 0.6000000
[37,] 2.7340230 -0.1797701
[38,] 1.9340230 2.7340230
[39,] 1.5340230 1.9340230
[40,] 0.5340230 1.5340230
[41,] 5.5340230 0.5340230
[42,] 3.1340230 5.5340230
[43,] 5.3340230 3.1340230
[44,] 5.7340230 5.3340230
[45,] 3.5743678 5.7340230
[46,] 2.1743678 3.5743678
[47,] 0.9743678 2.1743678
[48,] -2.8054023 0.9743678
[49,] 1.1083908 -2.8054023
[50,] 3.3083908 1.1083908
[51,] 0.9083908 3.3083908
[52,] -4.0916092 0.9083908
[53,] -5.0916092 -4.0916092
[54,] -3.4916092 -5.0916092
[55,] -2.2916092 -3.4916092
[56,] -5.8916092 -2.2916092
[57,] 1.9487356 -5.8916092
[58,] 0.5487356 1.9487356
[59,] 2.3487356 0.5487356
[60,] 2.5689655 2.3487356
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.8126437 5.8988506
2 2.0126437 1.8126437
3 -1.3873563 2.0126437
4 -0.3873563 -1.3873563
5 -0.3873563 -0.3873563
6 1.2126437 -0.3873563
7 -2.5873563 1.2126437
8 -6.1873563 -2.5873563
9 -5.5487356 -6.1873563
10 -9.9487356 -5.5487356
11 -2.1487356 -9.9487356
12 1.0714943 -2.1487356
13 3.9852874 1.0714943
14 6.1852874 3.9852874
15 4.7852874 6.1852874
16 6.7852874 4.7852874
17 4.7852874 6.7852874
18 5.3852874 4.7852874
19 3.5852874 5.3852874
20 3.9852874 3.5852874
21 5.8256322 3.9852874
22 4.4256322 5.8256322
23 -1.7743678 4.4256322
24 -6.5541379 -1.7743678
25 -9.6403448 -6.5541379
26 -13.4403448 -9.6403448
27 -5.8403448 -13.4403448
28 -2.8403448 -5.8403448
29 -4.8403448 -2.8403448
30 -6.2403448 -4.8403448
31 -4.0403448 -6.2403448
32 2.3596552 -4.0403448
33 -5.8000000 2.3596552
34 2.8000000 -5.8000000
35 0.6000000 2.8000000
36 -0.1797701 0.6000000
37 2.7340230 -0.1797701
38 1.9340230 2.7340230
39 1.5340230 1.9340230
40 0.5340230 1.5340230
41 5.5340230 0.5340230
42 3.1340230 5.5340230
43 5.3340230 3.1340230
44 5.7340230 5.3340230
45 3.5743678 5.7340230
46 2.1743678 3.5743678
47 0.9743678 2.1743678
48 -2.8054023 0.9743678
49 1.1083908 -2.8054023
50 3.3083908 1.1083908
51 0.9083908 3.3083908
52 -4.0916092 0.9083908
53 -5.0916092 -4.0916092
54 -3.4916092 -5.0916092
55 -2.2916092 -3.4916092
56 -5.8916092 -2.2916092
57 1.9487356 -5.8916092
58 0.5487356 1.9487356
59 2.3487356 0.5487356
60 2.5689655 2.3487356
> 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/7y2q31227735184.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/8zqnq1227735184.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/9m1y01227735184.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/10pgh61227735184.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/11dwtj1227735184.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/12d1s01227735184.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/134z6v1227735184.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/14j8y01227735184.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/154hmo1227735185.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/16e0q61227735185.tab")
+ }
>
> system("convert tmp/1tvlh1227735184.ps tmp/1tvlh1227735184.png")
> system("convert tmp/2v4401227735184.ps tmp/2v4401227735184.png")
> system("convert tmp/3uetp1227735184.ps tmp/3uetp1227735184.png")
> system("convert tmp/4zwtn1227735184.ps tmp/4zwtn1227735184.png")
> system("convert tmp/5ej8p1227735184.ps tmp/5ej8p1227735184.png")
> system("convert tmp/6wmpj1227735184.ps tmp/6wmpj1227735184.png")
> system("convert tmp/7y2q31227735184.ps tmp/7y2q31227735184.png")
> system("convert tmp/8zqnq1227735184.ps tmp/8zqnq1227735184.png")
> system("convert tmp/9m1y01227735184.ps tmp/9m1y01227735184.png")
> system("convert tmp/10pgh61227735184.ps tmp/10pgh61227735184.png")
>
>
> proc.time()
user system elapsed
2.419 1.600 6.312