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(112.3
+ ,1
+ ,117.2
+ ,96.8
+ ,80
+ ,117.3
+ ,1
+ ,112.3
+ ,117.2
+ ,96.8
+ ,111.1
+ ,1
+ ,117.3
+ ,112.3
+ ,117.2
+ ,102.2
+ ,1
+ ,111.1
+ ,117.3
+ ,112.3
+ ,104.3
+ ,1
+ ,102.2
+ ,111.1
+ ,117.3
+ ,122.9
+ ,0
+ ,104.3
+ ,102.2
+ ,111.1
+ ,107.6
+ ,0
+ ,122.9
+ ,104.3
+ ,102.2
+ ,121.3
+ ,0
+ ,107.6
+ ,122.9
+ ,104.3
+ ,131.5
+ ,0
+ ,121.3
+ ,107.6
+ ,122.9
+ ,89
+ ,0
+ ,131.5
+ ,121.3
+ ,107.6
+ ,104.4
+ ,0
+ ,89
+ ,131.5
+ ,121.3
+ ,128.9
+ ,0
+ ,104.4
+ ,89
+ ,131.5
+ ,135.9
+ ,0
+ ,128.9
+ ,104.4
+ ,89
+ ,133.3
+ ,0
+ ,135.9
+ ,128.9
+ ,104.4
+ ,121.3
+ ,0
+ ,133.3
+ ,135.9
+ ,128.9
+ ,120.5
+ ,0
+ ,121.3
+ ,133.3
+ ,135.9
+ ,120.4
+ ,0
+ ,120.5
+ ,121.3
+ ,133.3
+ ,137.9
+ ,0
+ ,120.4
+ ,120.5
+ ,121.3
+ ,126.1
+ ,0
+ ,137.9
+ ,120.4
+ ,120.5
+ ,133.2
+ ,0
+ ,126.1
+ ,137.9
+ ,120.4
+ ,151.1
+ ,0
+ ,133.2
+ ,126.1
+ ,137.9
+ ,105
+ ,0
+ ,151.1
+ ,133.2
+ ,126.1
+ ,119
+ ,0
+ ,105
+ ,151.1
+ ,133.2
+ ,140.4
+ ,0
+ ,119
+ ,105
+ ,151.1
+ ,156.6
+ ,1
+ ,140.4
+ ,119
+ ,105
+ ,137.1
+ ,1
+ ,156.6
+ ,140.4
+ ,119
+ ,122.7
+ ,1
+ ,137.1
+ ,156.6
+ ,140.4
+ ,125.8
+ ,1
+ ,122.7
+ ,137.1
+ ,156.6
+ ,139.3
+ ,1
+ ,125.8
+ ,122.7
+ ,137.1
+ ,134.9
+ ,1
+ ,139.3
+ ,125.8
+ ,122.7
+ ,149.2
+ ,1
+ ,134.9
+ ,139.3
+ ,125.8
+ ,132.3
+ ,1
+ ,149.2
+ ,134.9
+ ,139.3
+ ,149
+ ,1
+ ,132.3
+ ,149.2
+ ,134.9
+ ,117.2
+ ,1
+ ,149
+ ,132.3
+ ,149.2
+ ,119.6
+ ,1
+ ,117.2
+ ,149
+ ,132.3
+ ,152
+ ,1
+ ,119.6
+ ,117.2
+ ,149
+ ,149.4
+ ,1
+ ,152
+ ,119.6
+ ,117.2
+ ,127.3
+ ,1
+ ,149.4
+ ,152
+ ,119.6
+ ,114.1
+ ,1
+ ,127.3
+ ,149.4
+ ,152
+ ,102.1
+ ,1
+ ,114.1
+ ,127.3
+ ,149.4
+ ,107.7
+ ,1
+ ,102.1
+ ,114.1
+ ,127.3
+ ,104.4
+ ,1
+ ,107.7
+ ,102.1
+ ,114.1
+ ,102.1
+ ,1
+ ,104.4
+ ,107.7
+ ,102.1
+ ,96
+ ,1
+ ,102.1
+ ,104.4
+ ,107.7
+ ,109.3
+ ,1
+ ,96
+ ,102.1
+ ,104.4
+ ,90
+ ,1
+ ,109.3
+ ,96
+ ,102.1
+ ,83.9
+ ,1
+ ,90
+ ,109.3
+ ,96
+ ,112
+ ,1
+ ,83.9
+ ,90
+ ,109.3
+ ,114.3
+ ,1
+ ,112
+ ,83.9
+ ,90
+ ,103.6
+ ,1
+ ,114.3
+ ,112
+ ,83.9
+ ,91.7
+ ,1
+ ,103.6
+ ,114.3
+ ,112
+ ,80.8
+ ,1
+ ,91.7
+ ,103.6
+ ,114.3
+ ,87.2
+ ,1
+ ,80.8
+ ,91.7
+ ,103.6
+ ,109.2
+ ,1
+ ,87.2
+ ,80.8
+ ,91.7
+ ,102.7
+ ,1
+ ,109.2
+ ,87.2
+ ,80.8
+ ,95.1
+ ,1
+ ,102.7
+ ,109.2
+ ,87.2
+ ,117.5
+ ,1
+ ,95.1
+ ,102.7
+ ,109.2
+ ,85.1
+ ,1
+ ,117.5
+ ,95.1
+ ,102.7
+ ,92.1
+ ,1
+ ,85.1
+ ,117.5
+ ,95.1
+ ,113.5
+ ,1
+ ,92.1
+ ,85.1
+ ,117.5)
+ ,dim=c(5
+ ,60)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3')
+ ,1:60))
> y <- array(NA,dim=c(5,60),dimnames=list(c('Y','X','Y1','Y2','Y3'),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
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 Y1 Y2 Y3 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 112.3 1 117.2 96.8 80.0 1 0 0 0 0 0 0 0 0 0 0 1
2 117.3 1 112.3 117.2 96.8 0 1 0 0 0 0 0 0 0 0 0 2
3 111.1 1 117.3 112.3 117.2 0 0 1 0 0 0 0 0 0 0 0 3
4 102.2 1 111.1 117.3 112.3 0 0 0 1 0 0 0 0 0 0 0 4
5 104.3 1 102.2 111.1 117.3 0 0 0 0 1 0 0 0 0 0 0 5
6 122.9 0 104.3 102.2 111.1 0 0 0 0 0 1 0 0 0 0 0 6
7 107.6 0 122.9 104.3 102.2 0 0 0 0 0 0 1 0 0 0 0 7
8 121.3 0 107.6 122.9 104.3 0 0 0 0 0 0 0 1 0 0 0 8
9 131.5 0 121.3 107.6 122.9 0 0 0 0 0 0 0 0 1 0 0 9
10 89.0 0 131.5 121.3 107.6 0 0 0 0 0 0 0 0 0 1 0 10
11 104.4 0 89.0 131.5 121.3 0 0 0 0 0 0 0 0 0 0 1 11
12 128.9 0 104.4 89.0 131.5 0 0 0 0 0 0 0 0 0 0 0 12
13 135.9 0 128.9 104.4 89.0 1 0 0 0 0 0 0 0 0 0 0 13
14 133.3 0 135.9 128.9 104.4 0 1 0 0 0 0 0 0 0 0 0 14
15 121.3 0 133.3 135.9 128.9 0 0 1 0 0 0 0 0 0 0 0 15
16 120.5 0 121.3 133.3 135.9 0 0 0 1 0 0 0 0 0 0 0 16
17 120.4 0 120.5 121.3 133.3 0 0 0 0 1 0 0 0 0 0 0 17
18 137.9 0 120.4 120.5 121.3 0 0 0 0 0 1 0 0 0 0 0 18
19 126.1 0 137.9 120.4 120.5 0 0 0 0 0 0 1 0 0 0 0 19
20 133.2 0 126.1 137.9 120.4 0 0 0 0 0 0 0 1 0 0 0 20
21 151.1 0 133.2 126.1 137.9 0 0 0 0 0 0 0 0 1 0 0 21
22 105.0 0 151.1 133.2 126.1 0 0 0 0 0 0 0 0 0 1 0 22
23 119.0 0 105.0 151.1 133.2 0 0 0 0 0 0 0 0 0 0 1 23
24 140.4 0 119.0 105.0 151.1 0 0 0 0 0 0 0 0 0 0 0 24
25 156.6 1 140.4 119.0 105.0 1 0 0 0 0 0 0 0 0 0 0 25
26 137.1 1 156.6 140.4 119.0 0 1 0 0 0 0 0 0 0 0 0 26
27 122.7 1 137.1 156.6 140.4 0 0 1 0 0 0 0 0 0 0 0 27
28 125.8 1 122.7 137.1 156.6 0 0 0 1 0 0 0 0 0 0 0 28
29 139.3 1 125.8 122.7 137.1 0 0 0 0 1 0 0 0 0 0 0 29
30 134.9 1 139.3 125.8 122.7 0 0 0 0 0 1 0 0 0 0 0 30
31 149.2 1 134.9 139.3 125.8 0 0 0 0 0 0 1 0 0 0 0 31
32 132.3 1 149.2 134.9 139.3 0 0 0 0 0 0 0 1 0 0 0 32
33 149.0 1 132.3 149.2 134.9 0 0 0 0 0 0 0 0 1 0 0 33
34 117.2 1 149.0 132.3 149.2 0 0 0 0 0 0 0 0 0 1 0 34
35 119.6 1 117.2 149.0 132.3 0 0 0 0 0 0 0 0 0 0 1 35
36 152.0 1 119.6 117.2 149.0 0 0 0 0 0 0 0 0 0 0 0 36
37 149.4 1 152.0 119.6 117.2 1 0 0 0 0 0 0 0 0 0 0 37
38 127.3 1 149.4 152.0 119.6 0 1 0 0 0 0 0 0 0 0 0 38
39 114.1 1 127.3 149.4 152.0 0 0 1 0 0 0 0 0 0 0 0 39
40 102.1 1 114.1 127.3 149.4 0 0 0 1 0 0 0 0 0 0 0 40
41 107.7 1 102.1 114.1 127.3 0 0 0 0 1 0 0 0 0 0 0 41
42 104.4 1 107.7 102.1 114.1 0 0 0 0 0 1 0 0 0 0 0 42
43 102.1 1 104.4 107.7 102.1 0 0 0 0 0 0 1 0 0 0 0 43
44 96.0 1 102.1 104.4 107.7 0 0 0 0 0 0 0 1 0 0 0 44
45 109.3 1 96.0 102.1 104.4 0 0 0 0 0 0 0 0 1 0 0 45
46 90.0 1 109.3 96.0 102.1 0 0 0 0 0 0 0 0 0 1 0 46
47 83.9 1 90.0 109.3 96.0 0 0 0 0 0 0 0 0 0 0 1 47
48 112.0 1 83.9 90.0 109.3 0 0 0 0 0 0 0 0 0 0 0 48
49 114.3 1 112.0 83.9 90.0 1 0 0 0 0 0 0 0 0 0 0 49
50 103.6 1 114.3 112.0 83.9 0 1 0 0 0 0 0 0 0 0 0 50
51 91.7 1 103.6 114.3 112.0 0 0 1 0 0 0 0 0 0 0 0 51
52 80.8 1 91.7 103.6 114.3 0 0 0 1 0 0 0 0 0 0 0 52
53 87.2 1 80.8 91.7 103.6 0 0 0 0 1 0 0 0 0 0 0 53
54 109.2 1 87.2 80.8 91.7 0 0 0 0 0 1 0 0 0 0 0 54
55 102.7 1 109.2 87.2 80.8 0 0 0 0 0 0 1 0 0 0 0 55
56 95.1 1 102.7 109.2 87.2 0 0 0 0 0 0 0 1 0 0 0 56
57 117.5 1 95.1 102.7 109.2 0 0 0 0 0 0 0 0 1 0 0 57
58 85.1 1 117.5 95.1 102.7 0 0 0 0 0 0 0 0 0 1 0 58
59 92.1 1 85.1 117.5 95.1 0 0 0 0 0 0 0 0 0 0 1 59
60 113.5 1 92.1 85.1 117.5 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) X Y1 Y2 Y3 M1
36.04128 -1.07738 0.34607 0.30897 0.23917 0.54919
M2 M3 M4 M5 M6 M7
-20.44790 -35.61450 -35.20109 -21.60961 -8.96827 -16.96764
M8 M9 M10 M11 t
-21.76526 -5.96577 -44.22139 -30.17826 -0.09725
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.6178 -4.4623 -0.8783 4.8211 14.5298
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 36.04128 10.58928 3.404 0.001450 **
X -1.07738 2.99070 -0.360 0.720430
Y1 0.34607 0.14722 2.351 0.023395 *
Y2 0.30897 0.14759 2.093 0.042245 *
Y3 0.23917 0.14319 1.670 0.102133
M1 0.54919 9.21253 0.060 0.952740
M2 -20.44790 9.71025 -2.106 0.041098 *
M3 -35.61450 6.99308 -5.093 7.46e-06 ***
M4 -35.20109 5.96644 -5.900 5.11e-07 ***
M5 -21.60961 5.73904 -3.765 0.000500 ***
M6 -8.96827 6.30588 -1.422 0.162180
M7 -16.96764 7.69429 -2.205 0.032835 *
M8 -21.76526 7.56449 -2.877 0.006221 **
M9 -5.96577 6.26150 -0.953 0.346033
M10 -44.22139 7.38543 -5.988 3.81e-07 ***
M11 -30.17826 8.33990 -3.619 0.000775 ***
t -0.09725 0.08407 -1.157 0.253763
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7.764 on 43 degrees of freedom
Multiple R-squared: 0.8779, Adjusted R-squared: 0.8325
F-statistic: 19.32 on 16 and 43 DF, p-value: 1.322e-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,] 1.900271e-02 0.0380054190 0.9809973
[2,] 6.158854e-03 0.0123177087 0.9938411
[3,] 1.550487e-03 0.0031009746 0.9984495
[4,] 2.936208e-04 0.0005872416 0.9997064
[5,] 3.660515e-04 0.0007321029 0.9996339
[6,] 9.606633e-05 0.0001921327 0.9999039
[7,] 6.931193e-04 0.0013862386 0.9993069
[8,] 2.853938e-02 0.0570787506 0.9714606
[9,] 9.653451e-02 0.1930690284 0.9034655
[10,] 1.090355e-01 0.2180710358 0.8909645
[11,] 1.457164e-01 0.2914327937 0.8542836
[12,] 3.726083e-01 0.7452165548 0.6273917
[13,] 2.884877e-01 0.5769753699 0.7115123
[14,] 2.931175e-01 0.5862349547 0.7068825
[15,] 2.040931e-01 0.4081862719 0.7959069
[16,] 1.581167e-01 0.3162334251 0.8418833
[17,] 2.598746e-01 0.5197492009 0.7401254
[18,] 3.437805e-01 0.6875609260 0.6562195
[19,] 4.612946e-01 0.9225891502 0.5387054
[20,] 4.425425e-01 0.8850849028 0.5574575
[21,] 3.866125e-01 0.7732250711 0.6133875
> postscript(file="/var/www/html/rcomp/tmp/13brj1293560607.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/www/html/rcomp/tmp/2dk8m1293560607.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/www/html/rcomp/tmp/3dk8m1293560607.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/www/html/rcomp/tmp/4dk8m1293560607.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/www/html/rcomp/tmp/5ot7o1293560607.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
-12.71684469 4.75214052 8.72061767 1.27711617 -6.31732972 2.16716427
7 8 9 10 11 12
-9.99330614 7.64721002 -2.31735528 -10.56804175 -0.83423885 -1.05278919
13 14 15 16 17 18
2.42305085 7.24189057 3.38309529 5.54889004 -3.43897236 4.66872267
19 20 21 22 23 24
-4.86858614 5.82673769 5.02788372 -8.28536876 0.49367598 -3.06966262
25 26 27 28 29 30
13.04992240 -0.92239279 -3.43381307 6.48386180 14.52980339 -4.59999750
31 32 33 34 35 36
14.40674409 -4.41640126 -0.93612814 1.63901057 -0.01991012 7.29979157
37 38 39 40 41 42
-0.10071789 -10.79136501 -8.02514236 -8.32307274 -2.70046741 -13.61784076
43 44 45 46 47 48
-5.53945446 -6.26835380 -5.05971140 11.82530804 -4.19193238 -1.27967457
49 50 51 52 53 54
-2.65541067 -0.28027328 -0.64475753 -4.98679527 -2.07303390 11.38195132
55 56 57 58 59 60
5.99460266 -2.78919265 3.28531110 5.38909191 4.55240537 -1.89766519
> postscript(file="/var/www/html/rcomp/tmp/6ot7o1293560607.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 -12.71684469 NA
1 4.75214052 -12.71684469
2 8.72061767 4.75214052
3 1.27711617 8.72061767
4 -6.31732972 1.27711617
5 2.16716427 -6.31732972
6 -9.99330614 2.16716427
7 7.64721002 -9.99330614
8 -2.31735528 7.64721002
9 -10.56804175 -2.31735528
10 -0.83423885 -10.56804175
11 -1.05278919 -0.83423885
12 2.42305085 -1.05278919
13 7.24189057 2.42305085
14 3.38309529 7.24189057
15 5.54889004 3.38309529
16 -3.43897236 5.54889004
17 4.66872267 -3.43897236
18 -4.86858614 4.66872267
19 5.82673769 -4.86858614
20 5.02788372 5.82673769
21 -8.28536876 5.02788372
22 0.49367598 -8.28536876
23 -3.06966262 0.49367598
24 13.04992240 -3.06966262
25 -0.92239279 13.04992240
26 -3.43381307 -0.92239279
27 6.48386180 -3.43381307
28 14.52980339 6.48386180
29 -4.59999750 14.52980339
30 14.40674409 -4.59999750
31 -4.41640126 14.40674409
32 -0.93612814 -4.41640126
33 1.63901057 -0.93612814
34 -0.01991012 1.63901057
35 7.29979157 -0.01991012
36 -0.10071789 7.29979157
37 -10.79136501 -0.10071789
38 -8.02514236 -10.79136501
39 -8.32307274 -8.02514236
40 -2.70046741 -8.32307274
41 -13.61784076 -2.70046741
42 -5.53945446 -13.61784076
43 -6.26835380 -5.53945446
44 -5.05971140 -6.26835380
45 11.82530804 -5.05971140
46 -4.19193238 11.82530804
47 -1.27967457 -4.19193238
48 -2.65541067 -1.27967457
49 -0.28027328 -2.65541067
50 -0.64475753 -0.28027328
51 -4.98679527 -0.64475753
52 -2.07303390 -4.98679527
53 11.38195132 -2.07303390
54 5.99460266 11.38195132
55 -2.78919265 5.99460266
56 3.28531110 -2.78919265
57 5.38909191 3.28531110
58 4.55240537 5.38909191
59 -1.89766519 4.55240537
60 NA -1.89766519
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 4.75214052 -12.71684469
[2,] 8.72061767 4.75214052
[3,] 1.27711617 8.72061767
[4,] -6.31732972 1.27711617
[5,] 2.16716427 -6.31732972
[6,] -9.99330614 2.16716427
[7,] 7.64721002 -9.99330614
[8,] -2.31735528 7.64721002
[9,] -10.56804175 -2.31735528
[10,] -0.83423885 -10.56804175
[11,] -1.05278919 -0.83423885
[12,] 2.42305085 -1.05278919
[13,] 7.24189057 2.42305085
[14,] 3.38309529 7.24189057
[15,] 5.54889004 3.38309529
[16,] -3.43897236 5.54889004
[17,] 4.66872267 -3.43897236
[18,] -4.86858614 4.66872267
[19,] 5.82673769 -4.86858614
[20,] 5.02788372 5.82673769
[21,] -8.28536876 5.02788372
[22,] 0.49367598 -8.28536876
[23,] -3.06966262 0.49367598
[24,] 13.04992240 -3.06966262
[25,] -0.92239279 13.04992240
[26,] -3.43381307 -0.92239279
[27,] 6.48386180 -3.43381307
[28,] 14.52980339 6.48386180
[29,] -4.59999750 14.52980339
[30,] 14.40674409 -4.59999750
[31,] -4.41640126 14.40674409
[32,] -0.93612814 -4.41640126
[33,] 1.63901057 -0.93612814
[34,] -0.01991012 1.63901057
[35,] 7.29979157 -0.01991012
[36,] -0.10071789 7.29979157
[37,] -10.79136501 -0.10071789
[38,] -8.02514236 -10.79136501
[39,] -8.32307274 -8.02514236
[40,] -2.70046741 -8.32307274
[41,] -13.61784076 -2.70046741
[42,] -5.53945446 -13.61784076
[43,] -6.26835380 -5.53945446
[44,] -5.05971140 -6.26835380
[45,] 11.82530804 -5.05971140
[46,] -4.19193238 11.82530804
[47,] -1.27967457 -4.19193238
[48,] -2.65541067 -1.27967457
[49,] -0.28027328 -2.65541067
[50,] -0.64475753 -0.28027328
[51,] -4.98679527 -0.64475753
[52,] -2.07303390 -4.98679527
[53,] 11.38195132 -2.07303390
[54,] 5.99460266 11.38195132
[55,] -2.78919265 5.99460266
[56,] 3.28531110 -2.78919265
[57,] 5.38909191 3.28531110
[58,] 4.55240537 5.38909191
[59,] -1.89766519 4.55240537
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 4.75214052 -12.71684469
2 8.72061767 4.75214052
3 1.27711617 8.72061767
4 -6.31732972 1.27711617
5 2.16716427 -6.31732972
6 -9.99330614 2.16716427
7 7.64721002 -9.99330614
8 -2.31735528 7.64721002
9 -10.56804175 -2.31735528
10 -0.83423885 -10.56804175
11 -1.05278919 -0.83423885
12 2.42305085 -1.05278919
13 7.24189057 2.42305085
14 3.38309529 7.24189057
15 5.54889004 3.38309529
16 -3.43897236 5.54889004
17 4.66872267 -3.43897236
18 -4.86858614 4.66872267
19 5.82673769 -4.86858614
20 5.02788372 5.82673769
21 -8.28536876 5.02788372
22 0.49367598 -8.28536876
23 -3.06966262 0.49367598
24 13.04992240 -3.06966262
25 -0.92239279 13.04992240
26 -3.43381307 -0.92239279
27 6.48386180 -3.43381307
28 14.52980339 6.48386180
29 -4.59999750 14.52980339
30 14.40674409 -4.59999750
31 -4.41640126 14.40674409
32 -0.93612814 -4.41640126
33 1.63901057 -0.93612814
34 -0.01991012 1.63901057
35 7.29979157 -0.01991012
36 -0.10071789 7.29979157
37 -10.79136501 -0.10071789
38 -8.02514236 -10.79136501
39 -8.32307274 -8.02514236
40 -2.70046741 -8.32307274
41 -13.61784076 -2.70046741
42 -5.53945446 -13.61784076
43 -6.26835380 -5.53945446
44 -5.05971140 -6.26835380
45 11.82530804 -5.05971140
46 -4.19193238 11.82530804
47 -1.27967457 -4.19193238
48 -2.65541067 -1.27967457
49 -0.28027328 -2.65541067
50 -0.64475753 -0.28027328
51 -4.98679527 -0.64475753
52 -2.07303390 -4.98679527
53 11.38195132 -2.07303390
54 5.99460266 11.38195132
55 -2.78919265 5.99460266
56 3.28531110 -2.78919265
57 5.38909191 3.28531110
58 4.55240537 5.38909191
59 -1.89766519 4.55240537
> 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/7zl6r1293560607.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/www/html/rcomp/tmp/8zl6r1293560607.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/www/html/rcomp/tmp/9zl6r1293560607.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/www/html/rcomp/tmp/10suou1293560607.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/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/11vu4i1293560607.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/12gd2o1293560607.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/13c50f1293560607.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/14g5zl1293560607.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/15jox91293560607.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/165owx1293560607.tab")
+ }
>
> try(system("convert tmp/13brj1293560607.ps tmp/13brj1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/2dk8m1293560607.ps tmp/2dk8m1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/3dk8m1293560607.ps tmp/3dk8m1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/4dk8m1293560607.ps tmp/4dk8m1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ot7o1293560607.ps tmp/5ot7o1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ot7o1293560607.ps tmp/6ot7o1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/7zl6r1293560607.ps tmp/7zl6r1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/8zl6r1293560607.ps tmp/8zl6r1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/9zl6r1293560607.ps tmp/9zl6r1293560607.png",intern=TRUE))
character(0)
> try(system("convert tmp/10suou1293560607.ps tmp/10suou1293560607.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.450 1.660 5.573