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.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'
+ ,'cons')
+ ,1:70))
> y <- array(NA,dim=c(3,70),dimnames=list(c('Uitvoer','TIP','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 = 'No 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
Uitvoer TIP cons M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 103.34 98.6 96.33 1 0 0 0 0 0 0 0 0 0 0
2 102.60 96.9 96.33 0 1 0 0 0 0 0 0 0 0 0
3 100.69 95.1 95.05 0 0 1 0 0 0 0 0 0 0 0
4 105.67 97.0 96.84 0 0 0 1 0 0 0 0 0 0 0
5 123.61 112.7 96.92 0 0 0 0 1 0 0 0 0 0 0
6 113.08 102.9 97.44 0 0 0 0 0 1 0 0 0 0 0
7 106.46 97.4 97.78 0 0 0 0 0 0 1 0 0 0 0
8 123.38 111.4 97.69 0 0 0 0 0 0 0 1 0 0 0
9 109.87 87.4 96.67 0 0 0 0 0 0 0 0 1 0 0
10 95.74 96.8 98.29 0 0 0 0 0 0 0 0 0 1 0
11 123.06 114.1 98.20 0 0 0 0 0 0 0 0 0 0 1
12 123.39 110.3 98.71 0 0 0 0 0 0 0 0 0 0 0
13 120.28 103.9 98.54 1 0 0 0 0 0 0 0 0 0 0
14 115.33 101.6 98.20 0 1 0 0 0 0 0 0 0 0 0
15 110.40 94.6 100.80 0 0 1 0 0 0 0 0 0 0 0
16 114.49 95.9 101.33 0 0 0 1 0 0 0 0 0 0 0
17 132.03 104.7 101.88 0 0 0 0 1 0 0 0 0 0 0
18 123.16 102.8 101.85 0 0 0 0 0 1 0 0 0 0 0
19 118.82 98.1 102.04 0 0 0 0 0 0 1 0 0 0 0
20 128.32 113.9 102.22 0 0 0 0 0 0 0 1 0 0 0
21 112.24 80.9 102.63 0 0 0 0 0 0 0 0 1 0 0
22 104.53 95.7 102.65 0 0 0 0 0 0 0 0 0 1 0
23 132.57 113.2 102.54 0 0 0 0 0 0 0 0 0 0 1
24 122.52 105.9 102.37 0 0 0 0 0 0 0 0 0 0 0
25 131.80 108.8 102.68 1 0 0 0 0 0 0 0 0 0 0
26 124.55 102.3 102.76 0 1 0 0 0 0 0 0 0 0 0
27 120.96 99.0 102.82 0 0 1 0 0 0 0 0 0 0 0
28 122.60 100.7 103.31 0 0 0 1 0 0 0 0 0 0 0
29 145.52 115.5 103.23 0 0 0 0 1 0 0 0 0 0 0
30 118.57 100.7 103.60 0 0 0 0 0 1 0 0 0 0 0
31 134.25 109.9 103.95 0 0 0 0 0 0 1 0 0 0 0
32 136.70 114.6 103.93 0 0 0 0 0 0 0 1 0 0 0
33 121.37 85.4 104.25 0 0 0 0 0 0 0 0 1 0 0
34 111.63 100.5 104.38 0 0 0 0 0 0 0 0 0 1 0
35 134.42 114.8 104.36 0 0 0 0 0 0 0 0 0 0 1
36 137.65 116.5 104.32 0 0 0 0 0 0 0 0 0 0 0
37 137.86 112.9 104.58 1 0 0 0 0 0 0 0 0 0 0
38 119.77 102.0 104.68 0 1 0 0 0 0 0 0 0 0 0
39 130.69 106.0 104.92 0 0 1 0 0 0 0 0 0 0 0
40 128.28 105.3 105.46 0 0 0 1 0 0 0 0 0 0 0
41 147.45 118.8 105.23 0 0 0 0 1 0 0 0 0 0 0
42 128.42 106.1 105.58 0 0 0 0 0 1 0 0 0 0 0
43 136.90 109.3 105.34 0 0 0 0 0 0 1 0 0 0 0
44 143.95 117.2 105.28 0 0 0 0 0 0 0 1 0 0 0
45 135.64 92.5 105.70 0 0 0 0 0 0 0 0 1 0 0
46 122.48 104.2 105.67 0 0 0 0 0 0 0 0 0 1 0
47 136.83 112.5 105.71 0 0 0 0 0 0 0 0 0 0 1
48 153.04 122.4 106.19 0 0 0 0 0 0 0 0 0 0 0
49 142.71 113.3 106.93 1 0 0 0 0 0 0 0 0 0 0
50 123.46 100.0 107.44 0 1 0 0 0 0 0 0 0 0 0
51 144.37 110.7 107.85 0 0 1 0 0 0 0 0 0 0 0
52 146.15 112.8 108.71 0 0 0 1 0 0 0 0 0 0 0
53 147.61 109.8 109.32 0 0 0 0 1 0 0 0 0 0 0
54 158.51 117.3 109.49 0 0 0 0 0 1 0 0 0 0 0
55 147.40 109.1 110.20 0 0 0 0 0 0 1 0 0 0 0
56 165.05 115.9 110.62 0 0 0 0 0 0 0 1 0 0 0
57 154.64 96.0 111.22 0 0 0 0 0 0 0 0 1 0 0
58 126.20 99.8 110.88 0 0 0 0 0 0 0 0 0 1 0
59 157.36 116.8 111.15 0 0 0 0 0 0 0 0 0 0 1
60 154.15 115.7 111.29 0 0 0 0 0 0 0 0 0 0 0
61 123.21 99.4 111.09 1 0 0 0 0 0 0 0 0 0 0
62 113.07 94.3 111.24 0 1 0 0 0 0 0 0 0 0 0
63 110.45 91.0 111.45 0 0 1 0 0 0 0 0 0 0 0
64 113.57 93.2 111.75 0 0 0 1 0 0 0 0 0 0 0
65 122.44 103.1 111.07 0 0 0 0 1 0 0 0 0 0 0
66 114.93 94.1 111.17 0 0 0 0 0 1 0 0 0 0 0
67 111.85 91.8 110.96 0 0 0 0 0 0 1 0 0 0 0
68 126.04 102.7 110.50 0 0 0 0 0 0 0 1 0 0 0
69 121.34 82.6 110.48 0 0 0 0 0 0 0 0 1 0 0
70 124.36 89.1 110.66 0 0 0 0 0 0 0 0 0 1 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) TIP cons M1 M2 M3
-209.937 1.707 1.465 3.843 4.976 7.758
M4 M5 M6 M7 M8 M9
6.438 4.040 4.928 6.846 1.045 32.421
M10 M11
2.899 -1.237
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-10.3786 -3.0297 -0.2093 2.8361 17.1850
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -209.9368 17.8093 -11.788 < 2e-16 ***
TIP 1.7073 0.1091 15.642 < 2e-16 ***
cons 1.4648 0.1299 11.277 4.90e-16 ***
M1 3.8426 3.2124 1.196 0.2367
M2 4.9758 3.4771 1.431 0.1580
M3 7.7582 3.4831 2.227 0.0300 *
M4 6.4385 3.4167 1.884 0.0647 .
M5 4.0395 3.1129 1.298 0.1997
M6 4.9279 3.2855 1.500 0.1393
M7 6.8464 3.3409 2.049 0.0451 *
M8 1.0453 3.0962 0.338 0.7369
M9 32.4213 4.2525 7.624 3.22e-10 ***
M10 2.8991 3.5821 0.809 0.4218
M11 -1.2374 3.2284 -0.383 0.7030
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.104 on 56 degrees of freedom
Multiple R-squared: 0.9111, Adjusted R-squared: 0.8904
F-statistic: 44.14 on 13 and 56 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.858959e-01 5.717918e-01 0.7141041
[2,] 1.570926e-01 3.141852e-01 0.8429074
[3,] 8.225109e-02 1.645022e-01 0.9177489
[4,] 1.832482e-01 3.664963e-01 0.8167518
[5,] 1.344980e-01 2.689959e-01 0.8655020
[6,] 7.804342e-02 1.560868e-01 0.9219566
[7,] 4.242905e-02 8.485809e-02 0.9575710
[8,] 3.029014e-02 6.058029e-02 0.9697099
[9,] 1.639603e-02 3.279205e-02 0.9836040
[10,] 9.826184e-03 1.965237e-02 0.9901738
[11,] 6.464168e-03 1.292834e-02 0.9935358
[12,] 5.213111e-03 1.042622e-02 0.9947869
[13,] 3.656596e-03 7.313192e-03 0.9963434
[14,] 5.553262e-03 1.110652e-02 0.9944467
[15,] 2.905556e-03 5.811111e-03 0.9970944
[16,] 1.417500e-03 2.835000e-03 0.9985825
[17,] 8.224014e-04 1.644803e-03 0.9991776
[18,] 6.373080e-04 1.274616e-03 0.9993627
[19,] 4.268130e-04 8.536261e-04 0.9995732
[20,] 2.437837e-04 4.875674e-04 0.9997562
[21,] 1.169148e-04 2.338296e-04 0.9998831
[22,] 3.697633e-04 7.395266e-04 0.9996302
[23,] 1.851192e-04 3.702383e-04 0.9998149
[24,] 1.497370e-04 2.994741e-04 0.9998503
[25,] 8.738347e-05 1.747669e-04 0.9999126
[26,] 4.621643e-05 9.243286e-05 0.9999538
[27,] 2.013838e-05 4.027676e-05 0.9999799
[28,] 1.352421e-05 2.704843e-05 0.9999865
[29,] 1.019023e-05 2.038047e-05 0.9999898
[30,] 3.724354e-05 7.448707e-05 0.9999628
[31,] 1.414109e-05 2.828218e-05 0.9999859
[32,] 1.408116e-05 2.816233e-05 0.9999859
[33,] 6.263657e-06 1.252731e-05 0.9999937
[34,] 3.248623e-06 6.497245e-06 0.9999968
[35,] 1.119480e-06 2.238959e-06 0.9999989
[36,] 7.866593e-07 1.573319e-06 0.9999992
[37,] 1.258182e-06 2.516364e-06 0.9999987
> postscript(file="/var/www/html/rcomp/tmp/1t86h1260904629.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/2oi0y1260904629.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/37n3r1260904629.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/4q7yw1260904629.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/5cq281260904629.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 = 70
Frequency = 1
1 2 3 4 5
-0.008216403 1.021023421 1.276754702 1.710642246 -4.872648411
6 7 8 9 10
-0.320905504 0.032885689 -1.016804015 -3.432853469 -6.462385084
11 12 13 14 15
-4.410920807 0.422539930 4.645832428 2.987486186 3.418080724
16 17 18 19 20
5.831956358 9.940801158 3.470259972 4.957901146 -6.980464473
21 22 23 24 25
1.304848087 -2.180652884 0.278640684 1.703785982 1.735836639
26 27 28 29 30
4.333075288 3.507029011 2.846563227 3.014229391 -0.097669540
31 32 33 34 35
-2.556262149 -2.300324996 0.378965281 -5.809857386 -3.268938934
36 37 38 39 40
-4.120172697 -1.987245833 -2.747054687 -1.790258456 -2.476372373
41 42 43 44 45
-3.619465335 -2.367460069 -0.917873530 -1.466798988 0.403035351
46 47 48 49 50
-3.166508003 1.090499160 -1.542504728 -1.262350548 0.314880838
51 52 53 54 55
-0.426435479 -2.171792034 5.915649661 2.873264999 2.804885313
56 57 58 59 60
14.030939584 5.341938923 0.434368547 6.310719897 3.536351512
61 62 63 64 65
-3.123856282 -5.909411046 -5.985170501 -5.740997424 -10.378566464
66 67 68 69 70
-3.557489858 -4.321536470 -2.266547112 -3.995934173 17.185034810
> postscript(file="/var/www/html/rcomp/tmp/6irl21260904629.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 = 70
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.008216403 NA
1 1.021023421 -0.008216403
2 1.276754702 1.021023421
3 1.710642246 1.276754702
4 -4.872648411 1.710642246
5 -0.320905504 -4.872648411
6 0.032885689 -0.320905504
7 -1.016804015 0.032885689
8 -3.432853469 -1.016804015
9 -6.462385084 -3.432853469
10 -4.410920807 -6.462385084
11 0.422539930 -4.410920807
12 4.645832428 0.422539930
13 2.987486186 4.645832428
14 3.418080724 2.987486186
15 5.831956358 3.418080724
16 9.940801158 5.831956358
17 3.470259972 9.940801158
18 4.957901146 3.470259972
19 -6.980464473 4.957901146
20 1.304848087 -6.980464473
21 -2.180652884 1.304848087
22 0.278640684 -2.180652884
23 1.703785982 0.278640684
24 1.735836639 1.703785982
25 4.333075288 1.735836639
26 3.507029011 4.333075288
27 2.846563227 3.507029011
28 3.014229391 2.846563227
29 -0.097669540 3.014229391
30 -2.556262149 -0.097669540
31 -2.300324996 -2.556262149
32 0.378965281 -2.300324996
33 -5.809857386 0.378965281
34 -3.268938934 -5.809857386
35 -4.120172697 -3.268938934
36 -1.987245833 -4.120172697
37 -2.747054687 -1.987245833
38 -1.790258456 -2.747054687
39 -2.476372373 -1.790258456
40 -3.619465335 -2.476372373
41 -2.367460069 -3.619465335
42 -0.917873530 -2.367460069
43 -1.466798988 -0.917873530
44 0.403035351 -1.466798988
45 -3.166508003 0.403035351
46 1.090499160 -3.166508003
47 -1.542504728 1.090499160
48 -1.262350548 -1.542504728
49 0.314880838 -1.262350548
50 -0.426435479 0.314880838
51 -2.171792034 -0.426435479
52 5.915649661 -2.171792034
53 2.873264999 5.915649661
54 2.804885313 2.873264999
55 14.030939584 2.804885313
56 5.341938923 14.030939584
57 0.434368547 5.341938923
58 6.310719897 0.434368547
59 3.536351512 6.310719897
60 -3.123856282 3.536351512
61 -5.909411046 -3.123856282
62 -5.985170501 -5.909411046
63 -5.740997424 -5.985170501
64 -10.378566464 -5.740997424
65 -3.557489858 -10.378566464
66 -4.321536470 -3.557489858
67 -2.266547112 -4.321536470
68 -3.995934173 -2.266547112
69 17.185034810 -3.995934173
70 NA 17.185034810
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.02102342 -0.008216403
[2,] 1.27675470 1.021023421
[3,] 1.71064225 1.276754702
[4,] -4.87264841 1.710642246
[5,] -0.32090550 -4.872648411
[6,] 0.03288569 -0.320905504
[7,] -1.01680401 0.032885689
[8,] -3.43285347 -1.016804015
[9,] -6.46238508 -3.432853469
[10,] -4.41092081 -6.462385084
[11,] 0.42253993 -4.410920807
[12,] 4.64583243 0.422539930
[13,] 2.98748619 4.645832428
[14,] 3.41808072 2.987486186
[15,] 5.83195636 3.418080724
[16,] 9.94080116 5.831956358
[17,] 3.47025997 9.940801158
[18,] 4.95790115 3.470259972
[19,] -6.98046447 4.957901146
[20,] 1.30484809 -6.980464473
[21,] -2.18065288 1.304848087
[22,] 0.27864068 -2.180652884
[23,] 1.70378598 0.278640684
[24,] 1.73583664 1.703785982
[25,] 4.33307529 1.735836639
[26,] 3.50702901 4.333075288
[27,] 2.84656323 3.507029011
[28,] 3.01422939 2.846563227
[29,] -0.09766954 3.014229391
[30,] -2.55626215 -0.097669540
[31,] -2.30032500 -2.556262149
[32,] 0.37896528 -2.300324996
[33,] -5.80985739 0.378965281
[34,] -3.26893893 -5.809857386
[35,] -4.12017270 -3.268938934
[36,] -1.98724583 -4.120172697
[37,] -2.74705469 -1.987245833
[38,] -1.79025846 -2.747054687
[39,] -2.47637237 -1.790258456
[40,] -3.61946534 -2.476372373
[41,] -2.36746007 -3.619465335
[42,] -0.91787353 -2.367460069
[43,] -1.46679899 -0.917873530
[44,] 0.40303535 -1.466798988
[45,] -3.16650800 0.403035351
[46,] 1.09049916 -3.166508003
[47,] -1.54250473 1.090499160
[48,] -1.26235055 -1.542504728
[49,] 0.31488084 -1.262350548
[50,] -0.42643548 0.314880838
[51,] -2.17179203 -0.426435479
[52,] 5.91564966 -2.171792034
[53,] 2.87326500 5.915649661
[54,] 2.80488531 2.873264999
[55,] 14.03093958 2.804885313
[56,] 5.34193892 14.030939584
[57,] 0.43436855 5.341938923
[58,] 6.31071990 0.434368547
[59,] 3.53635151 6.310719897
[60,] -3.12385628 3.536351512
[61,] -5.90941105 -3.123856282
[62,] -5.98517050 -5.909411046
[63,] -5.74099742 -5.985170501
[64,] -10.37856646 -5.740997424
[65,] -3.55748986 -10.378566464
[66,] -4.32153647 -3.557489858
[67,] -2.26654711 -4.321536470
[68,] -3.99593417 -2.266547112
[69,] 17.18503481 -3.995934173
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.02102342 -0.008216403
2 1.27675470 1.021023421
3 1.71064225 1.276754702
4 -4.87264841 1.710642246
5 -0.32090550 -4.872648411
6 0.03288569 -0.320905504
7 -1.01680401 0.032885689
8 -3.43285347 -1.016804015
9 -6.46238508 -3.432853469
10 -4.41092081 -6.462385084
11 0.42253993 -4.410920807
12 4.64583243 0.422539930
13 2.98748619 4.645832428
14 3.41808072 2.987486186
15 5.83195636 3.418080724
16 9.94080116 5.831956358
17 3.47025997 9.940801158
18 4.95790115 3.470259972
19 -6.98046447 4.957901146
20 1.30484809 -6.980464473
21 -2.18065288 1.304848087
22 0.27864068 -2.180652884
23 1.70378598 0.278640684
24 1.73583664 1.703785982
25 4.33307529 1.735836639
26 3.50702901 4.333075288
27 2.84656323 3.507029011
28 3.01422939 2.846563227
29 -0.09766954 3.014229391
30 -2.55626215 -0.097669540
31 -2.30032500 -2.556262149
32 0.37896528 -2.300324996
33 -5.80985739 0.378965281
34 -3.26893893 -5.809857386
35 -4.12017270 -3.268938934
36 -1.98724583 -4.120172697
37 -2.74705469 -1.987245833
38 -1.79025846 -2.747054687
39 -2.47637237 -1.790258456
40 -3.61946534 -2.476372373
41 -2.36746007 -3.619465335
42 -0.91787353 -2.367460069
43 -1.46679899 -0.917873530
44 0.40303535 -1.466798988
45 -3.16650800 0.403035351
46 1.09049916 -3.166508003
47 -1.54250473 1.090499160
48 -1.26235055 -1.542504728
49 0.31488084 -1.262350548
50 -0.42643548 0.314880838
51 -2.17179203 -0.426435479
52 5.91564966 -2.171792034
53 2.87326500 5.915649661
54 2.80488531 2.873264999
55 14.03093958 2.804885313
56 5.34193892 14.030939584
57 0.43436855 5.341938923
58 6.31071990 0.434368547
59 3.53635151 6.310719897
60 -3.12385628 3.536351512
61 -5.90941105 -3.123856282
62 -5.98517050 -5.909411046
63 -5.74099742 -5.985170501
64 -10.37856646 -5.740997424
65 -3.55748986 -10.378566464
66 -4.32153647 -3.557489858
67 -2.26654711 -4.321536470
68 -3.99593417 -2.266547112
69 17.18503481 -3.995934173
> 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/7u0671260904629.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/8bo6a1260904629.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/9ly8u1260904629.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/10cs5k1260904629.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/11wmiu1260904630.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/12ti5t1260904630.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/13cxx41260904630.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/14vk291260904630.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/15wwco1260904630.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/16etd01260904630.tab")
+ }
>
> try(system("convert tmp/1t86h1260904629.ps tmp/1t86h1260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/2oi0y1260904629.ps tmp/2oi0y1260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/37n3r1260904629.ps tmp/37n3r1260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/4q7yw1260904629.ps tmp/4q7yw1260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/5cq281260904629.ps tmp/5cq281260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/6irl21260904629.ps tmp/6irl21260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/7u0671260904629.ps tmp/7u0671260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/8bo6a1260904629.ps tmp/8bo6a1260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/9ly8u1260904629.ps tmp/9ly8u1260904629.png",intern=TRUE))
character(0)
> try(system("convert tmp/10cs5k1260904629.ps tmp/10cs5k1260904629.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.569 1.584 3.907