R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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(1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,1,2,2,2,1,1,2,2,2,2,2,2,2,2,1,2,1,1,2,2,2,2,1,2,2,1,1,2,1,1,1,1,1,1,2,2,2,2,2,2,2,1,1,1,1,2,2,2,1,2,1,2,2,2,2,2,1,2,2,2,2,1,1,2,2,2,1,2,1,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,1,1,1,2,2,2,1,2,2,2,2,2,2,1,2,2,2,2,1,1,2,2,1,2,1,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,1,1,1,1,2,2,2,2,2,2,1,1,2,2,2,2,2,1,1,2,2,2,1,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,1,2,1,2,1,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,1,1,1,2,1,2,2,2,2,2,2,1,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,1,2,2,2),dim=c(4,86),dimnames=list(c('Uselimit','treatment4','usedstats','correctanalysis'),1:86))
> y <- array(NA,dim=c(4,86),dimnames=list(c('Uselimit','treatment4','usedstats','correctanalysis'),1:86))
> 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 = '4'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
correctanalysis Uselimit treatment4 usedstats
1 2 1 1 2
2 2 2 2 2
3 2 2 2 2
4 2 2 2 2
5 2 2 2 2
6 2 1 2 2
7 2 2 2 2
8 2 2 1 2
9 2 2 2 2
10 2 1 2 2
11 2 1 1 2
12 2 2 2 2
13 2 2 2 1
14 2 1 1 2
15 2 2 2 1
16 2 2 1 1
17 1 1 1 1
18 2 1 1 2
19 2 2 2 2
20 1 2 1 1
21 2 1 2 2
22 2 1 2 1
23 2 2 2 2
24 2 1 2 2
25 2 2 1 1
26 2 2 2 1
27 2 1 2 2
28 2 2 2 1
29 2 2 2 2
30 2 2 2 2
31 2 2 2 2
32 2 1 2 2
33 2 1 2 2
34 2 2 1 2
35 2 2 2 2
36 2 2 2 2
37 2 1 1 1
38 2 2 2 1
39 2 2 2 2
40 2 2 1 2
41 1 2 2 1
42 2 2 2 1
43 2 1 2 2
44 2 1 1 2
45 2 2 2 2
46 2 2 2 2
47 2 2 2 2
48 2 2 2 2
49 2 2 2 2
50 2 2 2 2
51 2 2 1 1
52 1 1 1 1
53 2 2 2 2
54 1 2 2 1
55 2 2 2 2
56 2 2 1 1
57 2 2 2 1
58 2 2 2 2
59 2 2 2 2
60 1 1 1 1
61 2 1 1 2
62 2 2 2 1
63 2 2 2 2
64 2 1 1 2
65 2 2 2 2
66 2 2 2 2
67 1 2 1 1
68 2 1 2 2
69 2 2 2 2
70 2 2 2 1
71 2 2 2 2
72 2 2 2 2
73 2 2 2 1
74 2 1 2 1
75 2 2 2 2
76 2 2 1 2
77 2 2 2 2
78 2 2 2 1
79 1 2 1 1
80 2 2 1 2
81 2 2 2 2
82 2 1 2 1
83 2 2 2 2
84 1 2 2 1
85 2 2 2 2
86 2 1 2 2
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Uselimit treatment4 usedstats
1.138310 0.001881 0.151606 0.293317
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.73860 -0.03192 -0.03192 0.12157 0.41489
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.138310 0.168118 6.771 1.78e-09 ***
Uselimit 0.001881 0.066339 0.028 0.9774
treatment4 0.151606 0.068498 2.213 0.0297 *
usedstats 0.293317 0.062393 4.701 1.03e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2644 on 82 degrees of freedom
Multiple R-squared: 0.2887, Adjusted R-squared: 0.2626
F-statistic: 11.09 on 3 and 82 DF, p-value: 3.472e-06
> 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.176850e-94 2.353701e-94 1.0000000
[2,] 7.577443e-61 1.515489e-60 1.0000000
[3,] 7.568873e-78 1.513775e-77 1.0000000
[4,] 4.211135e-93 8.422271e-93 1.0000000
[5,] 5.590623e-113 1.118125e-112 1.0000000
[6,] 1.784974e-120 3.569948e-120 1.0000000
[7,] 4.073789e-154 8.147579e-154 1.0000000
[8,] 5.107704e-149 1.021541e-148 1.0000000
[9,] 4.843538e-164 9.687077e-164 1.0000000
[10,] 0.000000e+00 0.000000e+00 1.0000000
[11,] 1.540157e-01 3.080314e-01 0.8459843
[12,] 1.168106e-01 2.336211e-01 0.8831894
[13,] 8.140091e-02 1.628018e-01 0.9185991
[14,] 4.003440e-01 8.006880e-01 0.5996560
[15,] 3.247354e-01 6.494708e-01 0.6752646
[16,] 3.332549e-01 6.665098e-01 0.6667451
[17,] 2.681450e-01 5.362899e-01 0.7318550
[18,] 2.111104e-01 4.222207e-01 0.7888896
[19,] 2.843116e-01 5.686232e-01 0.7156884
[20,] 2.604031e-01 5.208061e-01 0.7395969
[21,] 2.053239e-01 4.106478e-01 0.7946761
[22,] 1.843589e-01 3.687178e-01 0.8156411
[23,] 1.423602e-01 2.847205e-01 0.8576398
[24,] 1.074239e-01 2.148478e-01 0.8925761
[25,] 7.920470e-02 1.584094e-01 0.9207953
[26,] 5.672250e-02 1.134450e-01 0.9432775
[27,] 3.972256e-02 7.944512e-02 0.9602774
[28,] 2.937944e-02 5.875889e-02 0.9706206
[29,] 1.993336e-02 3.986672e-02 0.9800666
[30,] 1.320890e-02 2.641779e-02 0.9867911
[31,] 2.061812e-02 4.123624e-02 0.9793819
[32,] 1.806314e-02 3.612627e-02 0.9819369
[33,] 1.194544e-02 2.389088e-02 0.9880546
[34,] 8.472543e-03 1.694509e-02 0.9915275
[35,] 1.559288e-01 3.118576e-01 0.8440712
[36,] 1.511365e-01 3.022729e-01 0.8488635
[37,] 1.167782e-01 2.335564e-01 0.8832218
[38,] 9.406857e-02 1.881371e-01 0.9059314
[39,] 6.994346e-02 1.398869e-01 0.9300565
[40,] 5.089039e-02 1.017808e-01 0.9491096
[41,] 3.621980e-02 7.243960e-02 0.9637802
[42,] 2.520702e-02 5.041404e-02 0.9747930
[43,] 1.714799e-02 3.429598e-02 0.9828520
[44,] 1.139934e-02 2.279868e-02 0.9886007
[45,] 2.293623e-02 4.587245e-02 0.9770638
[46,] 8.773696e-02 1.754739e-01 0.9122630
[47,] 6.470745e-02 1.294149e-01 0.9352925
[48,] 3.201538e-01 6.403076e-01 0.6798462
[49,] 2.638151e-01 5.276302e-01 0.7361849
[50,] 4.381940e-01 8.763880e-01 0.5618060
[51,] 4.531011e-01 9.062022e-01 0.5468989
[52,] 3.872940e-01 7.745880e-01 0.6127060
[53,] 3.243209e-01 6.486417e-01 0.6756791
[54,] 5.333615e-01 9.332769e-01 0.4666385
[55,] 4.744419e-01 9.488838e-01 0.5255581
[56,] 4.976995e-01 9.953990e-01 0.5023005
[57,] 4.243629e-01 8.487258e-01 0.5756371
[58,] 3.687207e-01 7.374414e-01 0.6312793
[59,] 2.998217e-01 5.996434e-01 0.7001783
[60,] 2.366521e-01 4.733043e-01 0.7633479
[61,] 3.620866e-01 7.241732e-01 0.6379134
[62,] 3.132926e-01 6.265853e-01 0.6867074
[63,] 2.434647e-01 4.869294e-01 0.7565353
[64,] 2.676453e-01 5.352907e-01 0.7323547
[65,] 1.998138e-01 3.996276e-01 0.8001862
[66,] 1.422280e-01 2.844559e-01 0.8577720
[67,] 2.038901e-01 4.077803e-01 0.7961099
[68,] 1.761180e-01 3.522360e-01 0.8238820
[69,] 1.162425e-01 2.324849e-01 0.8837575
[70,] 8.589357e-02 1.717871e-01 0.9141064
[71,] 4.839477e-02 9.678953e-02 0.9516052
[72,] 2.395161e-01 4.790322e-01 0.7604839
[73,] 2.277647e-01 4.555295e-01 0.7722353
> postscript(file="/var/fisher/rcomp/tmp/1cyor1356128554.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/fisher/rcomp/tmp/2xb4r1356128554.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/fisher/rcomp/tmp/3w5eu1356128554.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/fisher/rcomp/tmp/4898y1356128554.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/fisher/rcomp/tmp/5syp21356128554.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 = 86
Frequency = 1
1 2 3 4 5 6
0.12156912 -0.03191818 -0.03191818 -0.03191818 -0.03191818 -0.03003684
7 8 9 10 11 12
-0.03191818 0.11968778 -0.03191818 -0.03003684 0.12156912 -0.03191818
13 14 15 16 17 18
0.26139875 0.12156912 0.26139875 0.41300471 -0.58511395 0.12156912
19 20 21 22 23 24
-0.03191818 -0.58699529 -0.03003684 0.26328009 -0.03191818 -0.03003684
25 26 27 28 29 30
0.41300471 0.26139875 -0.03003684 0.26139875 -0.03191818 -0.03191818
31 32 33 34 35 36
-0.03191818 -0.03003684 -0.03003684 0.11968778 -0.03191818 -0.03191818
37 38 39 40 41 42
0.41488605 0.26139875 -0.03191818 0.11968778 -0.73860125 0.26139875
43 44 45 46 47 48
-0.03003684 0.12156912 -0.03191818 -0.03191818 -0.03191818 -0.03191818
49 50 51 52 53 54
-0.03191818 -0.03191818 0.41300471 -0.58511395 -0.03191818 -0.73860125
55 56 57 58 59 60
-0.03191818 0.41300471 0.26139875 -0.03191818 -0.03191818 -0.58511395
61 62 63 64 65 66
0.12156912 0.26139875 -0.03191818 0.12156912 -0.03191818 -0.03191818
67 68 69 70 71 72
-0.58699529 -0.03003684 -0.03191818 0.26139875 -0.03191818 -0.03191818
73 74 75 76 77 78
0.26139875 0.26328009 -0.03191818 0.11968778 -0.03191818 0.26139875
79 80 81 82 83 84
-0.58699529 0.11968778 -0.03191818 0.26328009 -0.03191818 -0.73860125
85 86
-0.03191818 -0.03003684
> postscript(file="/var/fisher/rcomp/tmp/6862r1356128554.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 = 86
Frequency = 1
lag(myerror, k = 1) myerror
0 0.12156912 NA
1 -0.03191818 0.12156912
2 -0.03191818 -0.03191818
3 -0.03191818 -0.03191818
4 -0.03191818 -0.03191818
5 -0.03003684 -0.03191818
6 -0.03191818 -0.03003684
7 0.11968778 -0.03191818
8 -0.03191818 0.11968778
9 -0.03003684 -0.03191818
10 0.12156912 -0.03003684
11 -0.03191818 0.12156912
12 0.26139875 -0.03191818
13 0.12156912 0.26139875
14 0.26139875 0.12156912
15 0.41300471 0.26139875
16 -0.58511395 0.41300471
17 0.12156912 -0.58511395
18 -0.03191818 0.12156912
19 -0.58699529 -0.03191818
20 -0.03003684 -0.58699529
21 0.26328009 -0.03003684
22 -0.03191818 0.26328009
23 -0.03003684 -0.03191818
24 0.41300471 -0.03003684
25 0.26139875 0.41300471
26 -0.03003684 0.26139875
27 0.26139875 -0.03003684
28 -0.03191818 0.26139875
29 -0.03191818 -0.03191818
30 -0.03191818 -0.03191818
31 -0.03003684 -0.03191818
32 -0.03003684 -0.03003684
33 0.11968778 -0.03003684
34 -0.03191818 0.11968778
35 -0.03191818 -0.03191818
36 0.41488605 -0.03191818
37 0.26139875 0.41488605
38 -0.03191818 0.26139875
39 0.11968778 -0.03191818
40 -0.73860125 0.11968778
41 0.26139875 -0.73860125
42 -0.03003684 0.26139875
43 0.12156912 -0.03003684
44 -0.03191818 0.12156912
45 -0.03191818 -0.03191818
46 -0.03191818 -0.03191818
47 -0.03191818 -0.03191818
48 -0.03191818 -0.03191818
49 -0.03191818 -0.03191818
50 0.41300471 -0.03191818
51 -0.58511395 0.41300471
52 -0.03191818 -0.58511395
53 -0.73860125 -0.03191818
54 -0.03191818 -0.73860125
55 0.41300471 -0.03191818
56 0.26139875 0.41300471
57 -0.03191818 0.26139875
58 -0.03191818 -0.03191818
59 -0.58511395 -0.03191818
60 0.12156912 -0.58511395
61 0.26139875 0.12156912
62 -0.03191818 0.26139875
63 0.12156912 -0.03191818
64 -0.03191818 0.12156912
65 -0.03191818 -0.03191818
66 -0.58699529 -0.03191818
67 -0.03003684 -0.58699529
68 -0.03191818 -0.03003684
69 0.26139875 -0.03191818
70 -0.03191818 0.26139875
71 -0.03191818 -0.03191818
72 0.26139875 -0.03191818
73 0.26328009 0.26139875
74 -0.03191818 0.26328009
75 0.11968778 -0.03191818
76 -0.03191818 0.11968778
77 0.26139875 -0.03191818
78 -0.58699529 0.26139875
79 0.11968778 -0.58699529
80 -0.03191818 0.11968778
81 0.26328009 -0.03191818
82 -0.03191818 0.26328009
83 -0.73860125 -0.03191818
84 -0.03191818 -0.73860125
85 -0.03003684 -0.03191818
86 NA -0.03003684
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.03191818 0.12156912
[2,] -0.03191818 -0.03191818
[3,] -0.03191818 -0.03191818
[4,] -0.03191818 -0.03191818
[5,] -0.03003684 -0.03191818
[6,] -0.03191818 -0.03003684
[7,] 0.11968778 -0.03191818
[8,] -0.03191818 0.11968778
[9,] -0.03003684 -0.03191818
[10,] 0.12156912 -0.03003684
[11,] -0.03191818 0.12156912
[12,] 0.26139875 -0.03191818
[13,] 0.12156912 0.26139875
[14,] 0.26139875 0.12156912
[15,] 0.41300471 0.26139875
[16,] -0.58511395 0.41300471
[17,] 0.12156912 -0.58511395
[18,] -0.03191818 0.12156912
[19,] -0.58699529 -0.03191818
[20,] -0.03003684 -0.58699529
[21,] 0.26328009 -0.03003684
[22,] -0.03191818 0.26328009
[23,] -0.03003684 -0.03191818
[24,] 0.41300471 -0.03003684
[25,] 0.26139875 0.41300471
[26,] -0.03003684 0.26139875
[27,] 0.26139875 -0.03003684
[28,] -0.03191818 0.26139875
[29,] -0.03191818 -0.03191818
[30,] -0.03191818 -0.03191818
[31,] -0.03003684 -0.03191818
[32,] -0.03003684 -0.03003684
[33,] 0.11968778 -0.03003684
[34,] -0.03191818 0.11968778
[35,] -0.03191818 -0.03191818
[36,] 0.41488605 -0.03191818
[37,] 0.26139875 0.41488605
[38,] -0.03191818 0.26139875
[39,] 0.11968778 -0.03191818
[40,] -0.73860125 0.11968778
[41,] 0.26139875 -0.73860125
[42,] -0.03003684 0.26139875
[43,] 0.12156912 -0.03003684
[44,] -0.03191818 0.12156912
[45,] -0.03191818 -0.03191818
[46,] -0.03191818 -0.03191818
[47,] -0.03191818 -0.03191818
[48,] -0.03191818 -0.03191818
[49,] -0.03191818 -0.03191818
[50,] 0.41300471 -0.03191818
[51,] -0.58511395 0.41300471
[52,] -0.03191818 -0.58511395
[53,] -0.73860125 -0.03191818
[54,] -0.03191818 -0.73860125
[55,] 0.41300471 -0.03191818
[56,] 0.26139875 0.41300471
[57,] -0.03191818 0.26139875
[58,] -0.03191818 -0.03191818
[59,] -0.58511395 -0.03191818
[60,] 0.12156912 -0.58511395
[61,] 0.26139875 0.12156912
[62,] -0.03191818 0.26139875
[63,] 0.12156912 -0.03191818
[64,] -0.03191818 0.12156912
[65,] -0.03191818 -0.03191818
[66,] -0.58699529 -0.03191818
[67,] -0.03003684 -0.58699529
[68,] -0.03191818 -0.03003684
[69,] 0.26139875 -0.03191818
[70,] -0.03191818 0.26139875
[71,] -0.03191818 -0.03191818
[72,] 0.26139875 -0.03191818
[73,] 0.26328009 0.26139875
[74,] -0.03191818 0.26328009
[75,] 0.11968778 -0.03191818
[76,] -0.03191818 0.11968778
[77,] 0.26139875 -0.03191818
[78,] -0.58699529 0.26139875
[79,] 0.11968778 -0.58699529
[80,] -0.03191818 0.11968778
[81,] 0.26328009 -0.03191818
[82,] -0.03191818 0.26328009
[83,] -0.73860125 -0.03191818
[84,] -0.03191818 -0.73860125
[85,] -0.03003684 -0.03191818
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.03191818 0.12156912
2 -0.03191818 -0.03191818
3 -0.03191818 -0.03191818
4 -0.03191818 -0.03191818
5 -0.03003684 -0.03191818
6 -0.03191818 -0.03003684
7 0.11968778 -0.03191818
8 -0.03191818 0.11968778
9 -0.03003684 -0.03191818
10 0.12156912 -0.03003684
11 -0.03191818 0.12156912
12 0.26139875 -0.03191818
13 0.12156912 0.26139875
14 0.26139875 0.12156912
15 0.41300471 0.26139875
16 -0.58511395 0.41300471
17 0.12156912 -0.58511395
18 -0.03191818 0.12156912
19 -0.58699529 -0.03191818
20 -0.03003684 -0.58699529
21 0.26328009 -0.03003684
22 -0.03191818 0.26328009
23 -0.03003684 -0.03191818
24 0.41300471 -0.03003684
25 0.26139875 0.41300471
26 -0.03003684 0.26139875
27 0.26139875 -0.03003684
28 -0.03191818 0.26139875
29 -0.03191818 -0.03191818
30 -0.03191818 -0.03191818
31 -0.03003684 -0.03191818
32 -0.03003684 -0.03003684
33 0.11968778 -0.03003684
34 -0.03191818 0.11968778
35 -0.03191818 -0.03191818
36 0.41488605 -0.03191818
37 0.26139875 0.41488605
38 -0.03191818 0.26139875
39 0.11968778 -0.03191818
40 -0.73860125 0.11968778
41 0.26139875 -0.73860125
42 -0.03003684 0.26139875
43 0.12156912 -0.03003684
44 -0.03191818 0.12156912
45 -0.03191818 -0.03191818
46 -0.03191818 -0.03191818
47 -0.03191818 -0.03191818
48 -0.03191818 -0.03191818
49 -0.03191818 -0.03191818
50 0.41300471 -0.03191818
51 -0.58511395 0.41300471
52 -0.03191818 -0.58511395
53 -0.73860125 -0.03191818
54 -0.03191818 -0.73860125
55 0.41300471 -0.03191818
56 0.26139875 0.41300471
57 -0.03191818 0.26139875
58 -0.03191818 -0.03191818
59 -0.58511395 -0.03191818
60 0.12156912 -0.58511395
61 0.26139875 0.12156912
62 -0.03191818 0.26139875
63 0.12156912 -0.03191818
64 -0.03191818 0.12156912
65 -0.03191818 -0.03191818
66 -0.58699529 -0.03191818
67 -0.03003684 -0.58699529
68 -0.03191818 -0.03003684
69 0.26139875 -0.03191818
70 -0.03191818 0.26139875
71 -0.03191818 -0.03191818
72 0.26139875 -0.03191818
73 0.26328009 0.26139875
74 -0.03191818 0.26328009
75 0.11968778 -0.03191818
76 -0.03191818 0.11968778
77 0.26139875 -0.03191818
78 -0.58699529 0.26139875
79 0.11968778 -0.58699529
80 -0.03191818 0.11968778
81 0.26328009 -0.03191818
82 -0.03191818 0.26328009
83 -0.73860125 -0.03191818
84 -0.03191818 -0.73860125
85 -0.03003684 -0.03191818
> 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/fisher/rcomp/tmp/7s8r31356128554.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/fisher/rcomp/tmp/8iojy1356128554.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/fisher/rcomp/tmp/96ces1356128554.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/fisher/rcomp/tmp/10u54m1356128554.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/11jcus1356128554.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/fisher/rcomp/tmp/12wyco1356128554.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/fisher/rcomp/tmp/13t5561356128554.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/fisher/rcomp/tmp/14ahfq1356128554.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/fisher/rcomp/tmp/1559jm1356128554.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/fisher/rcomp/tmp/166jno1356128554.tab")
+ }
>
> try(system("convert tmp/1cyor1356128554.ps tmp/1cyor1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/2xb4r1356128554.ps tmp/2xb4r1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/3w5eu1356128554.ps tmp/3w5eu1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/4898y1356128554.ps tmp/4898y1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/5syp21356128554.ps tmp/5syp21356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/6862r1356128554.ps tmp/6862r1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/7s8r31356128554.ps tmp/7s8r31356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/8iojy1356128554.ps tmp/8iojy1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/96ces1356128554.ps tmp/96ces1356128554.png",intern=TRUE))
character(0)
> try(system("convert tmp/10u54m1356128554.ps tmp/10u54m1356128554.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.252 1.728 8.006