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(0.7790
+ ,0.0000
+ ,0.7775
+ ,0.7461
+ ,0.7744
+ ,0.0520
+ ,0.7790
+ ,0.7775
+ ,0.7905
+ ,0.3130
+ ,0.7744
+ ,0.7790
+ ,0.7719
+ ,0.3640
+ ,0.7905
+ ,0.7744
+ ,0.7811
+ ,0.3630
+ ,0.7719
+ ,0.7905
+ ,0.7557
+ ,-0.1550
+ ,0.7811
+ ,0.7719
+ ,0.7637
+ ,0.0520
+ ,0.7557
+ ,0.7811
+ ,0.7595
+ ,0.5680
+ ,0.7637
+ ,0.7557
+ ,0.7471
+ ,0.6680
+ ,0.7595
+ ,0.7637
+ ,0.7615
+ ,1.3780
+ ,0.7471
+ ,0.7595
+ ,0.7487
+ ,0.2520
+ ,0.7615
+ ,0.7471
+ ,0.7389
+ ,-0.4020
+ ,0.7487
+ ,0.7615
+ ,0.7337
+ ,-0.0500
+ ,0.7389
+ ,0.7487
+ ,0.7510
+ ,0.5550
+ ,0.7337
+ ,0.7389
+ ,0.7382
+ ,0.0500
+ ,0.7510
+ ,0.7337
+ ,0.7159
+ ,0.1500
+ ,0.7382
+ ,0.7510
+ ,0.7542
+ ,0.4500
+ ,0.7159
+ ,0.7382
+ ,0.7636
+ ,0.2990
+ ,0.7542
+ ,0.7159
+ ,0.7433
+ ,0.1990
+ ,0.7636
+ ,0.7542
+ ,0.7658
+ ,0.4960
+ ,0.7433
+ ,0.7636
+ ,0.7627
+ ,0.4440
+ ,0.7658
+ ,0.7433
+ ,0.7480
+ ,-0.3930
+ ,0.7627
+ ,0.7658
+ ,0.7692
+ ,-0.4440
+ ,0.7480
+ ,0.7627
+ ,0.7850
+ ,0.1980
+ ,0.7692
+ ,0.7480
+ ,0.7913
+ ,0.4940
+ ,0.7850
+ ,0.7692
+ ,0.7720
+ ,0.1330
+ ,0.7913
+ ,0.7850
+ ,0.7880
+ ,0.3880
+ ,0.7720
+ ,0.7913
+ ,0.8070
+ ,0.4840
+ ,0.7880
+ ,0.7720
+ ,0.8268
+ ,0.2780
+ ,0.8070
+ ,0.7880
+ ,0.8244
+ ,0.3690
+ ,0.8268
+ ,0.8070
+ ,0.8487
+ ,0.1650
+ ,0.8244
+ ,0.8268
+ ,0.8572
+ ,0.1550
+ ,0.8487
+ ,0.8244
+ ,0.8214
+ ,0.0870
+ ,0.8572
+ ,0.8487
+ ,0.8827
+ ,0.4140
+ ,0.8214
+ ,0.8572
+ ,0.9216
+ ,0.3600
+ ,0.8827
+ ,0.8214
+ ,0.8865
+ ,0.9750
+ ,0.9216
+ ,0.8827
+ ,0.8816
+ ,0.2700
+ ,0.8865
+ ,0.9216
+ ,0.8884
+ ,0.3590
+ ,0.8816
+ ,0.8865
+ ,0.9466
+ ,0.1690
+ ,0.8884
+ ,0.8816
+ ,0.9180
+ ,0.3810
+ ,0.9466
+ ,0.8884
+ ,0.9337
+ ,0.1540
+ ,0.9180
+ ,0.9466
+ ,0.9559
+ ,0.4860
+ ,0.9337
+ ,0.9180
+ ,0.9626
+ ,0.9250
+ ,0.9559
+ ,0.9337
+ ,0.9434
+ ,0.7280
+ ,0.9626
+ ,0.9559
+ ,0.8639
+ ,-0.0140
+ ,0.9434
+ ,0.9626
+ ,0.7996
+ ,0.0460
+ ,0.8639
+ ,0.9434
+ ,0.6680
+ ,-0.8190
+ ,0.7996
+ ,0.8639
+ ,0.6572
+ ,-1.6740
+ ,0.6680
+ ,0.7996
+ ,0.6928
+ ,-0.7880
+ ,0.6572
+ ,0.6680
+ ,0.6438
+ ,0.2790
+ ,0.6928
+ ,0.6572
+ ,0.6454
+ ,0.3960
+ ,0.6438
+ ,0.6928
+ ,0.6873
+ ,-0.1410
+ ,0.6454
+ ,0.6438
+ ,0.7265
+ ,-0.0190
+ ,0.6873
+ ,0.6454
+ ,0.7912
+ ,0.0990
+ ,0.7265
+ ,0.6873
+ ,0.8114
+ ,0.7420
+ ,0.7912
+ ,0.7265
+ ,0.8281
+ ,0.0050
+ ,0.8114
+ ,0.7912
+ ,0.8393
+ ,0.4480
+ ,0.8281
+ ,0.8114)
+ ,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 0.7790 0.000 0.7775 0.7461 1 0 0 0 0 0 0 0 0 0 0 1
2 0.7744 0.052 0.7790 0.7775 0 1 0 0 0 0 0 0 0 0 0 2
3 0.7905 0.313 0.7744 0.7790 0 0 1 0 0 0 0 0 0 0 0 3
4 0.7719 0.364 0.7905 0.7744 0 0 0 1 0 0 0 0 0 0 0 4
5 0.7811 0.363 0.7719 0.7905 0 0 0 0 1 0 0 0 0 0 0 5
6 0.7557 -0.155 0.7811 0.7719 0 0 0 0 0 1 0 0 0 0 0 6
7 0.7637 0.052 0.7557 0.7811 0 0 0 0 0 0 1 0 0 0 0 7
8 0.7595 0.568 0.7637 0.7557 0 0 0 0 0 0 0 1 0 0 0 8
9 0.7471 0.668 0.7595 0.7637 0 0 0 0 0 0 0 0 1 0 0 9
10 0.7615 1.378 0.7471 0.7595 0 0 0 0 0 0 0 0 0 1 0 10
11 0.7487 0.252 0.7615 0.7471 0 0 0 0 0 0 0 0 0 0 1 11
12 0.7389 -0.402 0.7487 0.7615 0 0 0 0 0 0 0 0 0 0 0 12
13 0.7337 -0.050 0.7389 0.7487 1 0 0 0 0 0 0 0 0 0 0 13
14 0.7510 0.555 0.7337 0.7389 0 1 0 0 0 0 0 0 0 0 0 14
15 0.7382 0.050 0.7510 0.7337 0 0 1 0 0 0 0 0 0 0 0 15
16 0.7159 0.150 0.7382 0.7510 0 0 0 1 0 0 0 0 0 0 0 16
17 0.7542 0.450 0.7159 0.7382 0 0 0 0 1 0 0 0 0 0 0 17
18 0.7636 0.299 0.7542 0.7159 0 0 0 0 0 1 0 0 0 0 0 18
19 0.7433 0.199 0.7636 0.7542 0 0 0 0 0 0 1 0 0 0 0 19
20 0.7658 0.496 0.7433 0.7636 0 0 0 0 0 0 0 1 0 0 0 20
21 0.7627 0.444 0.7658 0.7433 0 0 0 0 0 0 0 0 1 0 0 21
22 0.7480 -0.393 0.7627 0.7658 0 0 0 0 0 0 0 0 0 1 0 22
23 0.7692 -0.444 0.7480 0.7627 0 0 0 0 0 0 0 0 0 0 1 23
24 0.7850 0.198 0.7692 0.7480 0 0 0 0 0 0 0 0 0 0 0 24
25 0.7913 0.494 0.7850 0.7692 1 0 0 0 0 0 0 0 0 0 0 25
26 0.7720 0.133 0.7913 0.7850 0 1 0 0 0 0 0 0 0 0 0 26
27 0.7880 0.388 0.7720 0.7913 0 0 1 0 0 0 0 0 0 0 0 27
28 0.8070 0.484 0.7880 0.7720 0 0 0 1 0 0 0 0 0 0 0 28
29 0.8268 0.278 0.8070 0.7880 0 0 0 0 1 0 0 0 0 0 0 29
30 0.8244 0.369 0.8268 0.8070 0 0 0 0 0 1 0 0 0 0 0 30
31 0.8487 0.165 0.8244 0.8268 0 0 0 0 0 0 1 0 0 0 0 31
32 0.8572 0.155 0.8487 0.8244 0 0 0 0 0 0 0 1 0 0 0 32
33 0.8214 0.087 0.8572 0.8487 0 0 0 0 0 0 0 0 1 0 0 33
34 0.8827 0.414 0.8214 0.8572 0 0 0 0 0 0 0 0 0 1 0 34
35 0.9216 0.360 0.8827 0.8214 0 0 0 0 0 0 0 0 0 0 1 35
36 0.8865 0.975 0.9216 0.8827 0 0 0 0 0 0 0 0 0 0 0 36
37 0.8816 0.270 0.8865 0.9216 1 0 0 0 0 0 0 0 0 0 0 37
38 0.8884 0.359 0.8816 0.8865 0 1 0 0 0 0 0 0 0 0 0 38
39 0.9466 0.169 0.8884 0.8816 0 0 1 0 0 0 0 0 0 0 0 39
40 0.9180 0.381 0.9466 0.8884 0 0 0 1 0 0 0 0 0 0 0 40
41 0.9337 0.154 0.9180 0.9466 0 0 0 0 1 0 0 0 0 0 0 41
42 0.9559 0.486 0.9337 0.9180 0 0 0 0 0 1 0 0 0 0 0 42
43 0.9626 0.925 0.9559 0.9337 0 0 0 0 0 0 1 0 0 0 0 43
44 0.9434 0.728 0.9626 0.9559 0 0 0 0 0 0 0 1 0 0 0 44
45 0.8639 -0.014 0.9434 0.9626 0 0 0 0 0 0 0 0 1 0 0 45
46 0.7996 0.046 0.8639 0.9434 0 0 0 0 0 0 0 0 0 1 0 46
47 0.6680 -0.819 0.7996 0.8639 0 0 0 0 0 0 0 0 0 0 1 47
48 0.6572 -1.674 0.6680 0.7996 0 0 0 0 0 0 0 0 0 0 0 48
49 0.6928 -0.788 0.6572 0.6680 1 0 0 0 0 0 0 0 0 0 0 49
50 0.6438 0.279 0.6928 0.6572 0 1 0 0 0 0 0 0 0 0 0 50
51 0.6454 0.396 0.6438 0.6928 0 0 1 0 0 0 0 0 0 0 0 51
52 0.6873 -0.141 0.6454 0.6438 0 0 0 1 0 0 0 0 0 0 0 52
53 0.7265 -0.019 0.6873 0.6454 0 0 0 0 1 0 0 0 0 0 0 53
54 0.7912 0.099 0.7265 0.6873 0 0 0 0 0 1 0 0 0 0 0 54
55 0.8114 0.742 0.7912 0.7265 0 0 0 0 0 0 1 0 0 0 0 55
56 0.8281 0.005 0.8114 0.7912 0 0 0 0 0 0 0 1 0 0 0 56
57 0.8393 0.448 0.8281 0.8114 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
0.093390 0.013197 1.128980 -0.261041 0.009041 -0.012771
M3 M4 M5 M6 M7 M8
0.015713 -0.006467 0.023820 0.009559 0.005395 0.005137
M9 M10 M11 t
-0.021654 0.007844 -0.014177 0.000257
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.089703 -0.013513 0.001246 0.016065 0.063684
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0933903 0.0504272 1.852 0.0712 .
X 0.0131974 0.0132894 0.993 0.3265
Y1 1.1289805 0.1810568 6.236 2e-07 ***
Y2 -0.2610413 0.1692507 -1.542 0.1307
M1 0.0090410 0.0215234 0.420 0.6766
M2 -0.0127713 0.0220298 -0.580 0.5653
M3 0.0157128 0.0220695 0.712 0.4805
M4 -0.0064666 0.0221060 -0.293 0.7714
M5 0.0238196 0.0219097 1.087 0.2833
M6 0.0095592 0.0222786 0.429 0.6701
M7 0.0053951 0.0223833 0.241 0.8107
M8 0.0051366 0.0222782 0.231 0.8188
M9 -0.0216543 0.0221197 -0.979 0.3333
M10 0.0078439 0.0240088 0.327 0.7455
M11 -0.0141773 0.0226705 -0.625 0.5352
t 0.0002570 0.0002722 0.944 0.3505
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.03172 on 41 degrees of freedom
Multiple R-squared: 0.8808, Adjusted R-squared: 0.8373
F-statistic: 20.21 on 15 and 41 DF, p-value: 2.757e-14
> 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.0133254149 0.0266508298 0.9866746
[2,] 0.0440524468 0.0881048936 0.9559476
[3,] 0.0363568363 0.0727136726 0.9636432
[4,] 0.0222619275 0.0445238550 0.9777381
[5,] 0.0228613644 0.0457227288 0.9771386
[6,] 0.0097697646 0.0195395292 0.9902302
[7,] 0.0047425548 0.0094851096 0.9952574
[8,] 0.0027886590 0.0055773179 0.9972113
[9,] 0.0010379448 0.0020758896 0.9989621
[10,] 0.0010498379 0.0020996759 0.9989502
[11,] 0.0003770566 0.0007541132 0.9996229
[12,] 0.0002041263 0.0004082527 0.9997959
[13,] 0.0001199849 0.0002399698 0.9998800
[14,] 0.0000500011 0.0001000022 0.9999500
[15,] 0.0002167392 0.0004334785 0.9997833
[16,] 0.0004145669 0.0008291338 0.9995854
[17,] 0.0044677781 0.0089355562 0.9955322
[18,] 0.0090866367 0.0181732733 0.9909134
[19,] 0.0039049851 0.0078099703 0.9960950
[20,] 0.0109966312 0.0219932623 0.9890034
> postscript(file="/var/www/html/rcomp/tmp/16xks1258657899.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/2apc41258657899.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/35t511258657899.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/4q4td1258657899.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/5iava1258657899.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
-0.006707704 0.016064558 0.005563882 -0.011164204 -0.007292398 -0.027094725
7 8 9 10 11 12
0.013158168 -0.013512541 0.006131721 -0.005690658 -0.001360427 0.001246263
13 14 15 16 17 18
-0.010174586 0.024008794 -0.031756341 -0.014486758 0.011145771 -0.012519178
19 20 21 22 23 24
-0.028206909 0.015746994 0.009166008 -0.014869746 0.044554323 0.009675575
25 26 27 28 29 30
-0.009532716 -0.005501289 0.001826232 0.018379854 -0.006918649 -0.013910217
31 32 33 34 35 36
0.024867285 0.005439964 -0.006181693 0.063683891 0.046508983 -0.039057249
37 38 39 40 41 42
0.005830572 0.029380757 0.052391056 -0.021016015 0.014618043 0.021249160
43 44 45 46 47 48
0.005097559 -0.013270179 -0.033018372 -0.043123487 -0.089702880 0.028135412
49 50 51 52 53 54
0.020584434 -0.063952819 -0.028024829 0.028287123 -0.011552767 0.032274961
55 56 57
-0.014916104 0.005595761 0.023902336
> postscript(file="/var/www/html/rcomp/tmp/6lmsk1258657899.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 -0.006707704 NA
1 0.016064558 -0.006707704
2 0.005563882 0.016064558
3 -0.011164204 0.005563882
4 -0.007292398 -0.011164204
5 -0.027094725 -0.007292398
6 0.013158168 -0.027094725
7 -0.013512541 0.013158168
8 0.006131721 -0.013512541
9 -0.005690658 0.006131721
10 -0.001360427 -0.005690658
11 0.001246263 -0.001360427
12 -0.010174586 0.001246263
13 0.024008794 -0.010174586
14 -0.031756341 0.024008794
15 -0.014486758 -0.031756341
16 0.011145771 -0.014486758
17 -0.012519178 0.011145771
18 -0.028206909 -0.012519178
19 0.015746994 -0.028206909
20 0.009166008 0.015746994
21 -0.014869746 0.009166008
22 0.044554323 -0.014869746
23 0.009675575 0.044554323
24 -0.009532716 0.009675575
25 -0.005501289 -0.009532716
26 0.001826232 -0.005501289
27 0.018379854 0.001826232
28 -0.006918649 0.018379854
29 -0.013910217 -0.006918649
30 0.024867285 -0.013910217
31 0.005439964 0.024867285
32 -0.006181693 0.005439964
33 0.063683891 -0.006181693
34 0.046508983 0.063683891
35 -0.039057249 0.046508983
36 0.005830572 -0.039057249
37 0.029380757 0.005830572
38 0.052391056 0.029380757
39 -0.021016015 0.052391056
40 0.014618043 -0.021016015
41 0.021249160 0.014618043
42 0.005097559 0.021249160
43 -0.013270179 0.005097559
44 -0.033018372 -0.013270179
45 -0.043123487 -0.033018372
46 -0.089702880 -0.043123487
47 0.028135412 -0.089702880
48 0.020584434 0.028135412
49 -0.063952819 0.020584434
50 -0.028024829 -0.063952819
51 0.028287123 -0.028024829
52 -0.011552767 0.028287123
53 0.032274961 -0.011552767
54 -0.014916104 0.032274961
55 0.005595761 -0.014916104
56 0.023902336 0.005595761
57 NA 0.023902336
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.016064558 -0.006707704
[2,] 0.005563882 0.016064558
[3,] -0.011164204 0.005563882
[4,] -0.007292398 -0.011164204
[5,] -0.027094725 -0.007292398
[6,] 0.013158168 -0.027094725
[7,] -0.013512541 0.013158168
[8,] 0.006131721 -0.013512541
[9,] -0.005690658 0.006131721
[10,] -0.001360427 -0.005690658
[11,] 0.001246263 -0.001360427
[12,] -0.010174586 0.001246263
[13,] 0.024008794 -0.010174586
[14,] -0.031756341 0.024008794
[15,] -0.014486758 -0.031756341
[16,] 0.011145771 -0.014486758
[17,] -0.012519178 0.011145771
[18,] -0.028206909 -0.012519178
[19,] 0.015746994 -0.028206909
[20,] 0.009166008 0.015746994
[21,] -0.014869746 0.009166008
[22,] 0.044554323 -0.014869746
[23,] 0.009675575 0.044554323
[24,] -0.009532716 0.009675575
[25,] -0.005501289 -0.009532716
[26,] 0.001826232 -0.005501289
[27,] 0.018379854 0.001826232
[28,] -0.006918649 0.018379854
[29,] -0.013910217 -0.006918649
[30,] 0.024867285 -0.013910217
[31,] 0.005439964 0.024867285
[32,] -0.006181693 0.005439964
[33,] 0.063683891 -0.006181693
[34,] 0.046508983 0.063683891
[35,] -0.039057249 0.046508983
[36,] 0.005830572 -0.039057249
[37,] 0.029380757 0.005830572
[38,] 0.052391056 0.029380757
[39,] -0.021016015 0.052391056
[40,] 0.014618043 -0.021016015
[41,] 0.021249160 0.014618043
[42,] 0.005097559 0.021249160
[43,] -0.013270179 0.005097559
[44,] -0.033018372 -0.013270179
[45,] -0.043123487 -0.033018372
[46,] -0.089702880 -0.043123487
[47,] 0.028135412 -0.089702880
[48,] 0.020584434 0.028135412
[49,] -0.063952819 0.020584434
[50,] -0.028024829 -0.063952819
[51,] 0.028287123 -0.028024829
[52,] -0.011552767 0.028287123
[53,] 0.032274961 -0.011552767
[54,] -0.014916104 0.032274961
[55,] 0.005595761 -0.014916104
[56,] 0.023902336 0.005595761
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.016064558 -0.006707704
2 0.005563882 0.016064558
3 -0.011164204 0.005563882
4 -0.007292398 -0.011164204
5 -0.027094725 -0.007292398
6 0.013158168 -0.027094725
7 -0.013512541 0.013158168
8 0.006131721 -0.013512541
9 -0.005690658 0.006131721
10 -0.001360427 -0.005690658
11 0.001246263 -0.001360427
12 -0.010174586 0.001246263
13 0.024008794 -0.010174586
14 -0.031756341 0.024008794
15 -0.014486758 -0.031756341
16 0.011145771 -0.014486758
17 -0.012519178 0.011145771
18 -0.028206909 -0.012519178
19 0.015746994 -0.028206909
20 0.009166008 0.015746994
21 -0.014869746 0.009166008
22 0.044554323 -0.014869746
23 0.009675575 0.044554323
24 -0.009532716 0.009675575
25 -0.005501289 -0.009532716
26 0.001826232 -0.005501289
27 0.018379854 0.001826232
28 -0.006918649 0.018379854
29 -0.013910217 -0.006918649
30 0.024867285 -0.013910217
31 0.005439964 0.024867285
32 -0.006181693 0.005439964
33 0.063683891 -0.006181693
34 0.046508983 0.063683891
35 -0.039057249 0.046508983
36 0.005830572 -0.039057249
37 0.029380757 0.005830572
38 0.052391056 0.029380757
39 -0.021016015 0.052391056
40 0.014618043 -0.021016015
41 0.021249160 0.014618043
42 0.005097559 0.021249160
43 -0.013270179 0.005097559
44 -0.033018372 -0.013270179
45 -0.043123487 -0.033018372
46 -0.089702880 -0.043123487
47 0.028135412 -0.089702880
48 0.020584434 0.028135412
49 -0.063952819 0.020584434
50 -0.028024829 -0.063952819
51 0.028287123 -0.028024829
52 -0.011552767 0.028287123
53 0.032274961 -0.011552767
54 -0.014916104 0.032274961
55 0.005595761 -0.014916104
56 0.023902336 0.005595761
> 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/7fo611258657899.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/8126a1258657899.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/91qqn1258657899.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/10nxb31258657899.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/11wqi71258657899.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/12fg8k1258657899.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/13uzyy1258657899.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/14twtl1258657899.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/15wbwd1258657899.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/16lohp1258657899.tab")
+ }
>
> system("convert tmp/16xks1258657899.ps tmp/16xks1258657899.png")
> system("convert tmp/2apc41258657899.ps tmp/2apc41258657899.png")
> system("convert tmp/35t511258657899.ps tmp/35t511258657899.png")
> system("convert tmp/4q4td1258657899.ps tmp/4q4td1258657899.png")
> system("convert tmp/5iava1258657899.ps tmp/5iava1258657899.png")
> system("convert tmp/6lmsk1258657899.ps tmp/6lmsk1258657899.png")
> system("convert tmp/7fo611258657899.ps tmp/7fo611258657899.png")
> system("convert tmp/8126a1258657899.ps tmp/8126a1258657899.png")
> system("convert tmp/91qqn1258657899.ps tmp/91qqn1258657899.png")
> system("convert tmp/10nxb31258657899.ps tmp/10nxb31258657899.png")
>
>
> proc.time()
user system elapsed
2.339 1.536 2.715