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(127
+ ,0
+ ,130
+ ,135
+ ,139
+ ,149
+ ,122
+ ,0
+ ,127
+ ,130
+ ,135
+ ,139
+ ,117
+ ,0
+ ,122
+ ,127
+ ,130
+ ,135
+ ,112
+ ,0
+ ,117
+ ,122
+ ,127
+ ,130
+ ,113
+ ,0
+ ,112
+ ,117
+ ,122
+ ,127
+ ,149
+ ,0
+ ,113
+ ,112
+ ,117
+ ,122
+ ,157
+ ,0
+ ,149
+ ,113
+ ,112
+ ,117
+ ,157
+ ,0
+ ,157
+ ,149
+ ,113
+ ,112
+ ,147
+ ,0
+ ,157
+ ,157
+ ,149
+ ,113
+ ,137
+ ,0
+ ,147
+ ,157
+ ,157
+ ,149
+ ,132
+ ,0
+ ,137
+ ,147
+ ,157
+ ,157
+ ,125
+ ,0
+ ,132
+ ,137
+ ,147
+ ,157
+ ,123
+ ,0
+ ,125
+ ,132
+ ,137
+ ,147
+ ,117
+ ,0
+ ,123
+ ,125
+ ,132
+ ,137
+ ,114
+ ,0
+ ,117
+ ,123
+ ,125
+ ,132
+ ,111
+ ,0
+ ,114
+ ,117
+ ,123
+ ,125
+ ,112
+ ,0
+ ,111
+ ,114
+ ,117
+ ,123
+ ,144
+ ,0
+ ,112
+ ,111
+ ,114
+ ,117
+ ,150
+ ,0
+ ,144
+ ,112
+ ,111
+ ,114
+ ,149
+ ,0
+ ,150
+ ,144
+ ,112
+ ,111
+ ,134
+ ,0
+ ,149
+ ,150
+ ,144
+ ,112
+ ,123
+ ,0
+ ,134
+ ,149
+ ,150
+ ,144
+ ,116
+ ,0
+ ,123
+ ,134
+ ,149
+ ,150
+ ,117
+ ,0
+ ,116
+ ,123
+ ,134
+ ,149
+ ,111
+ ,0
+ ,117
+ ,116
+ ,123
+ ,134
+ ,105
+ ,0
+ ,111
+ ,117
+ ,116
+ ,123
+ ,102
+ ,0
+ ,105
+ ,111
+ ,117
+ ,116
+ ,95
+ ,0
+ ,102
+ ,105
+ ,111
+ ,117
+ ,93
+ ,0
+ ,95
+ ,102
+ ,105
+ ,111
+ ,124
+ ,0
+ ,93
+ ,95
+ ,102
+ ,105
+ ,130
+ ,0
+ ,124
+ ,93
+ ,95
+ ,102
+ ,124
+ ,0
+ ,130
+ ,124
+ ,93
+ ,95
+ ,115
+ ,0
+ ,124
+ ,130
+ ,124
+ ,93
+ ,106
+ ,0
+ ,115
+ ,124
+ ,130
+ ,124
+ ,105
+ ,0
+ ,106
+ ,115
+ ,124
+ ,130
+ ,105
+ ,0
+ ,105
+ ,106
+ ,115
+ ,124
+ ,101
+ ,0
+ ,105
+ ,105
+ ,106
+ ,115
+ ,95
+ ,0
+ ,101
+ ,105
+ ,105
+ ,106
+ ,93
+ ,0
+ ,95
+ ,101
+ ,105
+ ,105
+ ,84
+ ,0
+ ,93
+ ,95
+ ,101
+ ,105
+ ,87
+ ,0
+ ,84
+ ,93
+ ,95
+ ,101
+ ,116
+ ,0
+ ,87
+ ,84
+ ,93
+ ,95
+ ,120
+ ,0
+ ,116
+ ,87
+ ,84
+ ,93
+ ,117
+ ,1
+ ,120
+ ,116
+ ,87
+ ,84
+ ,109
+ ,1
+ ,117
+ ,120
+ ,116
+ ,87
+ ,105
+ ,1
+ ,109
+ ,117
+ ,120
+ ,116
+ ,107
+ ,1
+ ,105
+ ,109
+ ,117
+ ,120
+ ,109
+ ,1
+ ,107
+ ,105
+ ,109
+ ,117
+ ,109
+ ,1
+ ,109
+ ,107
+ ,105
+ ,109
+ ,108
+ ,1
+ ,109
+ ,109
+ ,107
+ ,105
+ ,107
+ ,1
+ ,108
+ ,109
+ ,109
+ ,107
+ ,99
+ ,1
+ ,107
+ ,108
+ ,109
+ ,109
+ ,103
+ ,1
+ ,99
+ ,107
+ ,108
+ ,109
+ ,131
+ ,1
+ ,103
+ ,99
+ ,107
+ ,108
+ ,137
+ ,1
+ ,131
+ ,103
+ ,99
+ ,107
+ ,135
+ ,1
+ ,137
+ ,131
+ ,103
+ ,99)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('WLH'
+ ,'X'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('WLH','X','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)'),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
WLH X Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 127 0 130 135 139 149 1 0 0 0 0 0 0 0 0 0 0 1
2 122 0 127 130 135 139 0 1 0 0 0 0 0 0 0 0 0 2
3 117 0 122 127 130 135 0 0 1 0 0 0 0 0 0 0 0 3
4 112 0 117 122 127 130 0 0 0 1 0 0 0 0 0 0 0 4
5 113 0 112 117 122 127 0 0 0 0 1 0 0 0 0 0 0 5
6 149 0 113 112 117 122 0 0 0 0 0 1 0 0 0 0 0 6
7 157 0 149 113 112 117 0 0 0 0 0 0 1 0 0 0 0 7
8 157 0 157 149 113 112 0 0 0 0 0 0 0 1 0 0 0 8
9 147 0 157 157 149 113 0 0 0 0 0 0 0 0 1 0 0 9
10 137 0 147 157 157 149 0 0 0 0 0 0 0 0 0 1 0 10
11 132 0 137 147 157 157 0 0 0 0 0 0 0 0 0 0 1 11
12 125 0 132 137 147 157 0 0 0 0 0 0 0 0 0 0 0 12
13 123 0 125 132 137 147 1 0 0 0 0 0 0 0 0 0 0 13
14 117 0 123 125 132 137 0 1 0 0 0 0 0 0 0 0 0 14
15 114 0 117 123 125 132 0 0 1 0 0 0 0 0 0 0 0 15
16 111 0 114 117 123 125 0 0 0 1 0 0 0 0 0 0 0 16
17 112 0 111 114 117 123 0 0 0 0 1 0 0 0 0 0 0 17
18 144 0 112 111 114 117 0 0 0 0 0 1 0 0 0 0 0 18
19 150 0 144 112 111 114 0 0 0 0 0 0 1 0 0 0 0 19
20 149 0 150 144 112 111 0 0 0 0 0 0 0 1 0 0 0 20
21 134 0 149 150 144 112 0 0 0 0 0 0 0 0 1 0 0 21
22 123 0 134 149 150 144 0 0 0 0 0 0 0 0 0 1 0 22
23 116 0 123 134 149 150 0 0 0 0 0 0 0 0 0 0 1 23
24 117 0 116 123 134 149 0 0 0 0 0 0 0 0 0 0 0 24
25 111 0 117 116 123 134 1 0 0 0 0 0 0 0 0 0 0 25
26 105 0 111 117 116 123 0 1 0 0 0 0 0 0 0 0 0 26
27 102 0 105 111 117 116 0 0 1 0 0 0 0 0 0 0 0 27
28 95 0 102 105 111 117 0 0 0 1 0 0 0 0 0 0 0 28
29 93 0 95 102 105 111 0 0 0 0 1 0 0 0 0 0 0 29
30 124 0 93 95 102 105 0 0 0 0 0 1 0 0 0 0 0 30
31 130 0 124 93 95 102 0 0 0 0 0 0 1 0 0 0 0 31
32 124 0 130 124 93 95 0 0 0 0 0 0 0 1 0 0 0 32
33 115 0 124 130 124 93 0 0 0 0 0 0 0 0 1 0 0 33
34 106 0 115 124 130 124 0 0 0 0 0 0 0 0 0 1 0 34
35 105 0 106 115 124 130 0 0 0 0 0 0 0 0 0 0 1 35
36 105 0 105 106 115 124 0 0 0 0 0 0 0 0 0 0 0 36
37 101 0 105 105 106 115 1 0 0 0 0 0 0 0 0 0 0 37
38 95 0 101 105 105 106 0 1 0 0 0 0 0 0 0 0 0 38
39 93 0 95 101 105 105 0 0 1 0 0 0 0 0 0 0 0 39
40 84 0 93 95 101 105 0 0 0 1 0 0 0 0 0 0 0 40
41 87 0 84 93 95 101 0 0 0 0 1 0 0 0 0 0 0 41
42 116 0 87 84 93 95 0 0 0 0 0 1 0 0 0 0 0 42
43 120 0 116 87 84 93 0 0 0 0 0 0 1 0 0 0 0 43
44 117 1 120 116 87 84 0 0 0 0 0 0 0 1 0 0 0 44
45 109 1 117 120 116 87 0 0 0 0 0 0 0 0 1 0 0 45
46 105 1 109 117 120 116 0 0 0 0 0 0 0 0 0 1 0 46
47 107 1 105 109 117 120 0 0 0 0 0 0 0 0 0 0 1 47
48 109 1 107 105 109 117 0 0 0 0 0 0 0 0 0 0 0 48
49 109 1 109 107 105 109 1 0 0 0 0 0 0 0 0 0 0 49
50 108 1 109 109 107 105 0 1 0 0 0 0 0 0 0 0 0 50
51 107 1 108 109 109 107 0 0 1 0 0 0 0 0 0 0 0 51
52 99 1 107 108 109 109 0 0 0 1 0 0 0 0 0 0 0 52
53 103 1 99 107 108 109 0 0 0 0 1 0 0 0 0 0 0 53
54 131 1 103 99 107 108 0 0 0 0 0 1 0 0 0 0 0 54
55 137 1 131 103 99 107 0 0 0 0 0 0 1 0 0 0 0 55
56 135 1 137 131 103 99 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) X `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)`
28.0538 4.5783 0.8939 0.2693 -0.2393 -0.1025
M1 M2 M3 M4 M5 M6
-4.4139 -7.4846 -5.7417 -9.0661 -2.4646 28.2279
M7 M8 M9 M10 M11 t
4.3256 -12.8925 -15.4920 -9.0354 -1.1608 -0.1826
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4.48110 -1.18869 0.08955 1.34707 3.85136
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 28.05377 8.90246 3.151 0.003166 **
X 4.57833 1.27781 3.583 0.000952 ***
`Y(t-1)` 0.89389 0.14971 5.971 6.25e-07 ***
`Y(t-2)` 0.26926 0.20259 1.329 0.191751
`Y(t-3)` -0.23929 0.20619 -1.160 0.253087
`Y(t-4)` -0.10248 0.15661 -0.654 0.516827
M1 -4.41388 1.71008 -2.581 0.013833 *
M2 -7.48460 2.19985 -3.402 0.001586 **
M3 -5.74169 2.41300 -2.379 0.022461 *
M4 -9.06608 2.20336 -4.115 0.000201 ***
M5 -2.46465 2.42443 -1.017 0.315779
M6 28.22785 2.26302 12.474 5.24e-15 ***
M7 4.32563 4.87525 0.887 0.380519
M8 -12.89252 5.42259 -2.378 0.022564 *
M9 -15.49197 6.68382 -2.318 0.025940 *
M10 -9.03535 3.37371 -2.678 0.010875 *
M11 -1.16080 2.25890 -0.514 0.610312
t -0.18259 0.05389 -3.388 0.001649 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.236 on 38 degrees of freedom
Multiple R-squared: 0.9887, Adjusted R-squared: 0.9836
F-statistic: 194.8 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.8589786 0.28204287 0.14102143
[2,] 0.7489106 0.50217880 0.25108940
[3,] 0.7950265 0.40994701 0.20497351
[4,] 0.9054660 0.18906807 0.09453403
[5,] 0.9032443 0.19351133 0.09675567
[6,] 0.8724000 0.25520004 0.12760002
[7,] 0.8340753 0.33184938 0.16592469
[8,] 0.8557840 0.28843199 0.14421600
[9,] 0.9103074 0.17938512 0.08969256
[10,] 0.9465570 0.10688590 0.05344295
[11,] 0.9545350 0.09093008 0.04546504
[12,] 0.9416131 0.11677376 0.05838688
[13,] 0.9480207 0.10395853 0.05197926
[14,] 0.8964840 0.20703194 0.10351597
[15,] 0.8547373 0.29052530 0.14526265
> postscript(file="/var/www/html/rcomp/tmp/1sckq1258620451.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/25suc1258620451.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/33qpy1258620451.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/4cw8o1258620451.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/5p6aa1258620451.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 7
-0.4835089 -0.1841411 -3.0735534 0.0189359 -1.0880042 3.1456682 1.0722303
8 9 10 11 12 13 14
1.3554246 0.7001472 -1.0314637 -1.2720833 -4.4810981 2.3012833 1.0059885
15 16 17 18 19 20 21
0.1601631 3.7684532 0.1984013 0.2696504 0.4553137 2.8082839 -2.3717250
22 23 24 25 26 27 28
-1.2530906 -1.6977659 3.8513602 -0.7305656 -1.1854001 0.7551356 0.2261055
29 30 31 32 33 34 35
-3.1782822 -0.3483188 0.5818713 -2.9236673 1.8190740 0.8181597 1.7737201
36 37 38 39 40 41 42
1.3442915 -0.8658532 -1.1985490 1.5790509 -1.4677798 1.8513171 -1.0103862
43 44 45 46 47 48 49
-2.0147932 -3.7808904 -0.1474962 1.4663947 1.1961291 -0.7145536 -0.2213557
50 51 52 53 54 55 56
1.5621017 0.5792038 -2.5457149 2.2165679 -2.0566136 -0.0946220 2.5408492
> postscript(file="/var/www/html/rcomp/tmp/6mke51258620451.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 -0.4835089 NA
1 -0.1841411 -0.4835089
2 -3.0735534 -0.1841411
3 0.0189359 -3.0735534
4 -1.0880042 0.0189359
5 3.1456682 -1.0880042
6 1.0722303 3.1456682
7 1.3554246 1.0722303
8 0.7001472 1.3554246
9 -1.0314637 0.7001472
10 -1.2720833 -1.0314637
11 -4.4810981 -1.2720833
12 2.3012833 -4.4810981
13 1.0059885 2.3012833
14 0.1601631 1.0059885
15 3.7684532 0.1601631
16 0.1984013 3.7684532
17 0.2696504 0.1984013
18 0.4553137 0.2696504
19 2.8082839 0.4553137
20 -2.3717250 2.8082839
21 -1.2530906 -2.3717250
22 -1.6977659 -1.2530906
23 3.8513602 -1.6977659
24 -0.7305656 3.8513602
25 -1.1854001 -0.7305656
26 0.7551356 -1.1854001
27 0.2261055 0.7551356
28 -3.1782822 0.2261055
29 -0.3483188 -3.1782822
30 0.5818713 -0.3483188
31 -2.9236673 0.5818713
32 1.8190740 -2.9236673
33 0.8181597 1.8190740
34 1.7737201 0.8181597
35 1.3442915 1.7737201
36 -0.8658532 1.3442915
37 -1.1985490 -0.8658532
38 1.5790509 -1.1985490
39 -1.4677798 1.5790509
40 1.8513171 -1.4677798
41 -1.0103862 1.8513171
42 -2.0147932 -1.0103862
43 -3.7808904 -2.0147932
44 -0.1474962 -3.7808904
45 1.4663947 -0.1474962
46 1.1961291 1.4663947
47 -0.7145536 1.1961291
48 -0.2213557 -0.7145536
49 1.5621017 -0.2213557
50 0.5792038 1.5621017
51 -2.5457149 0.5792038
52 2.2165679 -2.5457149
53 -2.0566136 2.2165679
54 -0.0946220 -2.0566136
55 2.5408492 -0.0946220
56 NA 2.5408492
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.1841411 -0.4835089
[2,] -3.0735534 -0.1841411
[3,] 0.0189359 -3.0735534
[4,] -1.0880042 0.0189359
[5,] 3.1456682 -1.0880042
[6,] 1.0722303 3.1456682
[7,] 1.3554246 1.0722303
[8,] 0.7001472 1.3554246
[9,] -1.0314637 0.7001472
[10,] -1.2720833 -1.0314637
[11,] -4.4810981 -1.2720833
[12,] 2.3012833 -4.4810981
[13,] 1.0059885 2.3012833
[14,] 0.1601631 1.0059885
[15,] 3.7684532 0.1601631
[16,] 0.1984013 3.7684532
[17,] 0.2696504 0.1984013
[18,] 0.4553137 0.2696504
[19,] 2.8082839 0.4553137
[20,] -2.3717250 2.8082839
[21,] -1.2530906 -2.3717250
[22,] -1.6977659 -1.2530906
[23,] 3.8513602 -1.6977659
[24,] -0.7305656 3.8513602
[25,] -1.1854001 -0.7305656
[26,] 0.7551356 -1.1854001
[27,] 0.2261055 0.7551356
[28,] -3.1782822 0.2261055
[29,] -0.3483188 -3.1782822
[30,] 0.5818713 -0.3483188
[31,] -2.9236673 0.5818713
[32,] 1.8190740 -2.9236673
[33,] 0.8181597 1.8190740
[34,] 1.7737201 0.8181597
[35,] 1.3442915 1.7737201
[36,] -0.8658532 1.3442915
[37,] -1.1985490 -0.8658532
[38,] 1.5790509 -1.1985490
[39,] -1.4677798 1.5790509
[40,] 1.8513171 -1.4677798
[41,] -1.0103862 1.8513171
[42,] -2.0147932 -1.0103862
[43,] -3.7808904 -2.0147932
[44,] -0.1474962 -3.7808904
[45,] 1.4663947 -0.1474962
[46,] 1.1961291 1.4663947
[47,] -0.7145536 1.1961291
[48,] -0.2213557 -0.7145536
[49,] 1.5621017 -0.2213557
[50,] 0.5792038 1.5621017
[51,] -2.5457149 0.5792038
[52,] 2.2165679 -2.5457149
[53,] -2.0566136 2.2165679
[54,] -0.0946220 -2.0566136
[55,] 2.5408492 -0.0946220
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.1841411 -0.4835089
2 -3.0735534 -0.1841411
3 0.0189359 -3.0735534
4 -1.0880042 0.0189359
5 3.1456682 -1.0880042
6 1.0722303 3.1456682
7 1.3554246 1.0722303
8 0.7001472 1.3554246
9 -1.0314637 0.7001472
10 -1.2720833 -1.0314637
11 -4.4810981 -1.2720833
12 2.3012833 -4.4810981
13 1.0059885 2.3012833
14 0.1601631 1.0059885
15 3.7684532 0.1601631
16 0.1984013 3.7684532
17 0.2696504 0.1984013
18 0.4553137 0.2696504
19 2.8082839 0.4553137
20 -2.3717250 2.8082839
21 -1.2530906 -2.3717250
22 -1.6977659 -1.2530906
23 3.8513602 -1.6977659
24 -0.7305656 3.8513602
25 -1.1854001 -0.7305656
26 0.7551356 -1.1854001
27 0.2261055 0.7551356
28 -3.1782822 0.2261055
29 -0.3483188 -3.1782822
30 0.5818713 -0.3483188
31 -2.9236673 0.5818713
32 1.8190740 -2.9236673
33 0.8181597 1.8190740
34 1.7737201 0.8181597
35 1.3442915 1.7737201
36 -0.8658532 1.3442915
37 -1.1985490 -0.8658532
38 1.5790509 -1.1985490
39 -1.4677798 1.5790509
40 1.8513171 -1.4677798
41 -1.0103862 1.8513171
42 -2.0147932 -1.0103862
43 -3.7808904 -2.0147932
44 -0.1474962 -3.7808904
45 1.4663947 -0.1474962
46 1.1961291 1.4663947
47 -0.7145536 1.1961291
48 -0.2213557 -0.7145536
49 1.5621017 -0.2213557
50 0.5792038 1.5621017
51 -2.5457149 0.5792038
52 2.2165679 -2.5457149
53 -2.0566136 2.2165679
54 -0.0946220 -2.0566136
55 2.5408492 -0.0946220
> 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/7fom51258620451.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/8hadz1258620451.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/9bxb01258620451.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/10odwi1258620451.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/11i5ub1258620451.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/12pu0z1258620451.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/13ik6w1258620451.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/14ztfb1258620451.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/15kklz1258620451.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/16o8sc1258620451.tab")
+ }
>
> system("convert tmp/1sckq1258620451.ps tmp/1sckq1258620451.png")
> system("convert tmp/25suc1258620451.ps tmp/25suc1258620451.png")
> system("convert tmp/33qpy1258620451.ps tmp/33qpy1258620451.png")
> system("convert tmp/4cw8o1258620451.ps tmp/4cw8o1258620451.png")
> system("convert tmp/5p6aa1258620451.ps tmp/5p6aa1258620451.png")
> system("convert tmp/6mke51258620451.ps tmp/6mke51258620451.png")
> system("convert tmp/7fom51258620451.ps tmp/7fom51258620451.png")
> system("convert tmp/8hadz1258620451.ps tmp/8hadz1258620451.png")
> system("convert tmp/9bxb01258620451.ps tmp/9bxb01258620451.png")
> system("convert tmp/10odwi1258620451.ps tmp/10odwi1258620451.png")
>
>
> proc.time()
user system elapsed
2.291 1.510 3.337