R version 2.7.0 (2008-04-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(7.3,0,7.1,0,6.9,0,6.8,0,7.5,0,7.6,0,7.8,0,8,0,8.1,0,8.2,0,8.3,0,8.2,0,8,0,7.9,0,7.6,0,7.6,0,8.2,0,8.3,0,8.4,0,8.4,0,8.4,0,8.6,0,8.9,0,8.8,0,8.3,0,7.5,0,7.2,0,7.5,0,8.8,0,9.3,0,9.3,0,8.7,0,8.2,0,8.3,0,8.5,0,8.6,0,8.6,0,8.2,0,8.1,0,8,0,8.6,0,8.7,0,8.8,0,8.5,0,8.4,0,8.5,0,8.7,0,8.7,0,8.6,0,8.5,0,8.3,0,8.1,0,8.2,0,8.1,0,8.1,0,7.9,0,7.9,0,7.9,0,8,0,8,0,7.9,0,8,0,7.7,1,7.2,1,7.5,1,7.3,1,7,1,7,1,7,1,7.2,1,7.3,1,7.1,1,6.8,1,6.6,1,6.2,1,6.2,1,6.8,1,6.9,1,6.8,1),dim=c(2,79),dimnames=list(c('y','x'),1:79))
> y <- array(NA,dim=c(2,79),dimnames=list(c('y','x'),1:79))
> 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
y x M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 7.3 0 1 0 0 0 0 0 0 0 0 0 0 1
2 7.1 0 0 1 0 0 0 0 0 0 0 0 0 2
3 6.9 0 0 0 1 0 0 0 0 0 0 0 0 3
4 6.8 0 0 0 0 1 0 0 0 0 0 0 0 4
5 7.5 0 0 0 0 0 1 0 0 0 0 0 0 5
6 7.6 0 0 0 0 0 0 1 0 0 0 0 0 6
7 7.8 0 0 0 0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 0 0 0 0 0 0 0 1 71
72 7.1 1 0 0 0 0 0 0 0 0 0 0 0 72
73 6.8 1 1 0 0 0 0 0 0 0 0 0 0 73
74 6.6 1 0 1 0 0 0 0 0 0 0 0 0 74
75 6.2 1 0 0 1 0 0 0 0 0 0 0 0 75
76 6.2 1 0 0 0 1 0 0 0 0 0 0 0 76
77 6.8 1 0 0 0 0 1 0 0 0 0 0 0 77
78 6.9 1 0 0 0 0 0 1 0 0 0 0 0 78
79 6.8 1 0 0 0 0 0 0 1 0 0 0 0 79
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
8.167593 -1.469167 -0.302766 -0.553018 -0.607675 -0.700785
M5 M6 M7 M8 M9 M10
-0.108180 -0.029861 -0.037256 -0.120419 -0.211147 -0.101876
M11 t
0.057395 0.007395
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.69639 -0.35254 0.01618 0.24946 1.14335
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.167593 0.211302 38.654 < 2e-16 ***
x -1.469167 0.174296 -8.429 5.05e-12 ***
M1 -0.302766 0.244681 -1.237 0.22039
M2 -0.553018 0.244540 -2.261 0.02708 *
M3 -0.607675 0.245961 -2.471 0.01612 *
M4 -0.700785 0.245675 -2.852 0.00581 **
M5 -0.108180 0.245427 -0.441 0.66083
M6 -0.029861 0.245219 -0.122 0.90345
M7 -0.037256 0.245050 -0.152 0.87963
M8 -0.120419 0.253869 -0.474 0.63685
M9 -0.211147 0.253735 -0.832 0.40837
M10 -0.101876 0.253639 -0.402 0.68925
M11 0.057395 0.253582 0.226 0.82165
t 0.007395 0.003113 2.376 0.02048 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4392 on 65 degrees of freedom
Multiple R-squared: 0.6694, Adjusted R-squared: 0.6032
F-statistic: 10.12 on 13 and 65 DF, p-value: 3.446e-11
> 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.0022698260 0.0045396520 0.997730174
[2,] 0.0002859880 0.0005719759 0.999714012
[3,] 0.0001824635 0.0003649270 0.999817537
[4,] 0.0013215393 0.0026430785 0.998678461
[5,] 0.0032822705 0.0065645410 0.996717730
[6,] 0.0019410386 0.0038820772 0.998058961
[7,] 0.0006073840 0.0012147680 0.999392616
[8,] 0.0001782510 0.0003565020 0.999821749
[9,] 0.0001648483 0.0003296966 0.999835152
[10,] 0.0305276716 0.0610553432 0.969472328
[11,] 0.2880974577 0.5761949154 0.711902542
[12,] 0.4641898759 0.9283797519 0.535810124
[13,] 0.4585752041 0.9171504081 0.541424796
[14,] 0.6447367202 0.7105265596 0.355263280
[15,] 0.7154964768 0.5690070464 0.284503523
[16,] 0.6590985275 0.6818029450 0.340901472
[17,] 0.8038456538 0.3923086923 0.196154346
[18,] 0.8976893370 0.2046213259 0.102310663
[19,] 0.9436002691 0.1127994618 0.056399731
[20,] 0.9485348221 0.1029303557 0.051465178
[21,] 0.9312072240 0.1375855520 0.068792776
[22,] 0.9576229862 0.0847540275 0.042377014
[23,] 0.9807414927 0.0385170147 0.019258507
[24,] 0.9911096953 0.0177806094 0.008890305
[25,] 0.9924174056 0.0151651888 0.007582594
[26,] 0.9916848332 0.0166303336 0.008315167
[27,] 0.9879806781 0.0240386437 0.012019322
[28,] 0.9855590044 0.0288819911 0.014440996
[29,] 0.9831258699 0.0337482602 0.016874130
[30,] 0.9807614807 0.0384770386 0.019238519
[31,] 0.9745685209 0.0508629582 0.025431479
[32,] 0.9629606798 0.0740786404 0.037039320
[33,] 0.9418382087 0.1163235827 0.058161791
[34,] 0.9121656664 0.1756686672 0.087834334
[35,] 0.8753180494 0.2493639012 0.124681951
[36,] 0.8316733926 0.3366532148 0.168326607
[37,] 0.8345586360 0.3308827281 0.165441364
[38,] 0.8739357328 0.2521285344 0.126064267
[39,] 0.8780779912 0.2438440177 0.121922009
[40,] 0.8636157004 0.2727685992 0.136384300
[41,] 0.8235138950 0.3529722100 0.176486105
[42,] 0.8004528383 0.3990943235 0.199547162
[43,] 0.7868904724 0.4262190552 0.213109528
[44,] 0.7326110568 0.5347778864 0.267388943
[45,] 0.6229933759 0.7540132483 0.377006624
[46,] 0.4498613162 0.8997226325 0.550138684
> postscript(file="/var/www/html/rcomp/tmp/1ako41227549885.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/2b3pb1227549885.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/38hyh1227549885.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/4fuqz1227549885.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/5lgdy1227549885.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 = 79
Frequency = 1
1 2 3 4 5 6
-0.572222222 -0.529365079 -0.682103175 -0.696388889 -0.596388889 -0.582103175
7 8 9 10 11 12
-0.382103175 -0.106335979 0.076997354 0.060330688 -0.006335979 -0.056335979
13 14 15 16 17 18
0.039034392 0.181891534 -0.070846561 0.014867725 0.014867725 0.029153439
19 20 21 22 23 24
0.129153439 0.204920635 0.288253968 0.371587302 0.504920635 0.454920635
25 26 27 28 29 30
0.250291005 -0.306851852 -0.559589947 -0.173875661 0.526124339 0.940410053
31 32 33 34 35 36
0.940410053 0.416177249 -0.000489418 -0.017156085 0.016177249 0.166177249
37 38 39 40 41 42
0.461547619 0.304404762 0.251666667 0.237380952 0.237380952 0.251666667
43 44 45 46 47 48
0.351666667 0.127433862 0.110767196 0.094100529 0.127433862 0.177433862
49 50 51 52 53 54
0.372804233 0.515661376 0.362923280 0.248637566 -0.251362434 -0.437076720
55 56 57 58 59 60
-0.437076720 -0.561309524 -0.477976190 -0.594642857 -0.661309524 -0.611309524
61 62 63 64 65 66
-0.415939153 -0.073082011 1.143346561 0.729060847 0.429060847 0.143346561
67 68 69 70 71 72
-0.156653439 -0.080886243 0.002447090 0.085780423 0.019113757 -0.130886243
73 74 75 76 77 78
-0.135515873 -0.092658730 -0.445396825 -0.359682540 -0.359682540 -0.345396825
79
-0.445396825
> postscript(file="/var/www/html/rcomp/tmp/6fpb21227549885.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 = 79
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.572222222 NA
1 -0.529365079 -0.572222222
2 -0.682103175 -0.529365079
3 -0.696388889 -0.682103175
4 -0.596388889 -0.696388889
5 -0.582103175 -0.596388889
6 -0.382103175 -0.582103175
7 -0.106335979 -0.382103175
8 0.076997354 -0.106335979
9 0.060330688 0.076997354
10 -0.006335979 0.060330688
11 -0.056335979 -0.006335979
12 0.039034392 -0.056335979
13 0.181891534 0.039034392
14 -0.070846561 0.181891534
15 0.014867725 -0.070846561
16 0.014867725 0.014867725
17 0.029153439 0.014867725
18 0.129153439 0.029153439
19 0.204920635 0.129153439
20 0.288253968 0.204920635
21 0.371587302 0.288253968
22 0.504920635 0.371587302
23 0.454920635 0.504920635
24 0.250291005 0.454920635
25 -0.306851852 0.250291005
26 -0.559589947 -0.306851852
27 -0.173875661 -0.559589947
28 0.526124339 -0.173875661
29 0.940410053 0.526124339
30 0.940410053 0.940410053
31 0.416177249 0.940410053
32 -0.000489418 0.416177249
33 -0.017156085 -0.000489418
34 0.016177249 -0.017156085
35 0.166177249 0.016177249
36 0.461547619 0.166177249
37 0.304404762 0.461547619
38 0.251666667 0.304404762
39 0.237380952 0.251666667
40 0.237380952 0.237380952
41 0.251666667 0.237380952
42 0.351666667 0.251666667
43 0.127433862 0.351666667
44 0.110767196 0.127433862
45 0.094100529 0.110767196
46 0.127433862 0.094100529
47 0.177433862 0.127433862
48 0.372804233 0.177433862
49 0.515661376 0.372804233
50 0.362923280 0.515661376
51 0.248637566 0.362923280
52 -0.251362434 0.248637566
53 -0.437076720 -0.251362434
54 -0.437076720 -0.437076720
55 -0.561309524 -0.437076720
56 -0.477976190 -0.561309524
57 -0.594642857 -0.477976190
58 -0.661309524 -0.594642857
59 -0.611309524 -0.661309524
60 -0.415939153 -0.611309524
61 -0.073082011 -0.415939153
62 1.143346561 -0.073082011
63 0.729060847 1.143346561
64 0.429060847 0.729060847
65 0.143346561 0.429060847
66 -0.156653439 0.143346561
67 -0.080886243 -0.156653439
68 0.002447090 -0.080886243
69 0.085780423 0.002447090
70 0.019113757 0.085780423
71 -0.130886243 0.019113757
72 -0.135515873 -0.130886243
73 -0.092658730 -0.135515873
74 -0.445396825 -0.092658730
75 -0.359682540 -0.445396825
76 -0.359682540 -0.359682540
77 -0.345396825 -0.359682540
78 -0.445396825 -0.345396825
79 NA -0.445396825
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.529365079 -0.572222222
[2,] -0.682103175 -0.529365079
[3,] -0.696388889 -0.682103175
[4,] -0.596388889 -0.696388889
[5,] -0.582103175 -0.596388889
[6,] -0.382103175 -0.582103175
[7,] -0.106335979 -0.382103175
[8,] 0.076997354 -0.106335979
[9,] 0.060330688 0.076997354
[10,] -0.006335979 0.060330688
[11,] -0.056335979 -0.006335979
[12,] 0.039034392 -0.056335979
[13,] 0.181891534 0.039034392
[14,] -0.070846561 0.181891534
[15,] 0.014867725 -0.070846561
[16,] 0.014867725 0.014867725
[17,] 0.029153439 0.014867725
[18,] 0.129153439 0.029153439
[19,] 0.204920635 0.129153439
[20,] 0.288253968 0.204920635
[21,] 0.371587302 0.288253968
[22,] 0.504920635 0.371587302
[23,] 0.454920635 0.504920635
[24,] 0.250291005 0.454920635
[25,] -0.306851852 0.250291005
[26,] -0.559589947 -0.306851852
[27,] -0.173875661 -0.559589947
[28,] 0.526124339 -0.173875661
[29,] 0.940410053 0.526124339
[30,] 0.940410053 0.940410053
[31,] 0.416177249 0.940410053
[32,] -0.000489418 0.416177249
[33,] -0.017156085 -0.000489418
[34,] 0.016177249 -0.017156085
[35,] 0.166177249 0.016177249
[36,] 0.461547619 0.166177249
[37,] 0.304404762 0.461547619
[38,] 0.251666667 0.304404762
[39,] 0.237380952 0.251666667
[40,] 0.237380952 0.237380952
[41,] 0.251666667 0.237380952
[42,] 0.351666667 0.251666667
[43,] 0.127433862 0.351666667
[44,] 0.110767196 0.127433862
[45,] 0.094100529 0.110767196
[46,] 0.127433862 0.094100529
[47,] 0.177433862 0.127433862
[48,] 0.372804233 0.177433862
[49,] 0.515661376 0.372804233
[50,] 0.362923280 0.515661376
[51,] 0.248637566 0.362923280
[52,] -0.251362434 0.248637566
[53,] -0.437076720 -0.251362434
[54,] -0.437076720 -0.437076720
[55,] -0.561309524 -0.437076720
[56,] -0.477976190 -0.561309524
[57,] -0.594642857 -0.477976190
[58,] -0.661309524 -0.594642857
[59,] -0.611309524 -0.661309524
[60,] -0.415939153 -0.611309524
[61,] -0.073082011 -0.415939153
[62,] 1.143346561 -0.073082011
[63,] 0.729060847 1.143346561
[64,] 0.429060847 0.729060847
[65,] 0.143346561 0.429060847
[66,] -0.156653439 0.143346561
[67,] -0.080886243 -0.156653439
[68,] 0.002447090 -0.080886243
[69,] 0.085780423 0.002447090
[70,] 0.019113757 0.085780423
[71,] -0.130886243 0.019113757
[72,] -0.135515873 -0.130886243
[73,] -0.092658730 -0.135515873
[74,] -0.445396825 -0.092658730
[75,] -0.359682540 -0.445396825
[76,] -0.359682540 -0.359682540
[77,] -0.345396825 -0.359682540
[78,] -0.445396825 -0.345396825
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.529365079 -0.572222222
2 -0.682103175 -0.529365079
3 -0.696388889 -0.682103175
4 -0.596388889 -0.696388889
5 -0.582103175 -0.596388889
6 -0.382103175 -0.582103175
7 -0.106335979 -0.382103175
8 0.076997354 -0.106335979
9 0.060330688 0.076997354
10 -0.006335979 0.060330688
11 -0.056335979 -0.006335979
12 0.039034392 -0.056335979
13 0.181891534 0.039034392
14 -0.070846561 0.181891534
15 0.014867725 -0.070846561
16 0.014867725 0.014867725
17 0.029153439 0.014867725
18 0.129153439 0.029153439
19 0.204920635 0.129153439
20 0.288253968 0.204920635
21 0.371587302 0.288253968
22 0.504920635 0.371587302
23 0.454920635 0.504920635
24 0.250291005 0.454920635
25 -0.306851852 0.250291005
26 -0.559589947 -0.306851852
27 -0.173875661 -0.559589947
28 0.526124339 -0.173875661
29 0.940410053 0.526124339
30 0.940410053 0.940410053
31 0.416177249 0.940410053
32 -0.000489418 0.416177249
33 -0.017156085 -0.000489418
34 0.016177249 -0.017156085
35 0.166177249 0.016177249
36 0.461547619 0.166177249
37 0.304404762 0.461547619
38 0.251666667 0.304404762
39 0.237380952 0.251666667
40 0.237380952 0.237380952
41 0.251666667 0.237380952
42 0.351666667 0.251666667
43 0.127433862 0.351666667
44 0.110767196 0.127433862
45 0.094100529 0.110767196
46 0.127433862 0.094100529
47 0.177433862 0.127433862
48 0.372804233 0.177433862
49 0.515661376 0.372804233
50 0.362923280 0.515661376
51 0.248637566 0.362923280
52 -0.251362434 0.248637566
53 -0.437076720 -0.251362434
54 -0.437076720 -0.437076720
55 -0.561309524 -0.437076720
56 -0.477976190 -0.561309524
57 -0.594642857 -0.477976190
58 -0.661309524 -0.594642857
59 -0.611309524 -0.661309524
60 -0.415939153 -0.611309524
61 -0.073082011 -0.415939153
62 1.143346561 -0.073082011
63 0.729060847 1.143346561
64 0.429060847 0.729060847
65 0.143346561 0.429060847
66 -0.156653439 0.143346561
67 -0.080886243 -0.156653439
68 0.002447090 -0.080886243
69 0.085780423 0.002447090
70 0.019113757 0.085780423
71 -0.130886243 0.019113757
72 -0.135515873 -0.130886243
73 -0.092658730 -0.135515873
74 -0.445396825 -0.092658730
75 -0.359682540 -0.445396825
76 -0.359682540 -0.359682540
77 -0.345396825 -0.359682540
78 -0.445396825 -0.345396825
> 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/7otj41227549885.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/8pj951227549885.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/9kfme1227549885.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/10fmyu1227549885.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/11b79c1227549886.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/12rjqn1227549886.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/13ei1q1227549886.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/142okg1227549886.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/15jcce1227549886.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/165sum1227549886.tab")
+ }
>
> system("convert tmp/1ako41227549885.ps tmp/1ako41227549885.png")
> system("convert tmp/2b3pb1227549885.ps tmp/2b3pb1227549885.png")
> system("convert tmp/38hyh1227549885.ps tmp/38hyh1227549885.png")
> system("convert tmp/4fuqz1227549885.ps tmp/4fuqz1227549885.png")
> system("convert tmp/5lgdy1227549885.ps tmp/5lgdy1227549885.png")
> system("convert tmp/6fpb21227549885.ps tmp/6fpb21227549885.png")
> system("convert tmp/7otj41227549885.ps tmp/7otj41227549885.png")
> system("convert tmp/8pj951227549885.ps tmp/8pj951227549885.png")
> system("convert tmp/9kfme1227549885.ps tmp/9kfme1227549885.png")
> system("convert tmp/10fmyu1227549885.ps tmp/10fmyu1227549885.png")
>
>
> proc.time()
user system elapsed
5.341 2.738 5.740