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(6.8,9.2,6.3,11.7,6.4,15.8,6.2,8.6,6.9,23.2,6.4,27.4,6.3,9.3,6.8,16,6.9,4.7,6.7,12.5,6.9,20.1,6.9,9.1,6.3,8.1,6.1,8.6,6.2,20.3,6.8,25,6.5,19.2,7.6,3.3,6.3,11.2,7.1,10.5,6.8,10.1,7.3,7.2,6.4,13.6,6.8,9,7.2,24.6,6.4,12.6,6.6,5.6,6.8,8.7,6.1,7.7,6.5,24.1,6.4,11.7,6,7.7,6,9.6,7.3,7.2,6.1,12.3,6.7,8.9,6.4,13.6,5.8,11.2,6.9,2.8,7,3.2,7.3,9.4,5.9,11.9,6.2,15.4,6.8,7.4,7,18.9,5.9,7.9,6.1,12.2,5.7,11,7.1,2.8,5.8,11.8,7.4,17.1,6.8,11.6,6.8,5.8,7,8.3,6.2,15.4,6.8,7.4,7,18.9,5.9,7.9,6.4,13.6,6,7.7),dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> 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'
> 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, 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 6.8 9.2 1 0 0 0 0 0 0 0 0 0 0
2 6.3 11.7 0 1 0 0 0 0 0 0 0 0 0
3 6.4 15.8 0 0 1 0 0 0 0 0 0 0 0
4 6.2 8.6 0 0 0 1 0 0 0 0 0 0 0
5 6.9 23.2 0 0 0 0 1 0 0 0 0 0 0
6 6.4 27.4 0 0 0 0 0 1 0 0 0 0 0
7 6.3 9.3 0 0 0 0 0 0 1 0 0 0 0
8 6.8 16.0 0 0 0 0 0 0 0 1 0 0 0
9 6.9 4.7 0 0 0 0 0 0 0 0 1 0 0
10 6.7 12.5 0 0 0 0 0 0 0 0 0 1 0
11 6.9 20.1 0 0 0 0 0 0 0 0 0 0 1
12 6.9 9.1 0 0 0 0 0 0 0 0 0 0 0
13 6.3 8.1 1 0 0 0 0 0 0 0 0 0 0
14 6.1 8.6 0 1 0 0 0 0 0 0 0 0 0
15 6.2 20.3 0 0 1 0 0 0 0 0 0 0 0
16 6.8 25.0 0 0 0 1 0 0 0 0 0 0 0
17 6.5 19.2 0 0 0 0 1 0 0 0 0 0 0
18 7.6 3.3 0 0 0 0 0 1 0 0 0 0 0
19 6.3 11.2 0 0 0 0 0 0 1 0 0 0 0
20 7.1 10.5 0 0 0 0 0 0 0 1 0 0 0
21 6.8 10.1 0 0 0 0 0 0 0 0 1 0 0
22 7.3 7.2 0 0 0 0 0 0 0 0 0 1 0
23 6.4 13.6 0 0 0 0 0 0 0 0 0 0 1
24 6.8 9.0 0 0 0 0 0 0 0 0 0 0 0
25 7.2 24.6 1 0 0 0 0 0 0 0 0 0 0
26 6.4 12.6 0 1 0 0 0 0 0 0 0 0 0
27 6.6 5.6 0 0 1 0 0 0 0 0 0 0 0
28 6.8 8.7 0 0 0 1 0 0 0 0 0 0 0
29 6.1 7.7 0 0 0 0 1 0 0 0 0 0 0
30 6.5 24.1 0 0 0 0 0 1 0 0 0 0 0
31 6.4 11.7 0 0 0 0 0 0 1 0 0 0 0
32 6.0 7.7 0 0 0 0 0 0 0 1 0 0 0
33 6.0 9.6 0 0 0 0 0 0 0 0 1 0 0
34 7.3 7.2 0 0 0 0 0 0 0 0 0 1 0
35 6.1 12.3 0 0 0 0 0 0 0 0 0 0 1
36 6.7 8.9 0 0 0 0 0 0 0 0 0 0 0
37 6.4 13.6 1 0 0 0 0 0 0 0 0 0 0
38 5.8 11.2 0 1 0 0 0 0 0 0 0 0 0
39 6.9 2.8 0 0 1 0 0 0 0 0 0 0 0
40 7.0 3.2 0 0 0 1 0 0 0 0 0 0 0
41 7.3 9.4 0 0 0 0 1 0 0 0 0 0 0
42 5.9 11.9 0 0 0 0 0 1 0 0 0 0 0
43 6.2 15.4 0 0 0 0 0 0 1 0 0 0 0
44 6.8 7.4 0 0 0 0 0 0 0 1 0 0 0
45 7.0 18.9 0 0 0 0 0 0 0 0 1 0 0
46 5.9 7.9 0 0 0 0 0 0 0 0 0 1 0
47 6.1 12.2 0 0 0 0 0 0 0 0 0 0 1
48 5.7 11.0 0 0 0 0 0 0 0 0 0 0 0
49 7.1 2.8 1 0 0 0 0 0 0 0 0 0 0
50 5.8 11.8 0 1 0 0 0 0 0 0 0 0 0
51 7.4 17.1 0 0 1 0 0 0 0 0 0 0 0
52 6.8 11.6 0 0 0 1 0 0 0 0 0 0 0
53 6.8 5.8 0 0 0 0 1 0 0 0 0 0 0
54 7.0 8.3 0 0 0 0 0 1 0 0 0 0 0
55 6.2 15.4 0 0 0 0 0 0 1 0 0 0 0
56 6.8 7.4 0 0 0 0 0 0 0 1 0 0 0
57 7.0 18.9 0 0 0 0 0 0 0 0 1 0 0
58 5.9 7.9 0 0 0 0 0 0 0 0 0 1 0
59 6.4 13.6 0 0 0 0 0 0 0 0 0 0 1
60 6.0 7.7 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
6.448775 -0.003148 0.347934 -0.333577 0.290012 0.307178
M5 M6 M7 M8 M9 M10
0.312341 0.278449 -0.129107 0.282078 0.330389 0.198111
M11
-0.023566
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.78976 -0.28157 0.05489 0.27952 0.88316
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.448775 0.225273 28.626 <2e-16 ***
X -0.003148 0.010812 -0.291 0.772
M1 0.347934 0.287585 1.210 0.232
M2 -0.333577 0.287140 -1.162 0.251
M3 0.290012 0.288349 1.006 0.320
M4 0.307178 0.287351 1.069 0.291
M5 0.312341 0.289412 1.079 0.286
M6 0.278449 0.293219 0.950 0.347
M7 -0.129107 0.288725 -0.447 0.657
M8 0.282078 0.286380 0.985 0.330
M9 0.330389 0.288506 1.145 0.258
M10 0.198111 0.286365 0.692 0.492
M11 -0.023566 0.291802 -0.081 0.936
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4527 on 47 degrees of freedom
Multiple R-squared: 0.2204, Adjusted R-squared: 0.02136
F-statistic: 1.107 on 12 and 47 DF, p-value: 0.3769
> 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.13064685 0.26129370 0.869353149
[2,] 0.06722114 0.13444229 0.932778857
[3,] 0.49475032 0.98950063 0.505249685
[4,] 0.35643124 0.71286248 0.643568759
[5,] 0.26400661 0.52801321 0.735993394
[6,] 0.17251443 0.34502886 0.827485568
[7,] 0.18444697 0.36889393 0.815553034
[8,] 0.18184127 0.36368255 0.818158726
[9,] 0.14099097 0.28198194 0.859009028
[10,] 0.20844402 0.41688803 0.791555983
[11,] 0.16814820 0.33629640 0.831851798
[12,] 0.13266871 0.26533742 0.867331292
[13,] 0.09212050 0.18424101 0.907879495
[14,] 0.14983469 0.29966938 0.850165310
[15,] 0.12441826 0.24883651 0.875581745
[16,] 0.08395273 0.16790545 0.916047274
[17,] 0.17611947 0.35223894 0.823880528
[18,] 0.32478788 0.64957575 0.675212124
[19,] 0.67525533 0.64948935 0.324744674
[20,] 0.62633118 0.74733763 0.373668815
[21,] 0.75384770 0.49230461 0.246152303
[22,] 0.79762921 0.40474159 0.202370795
[23,] 0.73053329 0.53893341 0.269466706
[24,] 0.77724738 0.44550524 0.222752621
[25,] 0.70286595 0.59426810 0.297134051
[26,] 0.93202325 0.13595350 0.067976748
[27,] 0.99427158 0.01145684 0.005728422
[28,] 0.97881252 0.04237497 0.021187485
[29,] 0.92994383 0.14011234 0.070056168
> postscript(file="/var/wessaorg/rcomp/tmp/1tzog1353256398.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/wessaorg/rcomp/tmp/2lt1s1353256398.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/wessaorg/rcomp/tmp/3nzwd1353256398.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/wessaorg/rcomp/tmp/4upyp1353256398.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/wessaorg/rcomp/tmp/5ahkd1353256398.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 = 60
Frequency = 1
1 2 3 4 5 6
0.032255200 0.221637112 -0.289043941 -0.528878185 0.211923688 -0.240961171
7 8 9 10 11 12
0.009610634 0.119519415 0.135632215 0.092467239 0.538071200 0.479874068
13 14 15 16 17 18
-0.471207922 0.011877405 -0.474876624 0.122753815 -0.200669483 0.883164976
19 20 21 22 23 24
0.015592390 0.402203805 0.052632995 0.675781288 0.017607298 0.379559239
25 26 27 28 29 30
0.480738907 0.324470576 -0.121156527 0.071436644 -0.636874849 -0.151350537
31 32 33 34 35 36
0.117166537 -0.706611415 -0.748941151 0.675781288 -0.286485483 0.279244410
37 38 39 40 41 42
-0.353892312 -0.279937034 0.170028254 0.254121034 0.568477249 -0.789759707
43 44 45 46 47 48
-0.071184780 0.092444098 0.280337971 -0.722014907 -0.286800312 -0.714144176
49 50 51 52 53 54
0.312106127 -0.278048059 0.715048839 0.080566693 0.057143395 0.298906439
55 56 57 58 59 60
-0.071184780 0.092444098 0.280337971 -0.722014907 0.017607298 -0.424533541
> postscript(file="/var/wessaorg/rcomp/tmp/6pfsm1353256398.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 0.032255200 NA
1 0.221637112 0.032255200
2 -0.289043941 0.221637112
3 -0.528878185 -0.289043941
4 0.211923688 -0.528878185
5 -0.240961171 0.211923688
6 0.009610634 -0.240961171
7 0.119519415 0.009610634
8 0.135632215 0.119519415
9 0.092467239 0.135632215
10 0.538071200 0.092467239
11 0.479874068 0.538071200
12 -0.471207922 0.479874068
13 0.011877405 -0.471207922
14 -0.474876624 0.011877405
15 0.122753815 -0.474876624
16 -0.200669483 0.122753815
17 0.883164976 -0.200669483
18 0.015592390 0.883164976
19 0.402203805 0.015592390
20 0.052632995 0.402203805
21 0.675781288 0.052632995
22 0.017607298 0.675781288
23 0.379559239 0.017607298
24 0.480738907 0.379559239
25 0.324470576 0.480738907
26 -0.121156527 0.324470576
27 0.071436644 -0.121156527
28 -0.636874849 0.071436644
29 -0.151350537 -0.636874849
30 0.117166537 -0.151350537
31 -0.706611415 0.117166537
32 -0.748941151 -0.706611415
33 0.675781288 -0.748941151
34 -0.286485483 0.675781288
35 0.279244410 -0.286485483
36 -0.353892312 0.279244410
37 -0.279937034 -0.353892312
38 0.170028254 -0.279937034
39 0.254121034 0.170028254
40 0.568477249 0.254121034
41 -0.789759707 0.568477249
42 -0.071184780 -0.789759707
43 0.092444098 -0.071184780
44 0.280337971 0.092444098
45 -0.722014907 0.280337971
46 -0.286800312 -0.722014907
47 -0.714144176 -0.286800312
48 0.312106127 -0.714144176
49 -0.278048059 0.312106127
50 0.715048839 -0.278048059
51 0.080566693 0.715048839
52 0.057143395 0.080566693
53 0.298906439 0.057143395
54 -0.071184780 0.298906439
55 0.092444098 -0.071184780
56 0.280337971 0.092444098
57 -0.722014907 0.280337971
58 0.017607298 -0.722014907
59 -0.424533541 0.017607298
60 NA -0.424533541
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.221637112 0.032255200
[2,] -0.289043941 0.221637112
[3,] -0.528878185 -0.289043941
[4,] 0.211923688 -0.528878185
[5,] -0.240961171 0.211923688
[6,] 0.009610634 -0.240961171
[7,] 0.119519415 0.009610634
[8,] 0.135632215 0.119519415
[9,] 0.092467239 0.135632215
[10,] 0.538071200 0.092467239
[11,] 0.479874068 0.538071200
[12,] -0.471207922 0.479874068
[13,] 0.011877405 -0.471207922
[14,] -0.474876624 0.011877405
[15,] 0.122753815 -0.474876624
[16,] -0.200669483 0.122753815
[17,] 0.883164976 -0.200669483
[18,] 0.015592390 0.883164976
[19,] 0.402203805 0.015592390
[20,] 0.052632995 0.402203805
[21,] 0.675781288 0.052632995
[22,] 0.017607298 0.675781288
[23,] 0.379559239 0.017607298
[24,] 0.480738907 0.379559239
[25,] 0.324470576 0.480738907
[26,] -0.121156527 0.324470576
[27,] 0.071436644 -0.121156527
[28,] -0.636874849 0.071436644
[29,] -0.151350537 -0.636874849
[30,] 0.117166537 -0.151350537
[31,] -0.706611415 0.117166537
[32,] -0.748941151 -0.706611415
[33,] 0.675781288 -0.748941151
[34,] -0.286485483 0.675781288
[35,] 0.279244410 -0.286485483
[36,] -0.353892312 0.279244410
[37,] -0.279937034 -0.353892312
[38,] 0.170028254 -0.279937034
[39,] 0.254121034 0.170028254
[40,] 0.568477249 0.254121034
[41,] -0.789759707 0.568477249
[42,] -0.071184780 -0.789759707
[43,] 0.092444098 -0.071184780
[44,] 0.280337971 0.092444098
[45,] -0.722014907 0.280337971
[46,] -0.286800312 -0.722014907
[47,] -0.714144176 -0.286800312
[48,] 0.312106127 -0.714144176
[49,] -0.278048059 0.312106127
[50,] 0.715048839 -0.278048059
[51,] 0.080566693 0.715048839
[52,] 0.057143395 0.080566693
[53,] 0.298906439 0.057143395
[54,] -0.071184780 0.298906439
[55,] 0.092444098 -0.071184780
[56,] 0.280337971 0.092444098
[57,] -0.722014907 0.280337971
[58,] 0.017607298 -0.722014907
[59,] -0.424533541 0.017607298
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.221637112 0.032255200
2 -0.289043941 0.221637112
3 -0.528878185 -0.289043941
4 0.211923688 -0.528878185
5 -0.240961171 0.211923688
6 0.009610634 -0.240961171
7 0.119519415 0.009610634
8 0.135632215 0.119519415
9 0.092467239 0.135632215
10 0.538071200 0.092467239
11 0.479874068 0.538071200
12 -0.471207922 0.479874068
13 0.011877405 -0.471207922
14 -0.474876624 0.011877405
15 0.122753815 -0.474876624
16 -0.200669483 0.122753815
17 0.883164976 -0.200669483
18 0.015592390 0.883164976
19 0.402203805 0.015592390
20 0.052632995 0.402203805
21 0.675781288 0.052632995
22 0.017607298 0.675781288
23 0.379559239 0.017607298
24 0.480738907 0.379559239
25 0.324470576 0.480738907
26 -0.121156527 0.324470576
27 0.071436644 -0.121156527
28 -0.636874849 0.071436644
29 -0.151350537 -0.636874849
30 0.117166537 -0.151350537
31 -0.706611415 0.117166537
32 -0.748941151 -0.706611415
33 0.675781288 -0.748941151
34 -0.286485483 0.675781288
35 0.279244410 -0.286485483
36 -0.353892312 0.279244410
37 -0.279937034 -0.353892312
38 0.170028254 -0.279937034
39 0.254121034 0.170028254
40 0.568477249 0.254121034
41 -0.789759707 0.568477249
42 -0.071184780 -0.789759707
43 0.092444098 -0.071184780
44 0.280337971 0.092444098
45 -0.722014907 0.280337971
46 -0.286800312 -0.722014907
47 -0.714144176 -0.286800312
48 0.312106127 -0.714144176
49 -0.278048059 0.312106127
50 0.715048839 -0.278048059
51 0.080566693 0.715048839
52 0.057143395 0.080566693
53 0.298906439 0.057143395
54 -0.071184780 0.298906439
55 0.092444098 -0.071184780
56 0.280337971 0.092444098
57 -0.722014907 0.280337971
58 0.017607298 -0.722014907
59 -0.424533541 0.017607298
> 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/wessaorg/rcomp/tmp/7pkz81353256398.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/wessaorg/rcomp/tmp/83y331353256398.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/wessaorg/rcomp/tmp/9jlsz1353256398.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/wessaorg/rcomp/tmp/10xweb1353256398.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11u17h1353256398.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/wessaorg/rcomp/tmp/12jbwn1353256398.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/wessaorg/rcomp/tmp/13e6yl1353256398.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/wessaorg/rcomp/tmp/14jo6f1353256398.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/wessaorg/rcomp/tmp/15tdq11353256398.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/wessaorg/rcomp/tmp/16lwn11353256398.tab")
+ }
>
> try(system("convert tmp/1tzog1353256398.ps tmp/1tzog1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/2lt1s1353256398.ps tmp/2lt1s1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/3nzwd1353256398.ps tmp/3nzwd1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/4upyp1353256398.ps tmp/4upyp1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ahkd1353256398.ps tmp/5ahkd1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/6pfsm1353256398.ps tmp/6pfsm1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/7pkz81353256398.ps tmp/7pkz81353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/83y331353256398.ps tmp/83y331353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/9jlsz1353256398.ps tmp/9jlsz1353256398.png",intern=TRUE))
character(0)
> try(system("convert tmp/10xweb1353256398.ps tmp/10xweb1353256398.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.459 1.027 7.477