R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(129.99
+ ,30
+ ,94
+ ,1
+ ,59.99
+ ,12
+ ,85.5
+ ,0
+ ,49.99
+ ,15
+ ,86
+ ,0
+ ,84.99
+ ,40
+ ,94
+ ,0
+ ,179.99
+ ,512
+ ,109
+ ,1
+ ,329.99
+ ,1500
+ ,118
+ ,1
+ ,25.99
+ ,16
+ ,72
+ ,0
+ ,499.99
+ ,8000
+ ,140
+ ,1
+ ,89.99
+ ,7
+ ,102.8
+ ,0
+ ,119.99
+ ,20
+ ,99.8
+ ,0
+ ,79.99
+ ,128
+ ,80
+ ,1
+ ,199.99
+ ,256
+ ,106
+ ,1
+ ,449.99
+ ,256
+ ,122
+ ,1
+ ,549.99
+ ,4000
+ ,161
+ ,1
+ ,529.99
+ ,8000
+ ,135
+ ,1
+ ,639.99
+ ,16000
+ ,140
+ ,1
+ ,749.99
+ ,32000
+ ,140
+ ,1
+ ,399.99
+ ,130
+ ,135
+ ,1
+ ,169.99
+ ,256
+ ,109
+ ,1
+ ,189.99
+ ,8000
+ ,135
+ ,1
+ ,199.99
+ ,8000
+ ,135
+ ,1
+ ,69.99
+ ,20
+ ,90
+ ,0
+ ,69.99
+ ,20
+ ,90
+ ,0
+ ,109.99
+ ,5
+ ,81
+ ,1
+ ,159.99
+ ,128
+ ,104
+ ,1
+ ,159.99
+ ,128
+ ,104
+ ,1
+ ,199.99
+ ,1000
+ ,135
+ ,1
+ ,75
+ ,30
+ ,81
+ ,0
+ ,349.99
+ ,512
+ ,126
+ ,1
+ ,439.99
+ ,8000
+ ,140
+ ,1
+ ,309.99
+ ,512
+ ,120
+ ,1
+ ,379.99
+ ,512
+ ,120
+ ,1
+ ,349.99
+ ,512
+ ,110
+ ,1
+ ,169.99
+ ,256
+ ,108
+ ,0
+ ,239.99
+ ,192
+ ,120
+ ,1
+ ,229.99
+ ,512
+ ,118
+ ,1
+ ,69.99
+ ,64
+ ,85
+ ,0
+ ,99.99
+ ,20
+ ,94
+ ,0
+ ,29.99
+ ,8
+ ,72.6
+ ,0
+ ,39.99
+ ,12
+ ,78
+ ,0
+ ,21.99
+ ,8
+ ,65
+ ,0
+ ,499.99
+ ,60
+ ,130
+ ,1
+ ,29.99
+ ,1
+ ,70
+ ,0
+ ,29.99
+ ,4
+ ,78.5
+ ,0
+ ,49.99
+ ,32
+ ,93.5
+ ,0
+ ,49.99
+ ,10
+ ,80
+ ,0
+ ,55.99
+ ,10
+ ,78.8
+ ,0
+ ,59.99
+ ,9
+ ,90.3
+ ,0
+ ,79.99
+ ,30
+ ,87.7
+ ,0
+ ,139.99
+ ,51
+ ,107
+ ,0
+ ,159.99
+ ,16000
+ ,90
+ ,0
+ ,169.99
+ ,46
+ ,103
+ ,1
+ ,229.99
+ ,32000
+ ,126
+ ,1
+ ,249.99
+ ,16000
+ ,98
+ ,1
+ ,309.99
+ ,256
+ ,128
+ ,1
+ ,499.99
+ ,16000
+ ,132
+ ,1
+ ,65.99
+ ,7
+ ,94
+ ,0
+ ,89.99
+ ,48
+ ,111
+ ,0
+ ,89.99
+ ,100
+ ,95
+ ,0
+ ,449.99
+ ,16000
+ ,155
+ ,1)
+ ,dim=c(4
+ ,60)
+ ,dimnames=list(c('Prijs'
+ ,'Geheugen'
+ ,'Gewicht'
+ ,'WiFi')
+ ,1:60))
> y <- array(NA,dim=c(4,60),dimnames=list(c('Prijs','Geheugen','Gewicht','WiFi'),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 = 'Do not include Seasonal Dummies'
> par1 = '1'
> library(lattice)
> library(lmtest)
Loading required package: zoo
> 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
Prijs Geheugen Gewicht WiFi
1 129.99 30 94.0 1
2 59.99 12 85.5 0
3 49.99 15 86.0 0
4 84.99 40 94.0 0
5 179.99 512 109.0 1
6 329.99 1500 118.0 1
7 25.99 16 72.0 0
8 499.99 8000 140.0 1
9 89.99 7 102.8 0
10 119.99 20 99.8 0
11 79.99 128 80.0 1
12 199.99 256 106.0 1
13 449.99 256 122.0 1
14 549.99 4000 161.0 1
15 529.99 8000 135.0 1
16 639.99 16000 140.0 1
17 749.99 32000 140.0 1
18 399.99 130 135.0 1
19 169.99 256 109.0 1
20 189.99 8000 135.0 1
21 199.99 8000 135.0 1
22 69.99 20 90.0 0
23 69.99 20 90.0 0
24 109.99 5 81.0 1
25 159.99 128 104.0 1
26 159.99 128 104.0 1
27 199.99 1000 135.0 1
28 75.00 30 81.0 0
29 349.99 512 126.0 1
30 439.99 8000 140.0 1
31 309.99 512 120.0 1
32 379.99 512 120.0 1
33 349.99 512 110.0 1
34 169.99 256 108.0 0
35 239.99 192 120.0 1
36 229.99 512 118.0 1
37 69.99 64 85.0 0
38 99.99 20 94.0 0
39 29.99 8 72.6 0
40 39.99 12 78.0 0
41 21.99 8 65.0 0
42 499.99 60 130.0 1
43 29.99 1 70.0 0
44 29.99 4 78.5 0
45 49.99 32 93.5 0
46 49.99 10 80.0 0
47 55.99 10 78.8 0
48 59.99 9 90.3 0
49 79.99 30 87.7 0
50 139.99 51 107.0 0
51 159.99 16000 90.0 0
52 169.99 46 103.0 1
53 229.99 32000 126.0 1
54 249.99 16000 98.0 1
55 309.99 256 128.0 1
56 499.99 16000 132.0 1
57 65.99 7 94.0 0
58 89.99 48 111.0 0
59 89.99 100 95.0 0
60 449.99 16000 155.0 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Geheugen Gewicht WiFi
-3.521e+02 4.917e-03 4.793e+00 6.555e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-244.679 -34.905 1.797 35.288 208.220
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.521e+02 6.648e+01 -5.297 2.05e-06 ***
Geheugen 4.917e-03 1.748e-03 2.812 0.00677 **
Gewicht 4.793e+00 7.352e-01 6.519 2.15e-08 ***
WiFi 6.555e+01 3.196e+01 2.051 0.04498 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 85.23 on 56 degrees of freedom
Multiple R-squared: 0.7793, Adjusted R-squared: 0.7675
F-statistic: 65.92 on 3 and 56 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.0070592761 0.014118552 0.99294072
[2,] 0.0436212167 0.087242433 0.95637878
[3,] 0.0207793490 0.041558698 0.97922065
[4,] 0.0076021532 0.015204306 0.99239785
[5,] 0.0026116309 0.005223262 0.99738837
[6,] 0.0007861251 0.001572250 0.99921387
[7,] 0.0671003040 0.134200608 0.93289970
[8,] 0.0424273411 0.084854682 0.95757266
[9,] 0.0365808017 0.073161603 0.96341920
[10,] 0.0336014167 0.067202833 0.96639858
[11,] 0.1097225326 0.219445065 0.89027747
[12,] 0.0773193262 0.154638652 0.92268067
[13,] 0.0963779463 0.192755893 0.90362205
[14,] 0.8686690752 0.262661850 0.13133092
[15,] 0.9890424220 0.021915156 0.01095758
[16,] 0.9817011423 0.036597715 0.01829886
[17,] 0.9706352347 0.058729531 0.02936477
[18,] 0.9568143133 0.086371373 0.04318569
[19,] 0.9495468474 0.100906305 0.05045315
[20,] 0.9456121281 0.108775744 0.05438787
[21,] 0.9890229279 0.021954144 0.01097707
[22,] 0.9832682727 0.033463455 0.01673173
[23,] 0.9756619206 0.048676159 0.02433808
[24,] 0.9653730870 0.069253826 0.03462691
[25,] 0.9496477724 0.100704455 0.05035223
[26,] 0.9526788473 0.094642305 0.04732115
[27,] 0.9622681050 0.075463790 0.03773190
[28,] 0.9434052186 0.113189563 0.05659478
[29,] 0.9345799588 0.130840082 0.06542004
[30,] 0.9363867781 0.127226444 0.06361322
[31,] 0.9058141010 0.188371798 0.09418590
[32,] 0.8645778376 0.270844325 0.13542216
[33,] 0.8146742900 0.370651420 0.18532571
[34,] 0.7507071751 0.498585650 0.24929282
[35,] 0.6965919113 0.606816177 0.30340809
[36,] 0.9069270882 0.186145824 0.09307291
[37,] 0.8686670758 0.262665848 0.13133292
[38,] 0.8088519502 0.382296100 0.19114805
[39,] 0.7550135467 0.489972907 0.24498645
[40,] 0.6687998904 0.662400219 0.33120011
[41,] 0.5785918684 0.842816263 0.42140813
[42,] 0.4722614838 0.944522968 0.52773852
[43,] 0.3652574268 0.730514854 0.63474257
[44,] 0.2600661393 0.520132279 0.73993386
[45,] 0.2815342015 0.563068403 0.71846580
[46,] 0.2729325903 0.545865181 0.72706741
[47,] 0.6464569015 0.707086197 0.35354310
> postscript(file="/var/wessaorg/rcomp/tmp/1cba21321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2tobh1321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/335tf1321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4qa2n1321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5hjzf1321992703.ps",horizontal=F,onefile=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
-34.100971 2.279600 -10.131604 -13.597777 -58.364675 43.640909
7 8 9 10 11 12
32.964149 76.234688 -50.613071 -6.298280 -17.482193 -22.727136
13 14 15 16 17 18
150.586383 45.252796 130.199213 176.896461 208.220007 38.898194
19 20 21 22 23 24
-67.105852 -209.800787 -199.800787 -9.327811 -9.327811 8.329727
25 26 27 28 29 30
-52.511915 -52.511915 -165.379838 38.769162 30.155939 16.234688
31 32 33 34 35 36
18.913370 88.913370 106.842420 3.239420 -49.513101 -51.500820
37 38 39 40 41 42
14.420354 1.500569 34.127744 18.226388 62.553823 163.206929
43 44 45 46 47 48
46.623718 5.869274 -46.161986 18.650412 30.401898 -20.711592
49 50 51 52 53 54
11.646698 -20.959632 2.094081 -37.315793 -244.679322 -11.801527
55 56 57 58 59 60
-18.171048 75.239701 -32.435506 -90.116501 -13.685718 -84.997115
> postscript(file="/var/wessaorg/rcomp/tmp/6cvb81321992703.ps",horizontal=F,onefile=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 -34.100971 NA
1 2.279600 -34.100971
2 -10.131604 2.279600
3 -13.597777 -10.131604
4 -58.364675 -13.597777
5 43.640909 -58.364675
6 32.964149 43.640909
7 76.234688 32.964149
8 -50.613071 76.234688
9 -6.298280 -50.613071
10 -17.482193 -6.298280
11 -22.727136 -17.482193
12 150.586383 -22.727136
13 45.252796 150.586383
14 130.199213 45.252796
15 176.896461 130.199213
16 208.220007 176.896461
17 38.898194 208.220007
18 -67.105852 38.898194
19 -209.800787 -67.105852
20 -199.800787 -209.800787
21 -9.327811 -199.800787
22 -9.327811 -9.327811
23 8.329727 -9.327811
24 -52.511915 8.329727
25 -52.511915 -52.511915
26 -165.379838 -52.511915
27 38.769162 -165.379838
28 30.155939 38.769162
29 16.234688 30.155939
30 18.913370 16.234688
31 88.913370 18.913370
32 106.842420 88.913370
33 3.239420 106.842420
34 -49.513101 3.239420
35 -51.500820 -49.513101
36 14.420354 -51.500820
37 1.500569 14.420354
38 34.127744 1.500569
39 18.226388 34.127744
40 62.553823 18.226388
41 163.206929 62.553823
42 46.623718 163.206929
43 5.869274 46.623718
44 -46.161986 5.869274
45 18.650412 -46.161986
46 30.401898 18.650412
47 -20.711592 30.401898
48 11.646698 -20.711592
49 -20.959632 11.646698
50 2.094081 -20.959632
51 -37.315793 2.094081
52 -244.679322 -37.315793
53 -11.801527 -244.679322
54 -18.171048 -11.801527
55 75.239701 -18.171048
56 -32.435506 75.239701
57 -90.116501 -32.435506
58 -13.685718 -90.116501
59 -84.997115 -13.685718
60 NA -84.997115
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 2.279600 -34.100971
[2,] -10.131604 2.279600
[3,] -13.597777 -10.131604
[4,] -58.364675 -13.597777
[5,] 43.640909 -58.364675
[6,] 32.964149 43.640909
[7,] 76.234688 32.964149
[8,] -50.613071 76.234688
[9,] -6.298280 -50.613071
[10,] -17.482193 -6.298280
[11,] -22.727136 -17.482193
[12,] 150.586383 -22.727136
[13,] 45.252796 150.586383
[14,] 130.199213 45.252796
[15,] 176.896461 130.199213
[16,] 208.220007 176.896461
[17,] 38.898194 208.220007
[18,] -67.105852 38.898194
[19,] -209.800787 -67.105852
[20,] -199.800787 -209.800787
[21,] -9.327811 -199.800787
[22,] -9.327811 -9.327811
[23,] 8.329727 -9.327811
[24,] -52.511915 8.329727
[25,] -52.511915 -52.511915
[26,] -165.379838 -52.511915
[27,] 38.769162 -165.379838
[28,] 30.155939 38.769162
[29,] 16.234688 30.155939
[30,] 18.913370 16.234688
[31,] 88.913370 18.913370
[32,] 106.842420 88.913370
[33,] 3.239420 106.842420
[34,] -49.513101 3.239420
[35,] -51.500820 -49.513101
[36,] 14.420354 -51.500820
[37,] 1.500569 14.420354
[38,] 34.127744 1.500569
[39,] 18.226388 34.127744
[40,] 62.553823 18.226388
[41,] 163.206929 62.553823
[42,] 46.623718 163.206929
[43,] 5.869274 46.623718
[44,] -46.161986 5.869274
[45,] 18.650412 -46.161986
[46,] 30.401898 18.650412
[47,] -20.711592 30.401898
[48,] 11.646698 -20.711592
[49,] -20.959632 11.646698
[50,] 2.094081 -20.959632
[51,] -37.315793 2.094081
[52,] -244.679322 -37.315793
[53,] -11.801527 -244.679322
[54,] -18.171048 -11.801527
[55,] 75.239701 -18.171048
[56,] -32.435506 75.239701
[57,] -90.116501 -32.435506
[58,] -13.685718 -90.116501
[59,] -84.997115 -13.685718
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 2.279600 -34.100971
2 -10.131604 2.279600
3 -13.597777 -10.131604
4 -58.364675 -13.597777
5 43.640909 -58.364675
6 32.964149 43.640909
7 76.234688 32.964149
8 -50.613071 76.234688
9 -6.298280 -50.613071
10 -17.482193 -6.298280
11 -22.727136 -17.482193
12 150.586383 -22.727136
13 45.252796 150.586383
14 130.199213 45.252796
15 176.896461 130.199213
16 208.220007 176.896461
17 38.898194 208.220007
18 -67.105852 38.898194
19 -209.800787 -67.105852
20 -199.800787 -209.800787
21 -9.327811 -199.800787
22 -9.327811 -9.327811
23 8.329727 -9.327811
24 -52.511915 8.329727
25 -52.511915 -52.511915
26 -165.379838 -52.511915
27 38.769162 -165.379838
28 30.155939 38.769162
29 16.234688 30.155939
30 18.913370 16.234688
31 88.913370 18.913370
32 106.842420 88.913370
33 3.239420 106.842420
34 -49.513101 3.239420
35 -51.500820 -49.513101
36 14.420354 -51.500820
37 1.500569 14.420354
38 34.127744 1.500569
39 18.226388 34.127744
40 62.553823 18.226388
41 163.206929 62.553823
42 46.623718 163.206929
43 5.869274 46.623718
44 -46.161986 5.869274
45 18.650412 -46.161986
46 30.401898 18.650412
47 -20.711592 30.401898
48 11.646698 -20.711592
49 -20.959632 11.646698
50 2.094081 -20.959632
51 -37.315793 2.094081
52 -244.679322 -37.315793
53 -11.801527 -244.679322
54 -18.171048 -11.801527
55 75.239701 -18.171048
56 -32.435506 75.239701
57 -90.116501 -32.435506
58 -13.685718 -90.116501
59 -84.997115 -13.685718
> 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/wessaorg/rcomp/tmp/7s4is1321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/8qo131321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/90b5t1321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10zga31321992703.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11l4ic1321992703.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/wessaorg/rcomp/tmp/12flzx1321992703.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/wessaorg/rcomp/tmp/134zdg1321992704.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/wessaorg/rcomp/tmp/14uopn1321992704.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/wessaorg/rcomp/tmp/15t8gj1321992704.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/wessaorg/rcomp/tmp/16wimw1321992704.tab")
+ }
>
> try(system("convert tmp/1cba21321992703.ps tmp/1cba21321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/2tobh1321992703.ps tmp/2tobh1321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/335tf1321992703.ps tmp/335tf1321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/4qa2n1321992703.ps tmp/4qa2n1321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/5hjzf1321992703.ps tmp/5hjzf1321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/6cvb81321992703.ps tmp/6cvb81321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/7s4is1321992703.ps tmp/7s4is1321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/8qo131321992703.ps tmp/8qo131321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/90b5t1321992703.ps tmp/90b5t1321992703.png",intern=TRUE))
character(0)
> try(system("convert tmp/10zga31321992703.ps tmp/10zga31321992703.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.334 0.494 3.899