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(18.0,16.4,19.6,17.8,23.3,22.3,23.7,22.8,20.3,18.3,22.8,22.4,24.3,23.9,21.5,21.3,23.5,23.0,22.2,21.4,20.9,21.2,22.2,20.9,19.5,17.9,21.1,20.7,22.0,22.2,19.2,19.8,17.8,17.7,19.2,19.6,19.9,20.8,19.6,19.8,18.1,18.6,20.4,21.,18.1,18.6,18.6,18.9,17.6,17.3,19.4,20.0,19.3,19.9,18.6,19.5,16.9,16.2,16.4,17.6,19.0,19.8,18.7,19.4,17.1,17.2,21.5,21.1,17.8,17.8,18.1,17.5,19.0,18.0,18.9,19.1,16.8,17.7,18.1,19.2,15.7,15.1,15.1,16.3,18.3,18.6,16.5,17.2,16.9,17.8,18.4,19.1,16.4,16.6,15.7,16.0,16.9,16.7,16.6,17.4,16.7,17.9,16.6,17.8,14.4,13.9,14.5,15.9,17.5,17.9,14.3,15.4,15.4,16.4,17.2,17.9,14.6,15.3,14.2,14.6,14.9,14.9,14.1,15.0,15.6,16.7,14.6,16.3,11.9,11.7,13.5,15.1,14.2,15.5,13.7,15.0,14.4,15.4,15.3,16.0,14.3,14.7,14.5,14.8),dim=c(2,72),dimnames=list(c('Y','X'),1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('Y','X'),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 = 'No 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 18.0 16.4 1 0 0 0 0 0 0 0 0 0 0
2 19.6 17.8 0 1 0 0 0 0 0 0 0 0 0
3 23.3 22.3 0 0 1 0 0 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0 1 0 0 0 0
68 13.7 15.0 0 0 0 0 0 0 0 1 0 0 0
69 14.4 15.4 0 0 0 0 0 0 0 0 1 0 0
70 15.3 16.0 0 0 0 0 0 0 0 0 0 1 0
71 14.3 14.7 0 0 0 0 0 0 0 0 0 0 1
72 14.5 14.8 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
-3.4169 1.2055 0.7347 -0.4000 -1.0794 -1.3016
M5 M6 M7 M8 M9 M10
0.9189 -1.1438 -1.1226 -0.9183 -0.7952 -0.8226
M11
-0.5014
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.03878 -0.31226 -0.02558 0.25425 1.95958
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.41689 0.53080 -6.437 2.41e-08 ***
X 1.20547 0.02839 42.457 < 2e-16 ***
M1 0.73470 0.30194 2.433 0.018014 *
M2 -0.39998 0.30383 -1.316 0.193109
M3 -1.07942 0.30905 -3.493 0.000913 ***
M4 -1.30157 0.30778 -4.229 8.29e-05 ***
M5 0.91893 0.30540 3.009 0.003852 **
M6 -1.14383 0.30251 -3.781 0.000367 ***
M7 -1.12257 0.30884 -3.635 0.000585 ***
M8 -0.91825 0.30294 -3.031 0.003615 **
M9 -0.79519 0.30306 -2.624 0.011050 *
M10 -0.82257 0.30884 -2.663 0.009957 **
M11 -0.50137 0.30194 -1.660 0.102128
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5228 on 59 degrees of freedom
Multiple R-squared: 0.9715, Adjusted R-squared: 0.9658
F-statistic: 167.9 on 12 and 59 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.9999431 1.138377e-04 5.691884e-05
[2,] 0.9999995 9.626925e-07 4.813463e-07
[3,] 0.9999992 1.552865e-06 7.764326e-07
[4,] 0.9999994 1.191974e-06 5.959868e-07
[5,] 0.9999985 2.946668e-06 1.473334e-06
[6,] 0.9999953 9.366001e-06 4.683001e-06
[7,] 0.9999989 2.289215e-06 1.144607e-06
[8,] 0.9999988 2.384809e-06 1.192405e-06
[9,] 0.9999998 3.264754e-07 1.632377e-07
[10,] 0.9999999 1.150352e-07 5.751760e-08
[11,] 1.0000000 5.675203e-09 2.837602e-09
[12,] 1.0000000 1.739792e-08 8.698961e-09
[13,] 1.0000000 4.287683e-08 2.143842e-08
[14,] 0.9999999 1.190802e-07 5.954011e-08
[15,] 0.9999998 3.323079e-07 1.661539e-07
[16,] 0.9999999 1.944406e-07 9.722030e-08
[17,] 0.9999999 2.498731e-07 1.249366e-07
[18,] 1.0000000 2.426923e-08 1.213462e-08
[19,] 1.0000000 2.565875e-08 1.282938e-08
[20,] 1.0000000 5.935859e-08 2.967930e-08
[21,] 1.0000000 2.513388e-08 1.256694e-08
[22,] 1.0000000 7.789516e-09 3.894758e-09
[23,] 1.0000000 1.631545e-08 8.157724e-09
[24,] 1.0000000 4.636804e-08 2.318402e-08
[25,] 0.9999999 1.544707e-07 7.723537e-08
[26,] 0.9999997 5.619879e-07 2.809939e-07
[27,] 0.9999992 1.578093e-06 7.890463e-07
[28,] 0.9999989 2.211918e-06 1.105959e-06
[29,] 0.9999977 4.563844e-06 2.281922e-06
[30,] 0.9999932 1.351941e-05 6.759705e-06
[31,] 0.9999887 2.255932e-05 1.127966e-05
[32,] 0.9999679 6.411980e-05 3.205990e-05
[33,] 0.9999021 1.958296e-04 9.791481e-05
[34,] 0.9997209 5.582238e-04 2.791119e-04
[35,] 0.9994700 1.059936e-03 5.299681e-04
[36,] 0.9990454 1.909176e-03 9.545881e-04
[37,] 0.9975617 4.876564e-03 2.438282e-03
[38,] 0.9926344 1.473121e-02 7.365604e-03
[39,] 0.9780094 4.398111e-02 2.199056e-02
[40,] 0.9954990 9.002074e-03 4.501037e-03
[41,] 0.9872399 2.552014e-02 1.276007e-02
> postscript(file="/var/www/html/rcomp/tmp/18l1l1258744856.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/283yj1258744856.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/37zse1258744856.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/4b1kl1258744856.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/53p0q1258744856.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.912550605 1.959581644 0.914423091 0.933839424 0.737938611 0.358282749
7 8 9 10 11 12
0.028829307 0.158721339 -0.013630205 0.642493262 -0.737618065 0.422655215
13 14 15 16 17 18
0.604352232 -0.036268544 -0.265030351 0.050236170 -1.038782040 0.133586379
19 20 21 22 23 24
-0.634227389 0.066919712 -0.109581644 -0.675320505 -0.403407551 -0.766413621
25 26 27 28 29 30
-0.572368419 -0.892442637 -0.192459512 -0.188124155 -0.130583667 -0.255482457
31 32 33 34 35 36
-0.328761806 -0.350894055 0.578070171 0.304132937 0.260964914 0.421238194
37 38 39 40 41 42
-0.016194326 -0.307523613 -0.040435231 -0.326484481 -0.004571527 0.011622799
43 44 45 46 47 48
0.417796892 0.101130225 -0.345209178 -0.384935899 0.307523613 -0.170563433
49 50 51 52 53 54
-0.549089070 -0.558232123 -0.381528348 -0.138832666 0.141987172 -0.106190968
55 56 57 58 59 60
0.461622799 0.070968273 -0.157557363 -0.138377201 0.074628870 0.017088382
61 62 63 64 65 66
-0.379251022 -0.165114726 -0.034969649 -0.330634293 0.294011452 -0.141818502
67 68 69 70 71 72
0.054740196 -0.046845494 0.047908219 0.252007405 0.497908219 0.075995265
> postscript(file="/var/www/html/rcomp/tmp/61ycm1258744856.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.912550605 NA
1 1.959581644 0.912550605
2 0.914423091 1.959581644
3 0.933839424 0.914423091
4 0.737938611 0.933839424
5 0.358282749 0.737938611
6 0.028829307 0.358282749
7 0.158721339 0.028829307
8 -0.013630205 0.158721339
9 0.642493262 -0.013630205
10 -0.737618065 0.642493262
11 0.422655215 -0.737618065
12 0.604352232 0.422655215
13 -0.036268544 0.604352232
14 -0.265030351 -0.036268544
15 0.050236170 -0.265030351
16 -1.038782040 0.050236170
17 0.133586379 -1.038782040
18 -0.634227389 0.133586379
19 0.066919712 -0.634227389
20 -0.109581644 0.066919712
21 -0.675320505 -0.109581644
22 -0.403407551 -0.675320505
23 -0.766413621 -0.403407551
24 -0.572368419 -0.766413621
25 -0.892442637 -0.572368419
26 -0.192459512 -0.892442637
27 -0.188124155 -0.192459512
28 -0.130583667 -0.188124155
29 -0.255482457 -0.130583667
30 -0.328761806 -0.255482457
31 -0.350894055 -0.328761806
32 0.578070171 -0.350894055
33 0.304132937 0.578070171
34 0.260964914 0.304132937
35 0.421238194 0.260964914
36 -0.016194326 0.421238194
37 -0.307523613 -0.016194326
38 -0.040435231 -0.307523613
39 -0.326484481 -0.040435231
40 -0.004571527 -0.326484481
41 0.011622799 -0.004571527
42 0.417796892 0.011622799
43 0.101130225 0.417796892
44 -0.345209178 0.101130225
45 -0.384935899 -0.345209178
46 0.307523613 -0.384935899
47 -0.170563433 0.307523613
48 -0.549089070 -0.170563433
49 -0.558232123 -0.549089070
50 -0.381528348 -0.558232123
51 -0.138832666 -0.381528348
52 0.141987172 -0.138832666
53 -0.106190968 0.141987172
54 0.461622799 -0.106190968
55 0.070968273 0.461622799
56 -0.157557363 0.070968273
57 -0.138377201 -0.157557363
58 0.074628870 -0.138377201
59 0.017088382 0.074628870
60 -0.379251022 0.017088382
61 -0.165114726 -0.379251022
62 -0.034969649 -0.165114726
63 -0.330634293 -0.034969649
64 0.294011452 -0.330634293
65 -0.141818502 0.294011452
66 0.054740196 -0.141818502
67 -0.046845494 0.054740196
68 0.047908219 -0.046845494
69 0.252007405 0.047908219
70 0.497908219 0.252007405
71 0.075995265 0.497908219
72 NA 0.075995265
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.959581644 0.912550605
[2,] 0.914423091 1.959581644
[3,] 0.933839424 0.914423091
[4,] 0.737938611 0.933839424
[5,] 0.358282749 0.737938611
[6,] 0.028829307 0.358282749
[7,] 0.158721339 0.028829307
[8,] -0.013630205 0.158721339
[9,] 0.642493262 -0.013630205
[10,] -0.737618065 0.642493262
[11,] 0.422655215 -0.737618065
[12,] 0.604352232 0.422655215
[13,] -0.036268544 0.604352232
[14,] -0.265030351 -0.036268544
[15,] 0.050236170 -0.265030351
[16,] -1.038782040 0.050236170
[17,] 0.133586379 -1.038782040
[18,] -0.634227389 0.133586379
[19,] 0.066919712 -0.634227389
[20,] -0.109581644 0.066919712
[21,] -0.675320505 -0.109581644
[22,] -0.403407551 -0.675320505
[23,] -0.766413621 -0.403407551
[24,] -0.572368419 -0.766413621
[25,] -0.892442637 -0.572368419
[26,] -0.192459512 -0.892442637
[27,] -0.188124155 -0.192459512
[28,] -0.130583667 -0.188124155
[29,] -0.255482457 -0.130583667
[30,] -0.328761806 -0.255482457
[31,] -0.350894055 -0.328761806
[32,] 0.578070171 -0.350894055
[33,] 0.304132937 0.578070171
[34,] 0.260964914 0.304132937
[35,] 0.421238194 0.260964914
[36,] -0.016194326 0.421238194
[37,] -0.307523613 -0.016194326
[38,] -0.040435231 -0.307523613
[39,] -0.326484481 -0.040435231
[40,] -0.004571527 -0.326484481
[41,] 0.011622799 -0.004571527
[42,] 0.417796892 0.011622799
[43,] 0.101130225 0.417796892
[44,] -0.345209178 0.101130225
[45,] -0.384935899 -0.345209178
[46,] 0.307523613 -0.384935899
[47,] -0.170563433 0.307523613
[48,] -0.549089070 -0.170563433
[49,] -0.558232123 -0.549089070
[50,] -0.381528348 -0.558232123
[51,] -0.138832666 -0.381528348
[52,] 0.141987172 -0.138832666
[53,] -0.106190968 0.141987172
[54,] 0.461622799 -0.106190968
[55,] 0.070968273 0.461622799
[56,] -0.157557363 0.070968273
[57,] -0.138377201 -0.157557363
[58,] 0.074628870 -0.138377201
[59,] 0.017088382 0.074628870
[60,] -0.379251022 0.017088382
[61,] -0.165114726 -0.379251022
[62,] -0.034969649 -0.165114726
[63,] -0.330634293 -0.034969649
[64,] 0.294011452 -0.330634293
[65,] -0.141818502 0.294011452
[66,] 0.054740196 -0.141818502
[67,] -0.046845494 0.054740196
[68,] 0.047908219 -0.046845494
[69,] 0.252007405 0.047908219
[70,] 0.497908219 0.252007405
[71,] 0.075995265 0.497908219
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.959581644 0.912550605
2 0.914423091 1.959581644
3 0.933839424 0.914423091
4 0.737938611 0.933839424
5 0.358282749 0.737938611
6 0.028829307 0.358282749
7 0.158721339 0.028829307
8 -0.013630205 0.158721339
9 0.642493262 -0.013630205
10 -0.737618065 0.642493262
11 0.422655215 -0.737618065
12 0.604352232 0.422655215
13 -0.036268544 0.604352232
14 -0.265030351 -0.036268544
15 0.050236170 -0.265030351
16 -1.038782040 0.050236170
17 0.133586379 -1.038782040
18 -0.634227389 0.133586379
19 0.066919712 -0.634227389
20 -0.109581644 0.066919712
21 -0.675320505 -0.109581644
22 -0.403407551 -0.675320505
23 -0.766413621 -0.403407551
24 -0.572368419 -0.766413621
25 -0.892442637 -0.572368419
26 -0.192459512 -0.892442637
27 -0.188124155 -0.192459512
28 -0.130583667 -0.188124155
29 -0.255482457 -0.130583667
30 -0.328761806 -0.255482457
31 -0.350894055 -0.328761806
32 0.578070171 -0.350894055
33 0.304132937 0.578070171
34 0.260964914 0.304132937
35 0.421238194 0.260964914
36 -0.016194326 0.421238194
37 -0.307523613 -0.016194326
38 -0.040435231 -0.307523613
39 -0.326484481 -0.040435231
40 -0.004571527 -0.326484481
41 0.011622799 -0.004571527
42 0.417796892 0.011622799
43 0.101130225 0.417796892
44 -0.345209178 0.101130225
45 -0.384935899 -0.345209178
46 0.307523613 -0.384935899
47 -0.170563433 0.307523613
48 -0.549089070 -0.170563433
49 -0.558232123 -0.549089070
50 -0.381528348 -0.558232123
51 -0.138832666 -0.381528348
52 0.141987172 -0.138832666
53 -0.106190968 0.141987172
54 0.461622799 -0.106190968
55 0.070968273 0.461622799
56 -0.157557363 0.070968273
57 -0.138377201 -0.157557363
58 0.074628870 -0.138377201
59 0.017088382 0.074628870
60 -0.379251022 0.017088382
61 -0.165114726 -0.379251022
62 -0.034969649 -0.165114726
63 -0.330634293 -0.034969649
64 0.294011452 -0.330634293
65 -0.141818502 0.294011452
66 0.054740196 -0.141818502
67 -0.046845494 0.054740196
68 0.047908219 -0.046845494
69 0.252007405 0.047908219
70 0.497908219 0.252007405
71 0.075995265 0.497908219
> 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/75vt41258744856.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/8wdn61258744856.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/9xgmi1258744856.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/10noue1258744856.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/11uplt1258744856.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/12mers1258744856.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/13m5nu1258744856.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/14osef1258744856.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/153pb71258744856.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/167i9l1258744856.tab")
+ }
>
> system("convert tmp/18l1l1258744856.ps tmp/18l1l1258744856.png")
> system("convert tmp/283yj1258744856.ps tmp/283yj1258744856.png")
> system("convert tmp/37zse1258744856.ps tmp/37zse1258744856.png")
> system("convert tmp/4b1kl1258744856.ps tmp/4b1kl1258744856.png")
> system("convert tmp/53p0q1258744856.ps tmp/53p0q1258744856.png")
> system("convert tmp/61ycm1258744856.ps tmp/61ycm1258744856.png")
> system("convert tmp/75vt41258744856.ps tmp/75vt41258744856.png")
> system("convert tmp/8wdn61258744856.ps tmp/8wdn61258744856.png")
> system("convert tmp/9xgmi1258744856.ps tmp/9xgmi1258744856.png")
> system("convert tmp/10noue1258744856.ps tmp/10noue1258744856.png")
>
>
> proc.time()
user system elapsed
2.625 1.608 2.994