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(101,0,104,0,99,0,105,0,107,0,111,0,117,0,119,0,127,0,128,0,135,0,132,0,136,0,143,0,142,0,153,0,145,0,138,0,148,0,152,0,169,0,169,0,161,0,174,0,179,0,191,0,190,0,182,0,175,0,181,0,197,0,194,0,197,0,216,0,221,0,218,0,230,0,227,0,204,0,197,0,199,0,208,0,191,0,202,0,211,0,224,1,224,1,231,1,244,1,235,1,250,1,266,1,288,1,283,1,295,1,312,1,334,1,348,1,383,1,407,1),dim=c(2,60),dimnames=list(c('IGrSt','D'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('IGrSt','D'),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 = '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
IGrSt D M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 101 0 1 0 0 0 0 0 0 0 0 0 0 1
2 104 0 0 1 0 0 0 0 0 0 0 0 0 2
3 99 0 0 0 1 0 0 0 0 0 0 0 0 3
4 105 0 0 0 0 1 0 0 0 0 0 0 0 4
5 107 0 0 0 0 0 1 0 0 0 0 0 0 5
6 111 0 0 0 0 0 0 1 0 0 0 0 0 6
7 117 0 0 0 0 0 0 0 1 0 0 0 0 7
8 119 0 0 0 0 0 0 0 0 1 0 0 0 8
9 127 0 0 0 0 0 0 0 0 0 1 0 0 9
10 128 0 0 0 0 0 0 0 0 0 0 1 0 10
11 135 0 0 0 0 0 0 0 0 0 0 0 1 11
12 132 0 0 0 0 0 0 0 0 0 0 0 0 12
13 136 0 1 0 0 0 0 0 0 0 0 0 0 13
14 143 0 0 1 0 0 0 0 0 0 0 0 0 14
15 142 0 0 0 1 0 0 0 0 0 0 0 0 15
16 153 0 0 0 0 1 0 0 0 0 0 0 0 16
17 145 0 0 0 0 0 1 0 0 0 0 0 0 17
18 138 0 0 0 0 0 0 1 0 0 0 0 0 18
19 148 0 0 0 0 0 0 0 1 0 0 0 0 19
20 152 0 0 0 0 0 0 0 0 1 0 0 0 20
21 169 0 0 0 0 0 0 0 0 0 1 0 0 21
22 169 0 0 0 0 0 0 0 0 0 0 1 0 22
23 161 0 0 0 0 0 0 0 0 0 0 0 1 23
24 174 0 0 0 0 0 0 0 0 0 0 0 0 24
25 179 0 1 0 0 0 0 0 0 0 0 0 0 25
26 191 0 0 1 0 0 0 0 0 0 0 0 0 26
27 190 0 0 0 1 0 0 0 0 0 0 0 0 27
28 182 0 0 0 0 1 0 0 0 0 0 0 0 28
29 175 0 0 0 0 0 1 0 0 0 0 0 0 29
30 181 0 0 0 0 0 0 1 0 0 0 0 0 30
31 197 0 0 0 0 0 0 0 1 0 0 0 0 31
32 194 0 0 0 0 0 0 0 0 1 0 0 0 32
33 197 0 0 0 0 0 0 0 0 0 1 0 0 33
34 216 0 0 0 0 0 0 0 0 0 0 1 0 34
35 221 0 0 0 0 0 0 0 0 0 0 0 1 35
36 218 0 0 0 0 0 0 0 0 0 0 0 0 36
37 230 0 1 0 0 0 0 0 0 0 0 0 0 37
38 227 0 0 1 0 0 0 0 0 0 0 0 0 38
39 204 0 0 0 1 0 0 0 0 0 0 0 0 39
40 197 0 0 0 0 1 0 0 0 0 0 0 0 40
41 199 0 0 0 0 0 1 0 0 0 0 0 0 41
42 208 0 0 0 0 0 0 1 0 0 0 0 0 42
43 191 0 0 0 0 0 0 0 1 0 0 0 0 43
44 202 0 0 0 0 0 0 0 0 1 0 0 0 44
45 211 0 0 0 0 0 0 0 0 0 1 0 0 45
46 224 1 0 0 0 0 0 0 0 0 0 1 0 46
47 224 1 0 0 0 0 0 0 0 0 0 0 1 47
48 231 1 0 0 0 0 0 0 0 0 0 0 0 48
49 244 1 1 0 0 0 0 0 0 0 0 0 0 49
50 235 1 0 1 0 0 0 0 0 0 0 0 0 50
51 250 1 0 0 1 0 0 0 0 0 0 0 0 51
52 266 1 0 0 0 1 0 0 0 0 0 0 0 52
53 288 1 0 0 0 0 1 0 0 0 0 0 0 53
54 283 1 0 0 0 0 0 1 0 0 0 0 0 54
55 295 1 0 0 0 0 0 0 1 0 0 0 0 55
56 312 1 0 0 0 0 0 0 0 1 0 0 0 56
57 334 1 0 0 0 0 0 0 0 0 1 0 0 57
58 348 1 0 0 0 0 0 0 0 0 0 1 0 58
59 383 1 0 0 0 0 0 0 0 0 0 0 1 59
60 407 1 0 0 0 0 0 0 0 0 0 0 0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) D M1 M2 M3 M4
108.519 25.704 -14.548 -15.704 -21.859 -21.415
M5 M6 M7 M8 M9 M10
-22.370 -24.126 -21.881 -18.837 -10.193 -9.089
M11 t
-4.444 3.156
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-54.689 -9.257 2.689 8.074 83.444
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 108.5185 14.2013 7.641 1.00e-09 ***
D 25.7037 12.1109 2.122 0.0392 *
M1 -14.5481 16.7950 -0.866 0.3909
M2 -15.7037 16.7704 -0.936 0.3540
M3 -21.8593 16.7513 -1.305 0.1984
M4 -21.4148 16.7376 -1.279 0.2072
M5 -22.3704 16.7294 -1.337 0.1877
M6 -24.1259 16.7266 -1.442 0.1560
M7 -21.8815 16.7294 -1.308 0.1974
M8 -18.8370 16.7376 -1.125 0.2662
M9 -10.1926 16.7513 -0.608 0.5459
M10 -9.0889 16.6607 -0.546 0.5880
M11 -4.4444 16.6525 -0.267 0.7907
t 3.1556 0.3028 10.422 1.07e-13 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 26.33 on 46 degrees of freedom
Multiple R-squared: 0.8881, Adjusted R-squared: 0.8565
F-statistic: 28.09 on 13 and 46 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,] 2.932863e-03 5.865725e-03 0.9970671
[2,] 1.851428e-03 3.702855e-03 0.9981486
[3,] 4.062392e-04 8.124784e-04 0.9995938
[4,] 6.816418e-05 1.363284e-04 0.9999318
[5,] 1.239723e-05 2.479446e-05 0.9999876
[6,] 1.858489e-06 3.716977e-06 0.9999981
[7,] 8.502225e-07 1.700445e-06 0.9999991
[8,] 1.445638e-07 2.891277e-07 0.9999999
[9,] 2.537080e-08 5.074161e-08 1.0000000
[10,] 1.509060e-08 3.018120e-08 1.0000000
[11,] 1.045091e-08 2.090182e-08 1.0000000
[12,] 3.451937e-09 6.903874e-09 1.0000000
[13,] 1.549777e-09 3.099554e-09 1.0000000
[14,] 3.339093e-10 6.678186e-10 1.0000000
[15,] 2.595355e-10 5.190710e-10 1.0000000
[16,] 1.600734e-10 3.201468e-10 1.0000000
[17,] 4.943569e-10 9.887139e-10 1.0000000
[18,] 9.820412e-10 1.964082e-09 1.0000000
[19,] 5.652011e-09 1.130402e-08 1.0000000
[20,] 5.546579e-09 1.109316e-08 1.0000000
[21,] 4.949312e-08 9.898624e-08 1.0000000
[22,] 6.526510e-06 1.305302e-05 0.9999935
[23,] 6.254941e-04 1.250988e-03 0.9993745
[24,] 1.144001e-02 2.288002e-02 0.9885600
[25,] 1.364472e-02 2.728944e-02 0.9863553
[26,] 5.263376e-02 1.052675e-01 0.9473662
[27,] 9.321414e-02 1.864283e-01 0.9067859
> postscript(file="/var/www/html/freestat/rcomp/tmp/1kykc1227522880.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/freestat/rcomp/tmp/2bqlh1227522880.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/freestat/rcomp/tmp/3dhjf1227522880.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/freestat/rcomp/tmp/436yr1227522880.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/freestat/rcomp/tmp/5hti01227522881.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
3.8740741 4.8740741 2.8740741 5.2740741 5.0740741 7.6740741
7 8 9 10 11 12
8.2740741 4.0740741 0.2740741 -2.9851852 -3.7851852 -14.3851852
13 14 15 16 17 18
1.0074074 6.0074074 8.0074074 15.4074074 5.2074074 -3.1925926
19 20 21 22 23 24
1.4074074 -0.7925926 4.4074074 0.1481481 -15.6518519 -10.2518519
25 26 27 28 29 30
6.1407407 16.1407407 18.1407407 6.5407407 -2.6592593 1.9407407
31 32 33 34 35 36
12.5407407 3.3407407 -5.4592593 9.2814815 6.4814815 -4.1185185
37 38 39 40 41 42
19.2740741 14.2740741 -5.7259259 -16.3259259 -16.5259259 -8.9259259
43 44 45 46 47 48
-31.3259259 -26.5259259 -29.3259259 -46.2888889 -54.0888889 -54.6888889
49 50 51 52 53 54
-30.2962963 -41.2962963 -23.2962963 -10.8962963 8.9037037 2.5037037
55 56 57 58 59 60
9.1037037 19.9037037 30.1037037 39.8444444 67.0444444 83.4444444
> postscript(file="/var/www/html/freestat/rcomp/tmp/6ua291227522881.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 3.8740741 NA
1 4.8740741 3.8740741
2 2.8740741 4.8740741
3 5.2740741 2.8740741
4 5.0740741 5.2740741
5 7.6740741 5.0740741
6 8.2740741 7.6740741
7 4.0740741 8.2740741
8 0.2740741 4.0740741
9 -2.9851852 0.2740741
10 -3.7851852 -2.9851852
11 -14.3851852 -3.7851852
12 1.0074074 -14.3851852
13 6.0074074 1.0074074
14 8.0074074 6.0074074
15 15.4074074 8.0074074
16 5.2074074 15.4074074
17 -3.1925926 5.2074074
18 1.4074074 -3.1925926
19 -0.7925926 1.4074074
20 4.4074074 -0.7925926
21 0.1481481 4.4074074
22 -15.6518519 0.1481481
23 -10.2518519 -15.6518519
24 6.1407407 -10.2518519
25 16.1407407 6.1407407
26 18.1407407 16.1407407
27 6.5407407 18.1407407
28 -2.6592593 6.5407407
29 1.9407407 -2.6592593
30 12.5407407 1.9407407
31 3.3407407 12.5407407
32 -5.4592593 3.3407407
33 9.2814815 -5.4592593
34 6.4814815 9.2814815
35 -4.1185185 6.4814815
36 19.2740741 -4.1185185
37 14.2740741 19.2740741
38 -5.7259259 14.2740741
39 -16.3259259 -5.7259259
40 -16.5259259 -16.3259259
41 -8.9259259 -16.5259259
42 -31.3259259 -8.9259259
43 -26.5259259 -31.3259259
44 -29.3259259 -26.5259259
45 -46.2888889 -29.3259259
46 -54.0888889 -46.2888889
47 -54.6888889 -54.0888889
48 -30.2962963 -54.6888889
49 -41.2962963 -30.2962963
50 -23.2962963 -41.2962963
51 -10.8962963 -23.2962963
52 8.9037037 -10.8962963
53 2.5037037 8.9037037
54 9.1037037 2.5037037
55 19.9037037 9.1037037
56 30.1037037 19.9037037
57 39.8444444 30.1037037
58 67.0444444 39.8444444
59 83.4444444 67.0444444
60 NA 83.4444444
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 4.8740741 3.8740741
[2,] 2.8740741 4.8740741
[3,] 5.2740741 2.8740741
[4,] 5.0740741 5.2740741
[5,] 7.6740741 5.0740741
[6,] 8.2740741 7.6740741
[7,] 4.0740741 8.2740741
[8,] 0.2740741 4.0740741
[9,] -2.9851852 0.2740741
[10,] -3.7851852 -2.9851852
[11,] -14.3851852 -3.7851852
[12,] 1.0074074 -14.3851852
[13,] 6.0074074 1.0074074
[14,] 8.0074074 6.0074074
[15,] 15.4074074 8.0074074
[16,] 5.2074074 15.4074074
[17,] -3.1925926 5.2074074
[18,] 1.4074074 -3.1925926
[19,] -0.7925926 1.4074074
[20,] 4.4074074 -0.7925926
[21,] 0.1481481 4.4074074
[22,] -15.6518519 0.1481481
[23,] -10.2518519 -15.6518519
[24,] 6.1407407 -10.2518519
[25,] 16.1407407 6.1407407
[26,] 18.1407407 16.1407407
[27,] 6.5407407 18.1407407
[28,] -2.6592593 6.5407407
[29,] 1.9407407 -2.6592593
[30,] 12.5407407 1.9407407
[31,] 3.3407407 12.5407407
[32,] -5.4592593 3.3407407
[33,] 9.2814815 -5.4592593
[34,] 6.4814815 9.2814815
[35,] -4.1185185 6.4814815
[36,] 19.2740741 -4.1185185
[37,] 14.2740741 19.2740741
[38,] -5.7259259 14.2740741
[39,] -16.3259259 -5.7259259
[40,] -16.5259259 -16.3259259
[41,] -8.9259259 -16.5259259
[42,] -31.3259259 -8.9259259
[43,] -26.5259259 -31.3259259
[44,] -29.3259259 -26.5259259
[45,] -46.2888889 -29.3259259
[46,] -54.0888889 -46.2888889
[47,] -54.6888889 -54.0888889
[48,] -30.2962963 -54.6888889
[49,] -41.2962963 -30.2962963
[50,] -23.2962963 -41.2962963
[51,] -10.8962963 -23.2962963
[52,] 8.9037037 -10.8962963
[53,] 2.5037037 8.9037037
[54,] 9.1037037 2.5037037
[55,] 19.9037037 9.1037037
[56,] 30.1037037 19.9037037
[57,] 39.8444444 30.1037037
[58,] 67.0444444 39.8444444
[59,] 83.4444444 67.0444444
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 4.8740741 3.8740741
2 2.8740741 4.8740741
3 5.2740741 2.8740741
4 5.0740741 5.2740741
5 7.6740741 5.0740741
6 8.2740741 7.6740741
7 4.0740741 8.2740741
8 0.2740741 4.0740741
9 -2.9851852 0.2740741
10 -3.7851852 -2.9851852
11 -14.3851852 -3.7851852
12 1.0074074 -14.3851852
13 6.0074074 1.0074074
14 8.0074074 6.0074074
15 15.4074074 8.0074074
16 5.2074074 15.4074074
17 -3.1925926 5.2074074
18 1.4074074 -3.1925926
19 -0.7925926 1.4074074
20 4.4074074 -0.7925926
21 0.1481481 4.4074074
22 -15.6518519 0.1481481
23 -10.2518519 -15.6518519
24 6.1407407 -10.2518519
25 16.1407407 6.1407407
26 18.1407407 16.1407407
27 6.5407407 18.1407407
28 -2.6592593 6.5407407
29 1.9407407 -2.6592593
30 12.5407407 1.9407407
31 3.3407407 12.5407407
32 -5.4592593 3.3407407
33 9.2814815 -5.4592593
34 6.4814815 9.2814815
35 -4.1185185 6.4814815
36 19.2740741 -4.1185185
37 14.2740741 19.2740741
38 -5.7259259 14.2740741
39 -16.3259259 -5.7259259
40 -16.5259259 -16.3259259
41 -8.9259259 -16.5259259
42 -31.3259259 -8.9259259
43 -26.5259259 -31.3259259
44 -29.3259259 -26.5259259
45 -46.2888889 -29.3259259
46 -54.0888889 -46.2888889
47 -54.6888889 -54.0888889
48 -30.2962963 -54.6888889
49 -41.2962963 -30.2962963
50 -23.2962963 -41.2962963
51 -10.8962963 -23.2962963
52 8.9037037 -10.8962963
53 2.5037037 8.9037037
54 9.1037037 2.5037037
55 19.9037037 9.1037037
56 30.1037037 19.9037037
57 39.8444444 30.1037037
58 67.0444444 39.8444444
59 83.4444444 67.0444444
> 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/freestat/rcomp/tmp/787kh1227522881.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/freestat/rcomp/tmp/8ijpx1227522881.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/freestat/rcomp/tmp/96tv31227522881.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/freestat/rcomp/tmp/10k02w1227522881.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11h4281227522881.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/freestat/rcomp/tmp/12a91a1227522881.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/freestat/rcomp/tmp/13a0u91227522881.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/freestat/rcomp/tmp/14p59f1227522881.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/freestat/rcomp/tmp/152ija1227522881.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/freestat/rcomp/tmp/16mmm31227522881.tab")
+ }
>
> system("convert tmp/1kykc1227522880.ps tmp/1kykc1227522880.png")
> system("convert tmp/2bqlh1227522880.ps tmp/2bqlh1227522880.png")
> system("convert tmp/3dhjf1227522880.ps tmp/3dhjf1227522880.png")
> system("convert tmp/436yr1227522880.ps tmp/436yr1227522880.png")
> system("convert tmp/5hti01227522881.ps tmp/5hti01227522881.png")
> system("convert tmp/6ua291227522881.ps tmp/6ua291227522881.png")
> system("convert tmp/787kh1227522881.ps tmp/787kh1227522881.png")
> system("convert tmp/8ijpx1227522881.ps tmp/8ijpx1227522881.png")
> system("convert tmp/96tv31227522881.ps tmp/96tv31227522881.png")
> system("convert tmp/10k02w1227522881.ps tmp/10k02w1227522881.png")
>
>
> proc.time()
user system elapsed
3.664 2.539 3.995