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(103.8
+ ,122.5
+ ,80.2
+ ,19
+ ,103.5
+ ,122.4
+ ,74.8
+ ,18
+ ,104.1
+ ,121.9
+ ,77.8
+ ,19
+ ,101.9
+ ,122.2
+ ,73
+ ,19
+ ,102
+ ,123.7
+ ,72
+ ,22
+ ,100.7
+ ,122.6
+ ,75.8
+ ,23
+ ,99
+ ,115.7
+ ,72.6
+ ,20
+ ,96.5
+ ,116.1
+ ,71.9
+ ,14
+ ,101.8
+ ,120.5
+ ,74.8
+ ,14
+ ,100.5
+ ,122.6
+ ,72.9
+ ,14
+ ,103.3
+ ,119.9
+ ,72.9
+ ,15
+ ,102.3
+ ,120.7
+ ,79.9
+ ,11
+ ,100.4
+ ,120.2
+ ,74
+ ,17
+ ,103
+ ,122.1
+ ,76
+ ,16
+ ,99
+ ,119.3
+ ,69.6
+ ,20
+ ,104.8
+ ,121.7
+ ,77.3
+ ,24
+ ,104.5
+ ,113.5
+ ,75.2
+ ,23
+ ,104.8
+ ,123.7
+ ,75.8
+ ,20
+ ,103.8
+ ,123.4
+ ,77.6
+ ,21
+ ,106.3
+ ,126.4
+ ,76.7
+ ,19
+ ,105.2
+ ,124.1
+ ,77
+ ,23
+ ,108.2
+ ,125.6
+ ,77.9
+ ,23
+ ,106.2
+ ,124.8
+ ,76.7
+ ,23
+ ,103.9
+ ,123
+ ,71.9
+ ,23
+ ,104.9
+ ,126.9
+ ,73.4
+ ,27
+ ,106.2
+ ,127.3
+ ,72.5
+ ,26
+ ,107.9
+ ,129
+ ,73.7
+ ,17
+ ,106.9
+ ,126.2
+ ,69.5
+ ,24
+ ,110.3
+ ,125.4
+ ,74.7
+ ,26
+ ,109.8
+ ,126.3
+ ,72.5
+ ,24
+ ,108.3
+ ,126.3
+ ,72.1
+ ,27
+ ,110.9
+ ,128.4
+ ,70.7
+ ,27
+ ,109.8
+ ,127.2
+ ,71.4
+ ,26
+ ,109.3
+ ,128.5
+ ,69.5
+ ,24
+ ,109
+ ,129
+ ,73.5
+ ,23
+ ,107.9
+ ,128.9
+ ,72.4
+ ,23
+ ,108.4
+ ,128.3
+ ,74.5
+ ,24
+ ,107.2
+ ,124.6
+ ,72.2
+ ,17
+ ,109.5
+ ,126.2
+ ,73
+ ,21
+ ,109.9
+ ,129.1
+ ,73.3
+ ,19
+ ,108
+ ,127.3
+ ,71.3
+ ,22
+ ,114.7
+ ,129.2
+ ,73.6
+ ,22
+ ,115.6
+ ,130.4
+ ,71.3
+ ,18
+ ,107.6
+ ,125.9
+ ,71.2
+ ,16
+ ,115.9
+ ,135.8
+ ,81.4
+ ,14
+ ,111.8
+ ,126.4
+ ,76.1
+ ,12
+ ,110
+ ,129.5
+ ,71.1
+ ,14
+ ,109.2
+ ,128.4
+ ,75.7
+ ,16
+ ,108
+ ,125.6
+ ,70
+ ,8
+ ,105.6
+ ,127.7
+ ,68.5
+ ,3
+ ,103
+ ,126.4
+ ,56.7
+ ,0
+ ,99.6
+ ,124.2
+ ,57.9
+ ,5
+ ,97.9
+ ,126.4
+ ,58.8
+ ,1
+ ,97.6
+ ,123.7
+ ,59.3
+ ,1
+ ,96.2
+ ,121.8
+ ,61.3
+ ,3
+ ,97.9
+ ,124
+ ,62.9
+ ,6
+ ,94.5
+ ,122.7
+ ,61.4
+ ,7
+ ,95.4
+ ,122.9
+ ,64.5
+ ,8
+ ,94.4
+ ,121
+ ,63.8
+ ,14
+ ,96.3
+ ,122.8
+ ,61.6
+ ,14
+ ,95.1
+ ,122.9
+ ,64.7
+ ,13)
+ ,dim=c(4
+ ,61)
+ ,dimnames=list(c('totid'
+ ,'ndzcg'
+ ,'dzcg'
+ ,'indc
')
+ ,1:61))
> y <- array(NA,dim=c(4,61),dimnames=list(c('totid','ndzcg','dzcg','indc
'),1:61))
> 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 = '3'
> #'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
dzcg totid ndzcg indc\r M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 80.2 103.8 122.5 19 1 0 0 0 0 0 0 0 0 0 0 1
2 74.8 103.5 122.4 18 0 1 0 0 0 0 0 0 0 0 0 2
3 77.8 104.1 121.9 19 0 0 1 0 0 0 0 0 0 0 0 3
4 73.0 101.9 122.2 19 0 0 0 1 0 0 0 0 0 0 0 4
5 72.0 102.0 123.7 22 0 0 0 0 1 0 0 0 0 0 0 5
6 75.8 100.7 122.6 23 0 0 0 0 0 1 0 0 0 0 0 6
7 72.6 99.0 115.7 20 0 0 0 0 0 0 1 0 0 0 0 7
8 71.9 96.5 116.1 14 0 0 0 0 0 0 0 1 0 0 0 8
9 74.8 101.8 120.5 14 0 0 0 0 0 0 0 0 1 0 0 9
10 72.9 100.5 122.6 14 0 0 0 0 0 0 0 0 0 1 0 10
11 72.9 103.3 119.9 15 0 0 0 0 0 0 0 0 0 0 1 11
12 79.9 102.3 120.7 11 0 0 0 0 0 0 0 0 0 0 0 12
13 74.0 100.4 120.2 17 1 0 0 0 0 0 0 0 0 0 0 13
14 76.0 103.0 122.1 16 0 1 0 0 0 0 0 0 0 0 0 14
15 69.6 99.0 119.3 20 0 0 1 0 0 0 0 0 0 0 0 15
16 77.3 104.8 121.7 24 0 0 0 1 0 0 0 0 0 0 0 16
17 75.2 104.5 113.5 23 0 0 0 0 1 0 0 0 0 0 0 17
18 75.8 104.8 123.7 20 0 0 0 0 0 1 0 0 0 0 0 18
19 77.6 103.8 123.4 21 0 0 0 0 0 0 1 0 0 0 0 19
20 76.7 106.3 126.4 19 0 0 0 0 0 0 0 1 0 0 0 20
21 77.0 105.2 124.1 23 0 0 0 0 0 0 0 0 1 0 0 21
22 77.9 108.2 125.6 23 0 0 0 0 0 0 0 0 0 1 0 22
23 76.7 106.2 124.8 23 0 0 0 0 0 0 0 0 0 0 1 23
24 71.9 103.9 123.0 23 0 0 0 0 0 0 0 0 0 0 0 24
25 73.4 104.9 126.9 27 1 0 0 0 0 0 0 0 0 0 0 25
26 72.5 106.2 127.3 26 0 1 0 0 0 0 0 0 0 0 0 26
27 73.7 107.9 129.0 17 0 0 1 0 0 0 0 0 0 0 0 27
28 69.5 106.9 126.2 24 0 0 0 1 0 0 0 0 0 0 0 28
29 74.7 110.3 125.4 26 0 0 0 0 1 0 0 0 0 0 0 29
30 72.5 109.8 126.3 24 0 0 0 0 0 1 0 0 0 0 0 30
31 72.1 108.3 126.3 27 0 0 0 0 0 0 1 0 0 0 0 31
32 70.7 110.9 128.4 27 0 0 0 0 0 0 0 1 0 0 0 32
33 71.4 109.8 127.2 26 0 0 0 0 0 0 0 0 1 0 0 33
34 69.5 109.3 128.5 24 0 0 0 0 0 0 0 0 0 1 0 34
35 73.5 109.0 129.0 23 0 0 0 0 0 0 0 0 0 0 1 35
36 72.4 107.9 128.9 23 0 0 0 0 0 0 0 0 0 0 0 36
37 74.5 108.4 128.3 24 1 0 0 0 0 0 0 0 0 0 0 37
38 72.2 107.2 124.6 17 0 1 0 0 0 0 0 0 0 0 0 38
39 73.0 109.5 126.2 21 0 0 1 0 0 0 0 0 0 0 0 39
40 73.3 109.9 129.1 19 0 0 0 1 0 0 0 0 0 0 0 40
41 71.3 108.0 127.3 22 0 0 0 0 1 0 0 0 0 0 0 41
42 73.6 114.7 129.2 22 0 0 0 0 0 1 0 0 0 0 0 42
43 71.3 115.6 130.4 18 0 0 0 0 0 0 1 0 0 0 0 43
44 71.2 107.6 125.9 16 0 0 0 0 0 0 0 1 0 0 0 44
45 81.4 115.9 135.8 14 0 0 0 0 0 0 0 0 1 0 0 45
46 76.1 111.8 126.4 12 0 0 0 0 0 0 0 0 0 1 0 46
47 71.1 110.0 129.5 14 0 0 0 0 0 0 0 0 0 0 1 47
48 75.7 109.2 128.4 16 0 0 0 0 0 0 0 0 0 0 0 48
49 70.0 108.0 125.6 8 1 0 0 0 0 0 0 0 0 0 0 49
50 68.5 105.6 127.7 3 0 1 0 0 0 0 0 0 0 0 0 50
51 56.7 103.0 126.4 0 0 0 1 0 0 0 0 0 0 0 0 51
52 57.9 99.6 124.2 5 0 0 0 1 0 0 0 0 0 0 0 52
53 58.8 97.9 126.4 1 0 0 0 0 1 0 0 0 0 0 0 53
54 59.3 97.6 123.7 1 0 0 0 0 0 1 0 0 0 0 0 54
55 61.3 96.2 121.8 3 0 0 0 0 0 0 1 0 0 0 0 55
56 62.9 97.9 124.0 6 0 0 0 0 0 0 0 1 0 0 0 56
57 61.4 94.5 122.7 7 0 0 0 0 0 0 0 0 1 0 0 57
58 64.5 95.4 122.9 8 0 0 0 0 0 0 0 0 0 1 0 58
59 63.8 94.4 121.0 14 0 0 0 0 0 0 0 0 0 0 1 59
60 61.6 96.3 122.8 14 0 0 0 0 0 0 0 0 0 0 0 60
61 64.7 95.1 122.9 13 1 0 0 0 0 0 0 0 0 0 0 61
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) totid ndzcg `indc\r` M1 M2
35.82719 0.62049 -0.17521 0.05056 -0.26776 -2.10353
M3 M4 M5 M6 M7 M8
-4.31529 -4.15092 -3.98515 -3.03514 -2.94333 -2.40599
M9 M10 M11 t
-0.37084 -1.06772 -1.31100 -0.19526
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.6179 -1.4986 -0.2028 2.0136 5.9009
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.82719 15.34312 2.335 0.0241 *
totid 0.62049 0.13130 4.726 2.28e-05 ***
ndzcg -0.17521 0.19063 -0.919 0.3629
`indc\r` 0.05056 0.07609 0.664 0.5098
M1 -0.26776 1.76059 -0.152 0.8798
M2 -2.10353 1.87775 -1.120 0.2686
M3 -4.31529 1.87507 -2.301 0.0261 *
M4 -4.15092 1.84597 -2.249 0.0295 *
M5 -3.98515 1.85268 -2.151 0.0369 *
M6 -3.03514 1.84595 -1.644 0.1071
M7 -2.94333 1.85045 -1.591 0.1187
M8 -2.40599 1.84069 -1.307 0.1978
M9 -0.37084 1.85200 -0.200 0.8422
M10 -1.06772 1.84441 -0.579 0.5655
M11 -1.31100 1.83447 -0.715 0.4785
t -0.19526 0.03267 -5.977 3.38e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.899 on 45 degrees of freedom
Multiple R-squared: 0.8052, Adjusted R-squared: 0.7403
F-statistic: 12.4 on 15 and 45 DF, p-value: 2.395e-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.23925992 0.4785198 0.7607401
[2,] 0.29421336 0.5884267 0.7057866
[3,] 0.17676334 0.3535267 0.8232367
[4,] 0.11308767 0.2261753 0.8869123
[5,] 0.08942496 0.1788499 0.9105750
[6,] 0.27017443 0.5403489 0.7298256
[7,] 0.19688616 0.3937723 0.8031138
[8,] 0.12808180 0.2561636 0.8719182
[9,] 0.18250093 0.3650019 0.8174991
[10,] 0.21257353 0.4251471 0.7874265
[11,] 0.15632449 0.3126490 0.8436755
[12,] 0.22270534 0.4454107 0.7772947
[13,] 0.20956589 0.4191318 0.7904341
[14,] 0.25734584 0.5146917 0.7426542
[15,] 0.28506057 0.5701211 0.7149394
[16,] 0.47224481 0.9444896 0.5277552
[17,] 0.37325594 0.7465119 0.6267441
[18,] 0.30536843 0.6107369 0.6946316
[19,] 0.35196138 0.7039228 0.6480386
[20,] 0.40563834 0.8112767 0.5943617
[21,] 0.35517118 0.7103424 0.6448288
[22,] 0.27059188 0.5411838 0.7294081
[23,] 0.18386984 0.3677397 0.8161302
[24,] 0.11120581 0.2224116 0.8887942
> postscript(file="/var/www/html/rcomp/tmp/1jw7e1258656266.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/2jhkd1258656266.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/3v0yl1258656266.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/47jyk1258656266.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/5qrcj1258656266.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 = 61
Frequency = 1
1 2 3 4 5 6 7
0.9311001 -2.2186758 2.6778916 -0.6735690 -1.5949866 2.0136235 -1.0853495
8 9 10 11 12 13 14
-0.2027730 -1.6603526 -1.4936284 -3.3160858 3.5310678 -1.1179168 1.6832949
15 16 17 18 19 20 21
-0.5205202 3.8297907 0.5592807 2.1571767 4.5780044 2.4114334 0.9488868
22 23 24 25 26 27 28
1.1423692 1.4817264 -3.3222461 -1.4986314 -1.0535912 2.2514566 -2.1416344
29 30 31 32 33 34 35
0.7369019 -1.6487969 -1.1662737 -4.1536939 -4.7707295 -5.1394524 -0.3766056
36 37 38 39 40 41 42
-1.9273158 0.1697796 0.3510377 2.2090350 2.9009474 1.6423290 -0.6368200
43 44 45 46 47 48 49
-2.9793337 0.8552068 5.9009057 2.4912322 -0.5113118 3.1755096 -1.4030067
50 51 52 53 54 55 56
1.2379344 -6.6178630 -3.9155346 -1.3435250 -1.8851833 0.6529524 1.0898266
57 58 59 60 61
-0.4187104 2.9994794 2.7222768 -1.4570156 2.9186752
> postscript(file="/var/www/html/rcomp/tmp/65glo1258656266.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 = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 0.9311001 NA
1 -2.2186758 0.9311001
2 2.6778916 -2.2186758
3 -0.6735690 2.6778916
4 -1.5949866 -0.6735690
5 2.0136235 -1.5949866
6 -1.0853495 2.0136235
7 -0.2027730 -1.0853495
8 -1.6603526 -0.2027730
9 -1.4936284 -1.6603526
10 -3.3160858 -1.4936284
11 3.5310678 -3.3160858
12 -1.1179168 3.5310678
13 1.6832949 -1.1179168
14 -0.5205202 1.6832949
15 3.8297907 -0.5205202
16 0.5592807 3.8297907
17 2.1571767 0.5592807
18 4.5780044 2.1571767
19 2.4114334 4.5780044
20 0.9488868 2.4114334
21 1.1423692 0.9488868
22 1.4817264 1.1423692
23 -3.3222461 1.4817264
24 -1.4986314 -3.3222461
25 -1.0535912 -1.4986314
26 2.2514566 -1.0535912
27 -2.1416344 2.2514566
28 0.7369019 -2.1416344
29 -1.6487969 0.7369019
30 -1.1662737 -1.6487969
31 -4.1536939 -1.1662737
32 -4.7707295 -4.1536939
33 -5.1394524 -4.7707295
34 -0.3766056 -5.1394524
35 -1.9273158 -0.3766056
36 0.1697796 -1.9273158
37 0.3510377 0.1697796
38 2.2090350 0.3510377
39 2.9009474 2.2090350
40 1.6423290 2.9009474
41 -0.6368200 1.6423290
42 -2.9793337 -0.6368200
43 0.8552068 -2.9793337
44 5.9009057 0.8552068
45 2.4912322 5.9009057
46 -0.5113118 2.4912322
47 3.1755096 -0.5113118
48 -1.4030067 3.1755096
49 1.2379344 -1.4030067
50 -6.6178630 1.2379344
51 -3.9155346 -6.6178630
52 -1.3435250 -3.9155346
53 -1.8851833 -1.3435250
54 0.6529524 -1.8851833
55 1.0898266 0.6529524
56 -0.4187104 1.0898266
57 2.9994794 -0.4187104
58 2.7222768 2.9994794
59 -1.4570156 2.7222768
60 2.9186752 -1.4570156
61 NA 2.9186752
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.2186758 0.9311001
[2,] 2.6778916 -2.2186758
[3,] -0.6735690 2.6778916
[4,] -1.5949866 -0.6735690
[5,] 2.0136235 -1.5949866
[6,] -1.0853495 2.0136235
[7,] -0.2027730 -1.0853495
[8,] -1.6603526 -0.2027730
[9,] -1.4936284 -1.6603526
[10,] -3.3160858 -1.4936284
[11,] 3.5310678 -3.3160858
[12,] -1.1179168 3.5310678
[13,] 1.6832949 -1.1179168
[14,] -0.5205202 1.6832949
[15,] 3.8297907 -0.5205202
[16,] 0.5592807 3.8297907
[17,] 2.1571767 0.5592807
[18,] 4.5780044 2.1571767
[19,] 2.4114334 4.5780044
[20,] 0.9488868 2.4114334
[21,] 1.1423692 0.9488868
[22,] 1.4817264 1.1423692
[23,] -3.3222461 1.4817264
[24,] -1.4986314 -3.3222461
[25,] -1.0535912 -1.4986314
[26,] 2.2514566 -1.0535912
[27,] -2.1416344 2.2514566
[28,] 0.7369019 -2.1416344
[29,] -1.6487969 0.7369019
[30,] -1.1662737 -1.6487969
[31,] -4.1536939 -1.1662737
[32,] -4.7707295 -4.1536939
[33,] -5.1394524 -4.7707295
[34,] -0.3766056 -5.1394524
[35,] -1.9273158 -0.3766056
[36,] 0.1697796 -1.9273158
[37,] 0.3510377 0.1697796
[38,] 2.2090350 0.3510377
[39,] 2.9009474 2.2090350
[40,] 1.6423290 2.9009474
[41,] -0.6368200 1.6423290
[42,] -2.9793337 -0.6368200
[43,] 0.8552068 -2.9793337
[44,] 5.9009057 0.8552068
[45,] 2.4912322 5.9009057
[46,] -0.5113118 2.4912322
[47,] 3.1755096 -0.5113118
[48,] -1.4030067 3.1755096
[49,] 1.2379344 -1.4030067
[50,] -6.6178630 1.2379344
[51,] -3.9155346 -6.6178630
[52,] -1.3435250 -3.9155346
[53,] -1.8851833 -1.3435250
[54,] 0.6529524 -1.8851833
[55,] 1.0898266 0.6529524
[56,] -0.4187104 1.0898266
[57,] 2.9994794 -0.4187104
[58,] 2.7222768 2.9994794
[59,] -1.4570156 2.7222768
[60,] 2.9186752 -1.4570156
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.2186758 0.9311001
2 2.6778916 -2.2186758
3 -0.6735690 2.6778916
4 -1.5949866 -0.6735690
5 2.0136235 -1.5949866
6 -1.0853495 2.0136235
7 -0.2027730 -1.0853495
8 -1.6603526 -0.2027730
9 -1.4936284 -1.6603526
10 -3.3160858 -1.4936284
11 3.5310678 -3.3160858
12 -1.1179168 3.5310678
13 1.6832949 -1.1179168
14 -0.5205202 1.6832949
15 3.8297907 -0.5205202
16 0.5592807 3.8297907
17 2.1571767 0.5592807
18 4.5780044 2.1571767
19 2.4114334 4.5780044
20 0.9488868 2.4114334
21 1.1423692 0.9488868
22 1.4817264 1.1423692
23 -3.3222461 1.4817264
24 -1.4986314 -3.3222461
25 -1.0535912 -1.4986314
26 2.2514566 -1.0535912
27 -2.1416344 2.2514566
28 0.7369019 -2.1416344
29 -1.6487969 0.7369019
30 -1.1662737 -1.6487969
31 -4.1536939 -1.1662737
32 -4.7707295 -4.1536939
33 -5.1394524 -4.7707295
34 -0.3766056 -5.1394524
35 -1.9273158 -0.3766056
36 0.1697796 -1.9273158
37 0.3510377 0.1697796
38 2.2090350 0.3510377
39 2.9009474 2.2090350
40 1.6423290 2.9009474
41 -0.6368200 1.6423290
42 -2.9793337 -0.6368200
43 0.8552068 -2.9793337
44 5.9009057 0.8552068
45 2.4912322 5.9009057
46 -0.5113118 2.4912322
47 3.1755096 -0.5113118
48 -1.4030067 3.1755096
49 1.2379344 -1.4030067
50 -6.6178630 1.2379344
51 -3.9155346 -6.6178630
52 -1.3435250 -3.9155346
53 -1.8851833 -1.3435250
54 0.6529524 -1.8851833
55 1.0898266 0.6529524
56 -0.4187104 1.0898266
57 2.9994794 -0.4187104
58 2.7222768 2.9994794
59 -1.4570156 2.7222768
60 2.9186752 -1.4570156
> 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/7mgji1258656266.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/83zuf1258656266.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/9gegn1258656266.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/107zim1258656266.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/11slx21258656266.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/12cudb1258656266.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/13mu5u1258656266.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/140qq31258656266.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/15k0fh1258656266.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/168nnv1258656266.tab")
+ }
>
> system("convert tmp/1jw7e1258656266.ps tmp/1jw7e1258656266.png")
> system("convert tmp/2jhkd1258656266.ps tmp/2jhkd1258656266.png")
> system("convert tmp/3v0yl1258656266.ps tmp/3v0yl1258656266.png")
> system("convert tmp/47jyk1258656266.ps tmp/47jyk1258656266.png")
> system("convert tmp/5qrcj1258656266.ps tmp/5qrcj1258656266.png")
> system("convert tmp/65glo1258656266.ps tmp/65glo1258656266.png")
> system("convert tmp/7mgji1258656266.ps tmp/7mgji1258656266.png")
> system("convert tmp/83zuf1258656266.ps tmp/83zuf1258656266.png")
> system("convert tmp/9gegn1258656266.ps tmp/9gegn1258656266.png")
> system("convert tmp/107zim1258656266.ps tmp/107zim1258656266.png")
>
>
> proc.time()
user system elapsed
2.412 1.574 2.825