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(277051
+ ,1
+ ,277838
+ ,276610
+ ,277026
+ ,1
+ ,277051
+ ,277838
+ ,274960
+ ,1
+ ,277026
+ ,277051
+ ,270073
+ ,1
+ ,274960
+ ,277026
+ ,267063
+ ,1
+ ,270073
+ ,274960
+ ,264916
+ ,1
+ ,267063
+ ,270073
+ ,287182
+ ,1
+ ,264916
+ ,267063
+ ,291109
+ ,1
+ ,287182
+ ,264916
+ ,292223
+ ,1
+ ,291109
+ ,287182
+ ,288109
+ ,1
+ ,292223
+ ,291109
+ ,281400
+ ,1
+ ,288109
+ ,292223
+ ,282579
+ ,1
+ ,281400
+ ,288109
+ ,280113
+ ,1
+ ,282579
+ ,281400
+ ,280331
+ ,1
+ ,280113
+ ,282579
+ ,276759
+ ,1
+ ,280331
+ ,280113
+ ,275139
+ ,1
+ ,276759
+ ,280331
+ ,274275
+ ,1
+ ,275139
+ ,276759
+ ,271234
+ ,1
+ ,274275
+ ,275139
+ ,289725
+ ,1
+ ,271234
+ ,274275
+ ,290649
+ ,1
+ ,289725
+ ,271234
+ ,292223
+ ,1
+ ,290649
+ ,289725
+ ,278429
+ ,0
+ ,292223
+ ,290649
+ ,269749
+ ,0
+ ,278429
+ ,292223
+ ,265784
+ ,0
+ ,269749
+ ,278429
+ ,268957
+ ,0
+ ,265784
+ ,269749
+ ,264099
+ ,0
+ ,268957
+ ,265784
+ ,255121
+ ,0
+ ,264099
+ ,268957
+ ,253276
+ ,0
+ ,255121
+ ,264099
+ ,245980
+ ,0
+ ,253276
+ ,255121
+ ,235295
+ ,0
+ ,245980
+ ,253276
+ ,258479
+ ,0
+ ,235295
+ ,245980
+ ,260916
+ ,0
+ ,258479
+ ,235295
+ ,254586
+ ,0
+ ,260916
+ ,258479
+ ,250566
+ ,0
+ ,254586
+ ,260916
+ ,243345
+ ,0
+ ,250566
+ ,254586
+ ,247028
+ ,0
+ ,243345
+ ,250566
+ ,248464
+ ,0
+ ,247028
+ ,243345
+ ,244962
+ ,0
+ ,248464
+ ,247028
+ ,237003
+ ,0
+ ,244962
+ ,248464
+ ,237008
+ ,0
+ ,237003
+ ,244962
+ ,225477
+ ,0
+ ,237008
+ ,237003
+ ,226762
+ ,0
+ ,225477
+ ,237008
+ ,247857
+ ,0
+ ,226762
+ ,225477
+ ,248256
+ ,0
+ ,247857
+ ,226762
+ ,246892
+ ,0
+ ,248256
+ ,247857
+ ,245021
+ ,0
+ ,246892
+ ,248256
+ ,246186
+ ,0
+ ,245021
+ ,246892
+ ,255688
+ ,0
+ ,246186
+ ,245021
+ ,264242
+ ,0
+ ,255688
+ ,246186
+ ,268270
+ ,0
+ ,264242
+ ,255688
+ ,272969
+ ,0
+ ,268270
+ ,264242
+ ,273886
+ ,0
+ ,272969
+ ,268270
+ ,267353
+ ,0
+ ,273886
+ ,272969
+ ,271916
+ ,0
+ ,267353
+ ,273886
+ ,292633
+ ,0
+ ,271916
+ ,267353
+ ,295804
+ ,0
+ ,292633
+ ,271916
+ ,293222
+ ,0
+ ,295804
+ ,292633)
+ ,dim=c(4
+ ,57)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2')
+ ,1:57))
> y <- array(NA,dim=c(4,57),dimnames=list(c('Y','X','Y1','Y2'),1:57))
> 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 Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 277051 1 277838 276610 1 0 0 0 0 0 0 0 0 0 0 1
2 277026 1 277051 277838 0 1 0 0 0 0 0 0 0 0 0 2
3 274960 1 277026 277051 0 0 1 0 0 0 0 0 0 0 0 3
4 270073 1 274960 277026 0 0 0 1 0 0 0 0 0 0 0 4
5 267063 1 270073 274960 0 0 0 0 1 0 0 0 0 0 0 5
6 264916 1 267063 270073 0 0 0 0 0 1 0 0 0 0 0 6
7 287182 1 264916 267063 0 0 0 0 0 0 1 0 0 0 0 7
8 291109 1 287182 264916 0 0 0 0 0 0 0 1 0 0 0 8
9 292223 1 291109 287182 0 0 0 0 0 0 0 0 1 0 0 9
10 288109 1 292223 291109 0 0 0 0 0 0 0 0 0 1 0 10
11 281400 1 288109 292223 0 0 0 0 0 0 0 0 0 0 1 11
12 282579 1 281400 288109 0 0 0 0 0 0 0 0 0 0 0 12
13 280113 1 282579 281400 1 0 0 0 0 0 0 0 0 0 0 13
14 280331 1 280113 282579 0 1 0 0 0 0 0 0 0 0 0 14
15 276759 1 280331 280113 0 0 1 0 0 0 0 0 0 0 0 15
16 275139 1 276759 280331 0 0 0 1 0 0 0 0 0 0 0 16
17 274275 1 275139 276759 0 0 0 0 1 0 0 0 0 0 0 17
18 271234 1 274275 275139 0 0 0 0 0 1 0 0 0 0 0 18
19 289725 1 271234 274275 0 0 0 0 0 0 1 0 0 0 0 19
20 290649 1 289725 271234 0 0 0 0 0 0 0 1 0 0 0 20
21 292223 1 290649 289725 0 0 0 0 0 0 0 0 1 0 0 21
22 278429 0 292223 290649 0 0 0 0 0 0 0 0 0 1 0 22
23 269749 0 278429 292223 0 0 0 0 0 0 0 0 0 0 1 23
24 265784 0 269749 278429 0 0 0 0 0 0 0 0 0 0 0 24
25 268957 0 265784 269749 1 0 0 0 0 0 0 0 0 0 0 25
26 264099 0 268957 265784 0 1 0 0 0 0 0 0 0 0 0 26
27 255121 0 264099 268957 0 0 1 0 0 0 0 0 0 0 0 27
28 253276 0 255121 264099 0 0 0 1 0 0 0 0 0 0 0 28
29 245980 0 253276 255121 0 0 0 0 1 0 0 0 0 0 0 29
30 235295 0 245980 253276 0 0 0 0 0 1 0 0 0 0 0 30
31 258479 0 235295 245980 0 0 0 0 0 0 1 0 0 0 0 31
32 260916 0 258479 235295 0 0 0 0 0 0 0 1 0 0 0 32
33 254586 0 260916 258479 0 0 0 0 0 0 0 0 1 0 0 33
34 250566 0 254586 260916 0 0 0 0 0 0 0 0 0 1 0 34
35 243345 0 250566 254586 0 0 0 0 0 0 0 0 0 0 1 35
36 247028 0 243345 250566 0 0 0 0 0 0 0 0 0 0 0 36
37 248464 0 247028 243345 1 0 0 0 0 0 0 0 0 0 0 37
38 244962 0 248464 247028 0 1 0 0 0 0 0 0 0 0 0 38
39 237003 0 244962 248464 0 0 1 0 0 0 0 0 0 0 0 39
40 237008 0 237003 244962 0 0 0 1 0 0 0 0 0 0 0 40
41 225477 0 237008 237003 0 0 0 0 1 0 0 0 0 0 0 41
42 226762 0 225477 237008 0 0 0 0 0 1 0 0 0 0 0 42
43 247857 0 226762 225477 0 0 0 0 0 0 1 0 0 0 0 43
44 248256 0 247857 226762 0 0 0 0 0 0 0 1 0 0 0 44
45 246892 0 248256 247857 0 0 0 0 0 0 0 0 1 0 0 45
46 245021 0 246892 248256 0 0 0 0 0 0 0 0 0 1 0 46
47 246186 0 245021 246892 0 0 0 0 0 0 0 0 0 0 1 47
48 255688 0 246186 245021 0 0 0 0 0 0 0 0 0 0 0 48
49 264242 0 255688 246186 1 0 0 0 0 0 0 0 0 0 0 49
50 268270 0 264242 255688 0 1 0 0 0 0 0 0 0 0 0 50
51 272969 0 268270 264242 0 0 1 0 0 0 0 0 0 0 0 51
52 273886 0 272969 268270 0 0 0 1 0 0 0 0 0 0 0 52
53 267353 0 273886 272969 0 0 0 0 1 0 0 0 0 0 0 53
54 271916 0 267353 273886 0 0 0 0 0 1 0 0 0 0 0 54
55 292633 0 271916 267353 0 0 0 0 0 0 1 0 0 0 0 55
56 295804 0 292633 271916 0 0 0 0 0 0 0 1 0 0 0 56
57 293222 0 295804 292633 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 M1 M2
9.690e+03 8.887e+03 9.285e-01 6.978e-03 -2.931e+02 -3.226e+03
M3 M4 M5 M6 M7 M8
-6.294e+03 -4.704e+03 -9.394e+03 -6.209e+03 1.660e+04 -1.104e+03
M9 M10 M11 t
-5.034e+03 -7.294e+03 -7.371e+03 2.483e+02
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6704.7 -2175.4 -281.5 2445.4 5989.0
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.690e+03 1.014e+04 0.956 0.344764
X 8.887e+03 2.266e+03 3.922 0.000327 ***
Y1 9.285e-01 1.481e-01 6.268 1.80e-07 ***
Y2 6.978e-03 1.487e-01 0.047 0.962787
M1 -2.931e+02 2.608e+03 -0.112 0.911064
M2 -3.226e+03 2.571e+03 -1.255 0.216663
M3 -6.294e+03 2.420e+03 -2.601 0.012877 *
M4 -4.704e+03 2.348e+03 -2.003 0.051819 .
M5 -9.394e+03 2.394e+03 -3.924 0.000326 ***
M6 -6.209e+03 2.375e+03 -2.614 0.012470 *
M7 1.660e+04 2.419e+03 6.862 2.58e-08 ***
M8 -1.104e+03 4.391e+03 -0.251 0.802737
M9 -5.034e+03 2.548e+03 -1.976 0.054939 .
M10 -7.294e+03 2.574e+03 -2.834 0.007101 **
M11 -7.371e+03 2.469e+03 -2.985 0.004763 **
t 2.483e+02 6.286e+01 3.951 0.000300 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3477 on 41 degrees of freedom
Multiple R-squared: 0.9737, Adjusted R-squared: 0.9641
F-statistic: 101.2 on 15 and 41 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.08332540 0.16665080 0.91667460
[2,] 0.03484873 0.06969747 0.96515127
[3,] 0.01371490 0.02742981 0.98628510
[4,] 0.00411816 0.00823632 0.99588184
[5,] 0.00724274 0.01448548 0.99275726
[6,] 0.01396802 0.02793604 0.98603198
[7,] 0.01924457 0.03848913 0.98075543
[8,] 0.01754811 0.03509623 0.98245189
[9,] 0.04641648 0.09283296 0.95358352
[10,] 0.02523525 0.05047051 0.97476475
[11,] 0.04774268 0.09548536 0.95225732
[12,] 0.19133339 0.38266677 0.80866661
[13,] 0.40649344 0.81298689 0.59350656
[14,] 0.44161111 0.88322222 0.55838889
[15,] 0.49537849 0.99075698 0.50462151
[16,] 0.61652717 0.76694566 0.38347283
[17,] 0.51532634 0.96934731 0.48467366
[18,] 0.53885230 0.92229540 0.46114770
[19,] 0.60556962 0.78886077 0.39443038
[20,] 0.91610897 0.16778207 0.08389103
> postscript(file="/var/www/html/rcomp/tmp/1p2ma1259340114.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/2xuk01259340114.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/3o4z01259340114.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/4nq3e1259340114.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/5eskh1259340114.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 = 57
Frequency = 1
1 2 3 4 5 6 7
-1370.5830 2010.7546 2793.9171 -2013.9027 3970.0263 1217.9306 2445.3748
8 9 10 11 12 13 14
3166.1719 4160.1862 996.2216 -2072.4385 -2254.6795 -5723.7827 -540.2345
15 16 17 18 19 20 21
-1476.9691 -1621.2380 3485.9521 -2175.3965 -3907.8927 -2678.9560 1589.5382
22 23 24 25 26 27 28
-2773.4176 1171.1142 -2257.6016 4701.9992 -390.0897 -2059.3591 2625.9974
29 30 31 32 33 34 35
1547.8130 -5784.1712 4318.2929 2756.3523 -2316.6480 1535.1713 -2080.8174
36 37 38 39 40 41 42
715.6524 -1172.7183 -3349.4579 -5246.5851 333.2177 -6704.7110 1852.3834
43 44 45 46 47 48 49
-1218.1536 -2962.0900 -1162.3305 242.0247 2982.1418 3796.6287 3565.0847
50 51 52 53 54 55 56
2269.0275 5988.9963 675.9255 -2299.0804 4889.2538 -1637.6214 -281.4781
57
-2270.7458
> postscript(file="/var/www/html/rcomp/tmp/6coio1259340114.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -1370.5830 NA
1 2010.7546 -1370.5830
2 2793.9171 2010.7546
3 -2013.9027 2793.9171
4 3970.0263 -2013.9027
5 1217.9306 3970.0263
6 2445.3748 1217.9306
7 3166.1719 2445.3748
8 4160.1862 3166.1719
9 996.2216 4160.1862
10 -2072.4385 996.2216
11 -2254.6795 -2072.4385
12 -5723.7827 -2254.6795
13 -540.2345 -5723.7827
14 -1476.9691 -540.2345
15 -1621.2380 -1476.9691
16 3485.9521 -1621.2380
17 -2175.3965 3485.9521
18 -3907.8927 -2175.3965
19 -2678.9560 -3907.8927
20 1589.5382 -2678.9560
21 -2773.4176 1589.5382
22 1171.1142 -2773.4176
23 -2257.6016 1171.1142
24 4701.9992 -2257.6016
25 -390.0897 4701.9992
26 -2059.3591 -390.0897
27 2625.9974 -2059.3591
28 1547.8130 2625.9974
29 -5784.1712 1547.8130
30 4318.2929 -5784.1712
31 2756.3523 4318.2929
32 -2316.6480 2756.3523
33 1535.1713 -2316.6480
34 -2080.8174 1535.1713
35 715.6524 -2080.8174
36 -1172.7183 715.6524
37 -3349.4579 -1172.7183
38 -5246.5851 -3349.4579
39 333.2177 -5246.5851
40 -6704.7110 333.2177
41 1852.3834 -6704.7110
42 -1218.1536 1852.3834
43 -2962.0900 -1218.1536
44 -1162.3305 -2962.0900
45 242.0247 -1162.3305
46 2982.1418 242.0247
47 3796.6287 2982.1418
48 3565.0847 3796.6287
49 2269.0275 3565.0847
50 5988.9963 2269.0275
51 675.9255 5988.9963
52 -2299.0804 675.9255
53 4889.2538 -2299.0804
54 -1637.6214 4889.2538
55 -281.4781 -1637.6214
56 -2270.7458 -281.4781
57 NA -2270.7458
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 2010.7546 -1370.5830
[2,] 2793.9171 2010.7546
[3,] -2013.9027 2793.9171
[4,] 3970.0263 -2013.9027
[5,] 1217.9306 3970.0263
[6,] 2445.3748 1217.9306
[7,] 3166.1719 2445.3748
[8,] 4160.1862 3166.1719
[9,] 996.2216 4160.1862
[10,] -2072.4385 996.2216
[11,] -2254.6795 -2072.4385
[12,] -5723.7827 -2254.6795
[13,] -540.2345 -5723.7827
[14,] -1476.9691 -540.2345
[15,] -1621.2380 -1476.9691
[16,] 3485.9521 -1621.2380
[17,] -2175.3965 3485.9521
[18,] -3907.8927 -2175.3965
[19,] -2678.9560 -3907.8927
[20,] 1589.5382 -2678.9560
[21,] -2773.4176 1589.5382
[22,] 1171.1142 -2773.4176
[23,] -2257.6016 1171.1142
[24,] 4701.9992 -2257.6016
[25,] -390.0897 4701.9992
[26,] -2059.3591 -390.0897
[27,] 2625.9974 -2059.3591
[28,] 1547.8130 2625.9974
[29,] -5784.1712 1547.8130
[30,] 4318.2929 -5784.1712
[31,] 2756.3523 4318.2929
[32,] -2316.6480 2756.3523
[33,] 1535.1713 -2316.6480
[34,] -2080.8174 1535.1713
[35,] 715.6524 -2080.8174
[36,] -1172.7183 715.6524
[37,] -3349.4579 -1172.7183
[38,] -5246.5851 -3349.4579
[39,] 333.2177 -5246.5851
[40,] -6704.7110 333.2177
[41,] 1852.3834 -6704.7110
[42,] -1218.1536 1852.3834
[43,] -2962.0900 -1218.1536
[44,] -1162.3305 -2962.0900
[45,] 242.0247 -1162.3305
[46,] 2982.1418 242.0247
[47,] 3796.6287 2982.1418
[48,] 3565.0847 3796.6287
[49,] 2269.0275 3565.0847
[50,] 5988.9963 2269.0275
[51,] 675.9255 5988.9963
[52,] -2299.0804 675.9255
[53,] 4889.2538 -2299.0804
[54,] -1637.6214 4889.2538
[55,] -281.4781 -1637.6214
[56,] -2270.7458 -281.4781
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 2010.7546 -1370.5830
2 2793.9171 2010.7546
3 -2013.9027 2793.9171
4 3970.0263 -2013.9027
5 1217.9306 3970.0263
6 2445.3748 1217.9306
7 3166.1719 2445.3748
8 4160.1862 3166.1719
9 996.2216 4160.1862
10 -2072.4385 996.2216
11 -2254.6795 -2072.4385
12 -5723.7827 -2254.6795
13 -540.2345 -5723.7827
14 -1476.9691 -540.2345
15 -1621.2380 -1476.9691
16 3485.9521 -1621.2380
17 -2175.3965 3485.9521
18 -3907.8927 -2175.3965
19 -2678.9560 -3907.8927
20 1589.5382 -2678.9560
21 -2773.4176 1589.5382
22 1171.1142 -2773.4176
23 -2257.6016 1171.1142
24 4701.9992 -2257.6016
25 -390.0897 4701.9992
26 -2059.3591 -390.0897
27 2625.9974 -2059.3591
28 1547.8130 2625.9974
29 -5784.1712 1547.8130
30 4318.2929 -5784.1712
31 2756.3523 4318.2929
32 -2316.6480 2756.3523
33 1535.1713 -2316.6480
34 -2080.8174 1535.1713
35 715.6524 -2080.8174
36 -1172.7183 715.6524
37 -3349.4579 -1172.7183
38 -5246.5851 -3349.4579
39 333.2177 -5246.5851
40 -6704.7110 333.2177
41 1852.3834 -6704.7110
42 -1218.1536 1852.3834
43 -2962.0900 -1218.1536
44 -1162.3305 -2962.0900
45 242.0247 -1162.3305
46 2982.1418 242.0247
47 3796.6287 2982.1418
48 3565.0847 3796.6287
49 2269.0275 3565.0847
50 5988.9963 2269.0275
51 675.9255 5988.9963
52 -2299.0804 675.9255
53 4889.2538 -2299.0804
54 -1637.6214 4889.2538
55 -281.4781 -1637.6214
56 -2270.7458 -281.4781
> 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/7rof11259340114.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/81foo1259340115.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/9ns6x1259340115.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/10uh6f1259340115.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/112xyz1259340115.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/126vqf1259340115.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/13129d1259340115.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/14gisz1259340115.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/15lddy1259340115.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/164s5m1259340115.tab")
+ }
> system("convert tmp/1p2ma1259340114.ps tmp/1p2ma1259340114.png")
> system("convert tmp/2xuk01259340114.ps tmp/2xuk01259340114.png")
> system("convert tmp/3o4z01259340114.ps tmp/3o4z01259340114.png")
> system("convert tmp/4nq3e1259340114.ps tmp/4nq3e1259340114.png")
> system("convert tmp/5eskh1259340114.ps tmp/5eskh1259340114.png")
> system("convert tmp/6coio1259340114.ps tmp/6coio1259340114.png")
> system("convert tmp/7rof11259340114.ps tmp/7rof11259340114.png")
> system("convert tmp/81foo1259340115.ps tmp/81foo1259340115.png")
> system("convert tmp/9ns6x1259340115.ps tmp/9ns6x1259340115.png")
> system("convert tmp/10uh6f1259340115.ps tmp/10uh6f1259340115.png")
>
>
> proc.time()
user system elapsed
2.371 1.572 3.462