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(50.9
+ ,0
+ ,52.7
+ ,54.8
+ ,56
+ ,56.6
+ ,50.6
+ ,0
+ ,50.9
+ ,52.7
+ ,54.8
+ ,56
+ ,52.1
+ ,0
+ ,50.6
+ ,50.9
+ ,52.7
+ ,54.8
+ ,53.3
+ ,0
+ ,52.1
+ ,50.6
+ ,50.9
+ ,52.7
+ ,53.9
+ ,0
+ ,53.3
+ ,52.1
+ ,50.6
+ ,50.9
+ ,54.3
+ ,0
+ ,53.9
+ ,53.3
+ ,52.1
+ ,50.6
+ ,54.2
+ ,0
+ ,54.3
+ ,53.9
+ ,53.3
+ ,52.1
+ ,54.2
+ ,0
+ ,54.2
+ ,54.3
+ ,53.9
+ ,53.3
+ ,53.5
+ ,0
+ ,54.2
+ ,54.2
+ ,54.3
+ ,53.9
+ ,51.4
+ ,0
+ ,53.5
+ ,54.2
+ ,54.2
+ ,54.3
+ ,50.5
+ ,0
+ ,51.4
+ ,53.5
+ ,54.2
+ ,54.2
+ ,50.3
+ ,0
+ ,50.5
+ ,51.4
+ ,53.5
+ ,54.2
+ ,49.8
+ ,0
+ ,50.3
+ ,50.5
+ ,51.4
+ ,53.5
+ ,50.7
+ ,0
+ ,49.8
+ ,50.3
+ ,50.5
+ ,51.4
+ ,52.8
+ ,0
+ ,50.7
+ ,49.8
+ ,50.3
+ ,50.5
+ ,55.3
+ ,0
+ ,52.8
+ ,50.7
+ ,49.8
+ ,50.3
+ ,57.3
+ ,0
+ ,55.3
+ ,52.8
+ ,50.7
+ ,49.8
+ ,57.5
+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do not include Seasonal 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 t
1 50.9 0 52.7 54.8 56.0 56.6 1
2 50.6 0 50.9 52.7 54.8 56.0 2
3 52.1 0 50.6 50.9 52.7 54.8 3
4 53.3 0 52.1 50.6 50.9 52.7 4
5 53.9 0 53.3 52.1 50.6 50.9 5
6 54.3 0 53.9 53.3 52.1 50.6 6
7 54.2 0 54.3 53.9 53.3 52.1 7
8 54.2 0 54.2 54.3 53.9 53.3 8
9 53.5 0 54.2 54.2 54.3 53.9 9
10 51.4 0 53.5 54.2 54.2 54.3 10
11 50.5 0 51.4 53.5 54.2 54.2 11
12 50.3 0 50.5 51.4 53.5 54.2 12
13 49.8 0 50.3 50.5 51.4 53.5 13
14 50.7 0 49.8 50.3 50.5 51.4 14
15 52.8 0 50.7 49.8 50.3 50.5 15
16 55.3 0 52.8 50.7 49.8 50.3 16
17 57.3 0 55.3 52.8 50.7 49.8 17
18 57.5 0 57.3 55.3 52.8 50.7 18
19 56.8 0 57.5 57.3 55.3 52.8 19
20 56.4 0 56.8 57.5 57.3 55.3 20
21 56.3 0 56.4 56.8 57.5 57.3 21
22 56.4 0 56.3 56.4 56.8 57.5 22
23 57.0 0 56.4 56.3 56.4 56.8 23
24 57.9 0 57.0 56.4 56.3 56.4 24
25 58.9 0 57.9 57.0 56.4 56.3 25
26 58.8 0 58.9 57.9 57.0 56.4 26
27 56.5 1 58.8 58.9 57.9 57.0 27
28 51.9 1 56.5 58.8 58.9 57.9 28
29 47.4 1 51.9 56.5 58.8 58.9 29
30 44.9 1 47.4 51.9 56.5 58.8 30
31 43.9 1 44.9 47.4 51.9 56.5 31
32 43.4 1 43.9 44.9 47.4 51.9 32
33 42.9 1 43.4 43.9 44.9 47.4 33
34 42.6 1 42.9 43.4 43.9 44.9 34
35 42.2 1 42.6 42.9 43.4 43.9 35
36 41.2 1 42.2 42.6 42.9 43.4 36
37 40.2 1 41.2 42.2 42.6 42.9 37
38 39.3 1 40.2 41.2 42.2 42.6 38
39 38.5 1 39.3 40.2 41.2 42.2 39
40 38.3 1 38.5 39.3 40.2 41.2 40
41 37.9 1 38.3 38.5 39.3 40.2 41
42 37.6 1 37.9 38.3 38.5 39.3 42
43 37.3 1 37.6 37.9 38.3 38.5 43
44 36.0 1 37.3 37.6 37.9 38.3 44
45 34.5 1 36.0 37.3 37.6 37.9 45
46 33.5 1 34.5 36.0 37.3 37.6 46
47 32.9 1 33.5 34.5 36.0 37.3 47
48 32.9 1 32.9 33.5 34.5 36.0 48
49 32.8 1 32.9 32.9 33.5 34.5 49
50 31.9 1 32.8 32.9 32.9 33.5 50
51 30.5 1 31.9 32.8 32.9 32.9 51
52 29.2 1 30.5 31.9 32.8 32.9 52
53 28.7 1 29.2 30.5 31.9 32.8 53
54 28.4 1 28.7 29.2 30.5 31.9 54
55 28.0 1 28.4 28.7 29.2 30.5 55
56 27.4 1 28.0 28.4 28.7 29.2 56
57 26.9 1 27.4 28.0 28.4 28.7 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
2.164157 -1.279847 2.053946 -1.728493 0.670044 -0.034138
t
0.002386
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.4525 -0.2639 0.1228 0.3606 1.0766
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.164157 0.954132 2.268 0.027669 *
X -1.279847 0.360586 -3.549 0.000851 ***
Y1 2.053946 0.136137 15.087 < 2e-16 ***
Y2 -1.728493 0.302339 -5.717 6e-07 ***
Y3 0.670044 0.294646 2.274 0.027288 *
Y4 -0.034138 0.126848 -0.269 0.788940
t 0.002386 0.012017 0.199 0.843435
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.529 on 50 degrees of freedom
Multiple R-squared: 0.9976, Adjusted R-squared: 0.9973
F-statistic: 3467 on 6 and 50 DF, p-value: < 2.2e-16
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.9015247 1.969506e-01 9.847530e-02
[2,] 0.8461126 3.077749e-01 1.538874e-01
[3,] 0.9292025 1.415949e-01 7.079747e-02
[4,] 0.9888088 2.238245e-02 1.119122e-02
[5,] 0.9855061 2.898783e-02 1.449392e-02
[6,] 0.9801192 3.976170e-02 1.988085e-02
[7,] 0.9979337 4.132556e-03 2.066278e-03
[8,] 0.9988075 2.385024e-03 1.192512e-03
[9,] 0.9993914 1.217226e-03 6.086128e-04
[10,] 0.9995992 8.015669e-04 4.007834e-04
[11,] 0.9997623 4.754950e-04 2.377475e-04
[12,] 0.9998900 2.200502e-04 1.100251e-04
[13,] 0.9999255 1.490290e-04 7.451448e-05
[14,] 0.9998842 2.315762e-04 1.157881e-04
[15,] 0.9997649 4.701304e-04 2.350652e-04
[16,] 0.9998314 3.372663e-04 1.686332e-04
[17,] 0.9997159 5.682383e-04 2.841191e-04
[18,] 0.9999811 3.786424e-05 1.893212e-05
[19,] 0.9999698 6.039553e-05 3.019776e-05
[20,] 0.9999320 1.360754e-04 6.803769e-05
[21,] 0.9999614 7.723087e-05 3.861544e-05
[22,] 0.9999715 5.694174e-05 2.847087e-05
[23,] 0.9999604 7.929089e-05 3.964544e-05
[24,] 0.9999022 1.955488e-04 9.777441e-05
[25,] 0.9997407 5.186093e-04 2.593046e-04
[26,] 0.9994073 1.185435e-03 5.927177e-04
[27,] 0.9994072 1.185612e-03 5.928058e-04
[28,] 0.9985959 2.808288e-03 1.404144e-03
[29,] 0.9978681 4.263809e-03 2.131905e-03
[30,] 0.9981018 3.796426e-03 1.898213e-03
[31,] 0.9954399 9.120148e-03 4.560074e-03
[32,] 0.9989284 2.143120e-03 1.071560e-03
[33,] 0.9968413 6.317359e-03 3.158680e-03
[34,] 0.9958463 8.307483e-03 4.153742e-03
[35,] 0.9909416 1.811671e-02 9.058353e-03
[36,] 0.9817328 3.653441e-02 1.826720e-02
[37,] 0.9487320 1.025360e-01 5.126800e-02
[38,] 0.8728589 2.542823e-01 1.271411e-01
> postscript(file="/var/www/html/rcomp/tmp/1x2c01258649741.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/2dtcz1258649741.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/3wq6q1258649741.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/45seh1258649741.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/5cpyn1258649741.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 = 57
Frequency = 1
1 2 3 4 5 6
-0.37833698 0.17011449 0.53875207 -0.72871066 0.13647328 0.36060397
7 8 9 10 11 12
-0.27911049 0.25423461 -0.86853546 -1.45249943 0.74504226 -0.76959707
13 14 15 16 17 18
-1.03364111 1.07659759 0.56469843 0.63286460 0.50534088 -0.46007256
19 20 21 22 23 24
0.28031798 0.40664930 -0.14983634 -0.06236623 0.40112520 0.29257039
25 26 27 28 29 30
0.40831095 -0.59098966 -0.26219812 -0.95267760 0.11869599 0.44568612
31 32 33 34 35 36
-0.19636798 -0.10787622 0.20970765 0.65474760 0.30518315 -0.07621906
37 38 39 40 41 42
0.46788814 0.14873138 0.12279282 0.64382620 -0.16166311 0.51714213
43 44 45 46 47 48
0.24624130 -0.69731855 0.13923558 0.16149939 -0.11886413 0.34331150
49 50 51 52 53 54
-0.17733290 -0.50643546 -0.25360197 -0.16910291 0.17837656 -0.43673965
55 56 57
-0.26392382 -0.27263640 -0.05010761
> postscript(file="/var/www/html/rcomp/tmp/6u70f1258649741.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.37833698 NA
1 0.17011449 -0.37833698
2 0.53875207 0.17011449
3 -0.72871066 0.53875207
4 0.13647328 -0.72871066
5 0.36060397 0.13647328
6 -0.27911049 0.36060397
7 0.25423461 -0.27911049
8 -0.86853546 0.25423461
9 -1.45249943 -0.86853546
10 0.74504226 -1.45249943
11 -0.76959707 0.74504226
12 -1.03364111 -0.76959707
13 1.07659759 -1.03364111
14 0.56469843 1.07659759
15 0.63286460 0.56469843
16 0.50534088 0.63286460
17 -0.46007256 0.50534088
18 0.28031798 -0.46007256
19 0.40664930 0.28031798
20 -0.14983634 0.40664930
21 -0.06236623 -0.14983634
22 0.40112520 -0.06236623
23 0.29257039 0.40112520
24 0.40831095 0.29257039
25 -0.59098966 0.40831095
26 -0.26219812 -0.59098966
27 -0.95267760 -0.26219812
28 0.11869599 -0.95267760
29 0.44568612 0.11869599
30 -0.19636798 0.44568612
31 -0.10787622 -0.19636798
32 0.20970765 -0.10787622
33 0.65474760 0.20970765
34 0.30518315 0.65474760
35 -0.07621906 0.30518315
36 0.46788814 -0.07621906
37 0.14873138 0.46788814
38 0.12279282 0.14873138
39 0.64382620 0.12279282
40 -0.16166311 0.64382620
41 0.51714213 -0.16166311
42 0.24624130 0.51714213
43 -0.69731855 0.24624130
44 0.13923558 -0.69731855
45 0.16149939 0.13923558
46 -0.11886413 0.16149939
47 0.34331150 -0.11886413
48 -0.17733290 0.34331150
49 -0.50643546 -0.17733290
50 -0.25360197 -0.50643546
51 -0.16910291 -0.25360197
52 0.17837656 -0.16910291
53 -0.43673965 0.17837656
54 -0.26392382 -0.43673965
55 -0.27263640 -0.26392382
56 -0.05010761 -0.27263640
57 NA -0.05010761
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.17011449 -0.37833698
[2,] 0.53875207 0.17011449
[3,] -0.72871066 0.53875207
[4,] 0.13647328 -0.72871066
[5,] 0.36060397 0.13647328
[6,] -0.27911049 0.36060397
[7,] 0.25423461 -0.27911049
[8,] -0.86853546 0.25423461
[9,] -1.45249943 -0.86853546
[10,] 0.74504226 -1.45249943
[11,] -0.76959707 0.74504226
[12,] -1.03364111 -0.76959707
[13,] 1.07659759 -1.03364111
[14,] 0.56469843 1.07659759
[15,] 0.63286460 0.56469843
[16,] 0.50534088 0.63286460
[17,] -0.46007256 0.50534088
[18,] 0.28031798 -0.46007256
[19,] 0.40664930 0.28031798
[20,] -0.14983634 0.40664930
[21,] -0.06236623 -0.14983634
[22,] 0.40112520 -0.06236623
[23,] 0.29257039 0.40112520
[24,] 0.40831095 0.29257039
[25,] -0.59098966 0.40831095
[26,] -0.26219812 -0.59098966
[27,] -0.95267760 -0.26219812
[28,] 0.11869599 -0.95267760
[29,] 0.44568612 0.11869599
[30,] -0.19636798 0.44568612
[31,] -0.10787622 -0.19636798
[32,] 0.20970765 -0.10787622
[33,] 0.65474760 0.20970765
[34,] 0.30518315 0.65474760
[35,] -0.07621906 0.30518315
[36,] 0.46788814 -0.07621906
[37,] 0.14873138 0.46788814
[38,] 0.12279282 0.14873138
[39,] 0.64382620 0.12279282
[40,] -0.16166311 0.64382620
[41,] 0.51714213 -0.16166311
[42,] 0.24624130 0.51714213
[43,] -0.69731855 0.24624130
[44,] 0.13923558 -0.69731855
[45,] 0.16149939 0.13923558
[46,] -0.11886413 0.16149939
[47,] 0.34331150 -0.11886413
[48,] -0.17733290 0.34331150
[49,] -0.50643546 -0.17733290
[50,] -0.25360197 -0.50643546
[51,] -0.16910291 -0.25360197
[52,] 0.17837656 -0.16910291
[53,] -0.43673965 0.17837656
[54,] -0.26392382 -0.43673965
[55,] -0.27263640 -0.26392382
[56,] -0.05010761 -0.27263640
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.17011449 -0.37833698
2 0.53875207 0.17011449
3 -0.72871066 0.53875207
4 0.13647328 -0.72871066
5 0.36060397 0.13647328
6 -0.27911049 0.36060397
7 0.25423461 -0.27911049
8 -0.86853546 0.25423461
9 -1.45249943 -0.86853546
10 0.74504226 -1.45249943
11 -0.76959707 0.74504226
12 -1.03364111 -0.76959707
13 1.07659759 -1.03364111
14 0.56469843 1.07659759
15 0.63286460 0.56469843
16 0.50534088 0.63286460
17 -0.46007256 0.50534088
18 0.28031798 -0.46007256
19 0.40664930 0.28031798
20 -0.14983634 0.40664930
21 -0.06236623 -0.14983634
22 0.40112520 -0.06236623
23 0.29257039 0.40112520
24 0.40831095 0.29257039
25 -0.59098966 0.40831095
26 -0.26219812 -0.59098966
27 -0.95267760 -0.26219812
28 0.11869599 -0.95267760
29 0.44568612 0.11869599
30 -0.19636798 0.44568612
31 -0.10787622 -0.19636798
32 0.20970765 -0.10787622
33 0.65474760 0.20970765
34 0.30518315 0.65474760
35 -0.07621906 0.30518315
36 0.46788814 -0.07621906
37 0.14873138 0.46788814
38 0.12279282 0.14873138
39 0.64382620 0.12279282
40 -0.16166311 0.64382620
41 0.51714213 -0.16166311
42 0.24624130 0.51714213
43 -0.69731855 0.24624130
44 0.13923558 -0.69731855
45 0.16149939 0.13923558
46 -0.11886413 0.16149939
47 0.34331150 -0.11886413
48 -0.17733290 0.34331150
49 -0.50643546 -0.17733290
50 -0.25360197 -0.50643546
51 -0.16910291 -0.25360197
52 0.17837656 -0.16910291
53 -0.43673965 0.17837656
54 -0.26392382 -0.43673965
55 -0.27263640 -0.26392382
56 -0.05010761 -0.27263640
> 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/7ur8u1258649741.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/86cir1258649741.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/91jao1258649741.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/10pbed1258649741.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/11ml1a1258649741.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/12b2vt1258649741.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/13btf21258649741.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/141qku1258649741.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/15wczt1258649741.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/16v3g61258649741.tab")
+ }
>
> system("convert tmp/1x2c01258649741.ps tmp/1x2c01258649741.png")
> system("convert tmp/2dtcz1258649741.ps tmp/2dtcz1258649741.png")
> system("convert tmp/3wq6q1258649741.ps tmp/3wq6q1258649741.png")
> system("convert tmp/45seh1258649741.ps tmp/45seh1258649741.png")
> system("convert tmp/5cpyn1258649741.ps tmp/5cpyn1258649741.png")
> system("convert tmp/6u70f1258649741.ps tmp/6u70f1258649741.png")
> system("convert tmp/7ur8u1258649741.ps tmp/7ur8u1258649741.png")
> system("convert tmp/86cir1258649741.ps tmp/86cir1258649741.png")
> system("convert tmp/91jao1258649741.ps tmp/91jao1258649741.png")
> system("convert tmp/10pbed1258649741.ps tmp/10pbed1258649741.png")
>
>
> proc.time()
user system elapsed
2.412 1.566 3.220