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.7
+ ,116.7
+ ,107.5
+ ,116.1
+ ,102.8
+ ,112.5
+ ,116.7
+ ,107.5
+ ,98.1
+ ,113
+ ,112.5
+ ,116.7
+ ,113.9
+ ,126.4
+ ,113
+ ,112.5
+ ,80.9
+ ,114.1
+ ,126.4
+ ,113
+ ,95.7
+ ,112.5
+ ,114.1
+ ,126.4
+ ,113.2
+ ,112.4
+ ,112.5
+ ,114.1
+ ,105.9
+ ,113.1
+ ,112.4
+ ,112.5
+ ,108.8
+ ,116.3
+ ,113.1
+ ,112.4
+ ,102.3
+ ,111.7
+ ,116.3
+ ,113.1
+ ,99
+ ,118.8
+ ,111.7
+ ,116.3
+ ,100.7
+ ,116.5
+ ,118.8
+ ,111.7
+ ,115.5
+ ,125.1
+ ,116.5
+ ,118.8
+ ,100.7
+ ,113.1
+ ,125.1
+ ,116.5
+ ,109.9
+ ,119.6
+ ,113.1
+ ,125.1
+ ,114.6
+ ,114.4
+ ,119.6
+ ,113.1
+ ,85.4
+ ,114
+ ,114.4
+ ,119.6
+ ,100.5
+ ,117.8
+ ,114
+ ,114.4
+ ,114.8
+ ,117
+ ,117.8
+ ,114
+ ,116.5
+ ,120.9
+ ,117
+ ,117.8
+ ,112.9
+ ,115
+ ,120.9
+ ,117
+ ,102
+ ,117.3
+ ,115
+ ,120.9
+ ,106
+ ,119.4
+ ,117.3
+ ,115
+ ,105.3
+ ,114.9
+ ,119.4
+ ,117.3
+ ,118.8
+ ,125.8
+ ,114.9
+ ,119.4
+ ,106.1
+ ,117.6
+ ,125.8
+ ,114.9
+ ,109.3
+ ,117.6
+ ,117.6
+ ,125.8
+ ,117.2
+ ,114.9
+ ,117.6
+ ,117.6
+ ,92.5
+ ,121.9
+ ,114.9
+ ,117.6
+ ,104.2
+ ,117
+ ,121.9
+ ,114.9
+ ,112.5
+ ,106.4
+ ,117
+ ,121.9
+ ,122.4
+ ,110.5
+ ,106.4
+ ,117
+ ,113.3
+ ,113.6
+ ,110.5
+ ,106.4
+ ,100
+ ,114.2
+ ,113.6
+ ,110.5
+ ,110.7
+ ,125.4
+ ,114.2
+ ,113.6
+ ,112.8
+ ,124.6
+ ,125.4
+ ,114.2
+ ,109.8
+ ,120.2
+ ,124.6
+ ,125.4
+ ,117.3
+ ,120.8
+ ,120.2
+ ,124.6
+ ,109.1
+ ,111.4
+ ,120.8
+ ,120.2
+ ,115.9
+ ,124.1
+ ,111.4
+ ,120.8
+ ,96
+ ,120.2
+ ,124.1
+ ,111.4
+ ,99.8
+ ,125.5
+ ,120.2
+ ,124.1
+ ,116.8
+ ,116
+ ,125.5
+ ,120.2
+ ,115.7
+ ,117
+ ,116
+ ,125.5
+ ,99.4
+ ,105.7
+ ,117
+ ,116
+ ,94.3
+ ,102
+ ,105.7
+ ,117
+ ,91
+ ,106.4
+ ,102
+ ,105.7
+ ,93.2
+ ,96.9
+ ,106.4
+ ,102
+ ,103.1
+ ,107.6
+ ,96.9
+ ,106.4
+ ,94.1
+ ,98.8
+ ,107.6
+ ,96.9
+ ,91.8
+ ,101.1
+ ,98.8
+ ,107.6
+ ,102.7
+ ,105.7
+ ,101.1
+ ,98.8
+ ,82.6
+ ,104.6
+ ,105.7
+ ,101.1
+ ,89.1
+ ,103.2
+ ,104.6
+ ,105.7
+ ,104.5
+ ,101.6
+ ,103.2
+ ,104.6
+ ,105.1
+ ,106.7
+ ,101.6
+ ,103.2
+ ,95.1
+ ,99.5
+ ,106.7
+ ,101.6
+ ,88.7
+ ,101
+ ,99.5
+ ,106.7)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('T.I.P.'
+ ,'I.P.C.N.'
+ ,'y(t-1)'
+ ,'y(t-2)')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('T.I.P.','I.P.C.N.','y(t-1)','y(t-2)'),1:58))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '2'
> 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.P.C.N. T.I.P. y(t-1) y(t-2) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 116.7 104.7 107.5 116.1 1 0 0 0 0 0 0 0 0 0 0 1
2 112.5 102.8 116.7 107.5 0 1 0 0 0 0 0 0 0 0 0 2
3 113.0 98.1 112.5 116.7 0 0 1 0 0 0 0 0 0 0 0 3
4 126.4 113.9 113.0 112.5 0 0 0 1 0 0 0 0 0 0 0 4
5 114.1 80.9 126.4 113.0 0 0 0 0 1 0 0 0 0 0 0 5
6 112.5 95.7 114.1 126.4 0 0 0 0 0 1 0 0 0 0 0 6
7 112.4 113.2 112.5 114.1 0 0 0 0 0 0 1 0 0 0 0 7
8 113.1 105.9 112.4 112.5 0 0 0 0 0 0 0 1 0 0 0 8
9 116.3 108.8 113.1 112.4 0 0 0 0 0 0 0 0 1 0 0 9
10 111.7 102.3 116.3 113.1 0 0 0 0 0 0 0 0 0 1 0 10
11 118.8 99.0 111.7 116.3 0 0 0 0 0 0 0 0 0 0 1 11
12 116.5 100.7 118.8 111.7 0 0 0 0 0 0 0 0 0 0 0 12
13 125.1 115.5 116.5 118.8 1 0 0 0 0 0 0 0 0 0 0 13
14 113.1 100.7 125.1 116.5 0 1 0 0 0 0 0 0 0 0 0 14
15 119.6 109.9 113.1 125.1 0 0 1 0 0 0 0 0 0 0 0 15
16 114.4 114.6 119.6 113.1 0 0 0 1 0 0 0 0 0 0 0 16
17 114.0 85.4 114.4 119.6 0 0 0 0 1 0 0 0 0 0 0 17
18 117.8 100.5 114.0 114.4 0 0 0 0 0 1 0 0 0 0 0 18
19 117.0 114.8 117.8 114.0 0 0 0 0 0 0 1 0 0 0 0 19
20 120.9 116.5 117.0 117.8 0 0 0 0 0 0 0 1 0 0 0 20
21 115.0 112.9 120.9 117.0 0 0 0 0 0 0 0 0 1 0 0 21
22 117.3 102.0 115.0 120.9 0 0 0 0 0 0 0 0 0 1 0 22
23 119.4 106.0 117.3 115.0 0 0 0 0 0 0 0 0 0 0 1 23
24 114.9 105.3 119.4 117.3 0 0 0 0 0 0 0 0 0 0 0 24
25 125.8 118.8 114.9 119.4 1 0 0 0 0 0 0 0 0 0 0 25
26 117.6 106.1 125.8 114.9 0 1 0 0 0 0 0 0 0 0 0 26
27 117.6 109.3 117.6 125.8 0 0 1 0 0 0 0 0 0 0 0 27
28 114.9 117.2 117.6 117.6 0 0 0 1 0 0 0 0 0 0 0 28
29 121.9 92.5 114.9 117.6 0 0 0 0 1 0 0 0 0 0 0 29
30 117.0 104.2 121.9 114.9 0 0 0 0 0 1 0 0 0 0 0 30
31 106.4 112.5 117.0 121.9 0 0 0 0 0 0 1 0 0 0 0 31
32 110.5 122.4 106.4 117.0 0 0 0 0 0 0 0 1 0 0 0 32
33 113.6 113.3 110.5 106.4 0 0 0 0 0 0 0 0 1 0 0 33
34 114.2 100.0 113.6 110.5 0 0 0 0 0 0 0 0 0 1 0 34
35 125.4 110.7 114.2 113.6 0 0 0 0 0 0 0 0 0 0 1 35
36 124.6 112.8 125.4 114.2 0 0 0 0 0 0 0 0 0 0 0 36
37 120.2 109.8 124.6 125.4 1 0 0 0 0 0 0 0 0 0 0 37
38 120.8 117.3 120.2 124.6 0 1 0 0 0 0 0 0 0 0 0 38
39 111.4 109.1 120.8 120.2 0 0 1 0 0 0 0 0 0 0 0 39
40 124.1 115.9 111.4 120.8 0 0 0 1 0 0 0 0 0 0 0 40
41 120.2 96.0 124.1 111.4 0 0 0 0 1 0 0 0 0 0 0 41
42 125.5 99.8 120.2 124.1 0 0 0 0 0 1 0 0 0 0 0 42
43 116.0 116.8 125.5 120.2 0 0 0 0 0 0 1 0 0 0 0 43
44 117.0 115.7 116.0 125.5 0 0 0 0 0 0 0 1 0 0 0 44
45 105.7 99.4 117.0 116.0 0 0 0 0 0 0 0 0 1 0 0 45
46 102.0 94.3 105.7 117.0 0 0 0 0 0 0 0 0 0 1 0 46
47 106.4 91.0 102.0 105.7 0 0 0 0 0 0 0 0 0 0 1 47
48 96.9 93.2 106.4 102.0 0 0 0 0 0 0 0 0 0 0 0 48
49 107.6 103.1 96.9 106.4 1 0 0 0 0 0 0 0 0 0 0 49
50 98.8 94.1 107.6 96.9 0 1 0 0 0 0 0 0 0 0 0 50
51 101.1 91.8 98.8 107.6 0 0 1 0 0 0 0 0 0 0 0 51
52 105.7 102.7 101.1 98.8 0 0 0 1 0 0 0 0 0 0 0 52
53 104.6 82.6 105.7 101.1 0 0 0 0 1 0 0 0 0 0 0 53
54 103.2 89.1 104.6 105.7 0 0 0 0 0 1 0 0 0 0 0 54
55 101.6 104.5 103.2 104.6 0 0 0 0 0 0 1 0 0 0 0 55
56 106.7 105.1 101.6 103.2 0 0 0 0 0 0 0 1 0 0 0 56
57 99.5 95.1 106.7 101.6 0 0 0 0 0 0 0 0 1 0 0 57
58 101.0 88.7 99.5 106.7 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) T.I.P. `y(t-1)` `y(t-2)` M1 M2
17.88867 0.59324 0.20515 0.11515 1.45879 -2.14950
M3 M4 M5 M6 M7 M8
-1.21609 -1.28122 10.79173 4.87747 -7.95769 -4.45923
M9 M10 M11 t
-3.79312 0.92531 6.08789 -0.08966
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-7.9745 -1.2844 0.1419 2.0198 8.3440
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.88867 11.04279 1.620 0.112730
T.I.P. 0.59324 0.10965 5.410 2.78e-06 ***
`y(t-1)` 0.20515 0.11741 1.747 0.087875 .
`y(t-2)` 0.11515 0.11661 0.988 0.329031
M1 1.45879 2.86821 0.509 0.613689
M2 -2.14950 2.49762 -0.861 0.394334
M3 -1.21609 2.80661 -0.433 0.667019
M4 -1.28122 2.86370 -0.447 0.656886
M5 10.79173 3.04013 3.550 0.000966 ***
M6 4.87747 2.72125 1.792 0.080280 .
M7 -7.95769 2.74478 -2.899 0.005926 **
M8 -4.45923 2.98533 -1.494 0.142725
M9 -3.79312 2.56813 -1.477 0.147136
M10 0.92531 2.71363 0.341 0.734813
M11 6.08789 2.74619 2.217 0.032102 *
t -0.08966 0.03388 -2.647 0.011394 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.717 on 42 degrees of freedom
Multiple R-squared: 0.8222, Adjusted R-squared: 0.7588
F-statistic: 12.95 on 15 and 42 DF, p-value: 3.165e-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.8051327 0.3897345 0.1948673
[2,] 0.7050336 0.5899328 0.2949664
[3,] 0.5871037 0.8257926 0.4128963
[4,] 0.6180238 0.7639525 0.3819762
[5,] 0.5140448 0.9719104 0.4859552
[6,] 0.4262110 0.8524219 0.5737890
[7,] 0.3247051 0.6494102 0.6752949
[8,] 0.2927108 0.5854216 0.7072892
[9,] 0.2168166 0.4336332 0.7831834
[10,] 0.2742513 0.5485027 0.7257487
[11,] 0.3363323 0.6726646 0.6636677
[12,] 0.2767512 0.5535023 0.7232488
[13,] 0.2242203 0.4484407 0.7757797
[14,] 0.5494315 0.9011371 0.4505685
[15,] 0.4553826 0.9107652 0.5446174
[16,] 0.4023501 0.8047002 0.5976499
[17,] 0.3055332 0.6110664 0.6944668
[18,] 0.4513527 0.9027054 0.5486473
[19,] 0.3441789 0.6883579 0.6558211
[20,] 0.2298648 0.4597297 0.7701352
[21,] 0.3099202 0.6198404 0.6900798
> postscript(file="/var/www/html/rcomp/tmp/1u5ci1292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2u5ci1292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3u5ci1292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/45et31292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/55et31292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 58
Frequency = 1
1 2 3 4 5 6
-0.09369603 -0.36568509 1.88104226 6.44367193 -1.06927075 -4.46497969
7 8 9 10 11 12
-0.27726747 1.54936253 2.32042380 -3.78937768 0.77063261 2.71277439
13 14 15 16 17 18
0.81792537 -0.20360775 1.46635120 -6.31876546 -1.06106431 0.46575499
19 20 21 22 23 24
3.37368555 2.58291660 -2.46583554 2.43305028 -2.70528613 -1.30814323
25 26 27 28 29 30
0.89532865 2.20946662 -0.10556094 -6.39312711 3.83059019 -3.13159572
31 32 33 34 35 36
-5.53149452 -7.97450128 0.32704777 3.08028985 2.37961624 4.14453019
37 38 39 40 41 42
-0.97046417 -0.12701698 -5.12260483 5.55750632 -0.04328861 8.34397382
43 44 45 46 47 48
1.04545289 0.62788150 -0.68991215 -3.79005160 -0.44496272 -5.54916135
49 50 51 52 53 54
-0.64909382 -1.51315680 1.88077231 0.71071432 -1.65696652 -1.21315340
55 56 57 58
1.38962355 3.21434065 0.50827612 2.06608915
> postscript(file="/var/www/html/rcomp/tmp/65et31292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.09369603 NA
1 -0.36568509 -0.09369603
2 1.88104226 -0.36568509
3 6.44367193 1.88104226
4 -1.06927075 6.44367193
5 -4.46497969 -1.06927075
6 -0.27726747 -4.46497969
7 1.54936253 -0.27726747
8 2.32042380 1.54936253
9 -3.78937768 2.32042380
10 0.77063261 -3.78937768
11 2.71277439 0.77063261
12 0.81792537 2.71277439
13 -0.20360775 0.81792537
14 1.46635120 -0.20360775
15 -6.31876546 1.46635120
16 -1.06106431 -6.31876546
17 0.46575499 -1.06106431
18 3.37368555 0.46575499
19 2.58291660 3.37368555
20 -2.46583554 2.58291660
21 2.43305028 -2.46583554
22 -2.70528613 2.43305028
23 -1.30814323 -2.70528613
24 0.89532865 -1.30814323
25 2.20946662 0.89532865
26 -0.10556094 2.20946662
27 -6.39312711 -0.10556094
28 3.83059019 -6.39312711
29 -3.13159572 3.83059019
30 -5.53149452 -3.13159572
31 -7.97450128 -5.53149452
32 0.32704777 -7.97450128
33 3.08028985 0.32704777
34 2.37961624 3.08028985
35 4.14453019 2.37961624
36 -0.97046417 4.14453019
37 -0.12701698 -0.97046417
38 -5.12260483 -0.12701698
39 5.55750632 -5.12260483
40 -0.04328861 5.55750632
41 8.34397382 -0.04328861
42 1.04545289 8.34397382
43 0.62788150 1.04545289
44 -0.68991215 0.62788150
45 -3.79005160 -0.68991215
46 -0.44496272 -3.79005160
47 -5.54916135 -0.44496272
48 -0.64909382 -5.54916135
49 -1.51315680 -0.64909382
50 1.88077231 -1.51315680
51 0.71071432 1.88077231
52 -1.65696652 0.71071432
53 -1.21315340 -1.65696652
54 1.38962355 -1.21315340
55 3.21434065 1.38962355
56 0.50827612 3.21434065
57 2.06608915 0.50827612
58 NA 2.06608915
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.36568509 -0.09369603
[2,] 1.88104226 -0.36568509
[3,] 6.44367193 1.88104226
[4,] -1.06927075 6.44367193
[5,] -4.46497969 -1.06927075
[6,] -0.27726747 -4.46497969
[7,] 1.54936253 -0.27726747
[8,] 2.32042380 1.54936253
[9,] -3.78937768 2.32042380
[10,] 0.77063261 -3.78937768
[11,] 2.71277439 0.77063261
[12,] 0.81792537 2.71277439
[13,] -0.20360775 0.81792537
[14,] 1.46635120 -0.20360775
[15,] -6.31876546 1.46635120
[16,] -1.06106431 -6.31876546
[17,] 0.46575499 -1.06106431
[18,] 3.37368555 0.46575499
[19,] 2.58291660 3.37368555
[20,] -2.46583554 2.58291660
[21,] 2.43305028 -2.46583554
[22,] -2.70528613 2.43305028
[23,] -1.30814323 -2.70528613
[24,] 0.89532865 -1.30814323
[25,] 2.20946662 0.89532865
[26,] -0.10556094 2.20946662
[27,] -6.39312711 -0.10556094
[28,] 3.83059019 -6.39312711
[29,] -3.13159572 3.83059019
[30,] -5.53149452 -3.13159572
[31,] -7.97450128 -5.53149452
[32,] 0.32704777 -7.97450128
[33,] 3.08028985 0.32704777
[34,] 2.37961624 3.08028985
[35,] 4.14453019 2.37961624
[36,] -0.97046417 4.14453019
[37,] -0.12701698 -0.97046417
[38,] -5.12260483 -0.12701698
[39,] 5.55750632 -5.12260483
[40,] -0.04328861 5.55750632
[41,] 8.34397382 -0.04328861
[42,] 1.04545289 8.34397382
[43,] 0.62788150 1.04545289
[44,] -0.68991215 0.62788150
[45,] -3.79005160 -0.68991215
[46,] -0.44496272 -3.79005160
[47,] -5.54916135 -0.44496272
[48,] -0.64909382 -5.54916135
[49,] -1.51315680 -0.64909382
[50,] 1.88077231 -1.51315680
[51,] 0.71071432 1.88077231
[52,] -1.65696652 0.71071432
[53,] -1.21315340 -1.65696652
[54,] 1.38962355 -1.21315340
[55,] 3.21434065 1.38962355
[56,] 0.50827612 3.21434065
[57,] 2.06608915 0.50827612
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.36568509 -0.09369603
2 1.88104226 -0.36568509
3 6.44367193 1.88104226
4 -1.06927075 6.44367193
5 -4.46497969 -1.06927075
6 -0.27726747 -4.46497969
7 1.54936253 -0.27726747
8 2.32042380 1.54936253
9 -3.78937768 2.32042380
10 0.77063261 -3.78937768
11 2.71277439 0.77063261
12 0.81792537 2.71277439
13 -0.20360775 0.81792537
14 1.46635120 -0.20360775
15 -6.31876546 1.46635120
16 -1.06106431 -6.31876546
17 0.46575499 -1.06106431
18 3.37368555 0.46575499
19 2.58291660 3.37368555
20 -2.46583554 2.58291660
21 2.43305028 -2.46583554
22 -2.70528613 2.43305028
23 -1.30814323 -2.70528613
24 0.89532865 -1.30814323
25 2.20946662 0.89532865
26 -0.10556094 2.20946662
27 -6.39312711 -0.10556094
28 3.83059019 -6.39312711
29 -3.13159572 3.83059019
30 -5.53149452 -3.13159572
31 -7.97450128 -5.53149452
32 0.32704777 -7.97450128
33 3.08028985 0.32704777
34 2.37961624 3.08028985
35 4.14453019 2.37961624
36 -0.97046417 4.14453019
37 -0.12701698 -0.97046417
38 -5.12260483 -0.12701698
39 5.55750632 -5.12260483
40 -0.04328861 5.55750632
41 8.34397382 -0.04328861
42 1.04545289 8.34397382
43 0.62788150 1.04545289
44 -0.68991215 0.62788150
45 -3.79005160 -0.68991215
46 -0.44496272 -3.79005160
47 -5.54916135 -0.44496272
48 -0.64909382 -5.54916135
49 -1.51315680 -0.64909382
50 1.88077231 -1.51315680
51 0.71071432 1.88077231
52 -1.65696652 0.71071432
53 -1.21315340 -1.65696652
54 1.38962355 -1.21315340
55 3.21434065 1.38962355
56 0.50827612 3.21434065
57 2.06608915 0.50827612
> 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/7xnbo1292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8qea91292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9qea91292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10qea91292672749.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/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/114o801292672749.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/12fxpl1292672749.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/134z4f1292672749.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/14w8lh1292672749.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/15iqkn1292672749.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/16w00w1292672749.tab")
+ }
>
> try(system("convert tmp/1u5ci1292672749.ps tmp/1u5ci1292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/2u5ci1292672749.ps tmp/2u5ci1292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/3u5ci1292672749.ps tmp/3u5ci1292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/45et31292672749.ps tmp/45et31292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/55et31292672749.ps tmp/55et31292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/65et31292672749.ps tmp/65et31292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/7xnbo1292672749.ps tmp/7xnbo1292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/8qea91292672749.ps tmp/8qea91292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/9qea91292672749.ps tmp/9qea91292672749.png",intern=TRUE))
character(0)
> try(system("convert tmp/10qea91292672749.ps tmp/10qea91292672749.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.372 1.625 6.234