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(102.9
+ ,120
+ ,112.7
+ ,97
+ ,95.1
+ ,97.4
+ ,114
+ ,102.9
+ ,112.7
+ ,97
+ ,111.4
+ ,116
+ ,97.4
+ ,102.9
+ ,112.7
+ ,87.4
+ ,153
+ ,111.4
+ ,97.4
+ ,102.9
+ ,96.8
+ ,162
+ ,87.4
+ ,111.4
+ ,97.4
+ ,114.1
+ ,161
+ ,96.8
+ ,87.4
+ ,111.4
+ ,110.3
+ ,149
+ ,114.1
+ ,96.8
+ ,87.4
+ ,103.9
+ ,139
+ ,110.3
+ ,114.1
+ ,96.8
+ ,101.6
+ ,135
+ ,103.9
+ ,110.3
+ ,114.1
+ ,94.6
+ ,130
+ ,101.6
+ ,103.9
+ ,110.3
+ ,95.9
+ ,127
+ ,94.6
+ ,101.6
+ ,103.9
+ ,104.7
+ ,122
+ ,95.9
+ ,94.6
+ ,101.6
+ ,102.8
+ ,117
+ ,104.7
+ ,95.9
+ ,94.6
+ ,98.1
+ ,112
+ ,102.8
+ ,104.7
+ ,95.9
+ ,113.9
+ ,113
+ ,98.1
+ ,102.8
+ ,104.7
+ ,80.9
+ ,149
+ ,113.9
+ ,98.1
+ ,102.8
+ ,95.7
+ ,157
+ ,80.9
+ ,113.9
+ ,98.1
+ ,113.2
+ ,157
+ ,95.7
+ ,80.9
+ ,113.9
+ ,105.9
+ ,147
+ ,113.2
+ ,95.7
+ ,80.9
+ ,108.8
+ ,137
+ ,105.9
+ ,113.2
+ ,95.7
+ ,102.3
+ ,132
+ ,108.8
+ ,105.9
+ ,113.2
+ ,99
+ ,125
+ ,102.3
+ ,108.8
+ ,105.9
+ ,100.7
+ ,123
+ ,99
+ ,102.3
+ ,108.8
+ ,115.5
+ ,117
+ ,100.7
+ ,99
+ ,102.3
+ ,100.7
+ ,114
+ ,115.5
+ ,100.7
+ ,99
+ ,109.9
+ ,111
+ ,100.7
+ ,115.5
+ ,100.7
+ ,114.6
+ ,112
+ ,109.9
+ ,100.7
+ ,115.5
+ ,85.4
+ ,144
+ ,114.6
+ ,109.9
+ ,100.7
+ ,100.5
+ ,150
+ ,85.4
+ ,114.6
+ ,109.9
+ ,114.8
+ ,149
+ ,100.5
+ ,85.4
+ ,114.6
+ ,116.5
+ ,134
+ ,114.8
+ ,100.5
+ ,85.4
+ ,112.9
+ ,123
+ ,116.5
+ ,114.8
+ ,100.5
+ ,102
+ ,116
+ ,112.9
+ ,116.5
+ ,114.8
+ ,106
+ ,117
+ ,102
+ ,112.9
+ ,116.5
+ ,105.3
+ ,111
+ ,106
+ ,102
+ ,112.9
+ ,118.8
+ ,105
+ ,105.3
+ ,106
+ ,102
+ ,106.1
+ ,102
+ ,118.8
+ ,105.3
+ ,106
+ ,109.3
+ ,95
+ ,106.1
+ ,118.8
+ ,105.3
+ ,117.2
+ ,93
+ ,109.3
+ ,106.1
+ ,118.8
+ ,92.5
+ ,124
+ ,117.2
+ ,109.3
+ ,106.1
+ ,104.2
+ ,130
+ ,92.5
+ ,117.2
+ ,109.3
+ ,112.5
+ ,124
+ ,104.2
+ ,92.5
+ ,117.2
+ ,122.4
+ ,115
+ ,112.5
+ ,104.2
+ ,92.5
+ ,113.3
+ ,106
+ ,122.4
+ ,112.5
+ ,104.2
+ ,100
+ ,105
+ ,113.3
+ ,122.4
+ ,112.5
+ ,110.7
+ ,105
+ ,100
+ ,113.3
+ ,122.4
+ ,112.8
+ ,101
+ ,110.7
+ ,100
+ ,113.3
+ ,109.8
+ ,95
+ ,112.8
+ ,110.7
+ ,100
+ ,117.3
+ ,93
+ ,109.8
+ ,112.8
+ ,110.7
+ ,109.1
+ ,84
+ ,117.3
+ ,109.8
+ ,112.8
+ ,115.9
+ ,87
+ ,109.1
+ ,117.3
+ ,109.8
+ ,96
+ ,116
+ ,115.9
+ ,109.1
+ ,117.3
+ ,99.8
+ ,120
+ ,96
+ ,115.9
+ ,109.1
+ ,116.8
+ ,117
+ ,99.8
+ ,96
+ ,115.9
+ ,115.7
+ ,109
+ ,116.8
+ ,99.8
+ ,96
+ ,99.4
+ ,105
+ ,115.7
+ ,116.8
+ ,99.8
+ ,94.3
+ ,107
+ ,99.4
+ ,115.7
+ ,116.8
+ ,91
+ ,109
+ ,94.3
+ ,99.4
+ ,115.7)
+ ,dim=c(5
+ ,58)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3')
+ ,1:58))
> y <- array(NA,dim=c(5,58),dimnames=list(c('Y','X','Y1','Y2','Y3'),1:58))
> 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 102.9 120 112.7 97.0 95.1 1 0 0 0 0 0 0 0 0 0 0 1
2 97.4 114 102.9 112.7 97.0 0 1 0 0 0 0 0 0 0 0 0 2
3 111.4 116 97.4 102.9 112.7 0 0 1 0 0 0 0 0 0 0 0 3
4 87.4 153 111.4 97.4 102.9 0 0 0 1 0 0 0 0 0 0 0 4
5 96.8 162 87.4 111.4 97.4 0 0 0 0 1 0 0 0 0 0 0 5
6 114.1 161 96.8 87.4 111.4 0 0 0 0 0 1 0 0 0 0 0 6
7 110.3 149 114.1 96.8 87.4 0 0 0 0 0 0 1 0 0 0 0 7
8 103.9 139 110.3 114.1 96.8 0 0 0 0 0 0 0 1 0 0 0 8
9 101.6 135 103.9 110.3 114.1 0 0 0 0 0 0 0 0 1 0 0 9
10 94.6 130 101.6 103.9 110.3 0 0 0 0 0 0 0 0 0 1 0 10
11 95.9 127 94.6 101.6 103.9 0 0 0 0 0 0 0 0 0 0 1 11
12 104.7 122 95.9 94.6 101.6 0 0 0 0 0 0 0 0 0 0 0 12
13 102.8 117 104.7 95.9 94.6 1 0 0 0 0 0 0 0 0 0 0 13
14 98.1 112 102.8 104.7 95.9 0 1 0 0 0 0 0 0 0 0 0 14
15 113.9 113 98.1 102.8 104.7 0 0 1 0 0 0 0 0 0 0 0 15
16 80.9 149 113.9 98.1 102.8 0 0 0 1 0 0 0 0 0 0 0 16
17 95.7 157 80.9 113.9 98.1 0 0 0 0 1 0 0 0 0 0 0 17
18 113.2 157 95.7 80.9 113.9 0 0 0 0 0 1 0 0 0 0 0 18
19 105.9 147 113.2 95.7 80.9 0 0 0 0 0 0 1 0 0 0 0 19
20 108.8 137 105.9 113.2 95.7 0 0 0 0 0 0 0 1 0 0 0 20
21 102.3 132 108.8 105.9 113.2 0 0 0 0 0 0 0 0 1 0 0 21
22 99.0 125 102.3 108.8 105.9 0 0 0 0 0 0 0 0 0 1 0 22
23 100.7 123 99.0 102.3 108.8 0 0 0 0 0 0 0 0 0 0 1 23
24 115.5 117 100.7 99.0 102.3 0 0 0 0 0 0 0 0 0 0 0 24
25 100.7 114 115.5 100.7 99.0 1 0 0 0 0 0 0 0 0 0 0 25
26 109.9 111 100.7 115.5 100.7 0 1 0 0 0 0 0 0 0 0 0 26
27 114.6 112 109.9 100.7 115.5 0 0 1 0 0 0 0 0 0 0 0 27
28 85.4 144 114.6 109.9 100.7 0 0 0 1 0 0 0 0 0 0 0 28
29 100.5 150 85.4 114.6 109.9 0 0 0 0 1 0 0 0 0 0 0 29
30 114.8 149 100.5 85.4 114.6 0 0 0 0 0 1 0 0 0 0 0 30
31 116.5 134 114.8 100.5 85.4 0 0 0 0 0 0 1 0 0 0 0 31
32 112.9 123 116.5 114.8 100.5 0 0 0 0 0 0 0 1 0 0 0 32
33 102.0 116 112.9 116.5 114.8 0 0 0 0 0 0 0 0 1 0 0 33
34 106.0 117 102.0 112.9 116.5 0 0 0 0 0 0 0 0 0 1 0 34
35 105.3 111 106.0 102.0 112.9 0 0 0 0 0 0 0 0 0 0 1 35
36 118.8 105 105.3 106.0 102.0 0 0 0 0 0 0 0 0 0 0 0 36
37 106.1 102 118.8 105.3 106.0 1 0 0 0 0 0 0 0 0 0 0 37
38 109.3 95 106.1 118.8 105.3 0 1 0 0 0 0 0 0 0 0 0 38
39 117.2 93 109.3 106.1 118.8 0 0 1 0 0 0 0 0 0 0 0 39
40 92.5 124 117.2 109.3 106.1 0 0 0 1 0 0 0 0 0 0 0 40
41 104.2 130 92.5 117.2 109.3 0 0 0 0 1 0 0 0 0 0 0 41
42 112.5 124 104.2 92.5 117.2 0 0 0 0 0 1 0 0 0 0 0 42
43 122.4 115 112.5 104.2 92.5 0 0 0 0 0 0 1 0 0 0 0 43
44 113.3 106 122.4 112.5 104.2 0 0 0 0 0 0 0 1 0 0 0 44
45 100.0 105 113.3 122.4 112.5 0 0 0 0 0 0 0 0 1 0 0 45
46 110.7 105 100.0 113.3 122.4 0 0 0 0 0 0 0 0 0 1 0 46
47 112.8 101 110.7 100.0 113.3 0 0 0 0 0 0 0 0 0 0 1 47
48 109.8 95 112.8 110.7 100.0 0 0 0 0 0 0 0 0 0 0 0 48
49 117.3 93 109.8 112.8 110.7 1 0 0 0 0 0 0 0 0 0 0 49
50 109.1 84 117.3 109.8 112.8 0 1 0 0 0 0 0 0 0 0 0 50
51 115.9 87 109.1 117.3 109.8 0 0 1 0 0 0 0 0 0 0 0 51
52 96.0 116 115.9 109.1 117.3 0 0 0 1 0 0 0 0 0 0 0 52
53 99.8 120 96.0 115.9 109.1 0 0 0 0 1 0 0 0 0 0 0 53
54 116.8 117 99.8 96.0 115.9 0 0 0 0 0 1 0 0 0 0 0 54
55 115.7 109 116.8 99.8 96.0 0 0 0 0 0 0 1 0 0 0 0 55
56 99.4 105 115.7 116.8 99.8 0 0 0 0 0 0 0 1 0 0 0 56
57 94.3 107 99.4 115.7 116.8 0 0 0 0 0 0 0 0 1 0 0 57
58 91.0 109 94.3 99.4 115.7 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 M1
-23.35633 0.05037 0.13734 0.44197 0.71372 -7.33929
M2 M3 M4 M5 M6 M7
-12.60207 -6.88850 -30.94098 -20.14759 -2.05731 10.21557
M8 M9 M10 M11 t
-10.15798 -27.23563 -22.85435 -14.13119 -0.06565
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-7.4389 -3.2092 0.1905 2.6268 8.0215
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -23.35633 38.66622 -0.604 0.549138
X 0.05037 0.13540 0.372 0.711816
Y1 0.13734 0.14016 0.980 0.332899
Y2 0.44197 0.14891 2.968 0.004986 **
Y3 0.71372 0.16600 4.299 0.000103 ***
M1 -7.33929 3.04066 -2.414 0.020342 *
M2 -12.60207 3.24317 -3.886 0.000365 ***
M3 -6.88850 3.43943 -2.003 0.051841 .
M4 -30.94098 5.35752 -5.775 9.03e-07 ***
M5 -20.14759 6.03868 -3.336 0.001812 **
M6 -2.05731 5.56834 -0.369 0.713683
M7 10.21557 4.84061 2.110 0.040970 *
M8 -10.15798 4.40675 -2.305 0.026298 *
M9 -27.23563 4.66928 -5.833 7.48e-07 ***
M10 -22.85435 4.02271 -5.681 1.23e-06 ***
M11 -14.13119 3.34704 -4.222 0.000131 ***
t -0.06565 0.09895 -0.663 0.510740
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.128 on 41 degrees of freedom
Multiple R-squared: 0.8531, Adjusted R-squared: 0.7958
F-statistic: 14.88 on 16 and 41 DF, p-value: 2.993e-12
> 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.4069737 0.8139474 0.5930263
[2,] 0.3292936 0.6585871 0.6707064
[3,] 0.3554284 0.7108568 0.6445716
[4,] 0.4136575 0.8273150 0.5863425
[5,] 0.4683619 0.9367238 0.5316381
[6,] 0.5077124 0.9845751 0.4922876
[7,] 0.5774420 0.8451160 0.4225580
[8,] 0.4572308 0.9144617 0.5427692
[9,] 0.3950098 0.7900197 0.6049902
[10,] 0.3306589 0.6613179 0.6693411
[11,] 0.2757506 0.5515011 0.7242494
[12,] 0.3151978 0.6303956 0.6848022
[13,] 0.4385673 0.8771346 0.5614327
[14,] 0.4421816 0.8843631 0.5578184
[15,] 0.4914453 0.9828906 0.5085547
[16,] 0.5964720 0.8070560 0.4035280
[17,] 0.6324177 0.7351647 0.3675823
[18,] 0.4993224 0.9986449 0.5006776
[19,] 0.3730438 0.7460877 0.6269562
> postscript(file="/var/www/html/rcomp/tmp/12qv71260976912.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/246vc1260976912.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/3cgvl1260976912.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/43oky1260976912.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/5h5jk1260976912.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 = 58
Frequency = 1
1 2 3 4 5 6
1.39366642 -5.42485473 -3.29218910 2.46497509 1.71782927 0.36790749
7 8 9 10 11 12
-4.43615844 -3.72649777 1.52939835 -3.67777387 -4.33850648 -4.79538763
13 14 15 16 17 18
4.17428688 0.49828904 5.80451768 -3.62710384 0.94561464 1.69677684
19 20 21 22 23 24
-2.69868377 3.84918318 5.08238273 2.64041754 -2.96011157 3.94075324
25 26 27 28 29 30
-3.73186427 5.22571501 -1.05788135 -1.90007563 -2.46327699 1.33981876
31 32 33 34 35 36
3.79094504 3.85335258 -0.01389161 1.49485785 -0.72291429 5.12151220
37 38 39 40 41 42
-4.42197203 0.73615314 -1.37263945 3.04908768 1.33586690 -4.41503875
43 44 45 46 47 48
5.04888511 3.46288271 -1.69308253 3.47400591 8.02153233 -4.26687781
49 50 51 52 53 54
2.58588299 -1.03530245 -0.08180778 0.01311670 -1.53603382 1.01053566
55 56 57 58
-1.70498795 -7.43892069 -4.90480694 -3.93150743
> postscript(file="/var/www/html/rcomp/tmp/6om3b1260976912.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 1.39366642 NA
1 -5.42485473 1.39366642
2 -3.29218910 -5.42485473
3 2.46497509 -3.29218910
4 1.71782927 2.46497509
5 0.36790749 1.71782927
6 -4.43615844 0.36790749
7 -3.72649777 -4.43615844
8 1.52939835 -3.72649777
9 -3.67777387 1.52939835
10 -4.33850648 -3.67777387
11 -4.79538763 -4.33850648
12 4.17428688 -4.79538763
13 0.49828904 4.17428688
14 5.80451768 0.49828904
15 -3.62710384 5.80451768
16 0.94561464 -3.62710384
17 1.69677684 0.94561464
18 -2.69868377 1.69677684
19 3.84918318 -2.69868377
20 5.08238273 3.84918318
21 2.64041754 5.08238273
22 -2.96011157 2.64041754
23 3.94075324 -2.96011157
24 -3.73186427 3.94075324
25 5.22571501 -3.73186427
26 -1.05788135 5.22571501
27 -1.90007563 -1.05788135
28 -2.46327699 -1.90007563
29 1.33981876 -2.46327699
30 3.79094504 1.33981876
31 3.85335258 3.79094504
32 -0.01389161 3.85335258
33 1.49485785 -0.01389161
34 -0.72291429 1.49485785
35 5.12151220 -0.72291429
36 -4.42197203 5.12151220
37 0.73615314 -4.42197203
38 -1.37263945 0.73615314
39 3.04908768 -1.37263945
40 1.33586690 3.04908768
41 -4.41503875 1.33586690
42 5.04888511 -4.41503875
43 3.46288271 5.04888511
44 -1.69308253 3.46288271
45 3.47400591 -1.69308253
46 8.02153233 3.47400591
47 -4.26687781 8.02153233
48 2.58588299 -4.26687781
49 -1.03530245 2.58588299
50 -0.08180778 -1.03530245
51 0.01311670 -0.08180778
52 -1.53603382 0.01311670
53 1.01053566 -1.53603382
54 -1.70498795 1.01053566
55 -7.43892069 -1.70498795
56 -4.90480694 -7.43892069
57 -3.93150743 -4.90480694
58 NA -3.93150743
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -5.42485473 1.39366642
[2,] -3.29218910 -5.42485473
[3,] 2.46497509 -3.29218910
[4,] 1.71782927 2.46497509
[5,] 0.36790749 1.71782927
[6,] -4.43615844 0.36790749
[7,] -3.72649777 -4.43615844
[8,] 1.52939835 -3.72649777
[9,] -3.67777387 1.52939835
[10,] -4.33850648 -3.67777387
[11,] -4.79538763 -4.33850648
[12,] 4.17428688 -4.79538763
[13,] 0.49828904 4.17428688
[14,] 5.80451768 0.49828904
[15,] -3.62710384 5.80451768
[16,] 0.94561464 -3.62710384
[17,] 1.69677684 0.94561464
[18,] -2.69868377 1.69677684
[19,] 3.84918318 -2.69868377
[20,] 5.08238273 3.84918318
[21,] 2.64041754 5.08238273
[22,] -2.96011157 2.64041754
[23,] 3.94075324 -2.96011157
[24,] -3.73186427 3.94075324
[25,] 5.22571501 -3.73186427
[26,] -1.05788135 5.22571501
[27,] -1.90007563 -1.05788135
[28,] -2.46327699 -1.90007563
[29,] 1.33981876 -2.46327699
[30,] 3.79094504 1.33981876
[31,] 3.85335258 3.79094504
[32,] -0.01389161 3.85335258
[33,] 1.49485785 -0.01389161
[34,] -0.72291429 1.49485785
[35,] 5.12151220 -0.72291429
[36,] -4.42197203 5.12151220
[37,] 0.73615314 -4.42197203
[38,] -1.37263945 0.73615314
[39,] 3.04908768 -1.37263945
[40,] 1.33586690 3.04908768
[41,] -4.41503875 1.33586690
[42,] 5.04888511 -4.41503875
[43,] 3.46288271 5.04888511
[44,] -1.69308253 3.46288271
[45,] 3.47400591 -1.69308253
[46,] 8.02153233 3.47400591
[47,] -4.26687781 8.02153233
[48,] 2.58588299 -4.26687781
[49,] -1.03530245 2.58588299
[50,] -0.08180778 -1.03530245
[51,] 0.01311670 -0.08180778
[52,] -1.53603382 0.01311670
[53,] 1.01053566 -1.53603382
[54,] -1.70498795 1.01053566
[55,] -7.43892069 -1.70498795
[56,] -4.90480694 -7.43892069
[57,] -3.93150743 -4.90480694
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -5.42485473 1.39366642
2 -3.29218910 -5.42485473
3 2.46497509 -3.29218910
4 1.71782927 2.46497509
5 0.36790749 1.71782927
6 -4.43615844 0.36790749
7 -3.72649777 -4.43615844
8 1.52939835 -3.72649777
9 -3.67777387 1.52939835
10 -4.33850648 -3.67777387
11 -4.79538763 -4.33850648
12 4.17428688 -4.79538763
13 0.49828904 4.17428688
14 5.80451768 0.49828904
15 -3.62710384 5.80451768
16 0.94561464 -3.62710384
17 1.69677684 0.94561464
18 -2.69868377 1.69677684
19 3.84918318 -2.69868377
20 5.08238273 3.84918318
21 2.64041754 5.08238273
22 -2.96011157 2.64041754
23 3.94075324 -2.96011157
24 -3.73186427 3.94075324
25 5.22571501 -3.73186427
26 -1.05788135 5.22571501
27 -1.90007563 -1.05788135
28 -2.46327699 -1.90007563
29 1.33981876 -2.46327699
30 3.79094504 1.33981876
31 3.85335258 3.79094504
32 -0.01389161 3.85335258
33 1.49485785 -0.01389161
34 -0.72291429 1.49485785
35 5.12151220 -0.72291429
36 -4.42197203 5.12151220
37 0.73615314 -4.42197203
38 -1.37263945 0.73615314
39 3.04908768 -1.37263945
40 1.33586690 3.04908768
41 -4.41503875 1.33586690
42 5.04888511 -4.41503875
43 3.46288271 5.04888511
44 -1.69308253 3.46288271
45 3.47400591 -1.69308253
46 8.02153233 3.47400591
47 -4.26687781 8.02153233
48 2.58588299 -4.26687781
49 -1.03530245 2.58588299
50 -0.08180778 -1.03530245
51 0.01311670 -0.08180778
52 -1.53603382 0.01311670
53 1.01053566 -1.53603382
54 -1.70498795 1.01053566
55 -7.43892069 -1.70498795
56 -4.90480694 -7.43892069
57 -3.93150743 -4.90480694
> 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/7vcap1260976912.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/8yfjg1260976912.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/916ru1260976912.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/10sxuq1260976912.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/111jzp1260976912.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/12prpd1260976913.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/1367vj1260976913.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/14qclf1260976913.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/15z60i1260976913.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/167x8j1260976913.tab")
+ }
> try(system("convert tmp/12qv71260976912.ps tmp/12qv71260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/246vc1260976912.ps tmp/246vc1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/3cgvl1260976912.ps tmp/3cgvl1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/43oky1260976912.ps tmp/43oky1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/5h5jk1260976912.ps tmp/5h5jk1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/6om3b1260976912.ps tmp/6om3b1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/7vcap1260976912.ps tmp/7vcap1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/8yfjg1260976912.ps tmp/8yfjg1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/916ru1260976912.ps tmp/916ru1260976912.png",intern=TRUE))
character(0)
> try(system("convert tmp/10sxuq1260976912.ps tmp/10sxuq1260976912.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.335 1.528 3.132