R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-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(112.3
+ ,0
+ ,117.2
+ ,96.8
+ ,117.3
+ ,0
+ ,112.3
+ ,117.2
+ ,111.1
+ ,1
+ ,117.3
+ ,112.3
+ ,102.2
+ ,1
+ ,111.1
+ ,117.3
+ ,104.3
+ ,1
+ ,102.2
+ ,111.1
+ ,122.9
+ ,1
+ ,104.3
+ ,102.2
+ ,107.6
+ ,1
+ ,122.9
+ ,104.3
+ ,121.3
+ ,1
+ ,107.6
+ ,122.9
+ ,131.5
+ ,1
+ ,121.3
+ ,107.6
+ ,89
+ ,1
+ ,131.5
+ ,121.3
+ ,104.4
+ ,1
+ ,89
+ ,131.5
+ ,128.9
+ ,1
+ ,104.4
+ ,89
+ ,135.9
+ ,1
+ ,128.9
+ ,104.4
+ ,133.3
+ ,1
+ ,135.9
+ ,128.9
+ ,121.3
+ ,1
+ ,133.3
+ ,135.9
+ ,120.5
+ ,0
+ ,121.3
+ ,133.3
+ ,120.4
+ ,0
+ ,120.5
+ ,121.3
+ ,137.9
+ ,0
+ ,120.4
+ ,120.5
+ ,126.1
+ ,0
+ ,137.9
+ ,120.4
+ ,133.2
+ ,0
+ ,126.1
+ ,137.9
+ ,151.1
+ ,0
+ ,133.2
+ ,126.1
+ ,105
+ ,0
+ ,151.1
+ ,133.2
+ ,119
+ ,0
+ ,105
+ ,151.1
+ ,140.4
+ ,0
+ ,119
+ ,105
+ ,156.6
+ ,0
+ ,140.4
+ ,119
+ ,137.1
+ ,0
+ ,156.6
+ ,140.4
+ ,122.7
+ ,0
+ ,137.1
+ ,156.6
+ ,125.8
+ ,0
+ ,122.7
+ ,137.1
+ ,139.3
+ ,0
+ ,125.8
+ ,122.7
+ ,134.9
+ ,0
+ ,139.3
+ ,125.8
+ ,149.2
+ ,0
+ ,134.9
+ ,139.3
+ ,132.3
+ ,0
+ ,149.2
+ ,134.9
+ ,149
+ ,0
+ ,132.3
+ ,149.2
+ ,117.2
+ ,0
+ ,149
+ ,132.3
+ ,119.6
+ ,0
+ ,117.2
+ ,149
+ ,152
+ ,0
+ ,119.6
+ ,117.2
+ ,149.4
+ ,0
+ ,152
+ ,119.6
+ ,127.3
+ ,0
+ ,149.4
+ ,152
+ ,114.1
+ ,0
+ ,127.3
+ ,149.4
+ ,102.1
+ ,0
+ ,114.1
+ ,127.3
+ ,107.7
+ ,0
+ ,102.1
+ ,114.1
+ ,104.4
+ ,0
+ ,107.7
+ ,102.1
+ ,102.1
+ ,0
+ ,104.4
+ ,107.7
+ ,96
+ ,1
+ ,102.1
+ ,104.4
+ ,109.3
+ ,0
+ ,96
+ ,102.1
+ ,90
+ ,1
+ ,109.3
+ ,96
+ ,83.9
+ ,1
+ ,90
+ ,109.3
+ ,112
+ ,1
+ ,83.9
+ ,90
+ ,114.3
+ ,1
+ ,112
+ ,83.9
+ ,103.6
+ ,1
+ ,114.3
+ ,112
+ ,91.7
+ ,1
+ ,103.6
+ ,114.3
+ ,80.8
+ ,1
+ ,91.7
+ ,103.6
+ ,87.2
+ ,1
+ ,80.8
+ ,91.7
+ ,109.2
+ ,1
+ ,87.2
+ ,80.8
+ ,102.7
+ ,1
+ ,109.2
+ ,87.2
+ ,95.1
+ ,1
+ ,102.7
+ ,109.2
+ ,117.5
+ ,1
+ ,95.1
+ ,102.7
+ ,85.1
+ ,1
+ ,117.5
+ ,95.1
+ ,92.1
+ ,1
+ ,85.1
+ ,117.5
+ ,113.5
+ ,1
+ ,92.1
+ ,85.1)
+ ,dim=c(4
+ ,60)
+ ,dimnames=list(c('X'
+ ,'Y'
+ ,'y(t)'
+ ,'y(t-1)')
+ ,1:60))
> y <- array(NA,dim=c(4,60),dimnames=list(c('X','Y','y(t)','y(t-1)'),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 = '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
> 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
X Y y(t) y(t-1) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 112.3 0 117.2 96.8 1 0 0 0 0 0 0 0 0 0 0 1
2 117.3 0 112.3 117.2 0 1 0 0 0 0 0 0 0 0 0 2
3 111.1 1 117.3 112.3 0 0 1 0 0 0 0 0 0 0 0 3
4 102.2 1 111.1 117.3 0 0 0 1 0 0 0 0 0 0 0 4
5 104.3 1 102.2 111.1 0 0 0 0 1 0 0 0 0 0 0 5
6 122.9 1 104.3 102.2 0 0 0 0 0 1 0 0 0 0 0 6
7 107.6 1 122.9 104.3 0 0 0 0 0 0 1 0 0 0 0 7
8 121.3 1 107.6 122.9 0 0 0 0 0 0 0 1 0 0 0 8
9 131.5 1 121.3 107.6 0 0 0 0 0 0 0 0 1 0 0 9
10 89.0 1 131.5 121.3 0 0 0 0 0 0 0 0 0 1 0 10
11 104.4 1 89.0 131.5 0 0 0 0 0 0 0 0 0 0 1 11
12 128.9 1 104.4 89.0 0 0 0 0 0 0 0 0 0 0 0 12
13 135.9 1 128.9 104.4 1 0 0 0 0 0 0 0 0 0 0 13
14 133.3 1 135.9 128.9 0 1 0 0 0 0 0 0 0 0 0 14
15 121.3 1 133.3 135.9 0 0 1 0 0 0 0 0 0 0 0 15
16 120.5 0 121.3 133.3 0 0 0 1 0 0 0 0 0 0 0 16
17 120.4 0 120.5 121.3 0 0 0 0 1 0 0 0 0 0 0 17
18 137.9 0 120.4 120.5 0 0 0 0 0 1 0 0 0 0 0 18
19 126.1 0 137.9 120.4 0 0 0 0 0 0 1 0 0 0 0 19
20 133.2 0 126.1 137.9 0 0 0 0 0 0 0 1 0 0 0 20
21 151.1 0 133.2 126.1 0 0 0 0 0 0 0 0 1 0 0 21
22 105.0 0 151.1 133.2 0 0 0 0 0 0 0 0 0 1 0 22
23 119.0 0 105.0 151.1 0 0 0 0 0 0 0 0 0 0 1 23
24 140.4 0 119.0 105.0 0 0 0 0 0 0 0 0 0 0 0 24
25 156.6 0 140.4 119.0 1 0 0 0 0 0 0 0 0 0 0 25
26 137.1 0 156.6 140.4 0 1 0 0 0 0 0 0 0 0 0 26
27 122.7 0 137.1 156.6 0 0 1 0 0 0 0 0 0 0 0 27
28 125.8 0 122.7 137.1 0 0 0 1 0 0 0 0 0 0 0 28
29 139.3 0 125.8 122.7 0 0 0 0 1 0 0 0 0 0 0 29
30 134.9 0 139.3 125.8 0 0 0 0 0 1 0 0 0 0 0 30
31 149.2 0 134.9 139.3 0 0 0 0 0 0 1 0 0 0 0 31
32 132.3 0 149.2 134.9 0 0 0 0 0 0 0 1 0 0 0 32
33 149.0 0 132.3 149.2 0 0 0 0 0 0 0 0 1 0 0 33
34 117.2 0 149.0 132.3 0 0 0 0 0 0 0 0 0 1 0 34
35 119.6 0 117.2 149.0 0 0 0 0 0 0 0 0 0 0 1 35
36 152.0 0 119.6 117.2 0 0 0 0 0 0 0 0 0 0 0 36
37 149.4 0 152.0 119.6 1 0 0 0 0 0 0 0 0 0 0 37
38 127.3 0 149.4 152.0 0 1 0 0 0 0 0 0 0 0 0 38
39 114.1 0 127.3 149.4 0 0 1 0 0 0 0 0 0 0 0 39
40 102.1 0 114.1 127.3 0 0 0 1 0 0 0 0 0 0 0 40
41 107.7 0 102.1 114.1 0 0 0 0 1 0 0 0 0 0 0 41
42 104.4 0 107.7 102.1 0 0 0 0 0 1 0 0 0 0 0 42
43 102.1 0 104.4 107.7 0 0 0 0 0 0 1 0 0 0 0 43
44 96.0 1 102.1 104.4 0 0 0 0 0 0 0 1 0 0 0 44
45 109.3 0 96.0 102.1 0 0 0 0 0 0 0 0 1 0 0 45
46 90.0 1 109.3 96.0 0 0 0 0 0 0 0 0 0 1 0 46
47 83.9 1 90.0 109.3 0 0 0 0 0 0 0 0 0 0 1 47
48 112.0 1 83.9 90.0 0 0 0 0 0 0 0 0 0 0 0 48
49 114.3 1 112.0 83.9 1 0 0 0 0 0 0 0 0 0 0 49
50 103.6 1 114.3 112.0 0 1 0 0 0 0 0 0 0 0 0 50
51 91.7 1 103.6 114.3 0 0 1 0 0 0 0 0 0 0 0 51
52 80.8 1 91.7 103.6 0 0 0 1 0 0 0 0 0 0 0 52
53 87.2 1 80.8 91.7 0 0 0 0 1 0 0 0 0 0 0 53
54 109.2 1 87.2 80.8 0 0 0 0 0 1 0 0 0 0 0 54
55 102.7 1 109.2 87.2 0 0 0 0 0 0 1 0 0 0 0 55
56 95.1 1 102.7 109.2 0 0 0 0 0 0 0 1 0 0 0 56
57 117.5 1 95.1 102.7 0 0 0 0 0 0 0 0 1 0 0 57
58 85.1 1 117.5 95.1 0 0 0 0 0 0 0 0 0 1 0 58
59 92.1 1 85.1 117.5 0 0 0 0 0 0 0 0 0 0 1 59
60 113.5 1 92.1 85.1 0 0 0 0 0 0 0 0 0 0 0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Y `y(t)` `y(t-1)` M1 M2
39.57185 1.44282 0.46265 0.45684 -12.03576 -35.16856
M3 M4 M5 M6 M7 M8
-43.92633 -39.54141 -25.94174 -15.61285 -27.01085 -31.76754
M9 M10 M11 t
-12.40052 -53.56424 -38.35671 -0.09813
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.7221 -4.3546 -0.5014 5.0563 14.2602
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 39.57185 14.91699 2.653 0.01106 *
Y 1.44282 3.35206 0.430 0.66899
`y(t)` 0.46265 0.13452 3.439 0.00129 **
`y(t-1)` 0.45684 0.15540 2.940 0.00522 **
M1 -12.03576 5.67362 -2.121 0.03956 *
M2 -35.16856 5.87623 -5.985 3.55e-07 ***
M3 -43.92633 6.51312 -6.744 2.71e-08 ***
M4 -39.54141 5.82835 -6.784 2.37e-08 ***
M5 -25.94174 5.31775 -4.878 1.44e-05 ***
M6 -15.61285 5.04665 -3.094 0.00343 **
M7 -27.01085 5.19111 -5.203 4.91e-06 ***
M8 -31.76754 5.75193 -5.523 1.69e-06 ***
M9 -12.40052 5.35011 -2.318 0.02517 *
M10 -53.56424 5.69895 -9.399 4.36e-12 ***
M11 -38.35671 7.79401 -4.921 1.25e-05 ***
t -0.09813 0.06734 -1.457 0.15212
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7.917 on 44 degrees of freedom
Multiple R-squared: 0.8701, Adjusted R-squared: 0.8258
F-statistic: 19.65 on 15 and 44 DF, p-value: 1.038e-14
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.0103166246 0.0206332492 0.98968338
[2,] 0.0043575352 0.0087150703 0.99564246
[3,] 0.0020285676 0.0040571352 0.99797143
[4,] 0.0009449645 0.0018899289 0.99905504
[5,] 0.0002091860 0.0004183721 0.99979081
[6,] 0.0003681085 0.0007362169 0.99963189
[7,] 0.0001345388 0.0002690776 0.99986546
[8,] 0.0011168879 0.0022337759 0.99888311
[9,] 0.0781291570 0.1562583140 0.92187084
[10,] 0.2216972725 0.4433945450 0.77830273
[11,] 0.2372747286 0.4745494572 0.76272527
[12,] 0.5147635554 0.9704728893 0.48523644
[13,] 0.6017481221 0.7965037557 0.39825188
[14,] 0.5741346903 0.8517306194 0.42586531
[15,] 0.6680146331 0.6639707338 0.33198537
[16,] 0.5762489459 0.8475021082 0.42375105
[17,] 0.5133391396 0.9733217208 0.48666086
[18,] 0.6556826876 0.6886346249 0.34431731
[19,] 0.6341537401 0.7316925198 0.36584626
[20,] 0.7139558512 0.5720882975 0.28604415
[21,] 0.6656465654 0.6687068693 0.33435343
[22,] 0.6565966518 0.6868066963 0.34340335
[23,] 0.9487824658 0.1024350685 0.05121753
> postscript(file="/var/wessaorg/rcomp/tmp/13w621322413080.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/27axr1322413080.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/30hmg1322413080.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/4r5jz1322413080.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/5dph41322413080.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
-13.58253732 7.59591276 8.73424179 -3.86829598 -8.31984807 3.14367797
7 8 9 10 11 12
-10.22487101 6.91136245 -1.50626343 -13.72211467 1.57144807 0.10359285
13 14 15 16 17 18
0.86723436 7.06709767 1.92804726 5.02367085 -2.72570857 4.95527485
19 20 21 22 23 24
-3.39931657 6.02015581 6.75710376 -9.60604478 2.43542253 0.15989168
25 26 27 28 29 30
12.19732509 -1.34301479 -5.26614639 9.11755792 14.26024429 -8.03249982
31 32 33 34 35 36
13.63200554 -3.01901255 -4.30185675 5.15425576 -0.47199398 7.08647260
37 38 39 40 41 42
0.53404081 -11.93364773 -4.86535616 -4.94905882 -1.26853394 -11.90809575
43 44 45 46 47 48
-3.74349809 -3.85983881 -4.51301225 12.63945844 -5.71669451 -4.23614522
49 50 51 52 53 54
-0.01606294 -1.38634791 -0.53078650 -5.32387398 -1.94615371 11.84164275
55 56 57 58 59 60
3.73568013 -6.05266691 3.56402867 5.53444526 2.18181788 -3.11381192
> postscript(file="/var/wessaorg/rcomp/tmp/6v49g1322413080.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 -13.58253732 NA
1 7.59591276 -13.58253732
2 8.73424179 7.59591276
3 -3.86829598 8.73424179
4 -8.31984807 -3.86829598
5 3.14367797 -8.31984807
6 -10.22487101 3.14367797
7 6.91136245 -10.22487101
8 -1.50626343 6.91136245
9 -13.72211467 -1.50626343
10 1.57144807 -13.72211467
11 0.10359285 1.57144807
12 0.86723436 0.10359285
13 7.06709767 0.86723436
14 1.92804726 7.06709767
15 5.02367085 1.92804726
16 -2.72570857 5.02367085
17 4.95527485 -2.72570857
18 -3.39931657 4.95527485
19 6.02015581 -3.39931657
20 6.75710376 6.02015581
21 -9.60604478 6.75710376
22 2.43542253 -9.60604478
23 0.15989168 2.43542253
24 12.19732509 0.15989168
25 -1.34301479 12.19732509
26 -5.26614639 -1.34301479
27 9.11755792 -5.26614639
28 14.26024429 9.11755792
29 -8.03249982 14.26024429
30 13.63200554 -8.03249982
31 -3.01901255 13.63200554
32 -4.30185675 -3.01901255
33 5.15425576 -4.30185675
34 -0.47199398 5.15425576
35 7.08647260 -0.47199398
36 0.53404081 7.08647260
37 -11.93364773 0.53404081
38 -4.86535616 -11.93364773
39 -4.94905882 -4.86535616
40 -1.26853394 -4.94905882
41 -11.90809575 -1.26853394
42 -3.74349809 -11.90809575
43 -3.85983881 -3.74349809
44 -4.51301225 -3.85983881
45 12.63945844 -4.51301225
46 -5.71669451 12.63945844
47 -4.23614522 -5.71669451
48 -0.01606294 -4.23614522
49 -1.38634791 -0.01606294
50 -0.53078650 -1.38634791
51 -5.32387398 -0.53078650
52 -1.94615371 -5.32387398
53 11.84164275 -1.94615371
54 3.73568013 11.84164275
55 -6.05266691 3.73568013
56 3.56402867 -6.05266691
57 5.53444526 3.56402867
58 2.18181788 5.53444526
59 -3.11381192 2.18181788
60 NA -3.11381192
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 7.59591276 -13.58253732
[2,] 8.73424179 7.59591276
[3,] -3.86829598 8.73424179
[4,] -8.31984807 -3.86829598
[5,] 3.14367797 -8.31984807
[6,] -10.22487101 3.14367797
[7,] 6.91136245 -10.22487101
[8,] -1.50626343 6.91136245
[9,] -13.72211467 -1.50626343
[10,] 1.57144807 -13.72211467
[11,] 0.10359285 1.57144807
[12,] 0.86723436 0.10359285
[13,] 7.06709767 0.86723436
[14,] 1.92804726 7.06709767
[15,] 5.02367085 1.92804726
[16,] -2.72570857 5.02367085
[17,] 4.95527485 -2.72570857
[18,] -3.39931657 4.95527485
[19,] 6.02015581 -3.39931657
[20,] 6.75710376 6.02015581
[21,] -9.60604478 6.75710376
[22,] 2.43542253 -9.60604478
[23,] 0.15989168 2.43542253
[24,] 12.19732509 0.15989168
[25,] -1.34301479 12.19732509
[26,] -5.26614639 -1.34301479
[27,] 9.11755792 -5.26614639
[28,] 14.26024429 9.11755792
[29,] -8.03249982 14.26024429
[30,] 13.63200554 -8.03249982
[31,] -3.01901255 13.63200554
[32,] -4.30185675 -3.01901255
[33,] 5.15425576 -4.30185675
[34,] -0.47199398 5.15425576
[35,] 7.08647260 -0.47199398
[36,] 0.53404081 7.08647260
[37,] -11.93364773 0.53404081
[38,] -4.86535616 -11.93364773
[39,] -4.94905882 -4.86535616
[40,] -1.26853394 -4.94905882
[41,] -11.90809575 -1.26853394
[42,] -3.74349809 -11.90809575
[43,] -3.85983881 -3.74349809
[44,] -4.51301225 -3.85983881
[45,] 12.63945844 -4.51301225
[46,] -5.71669451 12.63945844
[47,] -4.23614522 -5.71669451
[48,] -0.01606294 -4.23614522
[49,] -1.38634791 -0.01606294
[50,] -0.53078650 -1.38634791
[51,] -5.32387398 -0.53078650
[52,] -1.94615371 -5.32387398
[53,] 11.84164275 -1.94615371
[54,] 3.73568013 11.84164275
[55,] -6.05266691 3.73568013
[56,] 3.56402867 -6.05266691
[57,] 5.53444526 3.56402867
[58,] 2.18181788 5.53444526
[59,] -3.11381192 2.18181788
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 7.59591276 -13.58253732
2 8.73424179 7.59591276
3 -3.86829598 8.73424179
4 -8.31984807 -3.86829598
5 3.14367797 -8.31984807
6 -10.22487101 3.14367797
7 6.91136245 -10.22487101
8 -1.50626343 6.91136245
9 -13.72211467 -1.50626343
10 1.57144807 -13.72211467
11 0.10359285 1.57144807
12 0.86723436 0.10359285
13 7.06709767 0.86723436
14 1.92804726 7.06709767
15 5.02367085 1.92804726
16 -2.72570857 5.02367085
17 4.95527485 -2.72570857
18 -3.39931657 4.95527485
19 6.02015581 -3.39931657
20 6.75710376 6.02015581
21 -9.60604478 6.75710376
22 2.43542253 -9.60604478
23 0.15989168 2.43542253
24 12.19732509 0.15989168
25 -1.34301479 12.19732509
26 -5.26614639 -1.34301479
27 9.11755792 -5.26614639
28 14.26024429 9.11755792
29 -8.03249982 14.26024429
30 13.63200554 -8.03249982
31 -3.01901255 13.63200554
32 -4.30185675 -3.01901255
33 5.15425576 -4.30185675
34 -0.47199398 5.15425576
35 7.08647260 -0.47199398
36 0.53404081 7.08647260
37 -11.93364773 0.53404081
38 -4.86535616 -11.93364773
39 -4.94905882 -4.86535616
40 -1.26853394 -4.94905882
41 -11.90809575 -1.26853394
42 -3.74349809 -11.90809575
43 -3.85983881 -3.74349809
44 -4.51301225 -3.85983881
45 12.63945844 -4.51301225
46 -5.71669451 12.63945844
47 -4.23614522 -5.71669451
48 -0.01606294 -4.23614522
49 -1.38634791 -0.01606294
50 -0.53078650 -1.38634791
51 -5.32387398 -0.53078650
52 -1.94615371 -5.32387398
53 11.84164275 -1.94615371
54 3.73568013 11.84164275
55 -6.05266691 3.73568013
56 3.56402867 -6.05266691
57 5.53444526 3.56402867
58 2.18181788 5.53444526
59 -3.11381192 2.18181788
> 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/7mmg21322413080.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/8tkow1322413080.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/9gvzn1322413080.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/105wf61322413080.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/11e2n61322413080.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/12776k1322413080.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/13xnps1322413080.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/14rz9e1322413080.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/15lpgf1322413080.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/1695cq1322413080.tab")
+ }
>
> try(system("convert tmp/13w621322413080.ps tmp/13w621322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/27axr1322413080.ps tmp/27axr1322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/30hmg1322413080.ps tmp/30hmg1322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/4r5jz1322413080.ps tmp/4r5jz1322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/5dph41322413080.ps tmp/5dph41322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/6v49g1322413080.ps tmp/6v49g1322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/7mmg21322413080.ps tmp/7mmg21322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/8tkow1322413080.ps tmp/8tkow1322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/9gvzn1322413080.ps tmp/9gvzn1322413080.png",intern=TRUE))
character(0)
> try(system("convert tmp/105wf61322413080.ps tmp/105wf61322413080.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.238 0.512 3.773