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(105.7,0,105.7,0,111.1,0,82.4,0,60,0,107.3,0,99.3,0,113.5,0,108.9,0,100.2,0,103.9,0,138.7,0,120.2,0,100.2,0,143.2,0,70.9,0,85.2,0,133,0,136.6,0,117.9,0,106.3,0,122.3,0,125.5,0,148.4,0,126.3,0,99.6,0,140.4,0,80.3,0,92.6,0,138.5,0,110.9,0,119.6,0,105,0,109,0,129.4,0,148.6,0,101.4,0,134.8,0,143.7,0,81.6,0,90.3,0,141.5,0,140.7,0,140.2,0,100.2,0,125.7,0,119.6,0,134.7,0,109,0,116.3,0,146.9,0,97.4,0,89.4,0,132.1,0,139.8,0,129,0,112.5,0,121.9,0,121.7,0,123.1,0,131.6,0,119.3,0,132.5,0,98.3,0,85.1,0,131.7,0,129.3,0,90.7,1,78.6,1,68.9,1,79.1,1,83.5,1,74.1,1,59.7,1,93.3,1,61.3,1,56.6,1),dim=c(2,77),dimnames=list(c('Y','X'),1:77))
> y <- array(NA,dim=c(2,77),dimnames=list(c('Y','X'),1:77))
> 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 105.7 0 1 0 0 0 0 0 0 0 0 0 0
2 105.7 0 0 1 0 0 0 0 0 0 0 0 0
3 111.1 0 0 0 1 0 0 0 0 0 0 0 0
4 82.4 0 0 0 0 1 0 0 0 0 0 0 0
5 60.0 0 0 0 0 0 1 0 0 0 0 0 0
6 107.3 0 0 0 0 0 0 1 0 0 0 0 0
7 99.3 0 0 0 0 0 0 0 1 0 0 0 0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 0 0 0 1 0 0 0 0 0 0 0
77 56.6 1 0 0 0 0 1 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
136.0451 -39.2704 -20.6779 -25.3493 -0.2779 -48.6922
M5 M6 M7 M8 M9 M10
-50.5493 -5.3617 -9.9451 -11.0167 -27.5833 -21.5000
M11
-16.3000
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-26.800 -6.375 1.417 7.933 24.104
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 136.0451 4.8270 28.184 < 2e-16 ***
X -39.2704 4.0274 -9.751 2.82e-14 ***
M1 -20.6779 6.5149 -3.174 0.002312 **
M2 -25.3493 6.5149 -3.891 0.000240 ***
M3 -0.2779 6.5149 -0.043 0.966112
M4 -48.6922 6.5149 -7.474 2.73e-10 ***
M5 -50.5493 6.5149 -7.759 8.57e-11 ***
M6 -5.3617 6.7933 -0.789 0.432870
M7 -9.9451 6.7933 -1.464 0.148102
M8 -11.0167 6.7601 -1.630 0.108084
M9 -27.5833 6.7601 -4.080 0.000127 ***
M10 -21.5000 6.7601 -3.180 0.002268 **
M11 -16.3000 6.7601 -2.411 0.018780 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 11.71 on 64 degrees of freedom
Multiple R-squared: 0.8008, Adjusted R-squared: 0.7635
F-statistic: 21.44 on 12 and 64 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.9380278 0.123944311 0.061972156
[2,] 0.9639831 0.072033750 0.036016875
[3,] 0.9771664 0.045667105 0.022833553
[4,] 0.9949304 0.010139115 0.005069557
[5,] 0.9913076 0.017384849 0.008692425
[6,] 0.9833822 0.033235639 0.016617820
[7,] 0.9839595 0.032080953 0.016040477
[8,] 0.9833045 0.033391059 0.016695530
[9,] 0.9797242 0.040551553 0.020275777
[10,] 0.9770395 0.045921058 0.022960529
[11,] 0.9750380 0.049924029 0.024962015
[12,] 0.9675024 0.064995216 0.032497608
[13,] 0.9613852 0.077229518 0.038614759
[14,] 0.9622638 0.075472365 0.037736182
[15,] 0.9597485 0.080503093 0.040251546
[16,] 0.9755542 0.048891689 0.024445844
[17,] 0.9725628 0.054874321 0.027437161
[18,] 0.9599281 0.080143759 0.040071879
[19,] 0.9492977 0.101404603 0.050702302
[20,] 0.9439013 0.112197339 0.056098669
[21,] 0.9586350 0.082730011 0.041365005
[22,] 0.9745022 0.050995630 0.025497815
[23,] 0.9967855 0.006429091 0.003214545
[24,] 0.9954303 0.009139406 0.004569703
[25,] 0.9975629 0.004874145 0.002437073
[26,] 0.9959810 0.008038021 0.004019010
[27,] 0.9957024 0.008595292 0.004297646
[28,] 0.9960680 0.007863944 0.003931972
[29,] 0.9964130 0.007173968 0.003586984
[30,] 0.9978343 0.004331304 0.002165652
[31,] 0.9973656 0.005268757 0.002634379
[32,] 0.9948660 0.010268005 0.005134003
[33,] 0.9938404 0.012319158 0.006159579
[34,] 0.9960241 0.007951763 0.003975882
[35,] 0.9930325 0.013934981 0.006967491
[36,] 0.9943525 0.011294934 0.005647467
[37,] 0.9909731 0.018053775 0.009026887
[38,] 0.9828149 0.034370121 0.017185061
[39,] 0.9665740 0.066851911 0.033425955
[40,] 0.9607289 0.078542196 0.039271098
[41,] 0.9321342 0.135731514 0.067865757
[42,] 0.9089676 0.182064860 0.091032430
[43,] 0.8701490 0.259702087 0.129851044
[44,] 0.7752570 0.449485900 0.224742950
[45,] 0.6675950 0.664809985 0.332404992
[46,] 0.6501898 0.699620453 0.349810226
> postscript(file="/var/www/html/rcomp/tmp/15irn1258729697.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/2vt7f1258729697.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/3eej31258729697.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/42zs01258729697.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/5yn4f1258729697.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 = 77
Frequency = 1
1 2 3 4 5 6
-9.6672032 -4.9957746 -24.6672032 -4.9529175 -25.4957746 -23.3833333
7 8 9 10 11 12
-26.8000000 -11.5284038 0.4382629 -14.3450704 -15.8450704 2.6549296
13 14 15 16 17 18
4.8327968 -10.4957746 7.4327968 -16.4529175 -0.2957746 2.3166667
19 20 21 22 23 24
10.5000000 -7.1284038 -2.1617371 7.7549296 5.7549296 12.3549296
25 26 27 28 29 30
10.9327968 -11.0957746 4.6327968 -7.0529175 7.1042254 7.8166667
31 32 33 34 35 36
-15.2000000 -5.4284038 -3.4617371 -5.5450704 9.6549296 12.5549296
37 38 39 40 41 42
-13.9672032 24.1042254 7.9327968 -5.7529175 4.8042254 10.8166667
43 44 45 46 47 48
14.6000000 15.1715962 -8.2617371 11.1549296 -0.1450704 -1.3450704
49 50 51 52 53 54
-6.3672032 5.6042254 11.1327968 10.0470825 3.9042254 1.4166667
55 56 57 58 59 60
13.7000000 3.9715962 4.0382629 7.3549296 1.9549296 -12.9450704
61 62 63 64 65 66
16.2327968 8.6042254 -3.2672032 10.9470825 -0.3957746 1.0166667
67 68 69 70 71 72
3.2000000 4.9420188 9.4086854 -6.3746479 -1.3746479 -13.2746479
73 74 75 76 77
-1.9967807 -11.7253521 -3.1967807 13.2175050 10.3746479
> postscript(file="/var/www/html/rcomp/tmp/6sjqx1258729697.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 = 77
Frequency = 1
lag(myerror, k = 1) myerror
0 -9.6672032 NA
1 -4.9957746 -9.6672032
2 -24.6672032 -4.9957746
3 -4.9529175 -24.6672032
4 -25.4957746 -4.9529175
5 -23.3833333 -25.4957746
6 -26.8000000 -23.3833333
7 -11.5284038 -26.8000000
8 0.4382629 -11.5284038
9 -14.3450704 0.4382629
10 -15.8450704 -14.3450704
11 2.6549296 -15.8450704
12 4.8327968 2.6549296
13 -10.4957746 4.8327968
14 7.4327968 -10.4957746
15 -16.4529175 7.4327968
16 -0.2957746 -16.4529175
17 2.3166667 -0.2957746
18 10.5000000 2.3166667
19 -7.1284038 10.5000000
20 -2.1617371 -7.1284038
21 7.7549296 -2.1617371
22 5.7549296 7.7549296
23 12.3549296 5.7549296
24 10.9327968 12.3549296
25 -11.0957746 10.9327968
26 4.6327968 -11.0957746
27 -7.0529175 4.6327968
28 7.1042254 -7.0529175
29 7.8166667 7.1042254
30 -15.2000000 7.8166667
31 -5.4284038 -15.2000000
32 -3.4617371 -5.4284038
33 -5.5450704 -3.4617371
34 9.6549296 -5.5450704
35 12.5549296 9.6549296
36 -13.9672032 12.5549296
37 24.1042254 -13.9672032
38 7.9327968 24.1042254
39 -5.7529175 7.9327968
40 4.8042254 -5.7529175
41 10.8166667 4.8042254
42 14.6000000 10.8166667
43 15.1715962 14.6000000
44 -8.2617371 15.1715962
45 11.1549296 -8.2617371
46 -0.1450704 11.1549296
47 -1.3450704 -0.1450704
48 -6.3672032 -1.3450704
49 5.6042254 -6.3672032
50 11.1327968 5.6042254
51 10.0470825 11.1327968
52 3.9042254 10.0470825
53 1.4166667 3.9042254
54 13.7000000 1.4166667
55 3.9715962 13.7000000
56 4.0382629 3.9715962
57 7.3549296 4.0382629
58 1.9549296 7.3549296
59 -12.9450704 1.9549296
60 16.2327968 -12.9450704
61 8.6042254 16.2327968
62 -3.2672032 8.6042254
63 10.9470825 -3.2672032
64 -0.3957746 10.9470825
65 1.0166667 -0.3957746
66 3.2000000 1.0166667
67 4.9420188 3.2000000
68 9.4086854 4.9420188
69 -6.3746479 9.4086854
70 -1.3746479 -6.3746479
71 -13.2746479 -1.3746479
72 -1.9967807 -13.2746479
73 -11.7253521 -1.9967807
74 -3.1967807 -11.7253521
75 13.2175050 -3.1967807
76 10.3746479 13.2175050
77 NA 10.3746479
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.9957746 -9.6672032
[2,] -24.6672032 -4.9957746
[3,] -4.9529175 -24.6672032
[4,] -25.4957746 -4.9529175
[5,] -23.3833333 -25.4957746
[6,] -26.8000000 -23.3833333
[7,] -11.5284038 -26.8000000
[8,] 0.4382629 -11.5284038
[9,] -14.3450704 0.4382629
[10,] -15.8450704 -14.3450704
[11,] 2.6549296 -15.8450704
[12,] 4.8327968 2.6549296
[13,] -10.4957746 4.8327968
[14,] 7.4327968 -10.4957746
[15,] -16.4529175 7.4327968
[16,] -0.2957746 -16.4529175
[17,] 2.3166667 -0.2957746
[18,] 10.5000000 2.3166667
[19,] -7.1284038 10.5000000
[20,] -2.1617371 -7.1284038
[21,] 7.7549296 -2.1617371
[22,] 5.7549296 7.7549296
[23,] 12.3549296 5.7549296
[24,] 10.9327968 12.3549296
[25,] -11.0957746 10.9327968
[26,] 4.6327968 -11.0957746
[27,] -7.0529175 4.6327968
[28,] 7.1042254 -7.0529175
[29,] 7.8166667 7.1042254
[30,] -15.2000000 7.8166667
[31,] -5.4284038 -15.2000000
[32,] -3.4617371 -5.4284038
[33,] -5.5450704 -3.4617371
[34,] 9.6549296 -5.5450704
[35,] 12.5549296 9.6549296
[36,] -13.9672032 12.5549296
[37,] 24.1042254 -13.9672032
[38,] 7.9327968 24.1042254
[39,] -5.7529175 7.9327968
[40,] 4.8042254 -5.7529175
[41,] 10.8166667 4.8042254
[42,] 14.6000000 10.8166667
[43,] 15.1715962 14.6000000
[44,] -8.2617371 15.1715962
[45,] 11.1549296 -8.2617371
[46,] -0.1450704 11.1549296
[47,] -1.3450704 -0.1450704
[48,] -6.3672032 -1.3450704
[49,] 5.6042254 -6.3672032
[50,] 11.1327968 5.6042254
[51,] 10.0470825 11.1327968
[52,] 3.9042254 10.0470825
[53,] 1.4166667 3.9042254
[54,] 13.7000000 1.4166667
[55,] 3.9715962 13.7000000
[56,] 4.0382629 3.9715962
[57,] 7.3549296 4.0382629
[58,] 1.9549296 7.3549296
[59,] -12.9450704 1.9549296
[60,] 16.2327968 -12.9450704
[61,] 8.6042254 16.2327968
[62,] -3.2672032 8.6042254
[63,] 10.9470825 -3.2672032
[64,] -0.3957746 10.9470825
[65,] 1.0166667 -0.3957746
[66,] 3.2000000 1.0166667
[67,] 4.9420188 3.2000000
[68,] 9.4086854 4.9420188
[69,] -6.3746479 9.4086854
[70,] -1.3746479 -6.3746479
[71,] -13.2746479 -1.3746479
[72,] -1.9967807 -13.2746479
[73,] -11.7253521 -1.9967807
[74,] -3.1967807 -11.7253521
[75,] 13.2175050 -3.1967807
[76,] 10.3746479 13.2175050
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.9957746 -9.6672032
2 -24.6672032 -4.9957746
3 -4.9529175 -24.6672032
4 -25.4957746 -4.9529175
5 -23.3833333 -25.4957746
6 -26.8000000 -23.3833333
7 -11.5284038 -26.8000000
8 0.4382629 -11.5284038
9 -14.3450704 0.4382629
10 -15.8450704 -14.3450704
11 2.6549296 -15.8450704
12 4.8327968 2.6549296
13 -10.4957746 4.8327968
14 7.4327968 -10.4957746
15 -16.4529175 7.4327968
16 -0.2957746 -16.4529175
17 2.3166667 -0.2957746
18 10.5000000 2.3166667
19 -7.1284038 10.5000000
20 -2.1617371 -7.1284038
21 7.7549296 -2.1617371
22 5.7549296 7.7549296
23 12.3549296 5.7549296
24 10.9327968 12.3549296
25 -11.0957746 10.9327968
26 4.6327968 -11.0957746
27 -7.0529175 4.6327968
28 7.1042254 -7.0529175
29 7.8166667 7.1042254
30 -15.2000000 7.8166667
31 -5.4284038 -15.2000000
32 -3.4617371 -5.4284038
33 -5.5450704 -3.4617371
34 9.6549296 -5.5450704
35 12.5549296 9.6549296
36 -13.9672032 12.5549296
37 24.1042254 -13.9672032
38 7.9327968 24.1042254
39 -5.7529175 7.9327968
40 4.8042254 -5.7529175
41 10.8166667 4.8042254
42 14.6000000 10.8166667
43 15.1715962 14.6000000
44 -8.2617371 15.1715962
45 11.1549296 -8.2617371
46 -0.1450704 11.1549296
47 -1.3450704 -0.1450704
48 -6.3672032 -1.3450704
49 5.6042254 -6.3672032
50 11.1327968 5.6042254
51 10.0470825 11.1327968
52 3.9042254 10.0470825
53 1.4166667 3.9042254
54 13.7000000 1.4166667
55 3.9715962 13.7000000
56 4.0382629 3.9715962
57 7.3549296 4.0382629
58 1.9549296 7.3549296
59 -12.9450704 1.9549296
60 16.2327968 -12.9450704
61 8.6042254 16.2327968
62 -3.2672032 8.6042254
63 10.9470825 -3.2672032
64 -0.3957746 10.9470825
65 1.0166667 -0.3957746
66 3.2000000 1.0166667
67 4.9420188 3.2000000
68 9.4086854 4.9420188
69 -6.3746479 9.4086854
70 -1.3746479 -6.3746479
71 -13.2746479 -1.3746479
72 -1.9967807 -13.2746479
73 -11.7253521 -1.9967807
74 -3.1967807 -11.7253521
75 13.2175050 -3.1967807
76 10.3746479 13.2175050
> 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/7zc4t1258729697.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/8paze1258729697.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/9ftbi1258729697.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/10fv461258729697.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/113vze1258729697.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/122bdg1258729697.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/137qa01258729697.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/14y1bm1258729697.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/15ne611258729697.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/164hve1258729697.tab")
+ }
>
> system("convert tmp/15irn1258729697.ps tmp/15irn1258729697.png")
> system("convert tmp/2vt7f1258729697.ps tmp/2vt7f1258729697.png")
> system("convert tmp/3eej31258729697.ps tmp/3eej31258729697.png")
> system("convert tmp/42zs01258729697.ps tmp/42zs01258729697.png")
> system("convert tmp/5yn4f1258729697.ps tmp/5yn4f1258729697.png")
> system("convert tmp/6sjqx1258729697.ps tmp/6sjqx1258729697.png")
> system("convert tmp/7zc4t1258729697.ps tmp/7zc4t1258729697.png")
> system("convert tmp/8paze1258729697.ps tmp/8paze1258729697.png")
> system("convert tmp/9ftbi1258729697.ps tmp/9ftbi1258729697.png")
> system("convert tmp/10fv461258729697.ps tmp/10fv461258729697.png")
>
>
> proc.time()
user system elapsed
2.672 1.667 6.371