R version 2.12.0 (2010-10-15)
Copyright (C) 2010 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(102.8
+ ,112.5
+ ,116.7
+ ,116.1
+ ,98.1
+ ,113
+ ,112.5
+ ,107.5
+ ,113.9
+ ,126.4
+ ,113
+ ,116.7
+ ,80.9
+ ,114.1
+ ,126.4
+ ,112.5
+ ,95.7
+ ,112.5
+ ,114.1
+ ,113
+ ,113.2
+ ,112.4
+ ,112.5
+ ,126.4
+ ,105.9
+ ,113.1
+ ,112.4
+ ,114.1
+ ,108.8
+ ,116.3
+ ,113.1
+ ,112.5
+ ,102.3
+ ,111.7
+ ,116.3
+ ,112.4
+ ,99
+ ,118.8
+ ,111.7
+ ,113.1
+ ,100.7
+ ,116.5
+ ,118.8
+ ,116.3
+ ,115.5
+ ,125.1
+ ,116.5
+ ,111.7
+ ,100.7
+ ,113.1
+ ,125.1
+ ,118.8
+ ,109.9
+ ,119.6
+ ,113.1
+ ,116.5
+ ,114.6
+ ,114.4
+ ,119.6
+ ,125.1
+ ,85.4
+ ,114
+ ,114.4
+ ,113.1
+ ,100.5
+ ,117.8
+ ,114
+ ,119.6
+ ,114.8
+ ,117
+ ,117.8
+ ,114.4
+ ,116.5
+ ,120.9
+ ,117
+ ,114
+ ,112.9
+ ,115
+ ,120.9
+ ,117.8
+ ,102
+ ,117.3
+ ,115
+ ,117
+ ,106
+ ,119.4
+ ,117.3
+ ,120.9
+ ,105.3
+ ,114.9
+ ,119.4
+ ,115
+ ,118.8
+ ,125.8
+ ,114.9
+ ,117.3
+ ,106.1
+ ,117.6
+ ,125.8
+ ,119.4
+ ,109.3
+ ,117.6
+ ,117.6
+ ,114.9
+ ,117.2
+ ,114.9
+ ,117.6
+ ,125.8
+ ,92.5
+ ,121.9
+ ,114.9
+ ,117.6
+ ,104.2
+ ,117
+ ,121.9
+ ,117.6
+ ,112.5
+ ,106.4
+ ,117
+ ,114.9
+ ,122.4
+ ,110.5
+ ,106.4
+ ,121.9
+ ,113.3
+ ,113.6
+ ,110.5
+ ,117
+ ,100
+ ,114.2
+ ,113.6
+ ,106.4
+ ,110.7
+ ,125.4
+ ,114.2
+ ,110.5
+ ,112.8
+ ,124.6
+ ,125.4
+ ,113.6
+ ,109.8
+ ,120.2
+ ,124.6
+ ,114.2
+ ,117.3
+ ,120.8
+ ,120.2
+ ,125.4
+ ,109.1
+ ,111.4
+ ,120.8
+ ,124.6
+ ,115.9
+ ,124.1
+ ,111.4
+ ,120.2
+ ,96
+ ,120.2
+ ,124.1
+ ,120.8
+ ,99.8
+ ,125.5
+ ,120.2
+ ,111.4
+ ,116.8
+ ,116
+ ,125.5
+ ,124.1
+ ,115.7
+ ,117
+ ,116
+ ,120.2
+ ,99.4
+ ,105.7
+ ,117
+ ,125.5
+ ,94.3
+ ,102
+ ,105.7
+ ,116
+ ,91
+ ,106.4
+ ,102
+ ,117
+ ,93.2
+ ,96.9
+ ,106.4
+ ,105.7
+ ,103.1
+ ,107.6
+ ,96.9
+ ,102
+ ,94.1
+ ,98.8
+ ,107.6
+ ,106.4
+ ,91.8
+ ,101.1
+ ,98.8
+ ,96.9
+ ,102.7
+ ,105.7
+ ,101.1
+ ,107.6
+ ,82.6
+ ,104.6
+ ,105.7
+ ,98.8
+ ,89.1
+ ,103.2
+ ,104.6
+ ,101.1
+ ,104.5
+ ,101.6
+ ,103.2
+ ,105.7
+ ,105.1
+ ,106.7
+ ,101.6
+ ,104.6
+ ,95.1
+ ,99.5
+ ,106.7
+ ,103.2
+ ,88.7
+ ,101
+ ,99.5
+ ,101.6)
+ ,dim=c(4
+ ,57)
+ ,dimnames=list(c('T.I.P.'
+ ,'Y(t)'
+ ,'Y(t-1)'
+ ,'Y(t-3)')
+ ,1:57))
> y <- array(NA,dim=c(4,57),dimnames=list(c('T.I.P.','Y(t)','Y(t-1)','Y(t-3)'),1:57))
> 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 = '2'
> #'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
Y(t) T.I.P. Y(t-1) Y(t-3) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 112.5 102.8 116.7 116.1 1 0 0 0 0 0 0 0 0 0 0 1
2 113.0 98.1 112.5 107.5 0 1 0 0 0 0 0 0 0 0 0 2
3 126.4 113.9 113.0 116.7 0 0 1 0 0 0 0 0 0 0 0 3
4 114.1 80.9 126.4 112.5 0 0 0 1 0 0 0 0 0 0 0 4
5 112.5 95.7 114.1 113.0 0 0 0 0 1 0 0 0 0 0 0 5
6 112.4 113.2 112.5 126.4 0 0 0 0 0 1 0 0 0 0 0 6
7 113.1 105.9 112.4 114.1 0 0 0 0 0 0 1 0 0 0 0 7
8 116.3 108.8 113.1 112.5 0 0 0 0 0 0 0 1 0 0 0 8
9 111.7 102.3 116.3 112.4 0 0 0 0 0 0 0 0 1 0 0 9
10 118.8 99.0 111.7 113.1 0 0 0 0 0 0 0 0 0 1 0 10
11 116.5 100.7 118.8 116.3 0 0 0 0 0 0 0 0 0 0 1 11
12 125.1 115.5 116.5 111.7 0 0 0 0 0 0 0 0 0 0 0 12
13 113.1 100.7 125.1 118.8 1 0 0 0 0 0 0 0 0 0 0 13
14 119.6 109.9 113.1 116.5 0 1 0 0 0 0 0 0 0 0 0 14
15 114.4 114.6 119.6 125.1 0 0 1 0 0 0 0 0 0 0 0 15
16 114.0 85.4 114.4 113.1 0 0 0 1 0 0 0 0 0 0 0 16
17 117.8 100.5 114.0 119.6 0 0 0 0 1 0 0 0 0 0 0 17
18 117.0 114.8 117.8 114.4 0 0 0 0 0 1 0 0 0 0 0 18
19 120.9 116.5 117.0 114.0 0 0 0 0 0 0 1 0 0 0 0 19
20 115.0 112.9 120.9 117.8 0 0 0 0 0 0 0 1 0 0 0 20
21 117.3 102.0 115.0 117.0 0 0 0 0 0 0 0 0 1 0 0 21
22 119.4 106.0 117.3 120.9 0 0 0 0 0 0 0 0 0 1 0 22
23 114.9 105.3 119.4 115.0 0 0 0 0 0 0 0 0 0 0 1 23
24 125.8 118.8 114.9 117.3 0 0 0 0 0 0 0 0 0 0 0 24
25 117.6 106.1 125.8 119.4 1 0 0 0 0 0 0 0 0 0 0 25
26 117.6 109.3 117.6 114.9 0 1 0 0 0 0 0 0 0 0 0 26
27 114.9 117.2 117.6 125.8 0 0 1 0 0 0 0 0 0 0 0 27
28 121.9 92.5 114.9 117.6 0 0 0 1 0 0 0 0 0 0 0 28
29 117.0 104.2 121.9 117.6 0 0 0 0 1 0 0 0 0 0 0 29
30 106.4 112.5 117.0 114.9 0 0 0 0 0 1 0 0 0 0 0 30
31 110.5 122.4 106.4 121.9 0 0 0 0 0 0 1 0 0 0 0 31
32 113.6 113.3 110.5 117.0 0 0 0 0 0 0 0 1 0 0 0 32
33 114.2 100.0 113.6 106.4 0 0 0 0 0 0 0 0 1 0 0 33
34 125.4 110.7 114.2 110.5 0 0 0 0 0 0 0 0 0 1 0 34
35 124.6 112.8 125.4 113.6 0 0 0 0 0 0 0 0 0 0 1 35
36 120.2 109.8 124.6 114.2 0 0 0 0 0 0 0 0 0 0 0 36
37 120.8 117.3 120.2 125.4 1 0 0 0 0 0 0 0 0 0 0 37
38 111.4 109.1 120.8 124.6 0 1 0 0 0 0 0 0 0 0 0 38
39 124.1 115.9 111.4 120.2 0 0 1 0 0 0 0 0 0 0 0 39
40 120.2 96.0 124.1 120.8 0 0 0 1 0 0 0 0 0 0 0 40
41 125.5 99.8 120.2 111.4 0 0 0 0 1 0 0 0 0 0 0 41
42 116.0 116.8 125.5 124.1 0 0 0 0 0 1 0 0 0 0 0 42
43 117.0 115.7 116.0 120.2 0 0 0 0 0 0 1 0 0 0 0 43
44 105.7 99.4 117.0 125.5 0 0 0 0 0 0 0 1 0 0 0 44
45 102.0 94.3 105.7 116.0 0 0 0 0 0 0 0 0 1 0 0 45
46 106.4 91.0 102.0 117.0 0 0 0 0 0 0 0 0 0 1 0 46
47 96.9 93.2 106.4 105.7 0 0 0 0 0 0 0 0 0 0 1 47
48 107.6 103.1 96.9 102.0 0 0 0 0 0 0 0 0 0 0 0 48
49 98.8 94.1 107.6 106.4 1 0 0 0 0 0 0 0 0 0 0 49
50 101.1 91.8 98.8 96.9 0 1 0 0 0 0 0 0 0 0 0 50
51 105.7 102.7 101.1 107.6 0 0 1 0 0 0 0 0 0 0 0 51
52 104.6 82.6 105.7 98.8 0 0 0 1 0 0 0 0 0 0 0 52
53 103.2 89.1 104.6 101.1 0 0 0 0 1 0 0 0 0 0 0 53
54 101.6 104.5 103.2 105.7 0 0 0 0 0 1 0 0 0 0 0 54
55 106.7 105.1 101.6 104.6 0 0 0 0 0 0 1 0 0 0 0 55
56 99.5 95.1 106.7 103.2 0 0 0 0 0 0 0 1 0 0 0 56
57 101.0 88.7 99.5 101.6 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) T.I.P. `Y(t-1)` `Y(t-3)` M1 M2
27.5647 0.7192 0.3516 -0.2255 -2.8753 -1.2585
M3 M4 M5 M6 M7 M8
-1.6439 11.4974 5.1202 -8.7844 -5.1637 -4.4770
M9 M10 M11 t
1.1676 6.5019 -1.4200 -0.1005
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.7448 -1.8238 0.4007 1.8021 8.0116
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 27.56465 11.15424 2.471 0.01771 *
T.I.P. 0.71924 0.11058 6.504 8.3e-08 ***
`Y(t-1)` 0.35162 0.11157 3.151 0.00303 **
`Y(t-3)` -0.22548 0.11191 -2.015 0.05050 .
M1 -2.87532 2.81047 -1.023 0.31227
M2 -1.25845 2.60687 -0.483 0.63184
M3 -1.64389 2.58531 -0.636 0.52840
M4 11.49739 3.79326 3.031 0.00421 **
M5 5.12018 2.95082 1.735 0.09022 .
M6 -8.78442 2.49878 -3.515 0.00109 **
M7 -5.16373 2.50390 -2.062 0.04556 *
M8 -4.47697 2.60633 -1.718 0.09339 .
M9 1.16760 2.84131 0.411 0.68326
M10 6.50191 2.90250 2.240 0.03057 *
M11 -1.42000 2.85439 -0.497 0.62151
t -0.10053 0.03439 -2.923 0.00562 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.629 on 41 degrees of freedom
Multiple R-squared: 0.8341, Adjusted R-squared: 0.7733
F-statistic: 13.74 on 15 and 41 DF, p-value: 1.752e-11
> 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.6816132 0.6367736 0.3183868
[2,] 0.5310043 0.9379914 0.4689957
[3,] 0.6284292 0.7431417 0.3715708
[4,] 0.4990386 0.9980772 0.5009614
[5,] 0.4476663 0.8953325 0.5523337
[6,] 0.3365006 0.6730012 0.6634994
[7,] 0.2707139 0.5414278 0.7292861
[8,] 0.1918916 0.3837832 0.8081084
[9,] 0.2457544 0.4915088 0.7542456
[10,] 0.4225300 0.8450600 0.5774700
[11,] 0.3666108 0.7332216 0.6333892
[12,] 0.3847918 0.7695835 0.6152082
[13,] 0.6607695 0.6784611 0.3392305
[14,] 0.5754092 0.8491816 0.4245908
[15,] 0.4810182 0.9620364 0.5189818
[16,] 0.7157539 0.5684921 0.2842461
[17,] 0.5968694 0.8062612 0.4031306
[18,] 0.5153156 0.9693687 0.4846844
[19,] 0.3810356 0.7620711 0.6189644
[20,] 0.2874165 0.5748331 0.7125835
> postscript(file="/var/www/rcomp/tmp/1d7rg1292675371.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/rcomp/tmp/2d7rg1292675371.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/rcomp/tmp/3d7rg1292675371.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/rcomp/tmp/45h8j1292675371.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/rcomp/tmp/55h8j1292675371.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 = 57
Frequency = 1
1 2 3 4 5 6
-0.88155361 1.02017422 5.44081053 -1.82376469 -3.15312772 1.74939215
7 8 9 10 11 12
1.44140979 1.36249018 -5.25422086 0.76074890 3.48556057 -0.10712244
13 14 15 16 17 18
0.09046968 2.15793364 -6.28287646 0.40074104 1.42426967 1.83566194
19 20 21 22 23 24
1.18390617 -3.22753747 3.26226366 -2.67780841 -0.72063227 1.25107325
25 26 27 28 29 30
1.80214068 -0.14716982 -5.58542922 5.23941050 -4.05924209 -5.50966183
31 32 33 34 35 36
-6.74476534 -0.23241739 0.90928946 -0.10683141 2.36611218 -0.77905922
37 38 39 40 41 42
1.47501516 -3.93492275 6.67329546 -0.28484862 8.01155893 1.28971118
43 44 45 46 47 48
2.02169185 2.70247467 -1.04226918 2.02389091 -5.13104048 -0.36489159
49 50 51 52 53 54
-2.48607191 0.90398471 -0.24580032 -3.53153823 -2.22345880 0.63489656
55 56 57
2.09775753 -0.60500998 2.12493692
> postscript(file="/var/www/rcomp/tmp/65h8j1292675371.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.88155361 NA
1 1.02017422 -0.88155361
2 5.44081053 1.02017422
3 -1.82376469 5.44081053
4 -3.15312772 -1.82376469
5 1.74939215 -3.15312772
6 1.44140979 1.74939215
7 1.36249018 1.44140979
8 -5.25422086 1.36249018
9 0.76074890 -5.25422086
10 3.48556057 0.76074890
11 -0.10712244 3.48556057
12 0.09046968 -0.10712244
13 2.15793364 0.09046968
14 -6.28287646 2.15793364
15 0.40074104 -6.28287646
16 1.42426967 0.40074104
17 1.83566194 1.42426967
18 1.18390617 1.83566194
19 -3.22753747 1.18390617
20 3.26226366 -3.22753747
21 -2.67780841 3.26226366
22 -0.72063227 -2.67780841
23 1.25107325 -0.72063227
24 1.80214068 1.25107325
25 -0.14716982 1.80214068
26 -5.58542922 -0.14716982
27 5.23941050 -5.58542922
28 -4.05924209 5.23941050
29 -5.50966183 -4.05924209
30 -6.74476534 -5.50966183
31 -0.23241739 -6.74476534
32 0.90928946 -0.23241739
33 -0.10683141 0.90928946
34 2.36611218 -0.10683141
35 -0.77905922 2.36611218
36 1.47501516 -0.77905922
37 -3.93492275 1.47501516
38 6.67329546 -3.93492275
39 -0.28484862 6.67329546
40 8.01155893 -0.28484862
41 1.28971118 8.01155893
42 2.02169185 1.28971118
43 2.70247467 2.02169185
44 -1.04226918 2.70247467
45 2.02389091 -1.04226918
46 -5.13104048 2.02389091
47 -0.36489159 -5.13104048
48 -2.48607191 -0.36489159
49 0.90398471 -2.48607191
50 -0.24580032 0.90398471
51 -3.53153823 -0.24580032
52 -2.22345880 -3.53153823
53 0.63489656 -2.22345880
54 2.09775753 0.63489656
55 -0.60500998 2.09775753
56 2.12493692 -0.60500998
57 NA 2.12493692
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.02017422 -0.88155361
[2,] 5.44081053 1.02017422
[3,] -1.82376469 5.44081053
[4,] -3.15312772 -1.82376469
[5,] 1.74939215 -3.15312772
[6,] 1.44140979 1.74939215
[7,] 1.36249018 1.44140979
[8,] -5.25422086 1.36249018
[9,] 0.76074890 -5.25422086
[10,] 3.48556057 0.76074890
[11,] -0.10712244 3.48556057
[12,] 0.09046968 -0.10712244
[13,] 2.15793364 0.09046968
[14,] -6.28287646 2.15793364
[15,] 0.40074104 -6.28287646
[16,] 1.42426967 0.40074104
[17,] 1.83566194 1.42426967
[18,] 1.18390617 1.83566194
[19,] -3.22753747 1.18390617
[20,] 3.26226366 -3.22753747
[21,] -2.67780841 3.26226366
[22,] -0.72063227 -2.67780841
[23,] 1.25107325 -0.72063227
[24,] 1.80214068 1.25107325
[25,] -0.14716982 1.80214068
[26,] -5.58542922 -0.14716982
[27,] 5.23941050 -5.58542922
[28,] -4.05924209 5.23941050
[29,] -5.50966183 -4.05924209
[30,] -6.74476534 -5.50966183
[31,] -0.23241739 -6.74476534
[32,] 0.90928946 -0.23241739
[33,] -0.10683141 0.90928946
[34,] 2.36611218 -0.10683141
[35,] -0.77905922 2.36611218
[36,] 1.47501516 -0.77905922
[37,] -3.93492275 1.47501516
[38,] 6.67329546 -3.93492275
[39,] -0.28484862 6.67329546
[40,] 8.01155893 -0.28484862
[41,] 1.28971118 8.01155893
[42,] 2.02169185 1.28971118
[43,] 2.70247467 2.02169185
[44,] -1.04226918 2.70247467
[45,] 2.02389091 -1.04226918
[46,] -5.13104048 2.02389091
[47,] -0.36489159 -5.13104048
[48,] -2.48607191 -0.36489159
[49,] 0.90398471 -2.48607191
[50,] -0.24580032 0.90398471
[51,] -3.53153823 -0.24580032
[52,] -2.22345880 -3.53153823
[53,] 0.63489656 -2.22345880
[54,] 2.09775753 0.63489656
[55,] -0.60500998 2.09775753
[56,] 2.12493692 -0.60500998
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.02017422 -0.88155361
2 5.44081053 1.02017422
3 -1.82376469 5.44081053
4 -3.15312772 -1.82376469
5 1.74939215 -3.15312772
6 1.44140979 1.74939215
7 1.36249018 1.44140979
8 -5.25422086 1.36249018
9 0.76074890 -5.25422086
10 3.48556057 0.76074890
11 -0.10712244 3.48556057
12 0.09046968 -0.10712244
13 2.15793364 0.09046968
14 -6.28287646 2.15793364
15 0.40074104 -6.28287646
16 1.42426967 0.40074104
17 1.83566194 1.42426967
18 1.18390617 1.83566194
19 -3.22753747 1.18390617
20 3.26226366 -3.22753747
21 -2.67780841 3.26226366
22 -0.72063227 -2.67780841
23 1.25107325 -0.72063227
24 1.80214068 1.25107325
25 -0.14716982 1.80214068
26 -5.58542922 -0.14716982
27 5.23941050 -5.58542922
28 -4.05924209 5.23941050
29 -5.50966183 -4.05924209
30 -6.74476534 -5.50966183
31 -0.23241739 -6.74476534
32 0.90928946 -0.23241739
33 -0.10683141 0.90928946
34 2.36611218 -0.10683141
35 -0.77905922 2.36611218
36 1.47501516 -0.77905922
37 -3.93492275 1.47501516
38 6.67329546 -3.93492275
39 -0.28484862 6.67329546
40 8.01155893 -0.28484862
41 1.28971118 8.01155893
42 2.02169185 1.28971118
43 2.70247467 2.02169185
44 -1.04226918 2.70247467
45 2.02389091 -1.04226918
46 -5.13104048 2.02389091
47 -0.36489159 -5.13104048
48 -2.48607191 -0.36489159
49 0.90398471 -2.48607191
50 -0.24580032 0.90398471
51 -3.53153823 -0.24580032
52 -2.22345880 -3.53153823
53 0.63489656 -2.22345880
54 2.09775753 0.63489656
55 -0.60500998 2.09775753
56 2.12493692 -0.60500998
> 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/rcomp/tmp/7gqp41292675371.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/rcomp/tmp/8rz7p1292675371.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/rcomp/tmp/9rz7p1292675371.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/rcomp/tmp/10rz7p1292675371.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11nr4f1292675371.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/rcomp/tmp/12gi401292675371.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/rcomp/tmp/13ftl71292675372.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/rcomp/tmp/14732a1292675372.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/rcomp/tmp/15tl1g1292675372.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/rcomp/tmp/16pdhp1292675372.tab")
+ }
>
> try(system("convert tmp/1d7rg1292675371.ps tmp/1d7rg1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/2d7rg1292675371.ps tmp/2d7rg1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/3d7rg1292675371.ps tmp/3d7rg1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/45h8j1292675371.ps tmp/45h8j1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/55h8j1292675371.ps tmp/55h8j1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/65h8j1292675371.ps tmp/65h8j1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/7gqp41292675371.ps tmp/7gqp41292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/8rz7p1292675371.ps tmp/8rz7p1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/9rz7p1292675371.ps tmp/9rz7p1292675371.png",intern=TRUE))
character(0)
> try(system("convert tmp/10rz7p1292675371.ps tmp/10rz7p1292675371.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.950 1.730 4.648