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(3.75,0,3.75,0,3.55,0,3.5,0,3.5,0,3.1,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3.21,0,3.25,0,3.25,0,3.45,0,3.5,0,3.5,0,3.64,0,3.75,0,3.93,0,4,0,4.17,0,4.25,0,4.39,0,4.5,0,4.5,0,4.65,0,4.75,0,4.75,0,4.9,0,5,0,5,0,5,0,5,0,5,0,5,0,5,1,5,1,5,1,5,1,5,1,5,1,5.18,1,5.25,1,5.25,1,4.49,1,3.92,1,3.25,1),dim=c(2,72),dimnames=list(c('Yt','Xt'),1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('Yt','Xt'),1:72))
> 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
Yt Xt M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 3.75 0 1 0 0 0 0 0 0 0 0 0 0 1
2 3.75 0 0 1 0 0 0 0 0 0 0 0 0 2
3 3.55 0 0 0 1 0 0 0 0 0 0 0 0 3
4 3.50 0 0 0 0 1 0 0 0 0 0 0 0 4
5 3.50 0 0 0 0 0 1 0 0 0 0 0 0 5
6 3.10 0 0 0 0 0 0 1 0 0 0 0 0 6
7 3.00 0 0 0 0 0 0 0 1 0 0 0 0 7
8 3.00 0 0 0 0 0 0 0 0 1 0 0 0 8
9 3.00 0 0 0 0 0 0 0 0 0 1 0 0 9
10 3.00 0 0 0 0 0 0 0 0 0 0 1 0 10
11 3.00 0 0 0 0 0 0 0 0 0 0 0 1 11
12 3.00 0 0 0 0 0 0 0 0 0 0 0 0 12
13 3.00 0 1 0 0 0 0 0 0 0 0 0 0 13
14 3.00 0 0 1 0 0 0 0 0 0 0 0 0 14
15 3.00 0 0 0 1 0 0 0 0 0 0 0 0 15
16 3.00 0 0 0 0 1 0 0 0 0 0 0 0 16
17 3.00 0 0 0 0 0 1 0 0 0 0 0 0 17
18 3.00 0 0 0 0 0 0 1 0 0 0 0 0 18
19 3.00 0 0 0 0 0 0 0 1 0 0 0 0 19
20 3.00 0 0 0 0 0 0 0 0 1 0 0 0 20
21 3.00 0 0 0 0 0 0 0 0 0 1 0 0 21
22 3.00 0 0 0 0 0 0 0 0 0 0 1 0 22
23 3.00 0 0 0 0 0 0 0 0 0 0 0 1 23
24 3.00 0 0 0 0 0 0 0 0 0 0 0 0 24
25 3.00 0 1 0 0 0 0 0 0 0 0 0 0 25
26 3.00 0 0 1 0 0 0 0 0 0 0 0 0 26
27 3.00 0 0 0 1 0 0 0 0 0 0 0 0 27
28 3.00 0 0 0 0 1 0 0 0 0 0 0 0 28
29 3.00 0 0 0 0 0 1 0 0 0 0 0 0 29
30 3.00 0 0 0 0 0 0 1 0 0 0 0 0 30
31 3.00 0 0 0 0 0 0 0 1 0 0 0 0 31
32 3.00 0 0 0 0 0 0 0 0 1 0 0 0 32
33 3.00 0 0 0 0 0 0 0 0 0 1 0 0 33
34 3.00 0 0 0 0 0 0 0 0 0 0 1 0 34
35 3.00 0 0 0 0 0 0 0 0 0 0 0 1 35
36 3.21 0 0 0 0 0 0 0 0 0 0 0 0 36
37 3.25 0 1 0 0 0 0 0 0 0 0 0 0 37
38 3.25 0 0 1 0 0 0 0 0 0 0 0 0 38
39 3.45 0 0 0 1 0 0 0 0 0 0 0 0 39
40 3.50 0 0 0 0 1 0 0 0 0 0 0 0 40
41 3.50 0 0 0 0 0 1 0 0 0 0 0 0 41
42 3.64 0 0 0 0 0 0 1 0 0 0 0 0 42
43 3.75 0 0 0 0 0 0 0 1 0 0 0 0 43
44 3.93 0 0 0 0 0 0 0 0 1 0 0 0 44
45 4.00 0 0 0 0 0 0 0 0 0 1 0 0 45
46 4.17 0 0 0 0 0 0 0 0 0 0 1 0 46
47 4.25 0 0 0 0 0 0 0 0 0 0 0 1 47
48 4.39 0 0 0 0 0 0 0 0 0 0 0 0 48
49 4.50 0 1 0 0 0 0 0 0 0 0 0 0 49
50 4.50 0 0 1 0 0 0 0 0 0 0 0 0 50
51 4.65 0 0 0 1 0 0 0 0 0 0 0 0 51
52 4.75 0 0 0 0 1 0 0 0 0 0 0 0 52
53 4.75 0 0 0 0 0 1 0 0 0 0 0 0 53
54 4.90 0 0 0 0 0 0 1 0 0 0 0 0 54
55 5.00 0 0 0 0 0 0 0 1 0 0 0 0 55
56 5.00 0 0 0 0 0 0 0 0 1 0 0 0 56
57 5.00 0 0 0 0 0 0 0 0 0 1 0 0 57
58 5.00 0 0 0 0 0 0 0 0 0 0 1 0 58
59 5.00 0 0 0 0 0 0 0 0 0 0 0 1 59
60 5.00 0 0 0 0 0 0 0 0 0 0 0 0 60
61 5.00 1 1 0 0 0 0 0 0 0 0 0 0 61
62 5.00 1 0 1 0 0 0 0 0 0 0 0 0 62
63 5.00 1 0 0 1 0 0 0 0 0 0 0 0 63
64 5.00 1 0 0 0 1 0 0 0 0 0 0 0 64
65 5.00 1 0 0 0 0 1 0 0 0 0 0 0 65
66 5.00 1 0 0 0 0 0 1 0 0 0 0 0 66
67 5.18 1 0 0 0 0 0 0 1 0 0 0 0 67
68 5.25 1 0 0 0 0 0 0 0 1 0 0 0 68
69 5.25 1 0 0 0 0 0 0 0 0 1 0 0 69
70 4.49 1 0 0 0 0 0 0 0 0 0 1 0 70
71 3.92 1 0 0 0 0 0 0 0 0 0 0 1 71
72 3.25 1 0 0 0 0 0 0 0 0 0 0 0 72
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Xt M1 M2 M3 M4
2.26908 0.03150 0.46644 0.43389 0.42633 0.41044
M5 M6 M7 M8 M9 M10
0.37789 0.32700 0.34278 0.35189 0.33100 0.20011
M11 t
0.08589 0.03256
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.39458 -0.36300 0.02825 0.35779 0.98192
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.269083 0.268516 8.450 1.08e-11 ***
Xt 0.031500 0.227195 0.139 0.890
M1 0.466444 0.316836 1.472 0.146
M2 0.433889 0.316270 1.372 0.175
M3 0.426333 0.315757 1.350 0.182
M4 0.410444 0.315297 1.302 0.198
M5 0.377889 0.314890 1.200 0.235
M6 0.327000 0.314538 1.040 0.303
M7 0.342778 0.314239 1.091 0.280
M8 0.351889 0.313995 1.121 0.267
M9 0.331000 0.313804 1.055 0.296
M10 0.200111 0.313668 0.638 0.526
M11 0.085889 0.313587 0.274 0.785
t 0.032556 0.004132 7.880 9.74e-11 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5431 on 58 degrees of freedom
Multiple R-squared: 0.6591, Adjusted R-squared: 0.5827
F-statistic: 8.626 on 13 and 58 DF, p-value: 2.128e-09
> 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,] 1.834641e-02 0.0366928212 0.9816536
[2,] 5.389167e-02 0.1077833303 0.9461083
[3,] 7.111177e-02 0.1422235333 0.9288882
[4,] 6.429700e-02 0.1285940044 0.9357030
[5,] 5.075832e-02 0.1015166353 0.9492417
[6,] 3.964578e-02 0.0792915680 0.9603542
[7,] 3.352340e-02 0.0670467926 0.9664766
[8,] 3.418897e-02 0.0683779357 0.9658110
[9,] 1.813834e-02 0.0362766704 0.9818617
[10,] 9.279392e-03 0.0185587847 0.9907206
[11,] 4.701233e-03 0.0094024661 0.9952988
[12,] 2.312154e-03 0.0046243071 0.9976878
[13,] 1.085285e-03 0.0021705706 0.9989147
[14,] 7.616905e-04 0.0015233810 0.9992383
[15,] 5.621762e-04 0.0011243525 0.9994378
[16,] 3.758112e-04 0.0007516225 0.9996242
[17,] 2.334302e-04 0.0004668604 0.9997666
[18,] 1.311123e-04 0.0002622246 0.9998689
[19,] 7.193398e-05 0.0001438680 0.9999281
[20,] 1.263436e-04 0.0002526872 0.9998737
[21,] 9.015784e-05 0.0001803157 0.9999098
[22,] 6.374327e-05 0.0001274865 0.9999363
[23,] 9.906358e-05 0.0001981272 0.9999009
[24,] 1.652692e-04 0.0003305384 0.9998347
[25,] 2.378445e-04 0.0004756890 0.9997622
[26,] 8.106687e-04 0.0016213374 0.9991893
[27,] 3.510888e-03 0.0070217757 0.9964891
[28,] 1.481334e-02 0.0296266788 0.9851867
[29,] 5.144369e-02 0.1028873717 0.9485563
[30,] 9.940148e-02 0.1988029569 0.9005985
[31,] 1.393712e-01 0.2787423598 0.8606288
[32,] 1.569906e-01 0.3139811229 0.8430094
[33,] 1.741841e-01 0.3483682794 0.8258159
[34,] 1.860398e-01 0.3720795994 0.8139602
[35,] 1.878591e-01 0.3757181210 0.8121409
[36,] 1.790846e-01 0.3581692902 0.8209154
[37,] 1.651471e-01 0.3302942690 0.8348529
[38,] 1.437558e-01 0.2875116944 0.8562442
[39,] 1.335503e-01 0.2671005808 0.8664497
> postscript(file="/var/www/html/rcomp/tmp/13f9x1259326235.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/23cuf1259326235.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/3ow801259326235.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/47ur61259326235.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/5zfww1259326235.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 = 72
Frequency = 1
1 2 3 4 5 6
0.98191667 0.98191667 0.75691667 0.69025000 0.69025000 0.30858333
7 8 9 10 11 12
0.16025000 0.11858333 0.10691667 0.20525000 0.28691667 0.34025000
13 14 15 16 17 18
-0.15875000 -0.15875000 -0.18375000 -0.20041667 -0.20041667 -0.18208333
19 20 21 22 23 24
-0.23041667 -0.27208333 -0.28375000 -0.18541667 -0.10375000 -0.05041667
25 26 27 28 29 30
-0.54941667 -0.54941667 -0.57441667 -0.59108333 -0.59108333 -0.57275000
31 32 33 34 35 36
-0.62108333 -0.66275000 -0.67441667 -0.57608333 -0.49441667 -0.23108333
37 38 39 40 41 42
-0.69008333 -0.69008333 -0.51508333 -0.48175000 -0.48175000 -0.32341667
43 44 45 46 47 48
-0.26175000 -0.12341667 -0.06508333 0.20325000 0.36491667 0.55825000
49 50 51 52 53 54
0.16925000 0.16925000 0.29425000 0.37758333 0.37758333 0.54591667
55 56 57 58 59 60
0.59758333 0.55591667 0.54425000 0.64258333 0.72425000 0.77758333
61 62 63 64 65 66
0.24708333 0.24708333 0.22208333 0.20541667 0.20541667 0.22375000
67 68 69 70 71 72
0.35541667 0.38375000 0.37208333 -0.28958333 -0.77791667 -1.39458333
> postscript(file="/var/www/html/rcomp/tmp/689wx1259326235.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 0.98191667 NA
1 0.98191667 0.98191667
2 0.75691667 0.98191667
3 0.69025000 0.75691667
4 0.69025000 0.69025000
5 0.30858333 0.69025000
6 0.16025000 0.30858333
7 0.11858333 0.16025000
8 0.10691667 0.11858333
9 0.20525000 0.10691667
10 0.28691667 0.20525000
11 0.34025000 0.28691667
12 -0.15875000 0.34025000
13 -0.15875000 -0.15875000
14 -0.18375000 -0.15875000
15 -0.20041667 -0.18375000
16 -0.20041667 -0.20041667
17 -0.18208333 -0.20041667
18 -0.23041667 -0.18208333
19 -0.27208333 -0.23041667
20 -0.28375000 -0.27208333
21 -0.18541667 -0.28375000
22 -0.10375000 -0.18541667
23 -0.05041667 -0.10375000
24 -0.54941667 -0.05041667
25 -0.54941667 -0.54941667
26 -0.57441667 -0.54941667
27 -0.59108333 -0.57441667
28 -0.59108333 -0.59108333
29 -0.57275000 -0.59108333
30 -0.62108333 -0.57275000
31 -0.66275000 -0.62108333
32 -0.67441667 -0.66275000
33 -0.57608333 -0.67441667
34 -0.49441667 -0.57608333
35 -0.23108333 -0.49441667
36 -0.69008333 -0.23108333
37 -0.69008333 -0.69008333
38 -0.51508333 -0.69008333
39 -0.48175000 -0.51508333
40 -0.48175000 -0.48175000
41 -0.32341667 -0.48175000
42 -0.26175000 -0.32341667
43 -0.12341667 -0.26175000
44 -0.06508333 -0.12341667
45 0.20325000 -0.06508333
46 0.36491667 0.20325000
47 0.55825000 0.36491667
48 0.16925000 0.55825000
49 0.16925000 0.16925000
50 0.29425000 0.16925000
51 0.37758333 0.29425000
52 0.37758333 0.37758333
53 0.54591667 0.37758333
54 0.59758333 0.54591667
55 0.55591667 0.59758333
56 0.54425000 0.55591667
57 0.64258333 0.54425000
58 0.72425000 0.64258333
59 0.77758333 0.72425000
60 0.24708333 0.77758333
61 0.24708333 0.24708333
62 0.22208333 0.24708333
63 0.20541667 0.22208333
64 0.20541667 0.20541667
65 0.22375000 0.20541667
66 0.35541667 0.22375000
67 0.38375000 0.35541667
68 0.37208333 0.38375000
69 -0.28958333 0.37208333
70 -0.77791667 -0.28958333
71 -1.39458333 -0.77791667
72 NA -1.39458333
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.98191667 0.98191667
[2,] 0.75691667 0.98191667
[3,] 0.69025000 0.75691667
[4,] 0.69025000 0.69025000
[5,] 0.30858333 0.69025000
[6,] 0.16025000 0.30858333
[7,] 0.11858333 0.16025000
[8,] 0.10691667 0.11858333
[9,] 0.20525000 0.10691667
[10,] 0.28691667 0.20525000
[11,] 0.34025000 0.28691667
[12,] -0.15875000 0.34025000
[13,] -0.15875000 -0.15875000
[14,] -0.18375000 -0.15875000
[15,] -0.20041667 -0.18375000
[16,] -0.20041667 -0.20041667
[17,] -0.18208333 -0.20041667
[18,] -0.23041667 -0.18208333
[19,] -0.27208333 -0.23041667
[20,] -0.28375000 -0.27208333
[21,] -0.18541667 -0.28375000
[22,] -0.10375000 -0.18541667
[23,] -0.05041667 -0.10375000
[24,] -0.54941667 -0.05041667
[25,] -0.54941667 -0.54941667
[26,] -0.57441667 -0.54941667
[27,] -0.59108333 -0.57441667
[28,] -0.59108333 -0.59108333
[29,] -0.57275000 -0.59108333
[30,] -0.62108333 -0.57275000
[31,] -0.66275000 -0.62108333
[32,] -0.67441667 -0.66275000
[33,] -0.57608333 -0.67441667
[34,] -0.49441667 -0.57608333
[35,] -0.23108333 -0.49441667
[36,] -0.69008333 -0.23108333
[37,] -0.69008333 -0.69008333
[38,] -0.51508333 -0.69008333
[39,] -0.48175000 -0.51508333
[40,] -0.48175000 -0.48175000
[41,] -0.32341667 -0.48175000
[42,] -0.26175000 -0.32341667
[43,] -0.12341667 -0.26175000
[44,] -0.06508333 -0.12341667
[45,] 0.20325000 -0.06508333
[46,] 0.36491667 0.20325000
[47,] 0.55825000 0.36491667
[48,] 0.16925000 0.55825000
[49,] 0.16925000 0.16925000
[50,] 0.29425000 0.16925000
[51,] 0.37758333 0.29425000
[52,] 0.37758333 0.37758333
[53,] 0.54591667 0.37758333
[54,] 0.59758333 0.54591667
[55,] 0.55591667 0.59758333
[56,] 0.54425000 0.55591667
[57,] 0.64258333 0.54425000
[58,] 0.72425000 0.64258333
[59,] 0.77758333 0.72425000
[60,] 0.24708333 0.77758333
[61,] 0.24708333 0.24708333
[62,] 0.22208333 0.24708333
[63,] 0.20541667 0.22208333
[64,] 0.20541667 0.20541667
[65,] 0.22375000 0.20541667
[66,] 0.35541667 0.22375000
[67,] 0.38375000 0.35541667
[68,] 0.37208333 0.38375000
[69,] -0.28958333 0.37208333
[70,] -0.77791667 -0.28958333
[71,] -1.39458333 -0.77791667
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.98191667 0.98191667
2 0.75691667 0.98191667
3 0.69025000 0.75691667
4 0.69025000 0.69025000
5 0.30858333 0.69025000
6 0.16025000 0.30858333
7 0.11858333 0.16025000
8 0.10691667 0.11858333
9 0.20525000 0.10691667
10 0.28691667 0.20525000
11 0.34025000 0.28691667
12 -0.15875000 0.34025000
13 -0.15875000 -0.15875000
14 -0.18375000 -0.15875000
15 -0.20041667 -0.18375000
16 -0.20041667 -0.20041667
17 -0.18208333 -0.20041667
18 -0.23041667 -0.18208333
19 -0.27208333 -0.23041667
20 -0.28375000 -0.27208333
21 -0.18541667 -0.28375000
22 -0.10375000 -0.18541667
23 -0.05041667 -0.10375000
24 -0.54941667 -0.05041667
25 -0.54941667 -0.54941667
26 -0.57441667 -0.54941667
27 -0.59108333 -0.57441667
28 -0.59108333 -0.59108333
29 -0.57275000 -0.59108333
30 -0.62108333 -0.57275000
31 -0.66275000 -0.62108333
32 -0.67441667 -0.66275000
33 -0.57608333 -0.67441667
34 -0.49441667 -0.57608333
35 -0.23108333 -0.49441667
36 -0.69008333 -0.23108333
37 -0.69008333 -0.69008333
38 -0.51508333 -0.69008333
39 -0.48175000 -0.51508333
40 -0.48175000 -0.48175000
41 -0.32341667 -0.48175000
42 -0.26175000 -0.32341667
43 -0.12341667 -0.26175000
44 -0.06508333 -0.12341667
45 0.20325000 -0.06508333
46 0.36491667 0.20325000
47 0.55825000 0.36491667
48 0.16925000 0.55825000
49 0.16925000 0.16925000
50 0.29425000 0.16925000
51 0.37758333 0.29425000
52 0.37758333 0.37758333
53 0.54591667 0.37758333
54 0.59758333 0.54591667
55 0.55591667 0.59758333
56 0.54425000 0.55591667
57 0.64258333 0.54425000
58 0.72425000 0.64258333
59 0.77758333 0.72425000
60 0.24708333 0.77758333
61 0.24708333 0.24708333
62 0.22208333 0.24708333
63 0.20541667 0.22208333
64 0.20541667 0.20541667
65 0.22375000 0.20541667
66 0.35541667 0.22375000
67 0.38375000 0.35541667
68 0.37208333 0.38375000
69 -0.28958333 0.37208333
70 -0.77791667 -0.28958333
71 -1.39458333 -0.77791667
> 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/7oqfn1259326235.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/8idd61259326235.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/9b5lr1259326235.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/10o4bx1259326235.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/11bp1j1259326235.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/12uxs31259326235.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/13nyda1259326235.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/14ytwv1259326235.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/15x99d1259326235.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/167la61259326235.tab")
+ }
>
> system("convert tmp/13f9x1259326235.ps tmp/13f9x1259326235.png")
> system("convert tmp/23cuf1259326235.ps tmp/23cuf1259326235.png")
> system("convert tmp/3ow801259326235.ps tmp/3ow801259326235.png")
> system("convert tmp/47ur61259326235.ps tmp/47ur61259326235.png")
> system("convert tmp/5zfww1259326235.ps tmp/5zfww1259326235.png")
> system("convert tmp/689wx1259326235.ps tmp/689wx1259326235.png")
> system("convert tmp/7oqfn1259326235.ps tmp/7oqfn1259326235.png")
> system("convert tmp/8idd61259326235.ps tmp/8idd61259326235.png")
> system("convert tmp/9b5lr1259326235.ps tmp/9b5lr1259326235.png")
> system("convert tmp/10o4bx1259326235.ps tmp/10o4bx1259326235.png")
>
>
> proc.time()
user system elapsed
2.527 1.574 3.272