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(109.9
+ ,104
+ ,112.9
+ ,113.6
+ ,83.4
+ ,99
+ ,109.9
+ ,104
+ ,112.9
+ ,113.6
+ ,106.3
+ ,99
+ ,109.9
+ ,104
+ ,112.9
+ ,128.9
+ ,106.3
+ ,99
+ ,109.9
+ ,104
+ ,111.1
+ ,128.9
+ ,106.3
+ ,99
+ ,109.9
+ ,102.9
+ ,111.1
+ ,128.9
+ ,106.3
+ ,99
+ ,130
+ ,102.9
+ ,111.1
+ ,128.9
+ ,106.3
+ ,87
+ ,130
+ ,102.9
+ ,111.1
+ ,128.9
+ ,87.5
+ ,87
+ ,130
+ ,102.9
+ ,111.1
+ ,117.6
+ ,87.5
+ ,87
+ ,130
+ ,102.9
+ ,103.4
+ ,117.6
+ ,87.5
+ ,87
+ ,130
+ ,110.8
+ ,103.4
+ ,117.6
+ ,87.5
+ ,87
+ ,112.6
+ ,110.8
+ ,103.4
+ ,117.6
+ ,87.5
+ ,102.5
+ ,112.6
+ ,110.8
+ ,103.4
+ ,117.6
+ ,112.4
+ ,102.5
+ ,112.6
+ ,110.8
+ ,103.4
+ ,135.6
+ ,112.4
+ ,102.5
+ ,112.6
+ ,110.8
+ ,105.1
+ ,135.6
+ ,112.4
+ ,102.5
+ ,112.6
+ ,127.7
+ ,105.1
+ ,135.6
+ ,112.4
+ ,102.5
+ ,137
+ ,127.7
+ ,105.1
+ ,135.6
+ ,112.4
+ ,91
+ ,137
+ ,127.7
+ ,105.1
+ ,135.6
+ ,90.5
+ ,91
+ ,137
+ ,127.7
+ ,105.1
+ ,122.4
+ ,90.5
+ ,91
+ ,137
+ ,127.7
+ ,123.3
+ ,122.4
+ ,90.5
+ ,91
+ ,137
+ ,124.3
+ ,123.3
+ ,122.4
+ ,90.5
+ ,91
+ ,120
+ ,124.3
+ ,123.3
+ ,122.4
+ ,90.5
+ ,118.1
+ ,120
+ ,124.3
+ ,123.3
+ ,122.4
+ ,119
+ ,118.1
+ ,120
+ ,124.3
+ ,123.3
+ ,142.7
+ ,119
+ ,118.1
+ ,120
+ ,124.3
+ ,123.6
+ ,142.7
+ ,119
+ ,118.1
+ ,120
+ ,129.6
+ ,123.6
+ ,142.7
+ ,119
+ ,118.1
+ ,151.6
+ ,129.6
+ ,123.6
+ ,142.7
+ ,119
+ ,110.4
+ ,151.6
+ ,129.6
+ ,123.6
+ ,142.7
+ ,99.2
+ ,110.4
+ ,151.6
+ ,129.6
+ ,123.6
+ ,130.5
+ ,99.2
+ ,110.4
+ ,151.6
+ ,129.6
+ ,136.2
+ ,130.5
+ ,99.2
+ ,110.4
+ ,151.6
+ ,129.7
+ ,136.2
+ ,130.5
+ ,99.2
+ ,110.4
+ ,128
+ ,129.7
+ ,136.2
+ ,130.5
+ ,99.2
+ ,121.6
+ ,128
+ ,129.7
+ ,136.2
+ ,130.5
+ ,135.8
+ ,121.6
+ ,128
+ ,129.7
+ ,136.2
+ ,143.8
+ ,135.8
+ ,121.6
+ ,128
+ ,129.7
+ ,147.5
+ ,143.8
+ ,135.8
+ ,121.6
+ ,128
+ ,136.2
+ ,147.5
+ ,143.8
+ ,135.8
+ ,121.6
+ ,156.6
+ ,136.2
+ ,147.5
+ ,143.8
+ ,135.8
+ ,123.3
+ ,156.6
+ ,136.2
+ ,147.5
+ ,143.8
+ ,104.5
+ ,123.3
+ ,156.6
+ ,136.2
+ ,147.5
+ ,139.8
+ ,104.5
+ ,123.3
+ ,156.6
+ ,136.2
+ ,136.5
+ ,139.8
+ ,104.5
+ ,123.3
+ ,156.6
+ ,112.1
+ ,136.5
+ ,139.8
+ ,104.5
+ ,123.3
+ ,118.5
+ ,112.1
+ ,136.5
+ ,139.8
+ ,104.5
+ ,94.4
+ ,118.5
+ ,112.1
+ ,136.5
+ ,139.8
+ ,102.3
+ ,94.4
+ ,118.5
+ ,112.1
+ ,136.5
+ ,111.4
+ ,102.3
+ ,94.4
+ ,118.5
+ ,112.1
+ ,99.2
+ ,111.4
+ ,102.3
+ ,94.4
+ ,118.5
+ ,87.8
+ ,99.2
+ ,111.4
+ ,102.3
+ ,94.4
+ ,115.8
+ ,87.8
+ ,99.2
+ ,111.4
+ ,102.3
+ ,79.7
+ ,115.8
+ ,87.8
+ ,99.2
+ ,111.4)
+ ,dim=c(5
+ ,56)
+ ,dimnames=list(c('Yt'
+ ,'Yt-1'
+ ,'Yt-2'
+ ,'Yt-3'
+ ,'Yt-4')
+ ,1:56))
> y <- array(NA,dim=c(5,56),dimnames=list(c('Yt','Yt-1','Yt-2','Yt-3','Yt-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
Yt Yt-1 Yt-2 Yt-3 Yt-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 109.9 104.0 112.9 113.6 83.4 1 0 0 0 0 0 0 0 0 0 0 1
2 99.0 109.9 104.0 112.9 113.6 0 1 0 0 0 0 0 0 0 0 0 2
3 106.3 99.0 109.9 104.0 112.9 0 0 1 0 0 0 0 0 0 0 0 3
4 128.9 106.3 99.0 109.9 104.0 0 0 0 1 0 0 0 0 0 0 0 4
5 111.1 128.9 106.3 99.0 109.9 0 0 0 0 1 0 0 0 0 0 0 5
6 102.9 111.1 128.9 106.3 99.0 0 0 0 0 0 1 0 0 0 0 0 6
7 130.0 102.9 111.1 128.9 106.3 0 0 0 0 0 0 1 0 0 0 0 7
8 87.0 130.0 102.9 111.1 128.9 0 0 0 0 0 0 0 1 0 0 0 8
9 87.5 87.0 130.0 102.9 111.1 0 0 0 0 0 0 0 0 1 0 0 9
10 117.6 87.5 87.0 130.0 102.9 0 0 0 0 0 0 0 0 0 1 0 10
11 103.4 117.6 87.5 87.0 130.0 0 0 0 0 0 0 0 0 0 0 1 11
12 110.8 103.4 117.6 87.5 87.0 0 0 0 0 0 0 0 0 0 0 0 12
13 112.6 110.8 103.4 117.6 87.5 1 0 0 0 0 0 0 0 0 0 0 13
14 102.5 112.6 110.8 103.4 117.6 0 1 0 0 0 0 0 0 0 0 0 14
15 112.4 102.5 112.6 110.8 103.4 0 0 1 0 0 0 0 0 0 0 0 15
16 135.6 112.4 102.5 112.6 110.8 0 0 0 1 0 0 0 0 0 0 0 16
17 105.1 135.6 112.4 102.5 112.6 0 0 0 0 1 0 0 0 0 0 0 17
18 127.7 105.1 135.6 112.4 102.5 0 0 0 0 0 1 0 0 0 0 0 18
19 137.0 127.7 105.1 135.6 112.4 0 0 0 0 0 0 1 0 0 0 0 19
20 91.0 137.0 127.7 105.1 135.6 0 0 0 0 0 0 0 1 0 0 0 20
21 90.5 91.0 137.0 127.7 105.1 0 0 0 0 0 0 0 0 1 0 0 21
22 122.4 90.5 91.0 137.0 127.7 0 0 0 0 0 0 0 0 0 1 0 22
23 123.3 122.4 90.5 91.0 137.0 0 0 0 0 0 0 0 0 0 0 1 23
24 124.3 123.3 122.4 90.5 91.0 0 0 0 0 0 0 0 0 0 0 0 24
25 120.0 124.3 123.3 122.4 90.5 1 0 0 0 0 0 0 0 0 0 0 25
26 118.1 120.0 124.3 123.3 122.4 0 1 0 0 0 0 0 0 0 0 0 26
27 119.0 118.1 120.0 124.3 123.3 0 0 1 0 0 0 0 0 0 0 0 27
28 142.7 119.0 118.1 120.0 124.3 0 0 0 1 0 0 0 0 0 0 0 28
29 123.6 142.7 119.0 118.1 120.0 0 0 0 0 1 0 0 0 0 0 0 29
30 129.6 123.6 142.7 119.0 118.1 0 0 0 0 0 1 0 0 0 0 0 30
31 151.6 129.6 123.6 142.7 119.0 0 0 0 0 0 0 1 0 0 0 0 31
32 110.4 151.6 129.6 123.6 142.7 0 0 0 0 0 0 0 1 0 0 0 32
33 99.2 110.4 151.6 129.6 123.6 0 0 0 0 0 0 0 0 1 0 0 33
34 130.5 99.2 110.4 151.6 129.6 0 0 0 0 0 0 0 0 0 1 0 34
35 136.2 130.5 99.2 110.4 151.6 0 0 0 0 0 0 0 0 0 0 1 35
36 129.7 136.2 130.5 99.2 110.4 0 0 0 0 0 0 0 0 0 0 0 36
37 128.0 129.7 136.2 130.5 99.2 1 0 0 0 0 0 0 0 0 0 0 37
38 121.6 128.0 129.7 136.2 130.5 0 1 0 0 0 0 0 0 0 0 0 38
39 135.8 121.6 128.0 129.7 136.2 0 0 1 0 0 0 0 0 0 0 0 39
40 143.8 135.8 121.6 128.0 129.7 0 0 0 1 0 0 0 0 0 0 0 40
41 147.5 143.8 135.8 121.6 128.0 0 0 0 0 1 0 0 0 0 0 0 41
42 136.2 147.5 143.8 135.8 121.6 0 0 0 0 0 1 0 0 0 0 0 42
43 156.6 136.2 147.5 143.8 135.8 0 0 0 0 0 0 1 0 0 0 0 43
44 123.3 156.6 136.2 147.5 143.8 0 0 0 0 0 0 0 1 0 0 0 44
45 104.5 123.3 156.6 136.2 147.5 0 0 0 0 0 0 0 0 1 0 0 45
46 139.8 104.5 123.3 156.6 136.2 0 0 0 0 0 0 0 0 0 1 0 46
47 136.5 139.8 104.5 123.3 156.6 0 0 0 0 0 0 0 0 0 0 1 47
48 112.1 136.5 139.8 104.5 123.3 0 0 0 0 0 0 0 0 0 0 0 48
49 118.5 112.1 136.5 139.8 104.5 1 0 0 0 0 0 0 0 0 0 0 49
50 94.4 118.5 112.1 136.5 139.8 0 1 0 0 0 0 0 0 0 0 0 50
51 102.3 94.4 118.5 112.1 136.5 0 0 1 0 0 0 0 0 0 0 0 51
52 111.4 102.3 94.4 118.5 112.1 0 0 0 1 0 0 0 0 0 0 0 52
53 99.2 111.4 102.3 94.4 118.5 0 0 0 0 1 0 0 0 0 0 0 53
54 87.8 99.2 111.4 102.3 94.4 0 0 0 0 0 1 0 0 0 0 0 54
55 115.8 87.8 99.2 111.4 102.3 0 0 0 0 0 0 1 0 0 0 0 55
56 79.7 115.8 87.8 99.2 111.4 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) `Yt-1` `Yt-2` `Yt-3` `Yt-4` M1
3.4497 0.3458 0.5724 0.3293 -0.2846 -8.4090
M2 M3 M4 M5 M6 M7
-6.1679 6.1304 24.5480 2.8400 -7.8866 18.9911
M8 M9 M10 M11 t
-18.0392 -29.8250 22.5605 32.1621 -0.0850
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.8108 -2.9319 -0.4675 4.2802 13.6263
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.44968 11.43550 0.302 0.764511
`Yt-1` 0.34577 0.16095 2.148 0.037961 *
`Yt-2` 0.57239 0.15891 3.602 0.000882 ***
`Yt-3` 0.32928 0.17420 1.890 0.066177 .
`Yt-4` -0.28456 0.18406 -1.546 0.130164
M1 -8.40904 8.04022 -1.046 0.302059
M2 -6.16791 9.29760 -0.663 0.510985
M3 6.13035 9.17902 0.668 0.508153
M4 24.54803 8.84388 2.776 0.008416 **
M5 2.83995 6.66390 0.426 0.672327
M6 -7.88663 6.46688 -1.220 0.229963
M7 18.99111 9.53939 1.991 0.053542 .
M8 -18.03915 8.38865 -2.150 0.037779 *
M9 -29.82496 9.96068 -2.994 0.004759 **
M10 22.56045 14.94997 1.509 0.139342
M11 32.16210 12.12663 2.652 0.011504 *
t -0.08501 0.08498 -1.000 0.323314
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7.329 on 39 degrees of freedom
Multiple R-squared: 0.8798, Adjusted R-squared: 0.8305
F-statistic: 17.85 on 16 and 39 DF, p-value: 3.725e-13
> 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.7100641 0.5798718 0.2899359
[2,] 0.6439561 0.7120878 0.3560439
[3,] 0.5873176 0.8253649 0.4126824
[4,] 0.6460644 0.7078713 0.3539356
[5,] 0.6328518 0.7342965 0.3671482
[6,] 0.5044299 0.9911402 0.4955701
[7,] 0.4063114 0.8126228 0.5936886
[8,] 0.3900062 0.7800125 0.6099938
[9,] 0.3037847 0.6075694 0.6962153
[10,] 0.4219411 0.8438822 0.5780589
[11,] 0.5102563 0.9794873 0.4897437
[12,] 0.4663254 0.9326508 0.5336746
[13,] 0.4122977 0.8245954 0.5877023
[14,] 0.5628465 0.8743070 0.4371535
[15,] 0.6716681 0.6566639 0.3283319
[16,] 0.5456936 0.9086128 0.4543064
[17,] 0.6207446 0.7585109 0.3792554
> postscript(file="/var/www/html/rcomp/tmp/1i70i1258802531.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/2h9jp1258802531.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/3pu4e1258802531.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/4xa8j1258802531.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/53y591258802531.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
0.6872323 -0.4903503 -2.2804168 1.2265052 -1.5052255 -11.1804774
7 8 9 10 11 12
-3.2137167 -1.4829138 7.8790931 -1.1382103 -13.6780403 1.2491489
13 14 15 16 17 18
7.3434100 3.4703121 -2.8584286 5.8799953 -12.6775517 11.8665743
19 20 21 22 23 24
-0.8047276 -9.1963076 -3.3641767 6.1071942 4.5399965 6.2913268
25 26 27 28 29 30
-1.0218817 4.6176161 -3.6505578 4.1935929 -2.4212340 6.5918437
31 32 33 34 35 36
3.1093561 1.0166921 -4.0701998 -3.1521685 8.4461020 6.2703699
37 38 39 40 41 42
-1.4442942 1.3378631 10.2729421 -2.5962430 13.6263329 0.7824381
43 44 45 46 47 48
-2.4143852 1.8733556 -0.4447166 -1.8168154 0.6919418 -13.8108456
49 50 51 52 53 54
-5.5644664 -8.9354411 -1.4835389 -8.7038504 2.9776783 -8.0603787
55 56
3.3234735 7.7891737
> postscript(file="/var/www/html/rcomp/tmp/6eg1u1258802531.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.6872323 NA
1 -0.4903503 0.6872323
2 -2.2804168 -0.4903503
3 1.2265052 -2.2804168
4 -1.5052255 1.2265052
5 -11.1804774 -1.5052255
6 -3.2137167 -11.1804774
7 -1.4829138 -3.2137167
8 7.8790931 -1.4829138
9 -1.1382103 7.8790931
10 -13.6780403 -1.1382103
11 1.2491489 -13.6780403
12 7.3434100 1.2491489
13 3.4703121 7.3434100
14 -2.8584286 3.4703121
15 5.8799953 -2.8584286
16 -12.6775517 5.8799953
17 11.8665743 -12.6775517
18 -0.8047276 11.8665743
19 -9.1963076 -0.8047276
20 -3.3641767 -9.1963076
21 6.1071942 -3.3641767
22 4.5399965 6.1071942
23 6.2913268 4.5399965
24 -1.0218817 6.2913268
25 4.6176161 -1.0218817
26 -3.6505578 4.6176161
27 4.1935929 -3.6505578
28 -2.4212340 4.1935929
29 6.5918437 -2.4212340
30 3.1093561 6.5918437
31 1.0166921 3.1093561
32 -4.0701998 1.0166921
33 -3.1521685 -4.0701998
34 8.4461020 -3.1521685
35 6.2703699 8.4461020
36 -1.4442942 6.2703699
37 1.3378631 -1.4442942
38 10.2729421 1.3378631
39 -2.5962430 10.2729421
40 13.6263329 -2.5962430
41 0.7824381 13.6263329
42 -2.4143852 0.7824381
43 1.8733556 -2.4143852
44 -0.4447166 1.8733556
45 -1.8168154 -0.4447166
46 0.6919418 -1.8168154
47 -13.8108456 0.6919418
48 -5.5644664 -13.8108456
49 -8.9354411 -5.5644664
50 -1.4835389 -8.9354411
51 -8.7038504 -1.4835389
52 2.9776783 -8.7038504
53 -8.0603787 2.9776783
54 3.3234735 -8.0603787
55 7.7891737 3.3234735
56 NA 7.7891737
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.4903503 0.6872323
[2,] -2.2804168 -0.4903503
[3,] 1.2265052 -2.2804168
[4,] -1.5052255 1.2265052
[5,] -11.1804774 -1.5052255
[6,] -3.2137167 -11.1804774
[7,] -1.4829138 -3.2137167
[8,] 7.8790931 -1.4829138
[9,] -1.1382103 7.8790931
[10,] -13.6780403 -1.1382103
[11,] 1.2491489 -13.6780403
[12,] 7.3434100 1.2491489
[13,] 3.4703121 7.3434100
[14,] -2.8584286 3.4703121
[15,] 5.8799953 -2.8584286
[16,] -12.6775517 5.8799953
[17,] 11.8665743 -12.6775517
[18,] -0.8047276 11.8665743
[19,] -9.1963076 -0.8047276
[20,] -3.3641767 -9.1963076
[21,] 6.1071942 -3.3641767
[22,] 4.5399965 6.1071942
[23,] 6.2913268 4.5399965
[24,] -1.0218817 6.2913268
[25,] 4.6176161 -1.0218817
[26,] -3.6505578 4.6176161
[27,] 4.1935929 -3.6505578
[28,] -2.4212340 4.1935929
[29,] 6.5918437 -2.4212340
[30,] 3.1093561 6.5918437
[31,] 1.0166921 3.1093561
[32,] -4.0701998 1.0166921
[33,] -3.1521685 -4.0701998
[34,] 8.4461020 -3.1521685
[35,] 6.2703699 8.4461020
[36,] -1.4442942 6.2703699
[37,] 1.3378631 -1.4442942
[38,] 10.2729421 1.3378631
[39,] -2.5962430 10.2729421
[40,] 13.6263329 -2.5962430
[41,] 0.7824381 13.6263329
[42,] -2.4143852 0.7824381
[43,] 1.8733556 -2.4143852
[44,] -0.4447166 1.8733556
[45,] -1.8168154 -0.4447166
[46,] 0.6919418 -1.8168154
[47,] -13.8108456 0.6919418
[48,] -5.5644664 -13.8108456
[49,] -8.9354411 -5.5644664
[50,] -1.4835389 -8.9354411
[51,] -8.7038504 -1.4835389
[52,] 2.9776783 -8.7038504
[53,] -8.0603787 2.9776783
[54,] 3.3234735 -8.0603787
[55,] 7.7891737 3.3234735
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.4903503 0.6872323
2 -2.2804168 -0.4903503
3 1.2265052 -2.2804168
4 -1.5052255 1.2265052
5 -11.1804774 -1.5052255
6 -3.2137167 -11.1804774
7 -1.4829138 -3.2137167
8 7.8790931 -1.4829138
9 -1.1382103 7.8790931
10 -13.6780403 -1.1382103
11 1.2491489 -13.6780403
12 7.3434100 1.2491489
13 3.4703121 7.3434100
14 -2.8584286 3.4703121
15 5.8799953 -2.8584286
16 -12.6775517 5.8799953
17 11.8665743 -12.6775517
18 -0.8047276 11.8665743
19 -9.1963076 -0.8047276
20 -3.3641767 -9.1963076
21 6.1071942 -3.3641767
22 4.5399965 6.1071942
23 6.2913268 4.5399965
24 -1.0218817 6.2913268
25 4.6176161 -1.0218817
26 -3.6505578 4.6176161
27 4.1935929 -3.6505578
28 -2.4212340 4.1935929
29 6.5918437 -2.4212340
30 3.1093561 6.5918437
31 1.0166921 3.1093561
32 -4.0701998 1.0166921
33 -3.1521685 -4.0701998
34 8.4461020 -3.1521685
35 6.2703699 8.4461020
36 -1.4442942 6.2703699
37 1.3378631 -1.4442942
38 10.2729421 1.3378631
39 -2.5962430 10.2729421
40 13.6263329 -2.5962430
41 0.7824381 13.6263329
42 -2.4143852 0.7824381
43 1.8733556 -2.4143852
44 -0.4447166 1.8733556
45 -1.8168154 -0.4447166
46 0.6919418 -1.8168154
47 -13.8108456 0.6919418
48 -5.5644664 -13.8108456
49 -8.9354411 -5.5644664
50 -1.4835389 -8.9354411
51 -8.7038504 -1.4835389
52 2.9776783 -8.7038504
53 -8.0603787 2.9776783
54 3.3234735 -8.0603787
55 7.7891737 3.3234735
> 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/7utod1258802531.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/8ynpj1258802531.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/9ppbe1258802531.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/10yuf91258802531.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/11kp2l1258802531.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/12k3hf1258802531.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/13ow4a1258802531.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/14rl0e1258802531.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/15fwob1258802531.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/167y491258802531.tab")
+ }
>
> system("convert tmp/1i70i1258802531.ps tmp/1i70i1258802531.png")
> system("convert tmp/2h9jp1258802531.ps tmp/2h9jp1258802531.png")
> system("convert tmp/3pu4e1258802531.ps tmp/3pu4e1258802531.png")
> system("convert tmp/4xa8j1258802531.ps tmp/4xa8j1258802531.png")
> system("convert tmp/53y591258802531.ps tmp/53y591258802531.png")
> system("convert tmp/6eg1u1258802531.ps tmp/6eg1u1258802531.png")
> system("convert tmp/7utod1258802531.ps tmp/7utod1258802531.png")
> system("convert tmp/8ynpj1258802531.ps tmp/8ynpj1258802531.png")
> system("convert tmp/9ppbe1258802531.ps tmp/9ppbe1258802531.png")
> system("convert tmp/10yuf91258802531.ps tmp/10yuf91258802531.png")
>
>
> proc.time()
user system elapsed
2.338 1.562 2.948