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(1217
+ ,1210
+ ,31.00
+ ,48
+ ,961.00
+ ,2304
+ ,19.00
+ ,30.00
+ ,1488.00
+ ,10
+ ,0
+ ,1202
+ ,1209
+ ,34.40
+ ,38
+ ,1183.36
+ ,1444
+ ,18.30
+ ,29.95
+ ,1307.20
+ ,10
+ ,0
+ ,1180
+ ,1207
+ ,35.60
+ ,37
+ ,1267.36
+ ,1369
+ ,18.90
+ ,29.94
+ ,1317.20
+ ,10
+ ,0
+ ,1167
+ ,1206
+ ,32.80
+ ,48
+ ,1075.84
+ ,2304
+ ,20.60
+ ,29.83
+ ,1574.40
+ ,10
+ ,0
+ ,1186
+ ,1204
+ ,23.30
+ ,81
+ ,542.89
+ ,6561
+ ,20.00
+ ,29.85
+ ,1887.30
+ ,9
+ ,1
+ ,1168
+ ,1201
+ ,20.00
+ ,58
+ ,400.00
+ ,3364
+ ,11.76
+ ,29.92
+ ,1160.00
+ ,10
+ ,1
+ ,1142
+ ,1199
+ ,16.70
+ ,93
+ ,278.89
+ ,8649
+ ,15.60
+ ,29.95
+ ,1553.10
+ ,6
+ ,1
+ ,1147
+ ,1198
+ ,17.80
+ ,86
+ ,316.84
+ ,7396
+ ,15.60
+ ,29.94
+ ,1530.80
+ ,10
+ ,0
+ ,1183
+ ,1196
+ ,21.20
+ ,68
+ ,449.44
+ ,4624
+ ,15.80
+ ,29.94
+ ,1441.60
+ ,10
+ ,0
+ ,1149
+ ,1195
+ ,23.90
+ ,68
+ ,571.21
+ ,4624
+ ,17.80
+ ,30.00
+ ,1625.20
+ ,10
+ ,0
+ ,1197
+ ,1193
+ ,28.80
+ ,68
+ ,829.44
+ ,4624
+ ,16.70
+ ,30.03
+ ,1958.40
+ ,10
+ ,0
+ ,1210
+ ,1191
+ ,25.60
+ ,59
+ ,655.36
+ ,3481
+ ,17.20
+ ,29.99
+ ,1510.40
+ ,10
+ ,0
+ ,1206
+ ,1190
+ ,29.40
+ ,43
+ ,864.36
+ ,1849
+ ,15.60
+ ,29.89
+ ,1264.20
+ ,10
+ ,0
+ ,1196
+ ,1188
+ ,22.80
+ ,59
+ ,519.84
+ ,3481
+ ,14.40
+ ,29.98
+ ,1345.20
+ ,6
+ ,0
+ ,1190
+ ,1187
+ ,16.10
+ ,31
+ ,259.21
+ ,961
+ ,-0.60
+ ,30.26
+ ,499.10
+ ,10
+ ,0
+ ,1175
+ ,1185
+ ,16.10
+ ,49
+ ,259.21
+ ,2401
+ ,5.60
+ ,30.26
+ ,788.90
+ ,10
+ ,0
+ ,1186
+ ,1183
+ ,20.00
+ ,52
+ ,400.00
+ ,2704
+ ,10.08
+ ,30.23
+ ,1040.00
+ ,10
+ ,0
+ ,1172
+ ,1182
+ ,20.60
+ ,75
+ ,424.36
+ ,5625
+ ,16.10
+ ,30.16
+ ,1545.00
+ ,10
+ ,0
+ ,1152
+ ,1185
+ ,18.30
+ ,90
+ ,334.89
+ ,8100
+ ,16.70
+ ,30.00
+ ,1647.00
+ ,10
+ ,1
+ ,1154
+ ,1179
+ ,21.60
+ ,86
+ ,466.56
+ ,7396
+ ,18.30
+ ,30.60
+ ,1857.60
+ ,8
+ ,1
+ ,1168
+ ,1177
+ ,22.80
+ ,87
+ ,519.84
+ ,7569
+ ,20.60
+ ,30.00
+ ,1983.60
+ ,10
+ ,0
+ ,1180
+ ,1175
+ ,22.80
+ ,47
+ ,519.84
+ ,2209
+ ,11.10
+ ,30.06
+ ,1071.60
+ ,10
+ ,0
+ ,1169
+ ,1174
+ ,17.20
+ ,70
+ ,295.84
+ ,4900
+ ,11.70
+ ,30.01
+ ,1204.00
+ ,10
+ ,0
+ ,1166
+ ,1170
+ ,22.20
+ ,61
+ ,492.84
+ ,3721
+ ,14.40
+ ,29.86
+ ,1354.20
+ ,10
+ ,0
+ ,1177
+ ,1169
+ ,20.60
+ ,48
+ ,424.36
+ ,2304
+ ,9.40
+ ,29.82
+ ,988.80
+ ,10
+ ,0
+ ,1168
+ ,1167
+ ,18.30
+ ,67
+ ,334.89
+ ,4489
+ ,12.20
+ ,29.83
+ ,1226.10
+ ,10
+ ,0
+ ,1160
+ ,1166
+ ,16.70
+ ,74
+ ,278.89
+ ,5476
+ ,12.20
+ ,29.83
+ ,1235.80
+ ,10
+ ,0
+ ,1147
+ ,1164
+ ,22.80
+ ,55
+ ,519.84
+ ,3025
+ ,13.30
+ ,29.71
+ ,1254.00
+ ,10
+ ,1
+ ,1161
+ ,1162
+ ,13.90
+ ,47
+ ,193.21
+ ,2209
+ ,2.80
+ ,29.98
+ ,653.30
+ ,10
+ ,0
+ ,1143
+ ,1161
+ ,10.00
+ ,65
+ ,100.00
+ ,4225
+ ,3.90
+ ,30.18
+ ,650.00
+ ,10
+ ,0
+ ,1161
+ ,1159
+ ,16.10
+ ,28
+ ,259.21
+ ,784
+ ,-2.20
+ ,30.88
+ ,450.80
+ ,10
+ ,0
+ ,1161
+ ,1158
+ ,20.60
+ ,30
+ ,424.36
+ ,900
+ ,5.00
+ ,30.13
+ ,618.00
+ ,10
+ ,0
+ ,1168
+ ,1156
+ ,19.40
+ ,67
+ ,376.36
+ ,4489
+ ,13.30
+ ,30.24
+ ,1299.80
+ ,10
+ ,0
+ ,1172
+ ,1155
+ ,25.60
+ ,32
+ ,655.36
+ ,1024
+ ,7.80
+ ,30.24
+ ,819.20
+ ,10
+ ,0)
+ ,dim=c(11
+ ,34)
+ ,dimnames=list(c('Time'
+ ,'Sunset'
+ ,'T'
+ ,'H'
+ ,'T^2'
+ ,'H^2'
+ ,'Dewpoint'
+ ,'Pressure'
+ ,'TxH'
+ ,'Visibility'
+ ,'Rain')
+ ,1:34))
> y <- array(NA,dim=c(11,34),dimnames=list(c('Time','Sunset','T','H','T^2','H^2','Dewpoint','Pressure','TxH','Visibility','Rain'),1:34))
> 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'
> #'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
> 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
Time Sunset T H T^2 H^2 Dewpoint Pressure TxH Visibility Rain
1 1217 1210 31.0 48 961.00 2304 19.00 30.00 1488.0 10 0
2 1202 1209 34.4 38 1183.36 1444 18.30 29.95 1307.2 10 0
3 1180 1207 35.6 37 1267.36 1369 18.90 29.94 1317.2 10 0
4 1167 1206 32.8 48 1075.84 2304 20.60 29.83 1574.4 10 0
5 1186 1204 23.3 81 542.89 6561 20.00 29.85 1887.3 9 1
6 1168 1201 20.0 58 400.00 3364 11.76 29.92 1160.0 10 1
7 1142 1199 16.7 93 278.89 8649 15.60 29.95 1553.1 6 1
8 1147 1198 17.8 86 316.84 7396 15.60 29.94 1530.8 10 0
9 1183 1196 21.2 68 449.44 4624 15.80 29.94 1441.6 10 0
10 1149 1195 23.9 68 571.21 4624 17.80 30.00 1625.2 10 0
11 1197 1193 28.8 68 829.44 4624 16.70 30.03 1958.4 10 0
12 1210 1191 25.6 59 655.36 3481 17.20 29.99 1510.4 10 0
13 1206 1190 29.4 43 864.36 1849 15.60 29.89 1264.2 10 0
14 1196 1188 22.8 59 519.84 3481 14.40 29.98 1345.2 6 0
15 1190 1187 16.1 31 259.21 961 -0.60 30.26 499.1 10 0
16 1175 1185 16.1 49 259.21 2401 5.60 30.26 788.9 10 0
17 1186 1183 20.0 52 400.00 2704 10.08 30.23 1040.0 10 0
18 1172 1182 20.6 75 424.36 5625 16.10 30.16 1545.0 10 0
19 1152 1185 18.3 90 334.89 8100 16.70 30.00 1647.0 10 1
20 1154 1179 21.6 86 466.56 7396 18.30 30.60 1857.6 8 1
21 1168 1177 22.8 87 519.84 7569 20.60 30.00 1983.6 10 0
22 1180 1175 22.8 47 519.84 2209 11.10 30.06 1071.6 10 0
23 1169 1174 17.2 70 295.84 4900 11.70 30.01 1204.0 10 0
24 1166 1170 22.2 61 492.84 3721 14.40 29.86 1354.2 10 0
25 1177 1169 20.6 48 424.36 2304 9.40 29.82 988.8 10 0
26 1168 1167 18.3 67 334.89 4489 12.20 29.83 1226.1 10 0
27 1160 1166 16.7 74 278.89 5476 12.20 29.83 1235.8 10 0
28 1147 1164 22.8 55 519.84 3025 13.30 29.71 1254.0 10 1
29 1161 1162 13.9 47 193.21 2209 2.80 29.98 653.3 10 0
30 1143 1161 10.0 65 100.00 4225 3.90 30.18 650.0 10 0
31 1161 1159 16.1 28 259.21 784 -2.20 30.88 450.8 10 0
32 1161 1158 20.6 30 424.36 900 5.00 30.13 618.0 10 0
33 1168 1156 19.4 67 376.36 4489 13.30 30.24 1299.8 10 0
34 1172 1155 25.6 32 655.36 1024 7.80 30.24 819.2 10 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Sunset T H `T^2` `H^2`
334.09899 0.51879 6.68021 1.48097 -0.10690 -0.01409
Dewpoint Pressure TxH Visibility Rain
-2.03630 4.19326 0.01636 -1.83300 -13.74039
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-37.001 -6.111 0.850 5.819 21.633
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 334.09899 618.21133 0.540 0.594
Sunset 0.51879 0.22431 2.313 0.030 *
T 6.68021 7.47096 0.894 0.380
H 1.48097 2.27979 0.650 0.522
`T^2` -0.10690 0.09017 -1.186 0.248
`H^2` -0.01409 0.01007 -1.400 0.175
Dewpoint -2.03630 2.97767 -0.684 0.501
Pressure 4.19326 15.01778 0.279 0.783
TxH 0.01636 0.04812 0.340 0.737
Visibility -1.83300 2.89324 -0.634 0.533
Rain -13.74039 8.02893 -1.711 0.100
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 14.36 on 23 degrees of freedom
Multiple R-squared: 0.6231, Adjusted R-squared: 0.4593
F-statistic: 3.803 on 10 and 23 DF, p-value: 0.003894
> 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.9998655 0.0002690597 0.0001345298
[2,] 0.9997806 0.0004387155 0.0002193578
[3,] 0.9993728 0.0012544650 0.0006272325
[4,] 0.9983771 0.0032457989 0.0016228995
[5,] 0.9938998 0.0122003008 0.0061001504
[6,] 0.9835353 0.0329293400 0.0164646700
[7,] 0.9508088 0.0983824399 0.0491912200
> postscript(file="/var/wessaorg/rcomp/tmp/1nwnd1331156961.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/2ili91331156961.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/30wee1331156961.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/4fxun1331156961.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/5qap41331156961.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 = 34
Frequency = 1
1 2 3 4 5
19.071067286 10.080046045 -8.394752394 -26.044009515 17.082219874
6 7 8 9 10
-6.923227781 -6.216422461 -17.280504084 0.681526160 -37.001086757
11 12 13 14 15
-0.907450688 21.633457180 16.996097754 3.117698742 9.941976889
16 17 18 19 20
-2.501317700 3.501991531 0.007541233 10.877831065 -2.343662499
21 22 23 24 25
6.394287619 -1.538756358 4.567196878 -8.314219453 1.820347017
26 27 28 29 30
4.087734320 4.691273487 -12.476738198 1.018755704 2.832362938
31 32 33 34
-7.651000706 -5.794461289 6.194573678 -1.210375516
> postscript(file="/var/wessaorg/rcomp/tmp/6a1ev1331156961.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 = 34
Frequency = 1
lag(myerror, k = 1) myerror
0 19.071067286 NA
1 10.080046045 19.071067286
2 -8.394752394 10.080046045
3 -26.044009515 -8.394752394
4 17.082219874 -26.044009515
5 -6.923227781 17.082219874
6 -6.216422461 -6.923227781
7 -17.280504084 -6.216422461
8 0.681526160 -17.280504084
9 -37.001086757 0.681526160
10 -0.907450688 -37.001086757
11 21.633457180 -0.907450688
12 16.996097754 21.633457180
13 3.117698742 16.996097754
14 9.941976889 3.117698742
15 -2.501317700 9.941976889
16 3.501991531 -2.501317700
17 0.007541233 3.501991531
18 10.877831065 0.007541233
19 -2.343662499 10.877831065
20 6.394287619 -2.343662499
21 -1.538756358 6.394287619
22 4.567196878 -1.538756358
23 -8.314219453 4.567196878
24 1.820347017 -8.314219453
25 4.087734320 1.820347017
26 4.691273487 4.087734320
27 -12.476738198 4.691273487
28 1.018755704 -12.476738198
29 2.832362938 1.018755704
30 -7.651000706 2.832362938
31 -5.794461289 -7.651000706
32 6.194573678 -5.794461289
33 -1.210375516 6.194573678
34 NA -1.210375516
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 10.080046045 19.071067286
[2,] -8.394752394 10.080046045
[3,] -26.044009515 -8.394752394
[4,] 17.082219874 -26.044009515
[5,] -6.923227781 17.082219874
[6,] -6.216422461 -6.923227781
[7,] -17.280504084 -6.216422461
[8,] 0.681526160 -17.280504084
[9,] -37.001086757 0.681526160
[10,] -0.907450688 -37.001086757
[11,] 21.633457180 -0.907450688
[12,] 16.996097754 21.633457180
[13,] 3.117698742 16.996097754
[14,] 9.941976889 3.117698742
[15,] -2.501317700 9.941976889
[16,] 3.501991531 -2.501317700
[17,] 0.007541233 3.501991531
[18,] 10.877831065 0.007541233
[19,] -2.343662499 10.877831065
[20,] 6.394287619 -2.343662499
[21,] -1.538756358 6.394287619
[22,] 4.567196878 -1.538756358
[23,] -8.314219453 4.567196878
[24,] 1.820347017 -8.314219453
[25,] 4.087734320 1.820347017
[26,] 4.691273487 4.087734320
[27,] -12.476738198 4.691273487
[28,] 1.018755704 -12.476738198
[29,] 2.832362938 1.018755704
[30,] -7.651000706 2.832362938
[31,] -5.794461289 -7.651000706
[32,] 6.194573678 -5.794461289
[33,] -1.210375516 6.194573678
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 10.080046045 19.071067286
2 -8.394752394 10.080046045
3 -26.044009515 -8.394752394
4 17.082219874 -26.044009515
5 -6.923227781 17.082219874
6 -6.216422461 -6.923227781
7 -17.280504084 -6.216422461
8 0.681526160 -17.280504084
9 -37.001086757 0.681526160
10 -0.907450688 -37.001086757
11 21.633457180 -0.907450688
12 16.996097754 21.633457180
13 3.117698742 16.996097754
14 9.941976889 3.117698742
15 -2.501317700 9.941976889
16 3.501991531 -2.501317700
17 0.007541233 3.501991531
18 10.877831065 0.007541233
19 -2.343662499 10.877831065
20 6.394287619 -2.343662499
21 -1.538756358 6.394287619
22 4.567196878 -1.538756358
23 -8.314219453 4.567196878
24 1.820347017 -8.314219453
25 4.087734320 1.820347017
26 4.691273487 4.087734320
27 -12.476738198 4.691273487
28 1.018755704 -12.476738198
29 2.832362938 1.018755704
30 -7.651000706 2.832362938
31 -5.794461289 -7.651000706
32 6.194573678 -5.794461289
33 -1.210375516 6.194573678
> 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/7uunu1331156961.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/80rsn1331156961.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/9nf161331156961.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/101jf21331156961.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/11gugw1331156961.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/12sbji1331156961.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/13l9mw1331156961.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/14a1r51331156961.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/15wezw1331156961.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/166rkt1331156961.tab")
+ }
>
> try(system("convert tmp/1nwnd1331156961.ps tmp/1nwnd1331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/2ili91331156961.ps tmp/2ili91331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/30wee1331156961.ps tmp/30wee1331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/4fxun1331156961.ps tmp/4fxun1331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/5qap41331156961.ps tmp/5qap41331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/6a1ev1331156961.ps tmp/6a1ev1331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/7uunu1331156961.ps tmp/7uunu1331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/80rsn1331156961.ps tmp/80rsn1331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/9nf161331156961.ps tmp/9nf161331156961.png",intern=TRUE))
character(0)
> try(system("convert tmp/101jf21331156961.ps tmp/101jf21331156961.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.069 0.642 3.718