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(90398,562000,90269,561000,90390,555000,88219,544000,87032,537000,87175,543000,92603,594000,93571,611000,94118,613000,92159,611000,89528,594000,89955,595000,89587,591000,89488,589000,88521,584000,86587,573000,85159,567000,84915,569000,91378,621000,92729,629000,92194,628000,89664,612000,86285,595000,86858,597000,87184,593000,86629,590000,85220,580000,84816,574000,84831,573000,84957,573000,90951,620000,92134,626000,91790,620000,86625,588000,83324,566000,82719,557000,83614,561000,81640,549000,78665,532000,77828,526000,75728,511000,72187,499000,79357,555000,81329,565000,77304,542000,75576,527000,72932,510000,74291,514000,74988,517000,73302,508000,70483,493000,69848,490000,66466,469000,67610,478000,75091,528000,76207,534000,73454,518000,72008,506000,71362,502000,74250,516000),dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),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 = '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 90398 562000 1 0 0 0 0 0 0 0 0 0 0
2 90269 561000 0 1 0 0 0 0 0 0 0 0 0
3 90390 555000 0 0 1 0 0 0 0 0 0 0 0
4 88219 544000 0 0 0 1 0 0 0 0 0 0 0
5 87032 537000 0 0 0 0 1 0 0 0 0 0 0
6 87175 543000 0 0 0 0 0 1 0 0 0 0 0
7 92603 594000 0 0 0 0 0 0 1 0 0 0 0
8 93571 611000 0 0 0 0 0 0 0 1 0 0 0
9 94118 613000 0 0 0 0 0 0 0 0 1 0 0
10 92159 611000 0 0 0 0 0 0 0 0 0 1 0
11 89528 594000 0 0 0 0 0 0 0 0 0 0 1
12 89955 595000 0 0 0 0 0 0 0 0 0 0 0
13 89587 591000 1 0 0 0 0 0 0 0 0 0 0
14 89488 589000 0 1 0 0 0 0 0 0 0 0 0
15 88521 584000 0 0 1 0 0 0 0 0 0 0 0
16 86587 573000 0 0 0 1 0 0 0 0 0 0 0
17 85159 567000 0 0 0 0 1 0 0 0 0 0 0
18 84915 569000 0 0 0 0 0 1 0 0 0 0 0
19 91378 621000 0 0 0 0 0 0 1 0 0 0 0
20 92729 629000 0 0 0 0 0 0 0 1 0 0 0
21 92194 628000 0 0 0 0 0 0 0 0 1 0 0
22 89664 612000 0 0 0 0 0 0 0 0 0 1 0
23 86285 595000 0 0 0 0 0 0 0 0 0 0 1
24 86858 597000 0 0 0 0 0 0 0 0 0 0 0
25 87184 593000 1 0 0 0 0 0 0 0 0 0 0
26 86629 590000 0 1 0 0 0 0 0 0 0 0 0
27 85220 580000 0 0 1 0 0 0 0 0 0 0 0
28 84816 574000 0 0 0 1 0 0 0 0 0 0 0
29 84831 573000 0 0 0 0 1 0 0 0 0 0 0
30 84957 573000 0 0 0 0 0 1 0 0 0 0 0
31 90951 620000 0 0 0 0 0 0 1 0 0 0 0
32 92134 626000 0 0 0 0 0 0 0 1 0 0 0
33 91790 620000 0 0 0 0 0 0 0 0 1 0 0
34 86625 588000 0 0 0 0 0 0 0 0 0 1 0
35 83324 566000 0 0 0 0 0 0 0 0 0 0 1
36 82719 557000 0 0 0 0 0 0 0 0 0 0 0
37 83614 561000 1 0 0 0 0 0 0 0 0 0 0
38 81640 549000 0 1 0 0 0 0 0 0 0 0 0
39 78665 532000 0 0 1 0 0 0 0 0 0 0 0
40 77828 526000 0 0 0 1 0 0 0 0 0 0 0
41 75728 511000 0 0 0 0 1 0 0 0 0 0 0
42 72187 499000 0 0 0 0 0 1 0 0 0 0 0
43 79357 555000 0 0 0 0 0 0 1 0 0 0 0
44 81329 565000 0 0 0 0 0 0 0 1 0 0 0
45 77304 542000 0 0 0 0 0 0 0 0 1 0 0
46 75576 527000 0 0 0 0 0 0 0 0 0 1 0
47 72932 510000 0 0 0 0 0 0 0 0 0 0 1
48 74291 514000 0 0 0 0 0 0 0 0 0 0 0
49 74988 517000 1 0 0 0 0 0 0 0 0 0 0
50 73302 508000 0 1 0 0 0 0 0 0 0 0 0
51 70483 493000 0 0 1 0 0 0 0 0 0 0 0
52 69848 490000 0 0 0 1 0 0 0 0 0 0 0
53 66466 469000 0 0 0 0 1 0 0 0 0 0 0
54 67610 478000 0 0 0 0 0 1 0 0 0 0 0
55 75091 528000 0 0 0 0 0 0 1 0 0 0 0
56 76207 534000 0 0 0 0 0 0 0 1 0 0 0
57 73454 518000 0 0 0 0 0 0 0 0 1 0 0
58 72008 506000 0 0 0 0 0 0 0 0 0 1 0
59 71362 502000 0 0 0 0 0 0 0 0 0 0 1
60 74250 516000 0 0 0 0 0 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
-2.058e+04 1.839e-01 1.885e+03 1.989e+03 2.328e+03 2.493e+03
M5 M6 M7 M8 M9 M10
2.715e+03 2.057e+03 -8.501e+02 -1.260e+03 -1.064e+03 -7.985e+02
M11
-4.871e+02
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3262.9 -1492.3 -695.8 327.9 6594.2
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.058e+04 5.588e+03 -3.683 0.000595 ***
X 1.839e-01 9.798e-03 18.765 < 2e-16 ***
M1 1.885e+03 1.774e+03 1.063 0.293337
M2 1.989e+03 1.772e+03 1.123 0.267273
M3 2.328e+03 1.773e+03 1.313 0.195422
M4 2.493e+03 1.777e+03 1.403 0.167259
M5 2.715e+03 1.787e+03 1.519 0.135484
M6 2.057e+03 1.786e+03 1.151 0.255367
M7 -8.501e+02 1.792e+03 -0.474 0.637462
M8 -1.260e+03 1.808e+03 -0.697 0.489264
M9 -1.064e+03 1.793e+03 -0.594 0.555616
M10 -7.985e+02 1.776e+03 -0.450 0.655066
M11 -4.871e+02 1.772e+03 -0.275 0.784542
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2801 on 47 degrees of freedom
Multiple R-squared: 0.8945, Adjusted R-squared: 0.8675
F-statistic: 33.2 on 12 and 47 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.13139807 2.627961e-01 8.686019e-01
[2,] 0.07845247 1.569049e-01 9.215475e-01
[3,] 0.10535125 2.107025e-01 8.946488e-01
[4,] 0.05290289 1.058058e-01 9.470971e-01
[5,] 0.02368607 4.737214e-02 9.763139e-01
[6,] 0.04250234 8.500468e-02 9.574977e-01
[7,] 0.33394971 6.678994e-01 6.660503e-01
[8,] 0.79694010 4.061198e-01 2.030599e-01
[9,] 0.96232896 7.534209e-02 3.767104e-02
[10,] 0.98311604 3.376792e-02 1.688396e-02
[11,] 0.99627425 7.451495e-03 3.725747e-03
[12,] 0.99968714 6.257220e-04 3.128610e-04
[13,] 0.99966739 6.652235e-04 3.326117e-04
[14,] 0.99980359 3.928245e-04 1.964123e-04
[15,] 0.99957845 8.430914e-04 4.215457e-04
[16,] 0.99937994 1.240119e-03 6.200594e-04
[17,] 0.99933631 1.327380e-03 6.636901e-04
[18,] 0.99913406 1.731884e-03 8.659418e-04
[19,] 0.99996197 7.605938e-05 3.802969e-05
[20,] 0.99998881 2.237296e-05 1.118648e-05
[21,] 0.99999067 1.865209e-05 9.326043e-06
[22,] 0.99998334 3.332764e-05 1.666382e-05
[23,] 0.99997187 5.625855e-05 2.812927e-05
[24,] 0.99995447 9.106810e-05 4.553405e-05
[25,] 0.99993318 1.336300e-04 6.681502e-05
[26,] 0.99998915 2.170769e-05 1.085384e-05
[27,] 0.99999889 2.222163e-06 1.111081e-06
[28,] 0.99998404 3.191845e-05 1.595922e-05
[29,] 0.99968718 6.256470e-04 3.128235e-04
> postscript(file="/var/www/html/rcomp/tmp/1t24u1258569430.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/23bdo1258569430.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/3077n1258569430.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/4rri61258569430.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/50s1g1258569430.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
5758.62573 5709.21387 6594.22874 6281.34754 6159.14854 5857.21688
7 8 9 10 11 12
4814.79014 3067.40602 3050.64963 1193.44077 1376.82690 1132.83977
13 14 15 16 17 18
-384.49791 -220.04344 -606.89490 -682.77611 -1229.84144 -1183.30777
19 20 21 22 23 24
-1374.60083 -1084.18797 -1631.34536 -1485.42556 -2050.03943 -2331.89290
25 26 27 28 29 30
-3155.23058 -3262.90977 -3172.42957 -2637.64244 -2661.03943 -1876.77310
31 32 33 34 35 36
-1617.73450 -1127.58897 -564.41470 -111.63358 321.08421 883.76040
37 38 39 40 41 42
-841.50794 -713.39014 -901.84561 -800.05848 -364.32682 -1040.66450
43 44 45 46 47 48
-1260.42289 -716.74269 -708.84077 55.21270 225.59883 362.01270
49 50 51 52 53 54
-1377.38931 -1512.87051 -1913.05865 -2160.87051 -1903.94085 -1756.47151
55 56 57 58 59 60
-562.03191 -138.88638 -146.04879 348.40568 126.52949 -46.71997
> postscript(file="/var/www/html/rcomp/tmp/6ga4u1258569430.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 5758.62573 NA
1 5709.21387 5758.62573
2 6594.22874 5709.21387
3 6281.34754 6594.22874
4 6159.14854 6281.34754
5 5857.21688 6159.14854
6 4814.79014 5857.21688
7 3067.40602 4814.79014
8 3050.64963 3067.40602
9 1193.44077 3050.64963
10 1376.82690 1193.44077
11 1132.83977 1376.82690
12 -384.49791 1132.83977
13 -220.04344 -384.49791
14 -606.89490 -220.04344
15 -682.77611 -606.89490
16 -1229.84144 -682.77611
17 -1183.30777 -1229.84144
18 -1374.60083 -1183.30777
19 -1084.18797 -1374.60083
20 -1631.34536 -1084.18797
21 -1485.42556 -1631.34536
22 -2050.03943 -1485.42556
23 -2331.89290 -2050.03943
24 -3155.23058 -2331.89290
25 -3262.90977 -3155.23058
26 -3172.42957 -3262.90977
27 -2637.64244 -3172.42957
28 -2661.03943 -2637.64244
29 -1876.77310 -2661.03943
30 -1617.73450 -1876.77310
31 -1127.58897 -1617.73450
32 -564.41470 -1127.58897
33 -111.63358 -564.41470
34 321.08421 -111.63358
35 883.76040 321.08421
36 -841.50794 883.76040
37 -713.39014 -841.50794
38 -901.84561 -713.39014
39 -800.05848 -901.84561
40 -364.32682 -800.05848
41 -1040.66450 -364.32682
42 -1260.42289 -1040.66450
43 -716.74269 -1260.42289
44 -708.84077 -716.74269
45 55.21270 -708.84077
46 225.59883 55.21270
47 362.01270 225.59883
48 -1377.38931 362.01270
49 -1512.87051 -1377.38931
50 -1913.05865 -1512.87051
51 -2160.87051 -1913.05865
52 -1903.94085 -2160.87051
53 -1756.47151 -1903.94085
54 -562.03191 -1756.47151
55 -138.88638 -562.03191
56 -146.04879 -138.88638
57 348.40568 -146.04879
58 126.52949 348.40568
59 -46.71997 126.52949
60 NA -46.71997
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 5709.21387 5758.6257
[2,] 6594.22874 5709.2139
[3,] 6281.34754 6594.2287
[4,] 6159.14854 6281.3475
[5,] 5857.21688 6159.1485
[6,] 4814.79014 5857.2169
[7,] 3067.40602 4814.7901
[8,] 3050.64963 3067.4060
[9,] 1193.44077 3050.6496
[10,] 1376.82690 1193.4408
[11,] 1132.83977 1376.8269
[12,] -384.49791 1132.8398
[13,] -220.04344 -384.4979
[14,] -606.89490 -220.0434
[15,] -682.77611 -606.8949
[16,] -1229.84144 -682.7761
[17,] -1183.30777 -1229.8414
[18,] -1374.60083 -1183.3078
[19,] -1084.18797 -1374.6008
[20,] -1631.34536 -1084.1880
[21,] -1485.42556 -1631.3454
[22,] -2050.03943 -1485.4256
[23,] -2331.89290 -2050.0394
[24,] -3155.23058 -2331.8929
[25,] -3262.90977 -3155.2306
[26,] -3172.42957 -3262.9098
[27,] -2637.64244 -3172.4296
[28,] -2661.03943 -2637.6424
[29,] -1876.77310 -2661.0394
[30,] -1617.73450 -1876.7731
[31,] -1127.58897 -1617.7345
[32,] -564.41470 -1127.5890
[33,] -111.63358 -564.4147
[34,] 321.08421 -111.6336
[35,] 883.76040 321.0842
[36,] -841.50794 883.7604
[37,] -713.39014 -841.5079
[38,] -901.84561 -713.3901
[39,] -800.05848 -901.8456
[40,] -364.32682 -800.0585
[41,] -1040.66450 -364.3268
[42,] -1260.42289 -1040.6645
[43,] -716.74269 -1260.4229
[44,] -708.84077 -716.7427
[45,] 55.21270 -708.8408
[46,] 225.59883 55.2127
[47,] 362.01270 225.5988
[48,] -1377.38931 362.0127
[49,] -1512.87051 -1377.3893
[50,] -1913.05865 -1512.8705
[51,] -2160.87051 -1913.0586
[52,] -1903.94085 -2160.8705
[53,] -1756.47151 -1903.9409
[54,] -562.03191 -1756.4715
[55,] -138.88638 -562.0319
[56,] -146.04879 -138.8864
[57,] 348.40568 -146.0488
[58,] 126.52949 348.4057
[59,] -46.71997 126.5295
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 5709.21387 5758.6257
2 6594.22874 5709.2139
3 6281.34754 6594.2287
4 6159.14854 6281.3475
5 5857.21688 6159.1485
6 4814.79014 5857.2169
7 3067.40602 4814.7901
8 3050.64963 3067.4060
9 1193.44077 3050.6496
10 1376.82690 1193.4408
11 1132.83977 1376.8269
12 -384.49791 1132.8398
13 -220.04344 -384.4979
14 -606.89490 -220.0434
15 -682.77611 -606.8949
16 -1229.84144 -682.7761
17 -1183.30777 -1229.8414
18 -1374.60083 -1183.3078
19 -1084.18797 -1374.6008
20 -1631.34536 -1084.1880
21 -1485.42556 -1631.3454
22 -2050.03943 -1485.4256
23 -2331.89290 -2050.0394
24 -3155.23058 -2331.8929
25 -3262.90977 -3155.2306
26 -3172.42957 -3262.9098
27 -2637.64244 -3172.4296
28 -2661.03943 -2637.6424
29 -1876.77310 -2661.0394
30 -1617.73450 -1876.7731
31 -1127.58897 -1617.7345
32 -564.41470 -1127.5890
33 -111.63358 -564.4147
34 321.08421 -111.6336
35 883.76040 321.0842
36 -841.50794 883.7604
37 -713.39014 -841.5079
38 -901.84561 -713.3901
39 -800.05848 -901.8456
40 -364.32682 -800.0585
41 -1040.66450 -364.3268
42 -1260.42289 -1040.6645
43 -716.74269 -1260.4229
44 -708.84077 -716.7427
45 55.21270 -708.8408
46 225.59883 55.2127
47 362.01270 225.5988
48 -1377.38931 362.0127
49 -1512.87051 -1377.3893
50 -1913.05865 -1512.8705
51 -2160.87051 -1913.0586
52 -1903.94085 -2160.8705
53 -1756.47151 -1903.9409
54 -562.03191 -1756.4715
55 -138.88638 -562.0319
56 -146.04879 -138.8864
57 348.40568 -146.0488
58 126.52949 348.4057
59 -46.71997 126.5295
> 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/7mro71258569430.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/85r7x1258569430.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/95hd51258569430.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/1010z01258569430.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/11gr2q1258569430.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/12l1ms1258569430.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/137z291258569430.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/14eijg1258569431.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/15uddv1258569431.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/16izfg1258569431.tab")
+ }
>
> system("convert tmp/1t24u1258569430.ps tmp/1t24u1258569430.png")
> system("convert tmp/23bdo1258569430.ps tmp/23bdo1258569430.png")
> system("convert tmp/3077n1258569430.ps tmp/3077n1258569430.png")
> system("convert tmp/4rri61258569430.ps tmp/4rri61258569430.png")
> system("convert tmp/50s1g1258569430.ps tmp/50s1g1258569430.png")
> system("convert tmp/6ga4u1258569430.ps tmp/6ga4u1258569430.png")
> system("convert tmp/7mro71258569430.ps tmp/7mro71258569430.png")
> system("convert tmp/85r7x1258569430.ps tmp/85r7x1258569430.png")
> system("convert tmp/95hd51258569430.ps tmp/95hd51258569430.png")
> system("convert tmp/1010z01258569430.ps tmp/1010z01258569430.png")
>
>
> proc.time()
user system elapsed
2.394 1.559 2.807