R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-pc-linux-gnu (32-bit)
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.34
+ ,98.60
+ ,96.33
+ ,102.60
+ ,96.90
+ ,96.33
+ ,100.69
+ ,95.10
+ ,95.05
+ ,105.67
+ ,97.00
+ ,96.84
+ ,123.61
+ ,112.70
+ ,96.92
+ ,113.08
+ ,102.90
+ ,97.44
+ ,106.46
+ ,97.40
+ ,97.78
+ ,123.38
+ ,111.40
+ ,97.69
+ ,109.87
+ ,87.40
+ ,96.67
+ ,95.74
+ ,96.80
+ ,98.29
+ ,123.06
+ ,114.10
+ ,98.20
+ ,123.39
+ ,110.30
+ ,98.71
+ ,120.28
+ ,103.90
+ ,98.54
+ ,115.33
+ ,101.60
+ ,98.20
+ ,110.40
+ ,94.60
+ ,100.80
+ ,114.49
+ ,95.90
+ ,101.33
+ ,132.03
+ ,104.70
+ ,101.88
+ ,123.16
+ ,102.80
+ ,101.85
+ ,118.82
+ ,98.10
+ ,102.04
+ ,128.32
+ ,113.90
+ ,102.22
+ ,112.24
+ ,80.90
+ ,102.63
+ ,104.53
+ ,95.70
+ ,102.65
+ ,132.57
+ ,113.20
+ ,102.54
+ ,122.52
+ ,105.90
+ ,102.37
+ ,131.80
+ ,108.80
+ ,102.68
+ ,124.55
+ ,102.30
+ ,102.76
+ ,120.96
+ ,99.00
+ ,102.82
+ ,122.60
+ ,100.70
+ ,103.31
+ ,145.52
+ ,115.50
+ ,103.23
+ ,118.57
+ ,100.70
+ ,103.60
+ ,134.25
+ ,109.90
+ ,103.95
+ ,136.70
+ ,114.60
+ ,103.93
+ ,121.37
+ ,85.40
+ ,104.25
+ ,111.63
+ ,100.50
+ ,104.38
+ ,134.42
+ ,114.80
+ ,104.36
+ ,137.65
+ ,116.50
+ ,104.32
+ ,137.86
+ ,112.90
+ ,104.58
+ ,119.77
+ ,102.00
+ ,104.68
+ ,130.69
+ ,106.00
+ ,104.92
+ ,128.28
+ ,105.30
+ ,105.46
+ ,147.45
+ ,118.80
+ ,105.23
+ ,128.42
+ ,106.10
+ ,105.58
+ ,136.90
+ ,109.30
+ ,105.34
+ ,143.95
+ ,117.20
+ ,105.28
+ ,135.64
+ ,92.50
+ ,105.70
+ ,122.48
+ ,104.20
+ ,105.67
+ ,136.83
+ ,112.50
+ ,105.71
+ ,153.04
+ ,122.40
+ ,106.19
+ ,142.71
+ ,113.30
+ ,106.93
+ ,123.46
+ ,100.00
+ ,107.44
+ ,144.37
+ ,110.70
+ ,107.85
+ ,146.15
+ ,112.80
+ ,108.71
+ ,147.61
+ ,109.80
+ ,109.32
+ ,158.51
+ ,117.30
+ ,109.49
+ ,147.40
+ ,109.10
+ ,110.20
+ ,165.05
+ ,115.90
+ ,110.62
+ ,154.64
+ ,96.00
+ ,111.22
+ ,126.20
+ ,99.80
+ ,110.88
+ ,157.36
+ ,116.80
+ ,111.15
+ ,154.15
+ ,115.70
+ ,111.29
+ ,123.21
+ ,99.40
+ ,111.09
+ ,113.07
+ ,94.30
+ ,111.24
+ ,110.45
+ ,91.00
+ ,111.45
+ ,113.57
+ ,93.20
+ ,111.75
+ ,122.44
+ ,103.10
+ ,111.07
+ ,114.93
+ ,94.10
+ ,111.17
+ ,111.85
+ ,91.80
+ ,110.96
+ ,126.04
+ ,102.70
+ ,110.50
+ ,121.34
+ ,82.60
+ ,110.48
+ ,124.36
+ ,89.10
+ ,110.66)
+ ,dim=c(3
+ ,70)
+ ,dimnames=list(c('Uitvoer'
+ ,'TIP'
+ ,'index/cons')
+ ,1:70))
> y <- array(NA,dim=c(3,70),dimnames=list(c('Uitvoer','TIP','index/cons'),1:70))
> 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'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
Uitvoer TIP index/cons M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 103.34 98.6 96.33 1 0 0 0 0 0 0 0 0 0 0 1
2 102.60 96.9 96.33 0 1 0 0 0 0 0 0 0 0 0 2
3 100.69 95.1 95.05 0 0 1 0 0 0 0 0 0 0 0 3
4 105.67 97.0 96.84 0 0 0 1 0 0 0 0 0 0 0 4
5 123.61 112.7 96.92 0 0 0 0 1 0 0 0 0 0 0 5
6 113.08 102.9 97.44 0 0 0 0 0 1 0 0 0 0 0 6
7 106.46 97.4 97.78 0 0 0 0 0 0 1 0 0 0 0 7
8 123.38 111.4 97.69 0 0 0 0 0 0 0 1 0 0 0 8
9 109.87 87.4 96.67 0 0 0 0 0 0 0 0 1 0 0 9
10 95.74 96.8 98.29 0 0 0 0 0 0 0 0 0 1 0 10
11 123.06 114.1 98.20 0 0 0 0 0 0 0 0 0 0 1 11
12 123.39 110.3 98.71 0 0 0 0 0 0 0 0 0 0 0 12
13 120.28 103.9 98.54 1 0 0 0 0 0 0 0 0 0 0 13
14 115.33 101.6 98.20 0 1 0 0 0 0 0 0 0 0 0 14
15 110.40 94.6 100.80 0 0 1 0 0 0 0 0 0 0 0 15
16 114.49 95.9 101.33 0 0 0 1 0 0 0 0 0 0 0 16
17 132.03 104.7 101.88 0 0 0 0 1 0 0 0 0 0 0 17
18 123.16 102.8 101.85 0 0 0 0 0 1 0 0 0 0 0 18
19 118.82 98.1 102.04 0 0 0 0 0 0 1 0 0 0 0 19
20 128.32 113.9 102.22 0 0 0 0 0 0 0 1 0 0 0 20
21 112.24 80.9 102.63 0 0 0 0 0 0 0 0 1 0 0 21
22 104.53 95.7 102.65 0 0 0 0 0 0 0 0 0 1 0 22
23 132.57 113.2 102.54 0 0 0 0 0 0 0 0 0 0 1 23
24 122.52 105.9 102.37 0 0 0 0 0 0 0 0 0 0 0 24
25 131.80 108.8 102.68 1 0 0 0 0 0 0 0 0 0 0 25
26 124.55 102.3 102.76 0 1 0 0 0 0 0 0 0 0 0 26
27 120.96 99.0 102.82 0 0 1 0 0 0 0 0 0 0 0 27
28 122.60 100.7 103.31 0 0 0 1 0 0 0 0 0 0 0 28
29 145.52 115.5 103.23 0 0 0 0 1 0 0 0 0 0 0 29
30 118.57 100.7 103.60 0 0 0 0 0 1 0 0 0 0 0 30
31 134.25 109.9 103.95 0 0 0 0 0 0 1 0 0 0 0 31
32 136.70 114.6 103.93 0 0 0 0 0 0 0 1 0 0 0 32
33 121.37 85.4 104.25 0 0 0 0 0 0 0 0 1 0 0 33
34 111.63 100.5 104.38 0 0 0 0 0 0 0 0 0 1 0 34
35 134.42 114.8 104.36 0 0 0 0 0 0 0 0 0 0 1 35
36 137.65 116.5 104.32 0 0 0 0 0 0 0 0 0 0 0 36
37 137.86 112.9 104.58 1 0 0 0 0 0 0 0 0 0 0 37
38 119.77 102.0 104.68 0 1 0 0 0 0 0 0 0 0 0 38
39 130.69 106.0 104.92 0 0 1 0 0 0 0 0 0 0 0 39
40 128.28 105.3 105.46 0 0 0 1 0 0 0 0 0 0 0 40
41 147.45 118.8 105.23 0 0 0 0 1 0 0 0 0 0 0 41
42 128.42 106.1 105.58 0 0 0 0 0 1 0 0 0 0 0 42
43 136.90 109.3 105.34 0 0 0 0 0 0 1 0 0 0 0 43
44 143.95 117.2 105.28 0 0 0 0 0 0 0 1 0 0 0 44
45 135.64 92.5 105.70 0 0 0 0 0 0 0 0 1 0 0 45
46 122.48 104.2 105.67 0 0 0 0 0 0 0 0 0 1 0 46
47 136.83 112.5 105.71 0 0 0 0 0 0 0 0 0 0 1 47
48 153.04 122.4 106.19 0 0 0 0 0 0 0 0 0 0 0 48
49 142.71 113.3 106.93 1 0 0 0 0 0 0 0 0 0 0 49
50 123.46 100.0 107.44 0 1 0 0 0 0 0 0 0 0 0 50
51 144.37 110.7 107.85 0 0 1 0 0 0 0 0 0 0 0 51
52 146.15 112.8 108.71 0 0 0 1 0 0 0 0 0 0 0 52
53 147.61 109.8 109.32 0 0 0 0 1 0 0 0 0 0 0 53
54 158.51 117.3 109.49 0 0 0 0 0 1 0 0 0 0 0 54
55 147.40 109.1 110.20 0 0 0 0 0 0 1 0 0 0 0 55
56 165.05 115.9 110.62 0 0 0 0 0 0 0 1 0 0 0 56
57 154.64 96.0 111.22 0 0 0 0 0 0 0 0 1 0 0 57
58 126.20 99.8 110.88 0 0 0 0 0 0 0 0 0 1 0 58
59 157.36 116.8 111.15 0 0 0 0 0 0 0 0 0 0 1 59
60 154.15 115.7 111.29 0 0 0 0 0 0 0 0 0 0 0 60
61 123.21 99.4 111.09 1 0 0 0 0 0 0 0 0 0 0 61
62 113.07 94.3 111.24 0 1 0 0 0 0 0 0 0 0 0 62
63 110.45 91.0 111.45 0 0 1 0 0 0 0 0 0 0 0 63
64 113.57 93.2 111.75 0 0 0 1 0 0 0 0 0 0 0 64
65 122.44 103.1 111.07 0 0 0 0 1 0 0 0 0 0 0 65
66 114.93 94.1 111.17 0 0 0 0 0 1 0 0 0 0 0 66
67 111.85 91.8 110.96 0 0 0 0 0 0 1 0 0 0 0 67
68 126.04 102.7 110.50 0 0 0 0 0 0 0 1 0 0 0 68
69 121.34 82.6 110.48 0 0 0 0 0 0 0 0 1 0 0 69
70 124.36 89.1 110.66 0 0 0 0 0 0 0 0 0 1 0 70
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) TIP `index/cons` M1 M2
-331.1417 1.7062 2.7294 3.8569 5.1806
M3 M4 M5 M6 M7
7.7940 5.8286 3.6915 4.5637 6.5437
M8 M9 M10 M11 t
1.0635 32.5649 3.0244 -1.3079 -0.3033
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-9.4590 -2.4815 -0.1555 2.3653 19.6506
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -331.1417 63.5659 -5.209 2.92e-06 ***
TIP 1.7062 0.1064 16.035 < 2e-16 ***
`index/cons` 2.7294 0.6505 4.196 9.98e-05 ***
M1 3.8569 3.1316 1.232 0.2233
M2 5.1806 3.3912 1.528 0.1323
M3 7.7940 3.3955 2.295 0.0255 *
M4 5.8286 3.3449 1.743 0.0870 .
M5 3.6915 3.0397 1.214 0.2298
M6 4.5637 3.2081 1.423 0.1605
M7 6.5437 3.2604 2.007 0.0497 *
M8 1.0635 3.0183 0.352 0.7259
M9 32.5649 4.1461 7.854 1.51e-10 ***
M10 3.0244 3.4926 0.866 0.3903
M11 -1.3079 3.1473 -0.416 0.6794
t -0.3033 0.1530 -1.982 0.0525 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.976 on 55 degrees of freedom
Multiple R-squared: 0.917, Adjusted R-squared: 0.8959
F-statistic: 43.41 on 14 and 55 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,] 2.736297e-02 5.472593e-02 0.9726370
[2,] 7.843157e-03 1.568631e-02 0.9921568
[3,] 2.876702e-02 5.753405e-02 0.9712330
[4,] 1.982511e-02 3.965022e-02 0.9801749
[5,] 7.962019e-03 1.592404e-02 0.9920380
[6,] 2.781986e-03 5.563972e-03 0.9972180
[7,] 2.051621e-02 4.103242e-02 0.9794838
[8,] 9.692686e-03 1.938537e-02 0.9903073
[9,] 5.062094e-03 1.012419e-02 0.9949379
[10,] 3.093621e-03 6.187242e-03 0.9969064
[11,] 3.614488e-03 7.228975e-03 0.9963855
[12,] 2.115722e-03 4.231443e-03 0.9978843
[13,] 7.855269e-03 1.571054e-02 0.9921447
[14,] 4.097045e-03 8.194089e-03 0.9959030
[15,] 2.010226e-03 4.020453e-03 0.9979898
[16,] 1.167204e-03 2.334409e-03 0.9988328
[17,] 8.979914e-04 1.795983e-03 0.9991020
[18,] 6.041231e-04 1.208246e-03 0.9993959
[19,] 3.484115e-04 6.968230e-04 0.9996516
[20,] 1.620908e-04 3.241817e-04 0.9998379
[21,] 3.241405e-04 6.482810e-04 0.9996759
[22,] 1.508809e-04 3.017618e-04 0.9998491
[23,] 9.453009e-05 1.890602e-04 0.9999055
[24,] 4.297847e-05 8.595695e-05 0.9999570
[25,] 1.683680e-05 3.367360e-05 0.9999832
[26,] 9.168216e-06 1.833643e-05 0.9999908
[27,] 9.711148e-06 1.942230e-05 0.9999903
[28,] 7.815818e-06 1.563164e-05 0.9999922
[29,] 3.505190e-05 7.010380e-05 0.9999649
[30,] 1.488580e-05 2.977159e-05 0.9999851
[31,] 1.861602e-05 3.723204e-05 0.9999814
[32,] 7.973740e-06 1.594748e-05 0.9999920
[33,] 3.962080e-06 7.924161e-06 0.9999960
[34,] 1.184450e-06 2.368900e-06 0.9999988
[35,] 5.853134e-07 1.170627e-06 0.9999994
> postscript(file="/var/fisher/rcomp/tmp/1ras61356027354.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/fisher/rcomp/tmp/2bgxs1356027354.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/fisher/rcomp/tmp/3i1ex1356027354.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/fisher/rcomp/tmp/4yhng1356027354.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/fisher/rcomp/tmp/5e6061356027354.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 = 70
Frequency = 1
1 2 3 4 5 6
-0.22819084 0.91197503 3.25671927 2.37801198 -4.24730271 -0.04461951
7 8 9 10 11 12
0.11485178 -0.82287051 -1.79802579 -6.54419458 -3.86030992 0.55674114
13 14 15 16 17 18
5.27688863 4.15877891 1.76567310 4.45975047 7.92443614 1.80926558
19 20 21 22 23 24
3.29318369 -8.87265184 -0.96500996 -4.13763236 -1.02040073 0.84437402
25 26 27 28 29 30
0.77668298 3.37828683 2.94492692 2.61569824 2.94267550 -0.33419698
31 32 33 34 35 36
-2.98325488 -2.71431596 -0.29461146 -6.30933126 -3.22788614 -3.79379332
37 38 39 40 41 42
-1.70467166 -2.49034763 -1.36030914 -1.78111297 -2.57665530 -1.46197309
43 44 45 46 47 48
0.53656167 0.05481642 1.54365049 -1.65326119 3.06165793 0.06556280
49 50 51 52 53 54
-0.31129837 0.71886172 -0.05668338 -1.93827758 5.41587959 2.48648559
55 56 57 58 59 60
1.75283141 12.43779488 3.14554352 -1.00621896 5.04693885 2.32711537
61 62 63 64 65 66
-3.80941072 -6.67755486 -6.55032677 -5.73407015 -9.45903321 -2.45496159
67 68 69 70
-2.71417367 -0.08277299 -1.63154680 19.65063834
> postscript(file="/var/fisher/rcomp/tmp/6eku61356027354.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 = 70
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.22819084 NA
1 0.91197503 -0.22819084
2 3.25671927 0.91197503
3 2.37801198 3.25671927
4 -4.24730271 2.37801198
5 -0.04461951 -4.24730271
6 0.11485178 -0.04461951
7 -0.82287051 0.11485178
8 -1.79802579 -0.82287051
9 -6.54419458 -1.79802579
10 -3.86030992 -6.54419458
11 0.55674114 -3.86030992
12 5.27688863 0.55674114
13 4.15877891 5.27688863
14 1.76567310 4.15877891
15 4.45975047 1.76567310
16 7.92443614 4.45975047
17 1.80926558 7.92443614
18 3.29318369 1.80926558
19 -8.87265184 3.29318369
20 -0.96500996 -8.87265184
21 -4.13763236 -0.96500996
22 -1.02040073 -4.13763236
23 0.84437402 -1.02040073
24 0.77668298 0.84437402
25 3.37828683 0.77668298
26 2.94492692 3.37828683
27 2.61569824 2.94492692
28 2.94267550 2.61569824
29 -0.33419698 2.94267550
30 -2.98325488 -0.33419698
31 -2.71431596 -2.98325488
32 -0.29461146 -2.71431596
33 -6.30933126 -0.29461146
34 -3.22788614 -6.30933126
35 -3.79379332 -3.22788614
36 -1.70467166 -3.79379332
37 -2.49034763 -1.70467166
38 -1.36030914 -2.49034763
39 -1.78111297 -1.36030914
40 -2.57665530 -1.78111297
41 -1.46197309 -2.57665530
42 0.53656167 -1.46197309
43 0.05481642 0.53656167
44 1.54365049 0.05481642
45 -1.65326119 1.54365049
46 3.06165793 -1.65326119
47 0.06556280 3.06165793
48 -0.31129837 0.06556280
49 0.71886172 -0.31129837
50 -0.05668338 0.71886172
51 -1.93827758 -0.05668338
52 5.41587959 -1.93827758
53 2.48648559 5.41587959
54 1.75283141 2.48648559
55 12.43779488 1.75283141
56 3.14554352 12.43779488
57 -1.00621896 3.14554352
58 5.04693885 -1.00621896
59 2.32711537 5.04693885
60 -3.80941072 2.32711537
61 -6.67755486 -3.80941072
62 -6.55032677 -6.67755486
63 -5.73407015 -6.55032677
64 -9.45903321 -5.73407015
65 -2.45496159 -9.45903321
66 -2.71417367 -2.45496159
67 -0.08277299 -2.71417367
68 -1.63154680 -0.08277299
69 19.65063834 -1.63154680
70 NA 19.65063834
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.91197503 -0.22819084
[2,] 3.25671927 0.91197503
[3,] 2.37801198 3.25671927
[4,] -4.24730271 2.37801198
[5,] -0.04461951 -4.24730271
[6,] 0.11485178 -0.04461951
[7,] -0.82287051 0.11485178
[8,] -1.79802579 -0.82287051
[9,] -6.54419458 -1.79802579
[10,] -3.86030992 -6.54419458
[11,] 0.55674114 -3.86030992
[12,] 5.27688863 0.55674114
[13,] 4.15877891 5.27688863
[14,] 1.76567310 4.15877891
[15,] 4.45975047 1.76567310
[16,] 7.92443614 4.45975047
[17,] 1.80926558 7.92443614
[18,] 3.29318369 1.80926558
[19,] -8.87265184 3.29318369
[20,] -0.96500996 -8.87265184
[21,] -4.13763236 -0.96500996
[22,] -1.02040073 -4.13763236
[23,] 0.84437402 -1.02040073
[24,] 0.77668298 0.84437402
[25,] 3.37828683 0.77668298
[26,] 2.94492692 3.37828683
[27,] 2.61569824 2.94492692
[28,] 2.94267550 2.61569824
[29,] -0.33419698 2.94267550
[30,] -2.98325488 -0.33419698
[31,] -2.71431596 -2.98325488
[32,] -0.29461146 -2.71431596
[33,] -6.30933126 -0.29461146
[34,] -3.22788614 -6.30933126
[35,] -3.79379332 -3.22788614
[36,] -1.70467166 -3.79379332
[37,] -2.49034763 -1.70467166
[38,] -1.36030914 -2.49034763
[39,] -1.78111297 -1.36030914
[40,] -2.57665530 -1.78111297
[41,] -1.46197309 -2.57665530
[42,] 0.53656167 -1.46197309
[43,] 0.05481642 0.53656167
[44,] 1.54365049 0.05481642
[45,] -1.65326119 1.54365049
[46,] 3.06165793 -1.65326119
[47,] 0.06556280 3.06165793
[48,] -0.31129837 0.06556280
[49,] 0.71886172 -0.31129837
[50,] -0.05668338 0.71886172
[51,] -1.93827758 -0.05668338
[52,] 5.41587959 -1.93827758
[53,] 2.48648559 5.41587959
[54,] 1.75283141 2.48648559
[55,] 12.43779488 1.75283141
[56,] 3.14554352 12.43779488
[57,] -1.00621896 3.14554352
[58,] 5.04693885 -1.00621896
[59,] 2.32711537 5.04693885
[60,] -3.80941072 2.32711537
[61,] -6.67755486 -3.80941072
[62,] -6.55032677 -6.67755486
[63,] -5.73407015 -6.55032677
[64,] -9.45903321 -5.73407015
[65,] -2.45496159 -9.45903321
[66,] -2.71417367 -2.45496159
[67,] -0.08277299 -2.71417367
[68,] -1.63154680 -0.08277299
[69,] 19.65063834 -1.63154680
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.91197503 -0.22819084
2 3.25671927 0.91197503
3 2.37801198 3.25671927
4 -4.24730271 2.37801198
5 -0.04461951 -4.24730271
6 0.11485178 -0.04461951
7 -0.82287051 0.11485178
8 -1.79802579 -0.82287051
9 -6.54419458 -1.79802579
10 -3.86030992 -6.54419458
11 0.55674114 -3.86030992
12 5.27688863 0.55674114
13 4.15877891 5.27688863
14 1.76567310 4.15877891
15 4.45975047 1.76567310
16 7.92443614 4.45975047
17 1.80926558 7.92443614
18 3.29318369 1.80926558
19 -8.87265184 3.29318369
20 -0.96500996 -8.87265184
21 -4.13763236 -0.96500996
22 -1.02040073 -4.13763236
23 0.84437402 -1.02040073
24 0.77668298 0.84437402
25 3.37828683 0.77668298
26 2.94492692 3.37828683
27 2.61569824 2.94492692
28 2.94267550 2.61569824
29 -0.33419698 2.94267550
30 -2.98325488 -0.33419698
31 -2.71431596 -2.98325488
32 -0.29461146 -2.71431596
33 -6.30933126 -0.29461146
34 -3.22788614 -6.30933126
35 -3.79379332 -3.22788614
36 -1.70467166 -3.79379332
37 -2.49034763 -1.70467166
38 -1.36030914 -2.49034763
39 -1.78111297 -1.36030914
40 -2.57665530 -1.78111297
41 -1.46197309 -2.57665530
42 0.53656167 -1.46197309
43 0.05481642 0.53656167
44 1.54365049 0.05481642
45 -1.65326119 1.54365049
46 3.06165793 -1.65326119
47 0.06556280 3.06165793
48 -0.31129837 0.06556280
49 0.71886172 -0.31129837
50 -0.05668338 0.71886172
51 -1.93827758 -0.05668338
52 5.41587959 -1.93827758
53 2.48648559 5.41587959
54 1.75283141 2.48648559
55 12.43779488 1.75283141
56 3.14554352 12.43779488
57 -1.00621896 3.14554352
58 5.04693885 -1.00621896
59 2.32711537 5.04693885
60 -3.80941072 2.32711537
61 -6.67755486 -3.80941072
62 -6.55032677 -6.67755486
63 -5.73407015 -6.55032677
64 -9.45903321 -5.73407015
65 -2.45496159 -9.45903321
66 -2.71417367 -2.45496159
67 -0.08277299 -2.71417367
68 -1.63154680 -0.08277299
69 19.65063834 -1.63154680
> 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/fisher/rcomp/tmp/7ytge1356027354.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/fisher/rcomp/tmp/8lokx1356027354.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/fisher/rcomp/tmp/990na1356027354.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/fisher/rcomp/tmp/10hv561356027354.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/11g98e1356027354.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/fisher/rcomp/tmp/127e8s1356027354.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/fisher/rcomp/tmp/13y6es1356027354.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/fisher/rcomp/tmp/14b4631356027354.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/fisher/rcomp/tmp/15jhk51356027354.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/fisher/rcomp/tmp/161viu1356027354.tab")
+ }
>
> try(system("convert tmp/1ras61356027354.ps tmp/1ras61356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/2bgxs1356027354.ps tmp/2bgxs1356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/3i1ex1356027354.ps tmp/3i1ex1356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/4yhng1356027354.ps tmp/4yhng1356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/5e6061356027354.ps tmp/5e6061356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/6eku61356027354.ps tmp/6eku61356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ytge1356027354.ps tmp/7ytge1356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/8lokx1356027354.ps tmp/8lokx1356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/990na1356027354.ps tmp/990na1356027354.png",intern=TRUE))
character(0)
> try(system("convert tmp/10hv561356027354.ps tmp/10hv561356027354.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.554 1.814 8.364