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(104
+ ,120.28
+ ,112.9
+ ,113.6
+ ,83.4
+ ,79.8
+ ,109.9
+ ,115.33
+ ,104
+ ,112.9
+ ,113.6
+ ,83.4
+ ,99
+ ,110.4
+ ,109.9
+ ,104
+ ,112.9
+ ,113.6
+ ,106.3
+ ,114.49
+ ,99
+ ,109.9
+ ,104
+ ,112.9
+ ,128.9
+ ,132.03
+ ,106.3
+ ,99
+ ,109.9
+ ,104
+ ,111.1
+ ,123.16
+ ,128.9
+ ,106.3
+ ,99
+ ,109.9
+ ,102.9
+ ,118.82
+ ,111.1
+ ,128.9
+ ,106.3
+ ,99
+ ,130
+ ,128.32
+ ,102.9
+ ,111.1
+ ,128.9
+ ,106.3
+ ,87
+ ,112.24
+ ,130
+ ,102.9
+ ,111.1
+ ,128.9
+ ,87.5
+ ,104.53
+ ,87
+ ,130
+ ,102.9
+ ,111.1
+ ,117.6
+ ,132.57
+ ,87.5
+ ,87
+ ,130
+ ,102.9
+ ,103.4
+ ,122.52
+ ,117.6
+ ,87.5
+ ,87
+ ,130
+ ,110.8
+ ,131.8
+ ,103.4
+ ,117.6
+ ,87.5
+ ,87
+ ,112.6
+ ,124.55
+ ,110.8
+ ,103.4
+ ,117.6
+ ,87.5
+ ,102.5
+ ,120.96
+ ,112.6
+ ,110.8
+ ,103.4
+ ,117.6
+ ,112.4
+ ,122.6
+ ,102.5
+ ,112.6
+ ,110.8
+ ,103.4
+ ,135.6
+ ,145.52
+ ,112.4
+ ,102.5
+ ,112.6
+ ,110.8
+ ,105.1
+ ,118.57
+ ,135.6
+ ,112.4
+ ,102.5
+ ,112.6
+ ,127.7
+ ,134.25
+ ,105.1
+ ,135.6
+ ,112.4
+ ,102.5
+ ,137
+ ,136.7
+ ,127.7
+ ,105.1
+ ,135.6
+ ,112.4
+ ,91
+ ,121.37
+ ,137
+ ,127.7
+ ,105.1
+ ,135.6
+ ,90.5
+ ,111.63
+ ,91
+ ,137
+ ,127.7
+ ,105.1
+ ,122.4
+ ,134.42
+ ,90.5
+ ,91
+ ,137
+ ,127.7
+ ,123.3
+ ,137.65
+ ,122.4
+ ,90.5
+ ,91
+ ,137
+ ,124.3
+ ,137.86
+ ,123.3
+ ,122.4
+ ,90.5
+ ,91
+ ,120
+ ,119.77
+ ,124.3
+ ,123.3
+ ,122.4
+ ,90.5
+ ,118.1
+ ,130.69
+ ,120
+ ,124.3
+ ,123.3
+ ,122.4
+ ,119
+ ,128.28
+ ,118.1
+ ,120
+ ,124.3
+ ,123.3
+ ,142.7
+ ,147.45
+ ,119
+ ,118.1
+ ,120
+ ,124.3
+ ,123.6
+ ,128.42
+ ,142.7
+ ,119
+ ,118.1
+ ,120
+ ,129.6
+ ,136.9
+ ,123.6
+ ,142.7
+ ,119
+ ,118.1
+ ,151.6
+ ,143.95
+ ,129.6
+ ,123.6
+ ,142.7
+ ,119
+ ,110.4
+ ,135.64
+ ,151.6
+ ,129.6
+ ,123.6
+ ,142.7
+ ,99.2
+ ,122.48
+ ,110.4
+ ,151.6
+ ,129.6
+ ,123.6
+ ,130.5
+ ,136.83
+ ,99.2
+ ,110.4
+ ,151.6
+ ,129.6
+ ,136.2
+ ,153.04
+ ,130.5
+ ,99.2
+ ,110.4
+ ,151.6
+ ,129.7
+ ,142.71
+ ,136.2
+ ,130.5
+ ,99.2
+ ,110.4
+ ,128
+ ,123.46
+ ,129.7
+ ,136.2
+ ,130.5
+ ,99.2
+ ,121.6
+ ,144.37
+ ,128
+ ,129.7
+ ,136.2
+ ,130.5
+ ,135.8
+ ,146.15
+ ,121.6
+ ,128
+ ,129.7
+ ,136.2
+ ,143.8
+ ,147.61
+ ,135.8
+ ,121.6
+ ,128
+ ,129.7
+ ,147.5
+ ,158.51
+ ,143.8
+ ,135.8
+ ,121.6
+ ,128
+ ,136.2
+ ,147.4
+ ,147.5
+ ,143.8
+ ,135.8
+ ,121.6
+ ,156.6
+ ,165.05
+ ,136.2
+ ,147.5
+ ,143.8
+ ,135.8
+ ,123.3
+ ,154.64
+ ,156.6
+ ,136.2
+ ,147.5
+ ,143.8
+ ,104.5
+ ,126.2
+ ,123.3
+ ,156.6
+ ,136.2
+ ,147.5
+ ,139.8
+ ,157.36
+ ,104.5
+ ,123.3
+ ,156.6
+ ,136.2
+ ,136.5
+ ,154.15
+ ,139.8
+ ,104.5
+ ,123.3
+ ,156.6
+ ,112.1
+ ,123.21
+ ,136.5
+ ,139.8
+ ,104.5
+ ,123.3
+ ,118.5
+ ,113.07
+ ,112.1
+ ,136.5
+ ,139.8
+ ,104.5
+ ,94.4
+ ,110.45
+ ,118.5
+ ,112.1
+ ,136.5
+ ,139.8
+ ,102.3
+ ,113.57
+ ,94.4
+ ,118.5
+ ,112.1
+ ,136.5
+ ,111.4
+ ,122.44
+ ,102.3
+ ,94.4
+ ,118.5
+ ,112.1
+ ,99.2
+ ,114.93
+ ,111.4
+ ,102.3
+ ,94.4
+ ,118.5
+ ,87.8
+ ,111.85
+ ,99.2
+ ,111.4
+ ,102.3
+ ,94.4
+ ,115.8
+ ,126.04
+ ,87.8
+ ,99.2
+ ,111.4
+ ,102.3)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('I'
+ ,'U'
+ ,'m1'
+ ,'m2'
+ ,'m3'
+ ,'m4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('I','U','m1','m2','m3','m4'),1:56))
> 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
I U m1 m2 m3 m4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 104.0 120.28 112.9 113.6 83.4 79.8 1 0 0 0 0 0 0 0 0 0 0 1
2 109.9 115.33 104.0 112.9 113.6 83.4 0 1 0 0 0 0 0 0 0 0 0 2
3 99.0 110.40 109.9 104.0 112.9 113.6 0 0 1 0 0 0 0 0 0 0 0 3
4 106.3 114.49 99.0 109.9 104.0 112.9 0 0 0 1 0 0 0 0 0 0 0 4
5 128.9 132.03 106.3 99.0 109.9 104.0 0 0 0 0 1 0 0 0 0 0 0 5
6 111.1 123.16 128.9 106.3 99.0 109.9 0 0 0 0 0 1 0 0 0 0 0 6
7 102.9 118.82 111.1 128.9 106.3 99.0 0 0 0 0 0 0 1 0 0 0 0 7
8 130.0 128.32 102.9 111.1 128.9 106.3 0 0 0 0 0 0 0 1 0 0 0 8
9 87.0 112.24 130.0 102.9 111.1 128.9 0 0 0 0 0 0 0 0 1 0 0 9
10 87.5 104.53 87.0 130.0 102.9 111.1 0 0 0 0 0 0 0 0 0 1 0 10
11 117.6 132.57 87.5 87.0 130.0 102.9 0 0 0 0 0 0 0 0 0 0 1 11
12 103.4 122.52 117.6 87.5 87.0 130.0 0 0 0 0 0 0 0 0 0 0 0 12
13 110.8 131.80 103.4 117.6 87.5 87.0 1 0 0 0 0 0 0 0 0 0 0 13
14 112.6 124.55 110.8 103.4 117.6 87.5 0 1 0 0 0 0 0 0 0 0 0 14
15 102.5 120.96 112.6 110.8 103.4 117.6 0 0 1 0 0 0 0 0 0 0 0 15
16 112.4 122.60 102.5 112.6 110.8 103.4 0 0 0 1 0 0 0 0 0 0 0 16
17 135.6 145.52 112.4 102.5 112.6 110.8 0 0 0 0 1 0 0 0 0 0 0 17
18 105.1 118.57 135.6 112.4 102.5 112.6 0 0 0 0 0 1 0 0 0 0 0 18
19 127.7 134.25 105.1 135.6 112.4 102.5 0 0 0 0 0 0 1 0 0 0 0 19
20 137.0 136.70 127.7 105.1 135.6 112.4 0 0 0 0 0 0 0 1 0 0 0 20
21 91.0 121.37 137.0 127.7 105.1 135.6 0 0 0 0 0 0 0 0 1 0 0 21
22 90.5 111.63 91.0 137.0 127.7 105.1 0 0 0 0 0 0 0 0 0 1 0 22
23 122.4 134.42 90.5 91.0 137.0 127.7 0 0 0 0 0 0 0 0 0 0 1 23
24 123.3 137.65 122.4 90.5 91.0 137.0 0 0 0 0 0 0 0 0 0 0 0 24
25 124.3 137.86 123.3 122.4 90.5 91.0 1 0 0 0 0 0 0 0 0 0 0 25
26 120.0 119.77 124.3 123.3 122.4 90.5 0 1 0 0 0 0 0 0 0 0 0 26
27 118.1 130.69 120.0 124.3 123.3 122.4 0 0 1 0 0 0 0 0 0 0 0 27
28 119.0 128.28 118.1 120.0 124.3 123.3 0 0 0 1 0 0 0 0 0 0 0 28
29 142.7 147.45 119.0 118.1 120.0 124.3 0 0 0 0 1 0 0 0 0 0 0 29
30 123.6 128.42 142.7 119.0 118.1 120.0 0 0 0 0 0 1 0 0 0 0 0 30
31 129.6 136.90 123.6 142.7 119.0 118.1 0 0 0 0 0 0 1 0 0 0 0 31
32 151.6 143.95 129.6 123.6 142.7 119.0 0 0 0 0 0 0 0 1 0 0 0 32
33 110.4 135.64 151.6 129.6 123.6 142.7 0 0 0 0 0 0 0 0 1 0 0 33
34 99.2 122.48 110.4 151.6 129.6 123.6 0 0 0 0 0 0 0 0 0 1 0 34
35 130.5 136.83 99.2 110.4 151.6 129.6 0 0 0 0 0 0 0 0 0 0 1 35
36 136.2 153.04 130.5 99.2 110.4 151.6 0 0 0 0 0 0 0 0 0 0 0 36
37 129.7 142.71 136.2 130.5 99.2 110.4 1 0 0 0 0 0 0 0 0 0 0 37
38 128.0 123.46 129.7 136.2 130.5 99.2 0 1 0 0 0 0 0 0 0 0 0 38
39 121.6 144.37 128.0 129.7 136.2 130.5 0 0 1 0 0 0 0 0 0 0 0 39
40 135.8 146.15 121.6 128.0 129.7 136.2 0 0 0 1 0 0 0 0 0 0 0 40
41 143.8 147.61 135.8 121.6 128.0 129.7 0 0 0 0 1 0 0 0 0 0 0 41
42 147.5 158.51 143.8 135.8 121.6 128.0 0 0 0 0 0 1 0 0 0 0 0 42
43 136.2 147.40 147.5 143.8 135.8 121.6 0 0 0 0 0 0 1 0 0 0 0 43
44 156.6 165.05 136.2 147.5 143.8 135.8 0 0 0 0 0 0 0 1 0 0 0 44
45 123.3 154.64 156.6 136.2 147.5 143.8 0 0 0 0 0 0 0 0 1 0 0 45
46 104.5 126.20 123.3 156.6 136.2 147.5 0 0 0 0 0 0 0 0 0 1 0 46
47 139.8 157.36 104.5 123.3 156.6 136.2 0 0 0 0 0 0 0 0 0 0 1 47
48 136.5 154.15 139.8 104.5 123.3 156.6 0 0 0 0 0 0 0 0 0 0 0 48
49 112.1 123.21 136.5 139.8 104.5 123.3 1 0 0 0 0 0 0 0 0 0 0 49
50 118.5 113.07 112.1 136.5 139.8 104.5 0 1 0 0 0 0 0 0 0 0 0 50
51 94.4 110.45 118.5 112.1 136.5 139.8 0 0 1 0 0 0 0 0 0 0 0 51
52 102.3 113.57 94.4 118.5 112.1 136.5 0 0 0 1 0 0 0 0 0 0 0 52
53 111.4 122.44 102.3 94.4 118.5 112.1 0 0 0 0 1 0 0 0 0 0 0 53
54 99.2 114.93 111.4 102.3 94.4 118.5 0 0 0 0 0 1 0 0 0 0 0 54
55 87.8 111.85 99.2 111.4 102.3 94.4 0 0 0 0 0 0 1 0 0 0 0 55
56 115.8 126.04 87.8 99.2 111.4 102.3 0 0 0 0 0 0 0 1 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) U m1 m2 m3 m4
-25.14479 0.73022 0.06434 0.19482 0.17013 0.04640
M1 M2 M3 M4 M5 M6
-3.23375 2.95184 -10.55754 -2.01830 6.81572 -1.63565
M7 M8 M9 M10 M11 t
-6.03569 7.71868 -24.01075 -21.43493 -1.73157 -0.15208
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-8.0712 -2.1994 0.1549 2.6206 6.6788
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -25.14479 10.73327 -2.343 0.02448 *
U 0.73022 0.07898 9.245 2.89e-11 ***
m1 0.06434 0.09431 0.682 0.49924
m2 0.19482 0.09956 1.957 0.05774 .
m3 0.17013 0.09883 1.721 0.09330 .
m4 0.04640 0.10807 0.429 0.67006
M1 -3.23375 7.36294 -0.439 0.66301
M2 2.95184 8.49724 0.347 0.73022
M3 -10.55754 5.51992 -1.913 0.06336 .
M4 -2.01830 5.64156 -0.358 0.72251
M5 6.81572 4.86740 1.400 0.16954
M6 -1.63565 5.41332 -0.302 0.76418
M7 -6.03569 7.44668 -0.811 0.42269
M8 7.71868 6.13279 1.259 0.21586
M9 -24.01075 4.96614 -4.835 2.22e-05 ***
M10 -21.43493 8.43985 -2.540 0.01531 *
M11 -1.73157 6.84791 -0.253 0.80174
t -0.15208 0.05386 -2.823 0.00752 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.053 on 38 degrees of freedom
Multiple R-squared: 0.9614, Adjusted R-squared: 0.9441
F-statistic: 55.67 on 17 and 38 DF, p-value: < 2.2e-16
> 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.8564147 0.28717054 0.14358527
[2,] 0.9007050 0.19858992 0.09929496
[3,] 0.8600960 0.27980792 0.13990396
[4,] 0.8351438 0.32971233 0.16485617
[5,] 0.8587446 0.28251075 0.14125538
[6,] 0.9467823 0.10643548 0.05321774
[7,] 0.9566598 0.08668045 0.04334022
[8,] 0.9574614 0.08507714 0.04253857
[9,] 0.9360891 0.12782188 0.06391094
[10,] 0.9591826 0.08163473 0.04081736
[11,] 0.9282198 0.14356040 0.07178020
[12,] 0.8785055 0.24298891 0.12149445
[13,] 0.7917741 0.41645188 0.20822594
[14,] 0.7254681 0.54906371 0.27453185
[15,] 0.5544958 0.89100846 0.44550423
> postscript(file="/var/www/html/rcomp/tmp/1l49b1258714381.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/2d21t1258714381.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/3y4ss1258714381.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/4h5231258714381.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/5lh9v1258714381.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 = 56
Frequency = 1
1 2 3 4 5 6
-2.58802311 -3.70302856 2.73043306 -0.24478399 1.92826993 -2.08682941
7 8 9 10 11 12
-6.55941630 -0.18717263 2.26985894 5.68419035 -0.12748097 -4.54408782
13 14 15 16 17 18
-3.57490230 -5.36821515 0.27642311 0.29079604 -1.24669654 -5.25040418
19 20 21 22 23 24
6.67875996 0.66885892 -3.14412082 -0.23742240 1.83253446 4.23398267
25 26 27 28 29 30
4.41339119 1.64582223 3.88174512 -1.09750657 0.91966027 3.14178082
31 32 33 34 35 36
4.04833918 6.55908561 2.87412475 -2.90964815 3.08626460 1.52667450
37 38 39 40 41 42
3.30836014 4.13385506 -4.92005682 1.17733693 0.35334268 2.58395937
43 44 45 46 47 48
0.03328296 -8.07117653 -1.99986287 -2.53711980 -4.79131808 -1.21656935
49 50 51 52 53 54
-1.55882591 3.29156641 -1.96854446 -0.12584241 -1.95457633 1.61149340
55 56
-4.20096580 1.03040463
> postscript(file="/var/www/html/rcomp/tmp/6j7dc1258714381.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 -2.58802311 NA
1 -3.70302856 -2.58802311
2 2.73043306 -3.70302856
3 -0.24478399 2.73043306
4 1.92826993 -0.24478399
5 -2.08682941 1.92826993
6 -6.55941630 -2.08682941
7 -0.18717263 -6.55941630
8 2.26985894 -0.18717263
9 5.68419035 2.26985894
10 -0.12748097 5.68419035
11 -4.54408782 -0.12748097
12 -3.57490230 -4.54408782
13 -5.36821515 -3.57490230
14 0.27642311 -5.36821515
15 0.29079604 0.27642311
16 -1.24669654 0.29079604
17 -5.25040418 -1.24669654
18 6.67875996 -5.25040418
19 0.66885892 6.67875996
20 -3.14412082 0.66885892
21 -0.23742240 -3.14412082
22 1.83253446 -0.23742240
23 4.23398267 1.83253446
24 4.41339119 4.23398267
25 1.64582223 4.41339119
26 3.88174512 1.64582223
27 -1.09750657 3.88174512
28 0.91966027 -1.09750657
29 3.14178082 0.91966027
30 4.04833918 3.14178082
31 6.55908561 4.04833918
32 2.87412475 6.55908561
33 -2.90964815 2.87412475
34 3.08626460 -2.90964815
35 1.52667450 3.08626460
36 3.30836014 1.52667450
37 4.13385506 3.30836014
38 -4.92005682 4.13385506
39 1.17733693 -4.92005682
40 0.35334268 1.17733693
41 2.58395937 0.35334268
42 0.03328296 2.58395937
43 -8.07117653 0.03328296
44 -1.99986287 -8.07117653
45 -2.53711980 -1.99986287
46 -4.79131808 -2.53711980
47 -1.21656935 -4.79131808
48 -1.55882591 -1.21656935
49 3.29156641 -1.55882591
50 -1.96854446 3.29156641
51 -0.12584241 -1.96854446
52 -1.95457633 -0.12584241
53 1.61149340 -1.95457633
54 -4.20096580 1.61149340
55 1.03040463 -4.20096580
56 NA 1.03040463
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3.70302856 -2.58802311
[2,] 2.73043306 -3.70302856
[3,] -0.24478399 2.73043306
[4,] 1.92826993 -0.24478399
[5,] -2.08682941 1.92826993
[6,] -6.55941630 -2.08682941
[7,] -0.18717263 -6.55941630
[8,] 2.26985894 -0.18717263
[9,] 5.68419035 2.26985894
[10,] -0.12748097 5.68419035
[11,] -4.54408782 -0.12748097
[12,] -3.57490230 -4.54408782
[13,] -5.36821515 -3.57490230
[14,] 0.27642311 -5.36821515
[15,] 0.29079604 0.27642311
[16,] -1.24669654 0.29079604
[17,] -5.25040418 -1.24669654
[18,] 6.67875996 -5.25040418
[19,] 0.66885892 6.67875996
[20,] -3.14412082 0.66885892
[21,] -0.23742240 -3.14412082
[22,] 1.83253446 -0.23742240
[23,] 4.23398267 1.83253446
[24,] 4.41339119 4.23398267
[25,] 1.64582223 4.41339119
[26,] 3.88174512 1.64582223
[27,] -1.09750657 3.88174512
[28,] 0.91966027 -1.09750657
[29,] 3.14178082 0.91966027
[30,] 4.04833918 3.14178082
[31,] 6.55908561 4.04833918
[32,] 2.87412475 6.55908561
[33,] -2.90964815 2.87412475
[34,] 3.08626460 -2.90964815
[35,] 1.52667450 3.08626460
[36,] 3.30836014 1.52667450
[37,] 4.13385506 3.30836014
[38,] -4.92005682 4.13385506
[39,] 1.17733693 -4.92005682
[40,] 0.35334268 1.17733693
[41,] 2.58395937 0.35334268
[42,] 0.03328296 2.58395937
[43,] -8.07117653 0.03328296
[44,] -1.99986287 -8.07117653
[45,] -2.53711980 -1.99986287
[46,] -4.79131808 -2.53711980
[47,] -1.21656935 -4.79131808
[48,] -1.55882591 -1.21656935
[49,] 3.29156641 -1.55882591
[50,] -1.96854446 3.29156641
[51,] -0.12584241 -1.96854446
[52,] -1.95457633 -0.12584241
[53,] 1.61149340 -1.95457633
[54,] -4.20096580 1.61149340
[55,] 1.03040463 -4.20096580
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3.70302856 -2.58802311
2 2.73043306 -3.70302856
3 -0.24478399 2.73043306
4 1.92826993 -0.24478399
5 -2.08682941 1.92826993
6 -6.55941630 -2.08682941
7 -0.18717263 -6.55941630
8 2.26985894 -0.18717263
9 5.68419035 2.26985894
10 -0.12748097 5.68419035
11 -4.54408782 -0.12748097
12 -3.57490230 -4.54408782
13 -5.36821515 -3.57490230
14 0.27642311 -5.36821515
15 0.29079604 0.27642311
16 -1.24669654 0.29079604
17 -5.25040418 -1.24669654
18 6.67875996 -5.25040418
19 0.66885892 6.67875996
20 -3.14412082 0.66885892
21 -0.23742240 -3.14412082
22 1.83253446 -0.23742240
23 4.23398267 1.83253446
24 4.41339119 4.23398267
25 1.64582223 4.41339119
26 3.88174512 1.64582223
27 -1.09750657 3.88174512
28 0.91966027 -1.09750657
29 3.14178082 0.91966027
30 4.04833918 3.14178082
31 6.55908561 4.04833918
32 2.87412475 6.55908561
33 -2.90964815 2.87412475
34 3.08626460 -2.90964815
35 1.52667450 3.08626460
36 3.30836014 1.52667450
37 4.13385506 3.30836014
38 -4.92005682 4.13385506
39 1.17733693 -4.92005682
40 0.35334268 1.17733693
41 2.58395937 0.35334268
42 0.03328296 2.58395937
43 -8.07117653 0.03328296
44 -1.99986287 -8.07117653
45 -2.53711980 -1.99986287
46 -4.79131808 -2.53711980
47 -1.21656935 -4.79131808
48 -1.55882591 -1.21656935
49 3.29156641 -1.55882591
50 -1.96854446 3.29156641
51 -0.12584241 -1.96854446
52 -1.95457633 -0.12584241
53 1.61149340 -1.95457633
54 -4.20096580 1.61149340
55 1.03040463 -4.20096580
> 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/7bmrs1258714381.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/8ktvs1258714381.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/9kaan1258714381.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/103qny1258714381.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/11izdt1258714381.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/12dj9q1258714381.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/13aox81258714381.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/148ms31258714381.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/15k2a21258714381.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/16cdqy1258714381.tab")
+ }
>
> system("convert tmp/1l49b1258714381.ps tmp/1l49b1258714381.png")
> system("convert tmp/2d21t1258714381.ps tmp/2d21t1258714381.png")
> system("convert tmp/3y4ss1258714381.ps tmp/3y4ss1258714381.png")
> system("convert tmp/4h5231258714381.ps tmp/4h5231258714381.png")
> system("convert tmp/5lh9v1258714381.ps tmp/5lh9v1258714381.png")
> system("convert tmp/6j7dc1258714381.ps tmp/6j7dc1258714381.png")
> system("convert tmp/7bmrs1258714381.ps tmp/7bmrs1258714381.png")
> system("convert tmp/8ktvs1258714381.ps tmp/8ktvs1258714381.png")
> system("convert tmp/9kaan1258714381.ps tmp/9kaan1258714381.png")
> system("convert tmp/103qny1258714381.ps tmp/103qny1258714381.png")
>
>
> proc.time()
user system elapsed
2.303 1.532 2.712