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(7.2
+ ,6.5
+ ,8
+ ,17.4
+ ,7.4
+ ,6.6
+ ,8.5
+ ,17
+ ,8.8
+ ,7.6
+ ,10.4
+ ,18
+ ,9.3
+ ,8
+ ,11.1
+ ,23.8
+ ,9.3
+ ,8.1
+ ,10.9
+ ,25.6
+ ,8.7
+ ,7.7
+ ,10
+ ,23.7
+ ,8.2
+ ,7.5
+ ,9.2
+ ,22
+ ,8.3
+ ,7.6
+ ,9.2
+ ,21.3
+ ,8.5
+ ,7.8
+ ,9.5
+ ,20.7
+ ,8.6
+ ,7.8
+ ,9.6
+ ,20.4
+ ,8.5
+ ,7.8
+ ,9.5
+ ,20.3
+ ,8.2
+ ,7.5
+ ,9.1
+ ,20.4
+ ,8.1
+ ,7.5
+ ,8.9
+ ,19.8
+ ,7.9
+ ,7.1
+ ,9
+ ,19.5
+ ,8.6
+ ,7.5
+ ,10.1
+ ,23.1
+ ,8.7
+ ,7.5
+ ,10.3
+ ,23.5
+ ,8.7
+ ,7.6
+ ,10.2
+ ,23.5
+ ,8.5
+ ,7.7
+ ,9.6
+ ,22.9
+ ,8.4
+ ,7.7
+ ,9.2
+ ,21.9
+ ,8.5
+ ,7.9
+ ,9.3
+ ,21.5
+ ,8.7
+ ,8.1
+ ,9.4
+ ,20.5
+ ,8.7
+ ,8.2
+ ,9.4
+ ,20.2
+ ,8.6
+ ,8.2
+ ,9.2
+ ,19.4
+ ,8.5
+ ,8.2
+ ,9
+ ,19.2
+ ,8.3
+ ,7.9
+ ,9
+ ,18.8
+ ,8
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7.9
+ ,8.2
+ ,21.5
+ ,7.7
+ ,7.7
+ ,7.7
+ ,20.6
+ ,7.3
+ ,7.4
+ ,7.2
+ ,19.1
+ ,7.4
+ ,7.5
+ ,7.3
+ ,19.6
+ ,8.1
+ ,8
+ ,8.1
+ ,23.5
+ ,8.3
+ ,8.1
+ ,8.5
+ ,24
+ ,8.2
+ ,8
+ ,8.4
+ ,23.2)
+ ,dim=c(4
+ ,65)
+ ,dimnames=list(c('TW'
+ ,'WM'
+ ,'WV'
+ ,'WJ')
+ ,1:65))
> y <- array(NA,dim=c(4,65),dimnames=list(c('TW','WM','WV','WJ'),1:65))
> 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
TW WM WV WJ M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 7.2 6.5 8.0 17.4 1 0 0 0 0 0 0 0 0 0 0 1
2 7.4 6.6 8.5 17.0 0 1 0 0 0 0 0 0 0 0 0 2
3 8.8 7.6 10.4 18.0 0 0 1 0 0 0 0 0 0 0 0 3
4 9.3 8.0 11.1 23.8 0 0 0 1 0 0 0 0 0 0 0 4
5 9.3 8.1 10.9 25.6 0 0 0 0 1 0 0 0 0 0 0 5
6 8.7 7.7 10.0 23.7 0 0 0 0 0 1 0 0 0 0 0 6
7 8.2 7.5 9.2 22.0 0 0 0 0 0 0 1 0 0 0 0 7
8 8.3 7.6 9.2 21.3 0 0 0 0 0 0 0 1 0 0 0 8
9 8.5 7.8 9.5 20.7 0 0 0 0 0 0 0 0 1 0 0 9
10 8.6 7.8 9.6 20.4 0 0 0 0 0 0 0 0 0 1 0 10
11 8.5 7.8 9.5 20.3 0 0 0 0 0 0 0 0 0 0 1 11
12 8.2 7.5 9.1 20.4 0 0 0 0 0 0 0 0 0 0 0 12
13 8.1 7.5 8.9 19.8 1 0 0 0 0 0 0 0 0 0 0 13
14 7.9 7.1 9.0 19.5 0 1 0 0 0 0 0 0 0 0 0 14
15 8.6 7.5 10.1 23.1 0 0 1 0 0 0 0 0 0 0 0 15
16 8.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0 0 64
65 8.2 8.0 8.4 23.2 0 0 0 0 1 0 0 0 0 0 0 65
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) WM WV WJ M1 M2
0.2119996 0.5273749 0.4245759 0.0076335 -0.0107192 -0.0253430
M3 M4 M5 M6 M7 M8
0.0173208 -0.0147026 -0.0111384 -0.0127332 0.0137345 -0.0027356
M9 M10 M11 t
0.0198791 0.0049581 0.0148366 0.0001275
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.063990 -0.021138 -0.002554 0.024192 0.060692
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.2119996 0.0848297 2.499 0.0159 *
WM 0.5273749 0.0112946 46.693 <2e-16 ***
WV 0.4245759 0.0108285 39.209 <2e-16 ***
WJ 0.0076335 0.0040303 1.894 0.0641 .
M1 -0.0107192 0.0200701 -0.534 0.5957
M2 -0.0253430 0.0200912 -1.261 0.2131
M3 0.0173208 0.0222266 0.779 0.4396
M4 -0.0147026 0.0248481 -0.592 0.5568
M5 -0.0111384 0.0242612 -0.459 0.6482
M6 -0.0127332 0.0235967 -0.540 0.5919
M7 0.0137345 0.0217519 0.631 0.5307
M8 -0.0027356 0.0209223 -0.131 0.8965
M9 0.0198791 0.0207707 0.957 0.3432
M10 0.0049581 0.0207886 0.239 0.8125
M11 0.0148366 0.0206396 0.719 0.4757
t 0.0001275 0.0004259 0.299 0.7660
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.03241 on 49 degrees of freedom
Multiple R-squared: 0.9984, Adjusted R-squared: 0.9979
F-statistic: 1990 on 15 and 49 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.78853624 0.4229275 0.2114638
[2,] 0.65788403 0.6842319 0.3421160
[3,] 0.73187712 0.5362458 0.2681229
[4,] 0.71583424 0.5683315 0.2841658
[5,] 0.60708530 0.7858294 0.3929147
[6,] 0.52552340 0.9489532 0.4744766
[7,] 0.64638759 0.7072248 0.3536124
[8,] 0.56197253 0.8760549 0.4380275
[9,] 0.49078301 0.9815660 0.5092170
[10,] 0.41195533 0.8239107 0.5880447
[11,] 0.32507622 0.6501524 0.6749238
[12,] 0.31961182 0.6392236 0.6803882
[13,] 0.24408963 0.4881793 0.7559104
[14,] 0.27135845 0.5427169 0.7286416
[15,] 0.46594993 0.9318999 0.5340501
[16,] 0.38236125 0.7647225 0.6176387
[17,] 0.33842282 0.6768456 0.6615772
[18,] 0.28246587 0.5649317 0.7175341
[19,] 0.30113554 0.6022711 0.6988645
[20,] 0.24926822 0.4985364 0.7507318
[21,] 0.18268351 0.3653670 0.8173165
[22,] 0.14645524 0.2929105 0.8535448
[23,] 0.12588907 0.2517781 0.8741109
[24,] 0.10561590 0.2112318 0.8943841
[25,] 0.06084300 0.1216860 0.9391570
[26,] 0.10597355 0.2119471 0.8940265
[27,] 0.05600111 0.1120022 0.9439989
[28,] 0.22373471 0.4474694 0.7762653
> postscript(file="/var/www/html/rcomp/tmp/1qcwg1258897438.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/2348f1258897438.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/301we1258897439.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/4ww641258897439.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/53zk01258897439.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 = 65
Frequency = 1
1 2 3 4 5 6
0.041225433 -0.006250271 0.009255780 -0.011275551 0.003470271 0.012509512
7 8 9 10 11 12
-0.055973092 0.012975545 -0.038034313 0.036591601 -0.030193355 0.011795234
13 14 15 16 17 18
0.011882229 -0.002838985 -0.051094221 -0.007166936 -0.021138483 -0.013082980
19 20 21 22 23 24
0.037785634 0.009249147 0.046207861 0.010553878 -0.008430062 -0.007279100
25 26 27 28 29 30
-0.035421510 -0.004500184 -0.005009394 -0.005159672 0.025616413 0.046110289
31 32 33 34 35 36
0.005600545 -0.022397434 -0.038807995 0.030249660 0.024192055 0.033782555
37 38 39 40 41 42
0.025023068 -0.031135851 0.004792461 0.021378668 0.003679222 -0.019397663
43 44 45 46 47 48
0.015141411 0.030050703 -0.010736382 -0.063990052 0.060692178 -0.031380023
49 50 51 52 53 54
-0.028332921 0.043617031 0.016857096 -0.028486044 -0.039947162 -0.026139158
55 56 57 58 59 60
-0.002554498 -0.029877961 0.041370828 -0.013405087 -0.046260816 -0.006918666
61 62 63 64 65
-0.014376300 0.001108260 0.025198278 0.030709536 0.028319740
> postscript(file="/var/www/html/rcomp/tmp/63fql1258897439.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 = 65
Frequency = 1
lag(myerror, k = 1) myerror
0 0.041225433 NA
1 -0.006250271 0.041225433
2 0.009255780 -0.006250271
3 -0.011275551 0.009255780
4 0.003470271 -0.011275551
5 0.012509512 0.003470271
6 -0.055973092 0.012509512
7 0.012975545 -0.055973092
8 -0.038034313 0.012975545
9 0.036591601 -0.038034313
10 -0.030193355 0.036591601
11 0.011795234 -0.030193355
12 0.011882229 0.011795234
13 -0.002838985 0.011882229
14 -0.051094221 -0.002838985
15 -0.007166936 -0.051094221
16 -0.021138483 -0.007166936
17 -0.013082980 -0.021138483
18 0.037785634 -0.013082980
19 0.009249147 0.037785634
20 0.046207861 0.009249147
21 0.010553878 0.046207861
22 -0.008430062 0.010553878
23 -0.007279100 -0.008430062
24 -0.035421510 -0.007279100
25 -0.004500184 -0.035421510
26 -0.005009394 -0.004500184
27 -0.005159672 -0.005009394
28 0.025616413 -0.005159672
29 0.046110289 0.025616413
30 0.005600545 0.046110289
31 -0.022397434 0.005600545
32 -0.038807995 -0.022397434
33 0.030249660 -0.038807995
34 0.024192055 0.030249660
35 0.033782555 0.024192055
36 0.025023068 0.033782555
37 -0.031135851 0.025023068
38 0.004792461 -0.031135851
39 0.021378668 0.004792461
40 0.003679222 0.021378668
41 -0.019397663 0.003679222
42 0.015141411 -0.019397663
43 0.030050703 0.015141411
44 -0.010736382 0.030050703
45 -0.063990052 -0.010736382
46 0.060692178 -0.063990052
47 -0.031380023 0.060692178
48 -0.028332921 -0.031380023
49 0.043617031 -0.028332921
50 0.016857096 0.043617031
51 -0.028486044 0.016857096
52 -0.039947162 -0.028486044
53 -0.026139158 -0.039947162
54 -0.002554498 -0.026139158
55 -0.029877961 -0.002554498
56 0.041370828 -0.029877961
57 -0.013405087 0.041370828
58 -0.046260816 -0.013405087
59 -0.006918666 -0.046260816
60 -0.014376300 -0.006918666
61 0.001108260 -0.014376300
62 0.025198278 0.001108260
63 0.030709536 0.025198278
64 0.028319740 0.030709536
65 NA 0.028319740
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.006250271 0.041225433
[2,] 0.009255780 -0.006250271
[3,] -0.011275551 0.009255780
[4,] 0.003470271 -0.011275551
[5,] 0.012509512 0.003470271
[6,] -0.055973092 0.012509512
[7,] 0.012975545 -0.055973092
[8,] -0.038034313 0.012975545
[9,] 0.036591601 -0.038034313
[10,] -0.030193355 0.036591601
[11,] 0.011795234 -0.030193355
[12,] 0.011882229 0.011795234
[13,] -0.002838985 0.011882229
[14,] -0.051094221 -0.002838985
[15,] -0.007166936 -0.051094221
[16,] -0.021138483 -0.007166936
[17,] -0.013082980 -0.021138483
[18,] 0.037785634 -0.013082980
[19,] 0.009249147 0.037785634
[20,] 0.046207861 0.009249147
[21,] 0.010553878 0.046207861
[22,] -0.008430062 0.010553878
[23,] -0.007279100 -0.008430062
[24,] -0.035421510 -0.007279100
[25,] -0.004500184 -0.035421510
[26,] -0.005009394 -0.004500184
[27,] -0.005159672 -0.005009394
[28,] 0.025616413 -0.005159672
[29,] 0.046110289 0.025616413
[30,] 0.005600545 0.046110289
[31,] -0.022397434 0.005600545
[32,] -0.038807995 -0.022397434
[33,] 0.030249660 -0.038807995
[34,] 0.024192055 0.030249660
[35,] 0.033782555 0.024192055
[36,] 0.025023068 0.033782555
[37,] -0.031135851 0.025023068
[38,] 0.004792461 -0.031135851
[39,] 0.021378668 0.004792461
[40,] 0.003679222 0.021378668
[41,] -0.019397663 0.003679222
[42,] 0.015141411 -0.019397663
[43,] 0.030050703 0.015141411
[44,] -0.010736382 0.030050703
[45,] -0.063990052 -0.010736382
[46,] 0.060692178 -0.063990052
[47,] -0.031380023 0.060692178
[48,] -0.028332921 -0.031380023
[49,] 0.043617031 -0.028332921
[50,] 0.016857096 0.043617031
[51,] -0.028486044 0.016857096
[52,] -0.039947162 -0.028486044
[53,] -0.026139158 -0.039947162
[54,] -0.002554498 -0.026139158
[55,] -0.029877961 -0.002554498
[56,] 0.041370828 -0.029877961
[57,] -0.013405087 0.041370828
[58,] -0.046260816 -0.013405087
[59,] -0.006918666 -0.046260816
[60,] -0.014376300 -0.006918666
[61,] 0.001108260 -0.014376300
[62,] 0.025198278 0.001108260
[63,] 0.030709536 0.025198278
[64,] 0.028319740 0.030709536
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.006250271 0.041225433
2 0.009255780 -0.006250271
3 -0.011275551 0.009255780
4 0.003470271 -0.011275551
5 0.012509512 0.003470271
6 -0.055973092 0.012509512
7 0.012975545 -0.055973092
8 -0.038034313 0.012975545
9 0.036591601 -0.038034313
10 -0.030193355 0.036591601
11 0.011795234 -0.030193355
12 0.011882229 0.011795234
13 -0.002838985 0.011882229
14 -0.051094221 -0.002838985
15 -0.007166936 -0.051094221
16 -0.021138483 -0.007166936
17 -0.013082980 -0.021138483
18 0.037785634 -0.013082980
19 0.009249147 0.037785634
20 0.046207861 0.009249147
21 0.010553878 0.046207861
22 -0.008430062 0.010553878
23 -0.007279100 -0.008430062
24 -0.035421510 -0.007279100
25 -0.004500184 -0.035421510
26 -0.005009394 -0.004500184
27 -0.005159672 -0.005009394
28 0.025616413 -0.005159672
29 0.046110289 0.025616413
30 0.005600545 0.046110289
31 -0.022397434 0.005600545
32 -0.038807995 -0.022397434
33 0.030249660 -0.038807995
34 0.024192055 0.030249660
35 0.033782555 0.024192055
36 0.025023068 0.033782555
37 -0.031135851 0.025023068
38 0.004792461 -0.031135851
39 0.021378668 0.004792461
40 0.003679222 0.021378668
41 -0.019397663 0.003679222
42 0.015141411 -0.019397663
43 0.030050703 0.015141411
44 -0.010736382 0.030050703
45 -0.063990052 -0.010736382
46 0.060692178 -0.063990052
47 -0.031380023 0.060692178
48 -0.028332921 -0.031380023
49 0.043617031 -0.028332921
50 0.016857096 0.043617031
51 -0.028486044 0.016857096
52 -0.039947162 -0.028486044
53 -0.026139158 -0.039947162
54 -0.002554498 -0.026139158
55 -0.029877961 -0.002554498
56 0.041370828 -0.029877961
57 -0.013405087 0.041370828
58 -0.046260816 -0.013405087
59 -0.006918666 -0.046260816
60 -0.014376300 -0.006918666
61 0.001108260 -0.014376300
62 0.025198278 0.001108260
63 0.030709536 0.025198278
64 0.028319740 0.030709536
> 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/7whvr1258897439.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/83fok1258897439.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/9ajn21258897439.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/10mukm1258897439.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/11xaav1258897439.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/12c0dy1258897439.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/13bdtk1258897439.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/143t7y1258897439.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/155nnn1258897439.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/164coq1258897439.tab")
+ }
>
> system("convert tmp/1qcwg1258897438.ps tmp/1qcwg1258897438.png")
> system("convert tmp/2348f1258897438.ps tmp/2348f1258897438.png")
> system("convert tmp/301we1258897439.ps tmp/301we1258897439.png")
> system("convert tmp/4ww641258897439.ps tmp/4ww641258897439.png")
> system("convert tmp/53zk01258897439.ps tmp/53zk01258897439.png")
> system("convert tmp/63fql1258897439.ps tmp/63fql1258897439.png")
> system("convert tmp/7whvr1258897439.ps tmp/7whvr1258897439.png")
> system("convert tmp/83fok1258897439.ps tmp/83fok1258897439.png")
> system("convert tmp/9ajn21258897439.ps tmp/9ajn21258897439.png")
> system("convert tmp/10mukm1258897439.ps tmp/10mukm1258897439.png")
>
>
> proc.time()
user system elapsed
2.437 1.575 3.108