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(23
+ ,2497.84
+ ,21
+ ,25
+ ,19
+ ,21
+ ,23
+ ,2645.64
+ ,23
+ ,21
+ ,25
+ ,19
+ ,19
+ ,2756.76
+ ,23
+ ,23
+ ,21
+ ,25
+ ,18
+ ,2849.27
+ ,19
+ ,23
+ ,23
+ ,21
+ ,19
+ ,2921.44
+ ,18
+ ,19
+ ,23
+ ,23
+ ,19
+ ,2981.85
+ ,19
+ ,18
+ ,19
+ ,23
+ ,22
+ ,3080.58
+ ,19
+ ,19
+ ,18
+ ,19
+ ,23
+ ,3106.22
+ ,22
+ ,19
+ ,19
+ ,18
+ ,20
+ ,3119.31
+ ,23
+ ,22
+ ,19
+ ,19
+ ,14
+ ,3061.26
+ ,20
+ ,23
+ ,22
+ ,19
+ ,14
+ ,3097.31
+ ,14
+ ,20
+ ,23
+ ,22
+ ,14
+ ,3161.69
+ ,14
+ ,14
+ ,20
+ ,23
+ ,15
+ ,3257.16
+ ,14
+ ,14
+ ,14
+ ,20
+ ,11
+ ,3277.01
+ ,15
+ ,14
+ ,14
+ ,14
+ ,17
+ ,3295.32
+ ,11
+ ,15
+ ,14
+ ,14
+ ,16
+ ,3363.99
+ ,17
+ ,11
+ ,15
+ ,14
+ ,20
+ ,3494.17
+ ,16
+ ,17
+ ,11
+ ,15
+ ,24
+ ,3667.03
+ ,20
+ ,16
+ ,17
+ ,11
+ ,23
+ ,3813.06
+ ,24
+ ,20
+ ,16
+ ,17
+ ,20
+ ,3917.96
+ ,23
+ ,24
+ ,20
+ ,16
+ ,21
+ ,3895.51
+ ,20
+ ,23
+ ,24
+ ,20
+ ,19
+ ,3801.06
+ ,21
+ ,20
+ ,23
+ ,24
+ ,23
+ ,3570.12
+ ,19
+ ,21
+ ,20
+ ,23
+ ,23
+ ,3701.61
+ ,23
+ ,19
+ ,21
+ ,20
+ ,23
+ ,3862.27
+ ,23
+ ,23
+ ,19
+ ,21
+ ,23
+ ,3970.1
+ ,23
+ ,23
+ ,23
+ ,19
+ ,27
+ ,4138.52
+ ,23
+ ,23
+ ,23
+ ,23
+ ,26
+ ,4199.75
+ ,27
+ ,23
+ ,23
+ ,23
+ ,17
+ ,4290.89
+ ,26
+ ,27
+ ,23
+ ,23
+ ,24
+ ,4443.91
+ ,17
+ ,26
+ ,27
+ ,23
+ ,26
+ ,4502.64
+ ,24
+ ,17
+ ,26
+ ,27
+ ,24
+ ,4356.98
+ ,26
+ ,24
+ ,17
+ ,26
+ ,27
+ ,4591.27
+ ,24
+ ,26
+ ,24
+ ,17
+ ,27
+ ,4696.96
+ ,27
+ ,24
+ ,26
+ ,24
+ ,26
+ ,4621.4
+ ,27
+ ,27
+ ,24
+ ,26
+ ,24
+ ,4562.84
+ ,26
+ ,27
+ ,27
+ ,24
+ ,23
+ ,4202.52
+ ,24
+ ,26
+ ,27
+ ,27
+ ,23
+ ,4296.49
+ ,23
+ ,24
+ ,26
+ ,27
+ ,24
+ ,4435.23
+ ,23
+ ,23
+ ,24
+ ,26
+ ,17
+ ,4105.18
+ ,24
+ ,23
+ ,23
+ ,24
+ ,21
+ ,4116.68
+ ,17
+ ,24
+ ,23
+ ,23
+ ,19
+ ,3844.49
+ ,21
+ ,17
+ ,24
+ ,23
+ ,22
+ ,3720.98
+ ,19
+ ,21
+ ,17
+ ,24
+ ,22
+ ,3674.4
+ ,22
+ ,19
+ ,21
+ ,17
+ ,18
+ ,3857.62
+ ,22
+ ,22
+ ,19
+ ,21
+ ,16
+ ,3801.06
+ ,18
+ ,22
+ ,22
+ ,19
+ ,14
+ ,3504.37
+ ,16
+ ,18
+ ,22
+ ,22
+ ,12
+ ,3032.6
+ ,14
+ ,16
+ ,18
+ ,22
+ ,14
+ ,3047.03
+ ,12
+ ,14
+ ,16
+ ,18
+ ,16
+ ,2962.34
+ ,14
+ ,12
+ ,14
+ ,16
+ ,8
+ ,2197.82
+ ,16
+ ,14
+ ,12
+ ,14
+ ,3
+ ,2014.45
+ ,8
+ ,16
+ ,14
+ ,12
+ ,0
+ ,1862.83
+ ,3
+ ,8
+ ,16
+ ,14
+ ,5
+ ,1905.41
+ ,0
+ ,3
+ ,8
+ ,16
+ ,1
+ ,1810.99
+ ,5
+ ,0
+ ,3
+ ,8
+ ,1
+ ,1670.07
+ ,1
+ ,5
+ ,0
+ ,3
+ ,3
+ ,1864.44
+ ,1
+ ,1
+ ,5
+ ,0)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('Consvertr'
+ ,'Aand'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('Consvertr','Aand','Y1','Y2','Y3','Y4'),1:57))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Consvertr Aand Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 23 2497.84 21 25 19 21 1 0 0 0 0 0 0 0 0 0 0 1
2 23 2645.64 23 21 25 19 0 1 0 0 0 0 0 0 0 0 0 2
3 19 2756.76 23 23 21 25 0 0 1 0 0 0 0 0 0 0 0 3
4 18 2849.27 19 23 23 21 0 0 0 1 0 0 0 0 0 0 0 4
5 19 2921.44 18 19 23 23 0 0 0 0 1 0 0 0 0 0 0 5
6 19 2981.85 19 18 19 23 0 0 0 0 0 1 0 0 0 0 0 6
7 22 3080.58 19 19 18 19 0 0 0 0 0 0 1 0 0 0 0 7
8 23 3106.22 22 19 19 18 0 0 0 0 0 0 0 1 0 0 0 8
9 20 3119.31 23 22 19 19 0 0 0 0 0 0 0 0 1 0 0 9
10 14 3061.26 20 23 22 19 0 0 0 0 0 0 0 0 0 1 0 10
11 14 3097.31 14 20 23 22 0 0 0 0 0 0 0 0 0 0 1 11
12 14 3161.69 14 14 20 23 0 0 0 0 0 0 0 0 0 0 0 12
13 15 3257.16 14 14 14 20 1 0 0 0 0 0 0 0 0 0 0 13
14 11 3277.01 15 14 14 14 0 1 0 0 0 0 0 0 0 0 0 14
15 17 3295.32 11 15 14 14 0 0 1 0 0 0 0 0 0 0 0 15
16 16 3363.99 17 11 15 14 0 0 0 1 0 0 0 0 0 0 0 16
17 20 3494.17 16 17 11 15 0 0 0 0 1 0 0 0 0 0 0 17
18 24 3667.03 20 16 17 11 0 0 0 0 0 1 0 0 0 0 0 18
19 23 3813.06 24 20 16 17 0 0 0 0 0 0 1 0 0 0 0 19
20 20 3917.96 23 24 20 16 0 0 0 0 0 0 0 1 0 0 0 20
21 21 3895.51 20 23 24 20 0 0 0 0 0 0 0 0 1 0 0 21
22 19 3801.06 21 20 23 24 0 0 0 0 0 0 0 0 0 1 0 22
23 23 3570.12 19 21 20 23 0 0 0 0 0 0 0 0 0 0 1 23
24 23 3701.61 23 19 21 20 0 0 0 0 0 0 0 0 0 0 0 24
25 23 3862.27 23 23 19 21 1 0 0 0 0 0 0 0 0 0 0 25
26 23 3970.10 23 23 23 19 0 1 0 0 0 0 0 0 0 0 0 26
27 27 4138.52 23 23 23 23 0 0 1 0 0 0 0 0 0 0 0 27
28 26 4199.75 27 23 23 23 0 0 0 1 0 0 0 0 0 0 0 28
29 17 4290.89 26 27 23 23 0 0 0 0 1 0 0 0 0 0 0 29
30 24 4443.91 17 26 27 23 0 0 0 0 0 1 0 0 0 0 0 30
31 26 4502.64 24 17 26 27 0 0 0 0 0 0 1 0 0 0 0 31
32 24 4356.98 26 24 17 26 0 0 0 0 0 0 0 1 0 0 0 32
33 27 4591.27 24 26 24 17 0 0 0 0 0 0 0 0 1 0 0 33
34 27 4696.96 27 24 26 24 0 0 0 0 0 0 0 0 0 1 0 34
35 26 4621.40 27 27 24 26 0 0 0 0 0 0 0 0 0 0 1 35
36 24 4562.84 26 27 27 24 0 0 0 0 0 0 0 0 0 0 0 36
37 23 4202.52 24 26 27 27 1 0 0 0 0 0 0 0 0 0 0 37
38 23 4296.49 23 24 26 27 0 1 0 0 0 0 0 0 0 0 0 38
39 24 4435.23 23 23 24 26 0 0 1 0 0 0 0 0 0 0 0 39
40 17 4105.18 24 23 23 24 0 0 0 1 0 0 0 0 0 0 0 40
41 21 4116.68 17 24 23 23 0 0 0 0 1 0 0 0 0 0 0 41
42 19 3844.49 21 17 24 23 0 0 0 0 0 1 0 0 0 0 0 42
43 22 3720.98 19 21 17 24 0 0 0 0 0 0 1 0 0 0 0 43
44 22 3674.40 22 19 21 17 0 0 0 0 0 0 0 1 0 0 0 44
45 18 3857.62 22 22 19 21 0 0 0 0 0 0 0 0 1 0 0 45
46 16 3801.06 18 22 22 19 0 0 0 0 0 0 0 0 0 1 0 46
47 14 3504.37 16 18 22 22 0 0 0 0 0 0 0 0 0 0 1 47
48 12 3032.60 14 16 18 22 0 0 0 0 0 0 0 0 0 0 0 48
49 14 3047.03 12 14 16 18 1 0 0 0 0 0 0 0 0 0 0 49
50 16 2962.34 14 12 14 16 0 1 0 0 0 0 0 0 0 0 0 50
51 8 2197.82 16 14 12 14 0 0 1 0 0 0 0 0 0 0 0 51
52 3 2014.45 8 16 14 12 0 0 0 1 0 0 0 0 0 0 0 52
53 0 1862.83 3 8 16 14 0 0 0 0 1 0 0 0 0 0 0 53
54 5 1905.41 0 3 8 16 0 0 0 0 0 1 0 0 0 0 0 54
55 1 1810.99 5 0 3 8 0 0 0 0 0 0 1 0 0 0 0 55
56 1 1670.07 1 5 0 3 0 0 0 0 0 0 0 1 0 0 0 56
57 3 1864.44 1 1 5 0 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Aand Y1 Y2 Y3 Y4
-2.308028 0.003878 0.405105 0.040853 0.108241 -0.069330
M1 M2 M3 M4 M5 M6
2.152922 1.049356 1.597212 -1.183330 -0.486104 2.645847
M7 M8 M9 M10 M11 t
2.474491 1.425060 0.806606 -1.597565 0.569133 -0.093925
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.65160 -1.50113 -0.02916 1.97220 3.93013
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.3080282 2.6044466 -0.886 0.380948
Aand 0.0038777 0.0009731 3.985 0.000286 ***
Y1 0.4051050 0.1557588 2.601 0.013071 *
Y2 0.0408530 0.1614858 0.253 0.801611
Y3 0.1082406 0.1647096 0.657 0.514938
Y4 -0.0693297 0.1443381 -0.480 0.633677
M1 2.1529221 1.9789548 1.088 0.283313
M2 1.0493563 1.9517731 0.538 0.593879
M3 1.5972117 1.9597345 0.815 0.420014
M4 -1.1833300 1.9640639 -0.602 0.550335
M5 -0.4861041 1.9681482 -0.247 0.806215
M6 2.6458473 1.9312765 1.370 0.178523
M7 2.4744907 1.9955881 1.240 0.222392
M8 1.4250603 2.1026859 0.678 0.501942
M9 0.8066061 2.0770539 0.388 0.699875
M10 -1.5975647 2.0502194 -0.779 0.440555
M11 0.5691325 2.0440532 0.278 0.782151
t -0.0939253 0.0289774 -3.241 0.002438 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.838 on 39 degrees of freedom
Multiple R-squared: 0.8861, Adjusted R-squared: 0.8364
F-statistic: 17.84 on 17 and 39 DF, p-value: 2.446e-13
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.5864798 0.8270404 0.4135202
[2,] 0.7037315 0.5925369 0.2962685
[3,] 0.5936127 0.8127746 0.4063873
[4,] 0.5596458 0.8807085 0.4403542
[5,] 0.5177667 0.9644666 0.4822333
[6,] 0.3933473 0.7866946 0.6066527
[7,] 0.3722195 0.7444391 0.6277805
[8,] 0.4962646 0.9925291 0.5037354
[9,] 0.8778054 0.2443893 0.1221946
[10,] 0.8259605 0.3480789 0.1740395
[11,] 0.7470893 0.5058213 0.2529107
[12,] 0.6480549 0.7038902 0.3519451
[13,] 0.5411702 0.9176596 0.4588298
[14,] 0.6603729 0.6792542 0.3396271
[15,] 0.6985734 0.6028532 0.3014266
[16,] 0.5232912 0.9534177 0.4767088
> postscript(file="/var/www/html/rcomp/tmp/17beh1258619288.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/2zevu1258619288.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/3mhgp1258619288.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/49e9n1258619288.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/5ztgv1258619288.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 = 57
Frequency = 1
1 2 3 4 5 6
3.43393962 2.62340315 -1.49418397 1.14817553 1.97219652 -1.23137208
7 8 9 10 11 12
1.44113162 2.09217720 -0.70453678 -3.13159894 -2.69122479 -1.63864491
13 14 15 16 17 18
-2.62639297 -6.32695794 0.72767813 -0.03959650 3.51458098 1.29992324
19 20 21 22 23 24
-1.26067075 -3.78468652 -0.88472755 0.08263226 3.93012922 2.22836219
25 26 27 28 29 30
-0.33122952 -0.12349435 3.04680952 3.06342383 -6.65159877 -0.02915706
31 32 33 34 35 36
-0.07411223 -0.55727380 1.59344798 2.81692605 0.26973605 -0.89840324
37 38 39 40 41 42
-1.50112908 -0.07297535 0.12310462 -3.15811204 2.91954609 -2.50569425
43 44 45 46 47 48
2.71233645 1.98443647 -1.64241795 0.23204064 -1.50864048 0.30868596
49 50 51 52 53 54
1.02481196 3.90002450 -2.40340831 -1.01389081 -1.75472482 2.46630015
55 56 57
-2.81868509 0.26534665 1.63823429
> postscript(file="/var/www/html/rcomp/tmp/6ia4c1258619288.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 3.43393962 NA
1 2.62340315 3.43393962
2 -1.49418397 2.62340315
3 1.14817553 -1.49418397
4 1.97219652 1.14817553
5 -1.23137208 1.97219652
6 1.44113162 -1.23137208
7 2.09217720 1.44113162
8 -0.70453678 2.09217720
9 -3.13159894 -0.70453678
10 -2.69122479 -3.13159894
11 -1.63864491 -2.69122479
12 -2.62639297 -1.63864491
13 -6.32695794 -2.62639297
14 0.72767813 -6.32695794
15 -0.03959650 0.72767813
16 3.51458098 -0.03959650
17 1.29992324 3.51458098
18 -1.26067075 1.29992324
19 -3.78468652 -1.26067075
20 -0.88472755 -3.78468652
21 0.08263226 -0.88472755
22 3.93012922 0.08263226
23 2.22836219 3.93012922
24 -0.33122952 2.22836219
25 -0.12349435 -0.33122952
26 3.04680952 -0.12349435
27 3.06342383 3.04680952
28 -6.65159877 3.06342383
29 -0.02915706 -6.65159877
30 -0.07411223 -0.02915706
31 -0.55727380 -0.07411223
32 1.59344798 -0.55727380
33 2.81692605 1.59344798
34 0.26973605 2.81692605
35 -0.89840324 0.26973605
36 -1.50112908 -0.89840324
37 -0.07297535 -1.50112908
38 0.12310462 -0.07297535
39 -3.15811204 0.12310462
40 2.91954609 -3.15811204
41 -2.50569425 2.91954609
42 2.71233645 -2.50569425
43 1.98443647 2.71233645
44 -1.64241795 1.98443647
45 0.23204064 -1.64241795
46 -1.50864048 0.23204064
47 0.30868596 -1.50864048
48 1.02481196 0.30868596
49 3.90002450 1.02481196
50 -2.40340831 3.90002450
51 -1.01389081 -2.40340831
52 -1.75472482 -1.01389081
53 2.46630015 -1.75472482
54 -2.81868509 2.46630015
55 0.26534665 -2.81868509
56 1.63823429 0.26534665
57 NA 1.63823429
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 2.62340315 3.43393962
[2,] -1.49418397 2.62340315
[3,] 1.14817553 -1.49418397
[4,] 1.97219652 1.14817553
[5,] -1.23137208 1.97219652
[6,] 1.44113162 -1.23137208
[7,] 2.09217720 1.44113162
[8,] -0.70453678 2.09217720
[9,] -3.13159894 -0.70453678
[10,] -2.69122479 -3.13159894
[11,] -1.63864491 -2.69122479
[12,] -2.62639297 -1.63864491
[13,] -6.32695794 -2.62639297
[14,] 0.72767813 -6.32695794
[15,] -0.03959650 0.72767813
[16,] 3.51458098 -0.03959650
[17,] 1.29992324 3.51458098
[18,] -1.26067075 1.29992324
[19,] -3.78468652 -1.26067075
[20,] -0.88472755 -3.78468652
[21,] 0.08263226 -0.88472755
[22,] 3.93012922 0.08263226
[23,] 2.22836219 3.93012922
[24,] -0.33122952 2.22836219
[25,] -0.12349435 -0.33122952
[26,] 3.04680952 -0.12349435
[27,] 3.06342383 3.04680952
[28,] -6.65159877 3.06342383
[29,] -0.02915706 -6.65159877
[30,] -0.07411223 -0.02915706
[31,] -0.55727380 -0.07411223
[32,] 1.59344798 -0.55727380
[33,] 2.81692605 1.59344798
[34,] 0.26973605 2.81692605
[35,] -0.89840324 0.26973605
[36,] -1.50112908 -0.89840324
[37,] -0.07297535 -1.50112908
[38,] 0.12310462 -0.07297535
[39,] -3.15811204 0.12310462
[40,] 2.91954609 -3.15811204
[41,] -2.50569425 2.91954609
[42,] 2.71233645 -2.50569425
[43,] 1.98443647 2.71233645
[44,] -1.64241795 1.98443647
[45,] 0.23204064 -1.64241795
[46,] -1.50864048 0.23204064
[47,] 0.30868596 -1.50864048
[48,] 1.02481196 0.30868596
[49,] 3.90002450 1.02481196
[50,] -2.40340831 3.90002450
[51,] -1.01389081 -2.40340831
[52,] -1.75472482 -1.01389081
[53,] 2.46630015 -1.75472482
[54,] -2.81868509 2.46630015
[55,] 0.26534665 -2.81868509
[56,] 1.63823429 0.26534665
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 2.62340315 3.43393962
2 -1.49418397 2.62340315
3 1.14817553 -1.49418397
4 1.97219652 1.14817553
5 -1.23137208 1.97219652
6 1.44113162 -1.23137208
7 2.09217720 1.44113162
8 -0.70453678 2.09217720
9 -3.13159894 -0.70453678
10 -2.69122479 -3.13159894
11 -1.63864491 -2.69122479
12 -2.62639297 -1.63864491
13 -6.32695794 -2.62639297
14 0.72767813 -6.32695794
15 -0.03959650 0.72767813
16 3.51458098 -0.03959650
17 1.29992324 3.51458098
18 -1.26067075 1.29992324
19 -3.78468652 -1.26067075
20 -0.88472755 -3.78468652
21 0.08263226 -0.88472755
22 3.93012922 0.08263226
23 2.22836219 3.93012922
24 -0.33122952 2.22836219
25 -0.12349435 -0.33122952
26 3.04680952 -0.12349435
27 3.06342383 3.04680952
28 -6.65159877 3.06342383
29 -0.02915706 -6.65159877
30 -0.07411223 -0.02915706
31 -0.55727380 -0.07411223
32 1.59344798 -0.55727380
33 2.81692605 1.59344798
34 0.26973605 2.81692605
35 -0.89840324 0.26973605
36 -1.50112908 -0.89840324
37 -0.07297535 -1.50112908
38 0.12310462 -0.07297535
39 -3.15811204 0.12310462
40 2.91954609 -3.15811204
41 -2.50569425 2.91954609
42 2.71233645 -2.50569425
43 1.98443647 2.71233645
44 -1.64241795 1.98443647
45 0.23204064 -1.64241795
46 -1.50864048 0.23204064
47 0.30868596 -1.50864048
48 1.02481196 0.30868596
49 3.90002450 1.02481196
50 -2.40340831 3.90002450
51 -1.01389081 -2.40340831
52 -1.75472482 -1.01389081
53 2.46630015 -1.75472482
54 -2.81868509 2.46630015
55 0.26534665 -2.81868509
56 1.63823429 0.26534665
> 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/7v8le1258619288.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/8kepi1258619288.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/9l6h81258619288.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/10p4031258619288.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/11194u1258619288.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/12cmvk1258619288.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/13we9v1258619288.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/14hd4g1258619288.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/15p8ka1258619288.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/162g8o1258619288.tab")
+ }
>
> system("convert tmp/17beh1258619288.ps tmp/17beh1258619288.png")
> system("convert tmp/2zevu1258619288.ps tmp/2zevu1258619288.png")
> system("convert tmp/3mhgp1258619288.ps tmp/3mhgp1258619288.png")
> system("convert tmp/49e9n1258619288.ps tmp/49e9n1258619288.png")
> system("convert tmp/5ztgv1258619288.ps tmp/5ztgv1258619288.png")
> system("convert tmp/6ia4c1258619288.ps tmp/6ia4c1258619288.png")
> system("convert tmp/7v8le1258619288.ps tmp/7v8le1258619288.png")
> system("convert tmp/8kepi1258619288.ps tmp/8kepi1258619288.png")
> system("convert tmp/9l6h81258619288.ps tmp/9l6h81258619288.png")
> system("convert tmp/10p4031258619288.ps tmp/10p4031258619288.png")
>
>
> proc.time()
user system elapsed
2.354 1.544 4.916