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(19554.2
+ ,19691.6
+ ,0
+ ,16554.2
+ ,16198.9
+ ,15903.8
+ ,15930.7
+ ,0
+ ,19554.2
+ ,16554.2
+ ,18003.8
+ ,17444.6
+ ,0
+ ,15903.8
+ ,19554.2
+ ,18329.6
+ ,17699.4
+ ,0
+ ,18003.8
+ ,15903.8
+ ,16260.7
+ ,15189.8
+ ,0
+ ,18329.6
+ ,18003.8
+ ,14851.9
+ ,15672.7
+ ,0
+ ,16260.7
+ ,18329.6
+ ,18174.1
+ ,17180.8
+ ,0
+ ,14851.9
+ ,16260.7
+ ,18406.6
+ ,17664.9
+ ,0
+ ,18174.1
+ ,14851.9
+ ,18466.5
+ ,17862.9
+ ,0
+ ,18406.6
+ ,18174.1
+ ,16016.5
+ ,16162.3
+ ,0
+ ,18466.5
+ ,18406.6
+ ,17428.5
+ ,17463.6
+ ,0
+ ,16016.5
+ ,18466.5
+ ,17167.2
+ ,16772.1
+ ,0
+ ,17428.5
+ ,16016.5
+ ,19630
+ ,19106.9
+ ,0
+ ,17167.2
+ ,17428.5
+ ,17183.6
+ ,16721.3
+ ,0
+ ,19630
+ ,17167.2
+ ,18344.7
+ ,18161.3
+ ,0
+ ,17183.6
+ ,19630
+ ,19301.4
+ ,18509.9
+ ,0
+ ,18344.7
+ ,17183.6
+ ,18147.5
+ ,17802.7
+ ,0
+ ,19301.4
+ ,18344.7
+ ,16192.9
+ ,16409.9
+ ,0
+ ,18147.5
+ ,19301.4
+ ,18374.4
+ ,17967.7
+ ,0
+ ,16192.9
+ ,18147.5
+ ,20515.2
+ ,20286.6
+ ,0
+ ,18374.4
+ ,16192.9
+ ,18957.2
+ ,19537.3
+ ,0
+ ,20515.2
+ ,18374.4
+ ,16471.5
+ ,18021.9
+ ,0
+ ,18957.2
+ ,20515.2
+ ,18746.8
+ ,20194.3
+ ,0
+ ,16471.5
+ ,18957.2
+ ,19009.5
+ ,19049.6
+ ,0
+ ,18746.8
+ ,16471.5
+ ,19211.2
+ ,20244.7
+ ,0
+ ,19009.5
+ ,18746.8
+ ,20547.7
+ ,21473.3
+ ,0
+ ,19211.2
+ ,19009.5
+ ,19325.8
+ ,19673.6
+ ,0
+ ,20547.7
+ ,19211.2
+ ,20605.5
+ ,21053.2
+ ,0
+ ,19325.8
+ ,20547.7
+ ,20056.9
+ ,20159.5
+ ,0
+ ,20605.5
+ ,19325.8
+ ,16141.4
+ ,18203.6
+ ,0
+ ,20056.9
+ ,20605.5
+ ,20359.8
+ ,21289.5
+ ,0
+ ,16141.4
+ ,20056.9
+ ,19711.6
+ ,20432.3
+ ,1
+ ,20359.8
+ ,16141.4
+ ,15638.6
+ ,17180.4
+ ,1
+ ,19711.6
+ ,20359.8
+ ,14384.5
+ ,15816.8
+ ,1
+ ,15638.6
+ ,19711.6
+ ,13855.6
+ ,15071.8
+ ,1
+ ,14384.5
+ ,15638.6
+ ,14308.3
+ ,14521.1
+ ,1
+ ,13855.6
+ ,14384.5
+ ,15290.6
+ ,15668.8
+ ,1
+ ,14308.3
+ ,13855.6
+ ,14423.8
+ ,14346.9
+ ,1
+ ,15290.6
+ ,14308.3
+ ,13779.7
+ ,13881
+ ,1
+ ,14423.8
+ ,15290.6
+ ,15686.3
+ ,15465.9
+ ,1
+ ,13779.7
+ ,14423.8
+ ,14733.8
+ ,14238.2
+ ,1
+ ,15686.3
+ ,13779.7
+ ,12522.5
+ ,13557.7
+ ,1
+ ,14733.8
+ ,15686.3
+ ,16189.4
+ ,16127.6
+ ,1
+ ,12522.5
+ ,14733.8
+ ,16059.1
+ ,16793.9
+ ,1
+ ,16189.4
+ ,12522.5
+ ,16007.1
+ ,16014
+ ,1
+ ,16059.1
+ ,16189.4
+ ,15806.8
+ ,16867.9
+ ,1
+ ,16007.1
+ ,16059.1
+ ,15160
+ ,16014.6
+ ,0
+ ,15806.8
+ ,16007.1
+ ,15692.1
+ ,15878.6
+ ,0
+ ,15160
+ ,15806.8
+ ,18908.9
+ ,18664.9
+ ,0
+ ,15692.1
+ ,15160
+ ,16969.9
+ ,17962.5
+ ,0
+ ,18908.9
+ ,15692.1
+ ,16997.5
+ ,17332.7
+ ,0
+ ,16969.9
+ ,18908.9
+ ,19858.9
+ ,19542.1
+ ,0
+ ,16997.5
+ ,16969.9
+ ,17681.2
+ ,17203.6
+ ,0
+ ,19858.9
+ ,16997.5)
+ ,dim=c(5
+ ,53)
+ ,dimnames=list(c('uitvoer'
+ ,'invoer'
+ ,'crisis'
+ ,'y-1t'
+ ,'y-2t')
+ ,1:53))
> y <- array(NA,dim=c(5,53),dimnames=list(c('uitvoer','invoer','crisis','y-1t','y-2t'),1:53))
> 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
uitvoer invoer crisis y-1t y-2t M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 19554.2 19691.6 0 16554.2 16198.9 1 0 0 0 0 0 0 0 0 0 0 1
2 15903.8 15930.7 0 19554.2 16554.2 0 1 0 0 0 0 0 0 0 0 0 2
3 18003.8 17444.6 0 15903.8 19554.2 0 0 1 0 0 0 0 0 0 0 0 3
4 18329.6 17699.4 0 18003.8 15903.8 0 0 0 1 0 0 0 0 0 0 0 4
5 16260.7 15189.8 0 18329.6 18003.8 0 0 0 0 1 0 0 0 0 0 0 5
6 14851.9 15672.7 0 16260.7 18329.6 0 0 0 0 0 1 0 0 0 0 0 6
7 18174.1 17180.8 0 14851.9 16260.7 0 0 0 0 0 0 1 0 0 0 0 7
8 18406.6 17664.9 0 18174.1 14851.9 0 0 0 0 0 0 0 1 0 0 0 8
9 18466.5 17862.9 0 18406.6 18174.1 0 0 0 0 0 0 0 0 1 0 0 9
10 16016.5 16162.3 0 18466.5 18406.6 0 0 0 0 0 0 0 0 0 1 0 10
11 17428.5 17463.6 0 16016.5 18466.5 0 0 0 0 0 0 0 0 0 0 1 11
12 17167.2 16772.1 0 17428.5 16016.5 0 0 0 0 0 0 0 0 0 0 0 12
13 19630.0 19106.9 0 17167.2 17428.5 1 0 0 0 0 0 0 0 0 0 0 13
14 17183.6 16721.3 0 19630.0 17167.2 0 1 0 0 0 0 0 0 0 0 0 14
15 18344.7 18161.3 0 17183.6 19630.0 0 0 1 0 0 0 0 0 0 0 0 15
16 19301.4 18509.9 0 18344.7 17183.6 0 0 0 1 0 0 0 0 0 0 0 16
17 18147.5 17802.7 0 19301.4 18344.7 0 0 0 0 1 0 0 0 0 0 0 17
18 16192.9 16409.9 0 18147.5 19301.4 0 0 0 0 0 1 0 0 0 0 0 18
19 18374.4 17967.7 0 16192.9 18147.5 0 0 0 0 0 0 1 0 0 0 0 19
20 20515.2 20286.6 0 18374.4 16192.9 0 0 0 0 0 0 0 1 0 0 0 20
21 18957.2 19537.3 0 20515.2 18374.4 0 0 0 0 0 0 0 0 1 0 0 21
22 16471.5 18021.9 0 18957.2 20515.2 0 0 0 0 0 0 0 0 0 1 0 22
23 18746.8 20194.3 0 16471.5 18957.2 0 0 0 0 0 0 0 0 0 0 1 23
24 19009.5 19049.6 0 18746.8 16471.5 0 0 0 0 0 0 0 0 0 0 0 24
25 19211.2 20244.7 0 19009.5 18746.8 1 0 0 0 0 0 0 0 0 0 0 25
26 20547.7 21473.3 0 19211.2 19009.5 0 1 0 0 0 0 0 0 0 0 0 26
27 19325.8 19673.6 0 20547.7 19211.2 0 0 1 0 0 0 0 0 0 0 0 27
28 20605.5 21053.2 0 19325.8 20547.7 0 0 0 1 0 0 0 0 0 0 0 28
29 20056.9 20159.5 0 20605.5 19325.8 0 0 0 0 1 0 0 0 0 0 0 29
30 16141.4 18203.6 0 20056.9 20605.5 0 0 0 0 0 1 0 0 0 0 0 30
31 20359.8 21289.5 0 16141.4 20056.9 0 0 0 0 0 0 1 0 0 0 0 31
32 19711.6 20432.3 1 20359.8 16141.4 0 0 0 0 0 0 0 1 0 0 0 32
33 15638.6 17180.4 1 19711.6 20359.8 0 0 0 0 0 0 0 0 1 0 0 33
34 14384.5 15816.8 1 15638.6 19711.6 0 0 0 0 0 0 0 0 0 1 0 34
35 13855.6 15071.8 1 14384.5 15638.6 0 0 0 0 0 0 0 0 0 0 1 35
36 14308.3 14521.1 1 13855.6 14384.5 0 0 0 0 0 0 0 0 0 0 0 36
37 15290.6 15668.8 1 14308.3 13855.6 1 0 0 0 0 0 0 0 0 0 0 37
38 14423.8 14346.9 1 15290.6 14308.3 0 1 0 0 0 0 0 0 0 0 0 38
39 13779.7 13881.0 1 14423.8 15290.6 0 0 1 0 0 0 0 0 0 0 0 39
40 15686.3 15465.9 1 13779.7 14423.8 0 0 0 1 0 0 0 0 0 0 0 40
41 14733.8 14238.2 1 15686.3 13779.7 0 0 0 0 1 0 0 0 0 0 0 41
42 12522.5 13557.7 1 14733.8 15686.3 0 0 0 0 0 1 0 0 0 0 0 42
43 16189.4 16127.6 1 12522.5 14733.8 0 0 0 0 0 0 1 0 0 0 0 43
44 16059.1 16793.9 1 16189.4 12522.5 0 0 0 0 0 0 0 1 0 0 0 44
45 16007.1 16014.0 1 16059.1 16189.4 0 0 0 0 0 0 0 0 1 0 0 45
46 15806.8 16867.9 1 16007.1 16059.1 0 0 0 0 0 0 0 0 0 1 0 46
47 15160.0 16014.6 0 15806.8 16007.1 0 0 0 0 0 0 0 0 0 0 1 47
48 15692.1 15878.6 0 15160.0 15806.8 0 0 0 0 0 0 0 0 0 0 0 48
49 18908.9 18664.9 0 15692.1 15160.0 1 0 0 0 0 0 0 0 0 0 0 49
50 16969.9 17962.5 0 18908.9 15692.1 0 1 0 0 0 0 0 0 0 0 0 50
51 16997.5 17332.7 0 16969.9 18908.9 0 0 1 0 0 0 0 0 0 0 0 51
52 19858.9 19542.1 0 16997.5 16969.9 0 0 0 1 0 0 0 0 0 0 0 52
53 17681.2 17203.6 0 19858.9 16997.5 0 0 0 0 1 0 0 0 0 0 0 53
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) invoer crisis `y-1t` `y-2t` M1
5955.7711 0.9002 -867.8959 -0.0883 -0.1386 47.9933
M2 M3 M4 M5 M6 M7
12.2727 442.3131 699.7922 886.7197 -701.2408 326.1782
M8 M9 M10 M11 t
336.9343 477.9925 -333.7135 -664.5636 -16.2181
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-604.703 -249.490 6.556 232.991 735.940
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5955.77107 846.15132 7.039 2.92e-08 ***
invoer 0.90021 0.06033 14.921 < 2e-16 ***
crisis -867.89594 195.97405 -4.429 8.48e-05 ***
`y-1t` -0.08831 0.05983 -1.476 0.14862
`y-2t` -0.13861 0.06150 -2.254 0.03039 *
M1 47.99326 278.29163 0.172 0.86404
M2 12.27269 275.36734 0.045 0.96470
M3 442.31308 290.44895 1.523 0.13653
M4 699.79223 264.84154 2.642 0.01211 *
M5 886.71966 288.61365 3.072 0.00403 **
M6 -701.24082 326.83046 -2.146 0.03872 *
M7 326.17823 314.45132 1.037 0.30652
M8 336.93431 342.15703 0.985 0.33133
M9 477.99250 316.01955 1.513 0.13913
M10 -333.71352 324.54810 -1.028 0.31070
M11 -664.56361 289.25061 -2.298 0.02751 *
t -16.21811 4.36150 -3.718 0.00068 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 380.2 on 36 degrees of freedom
Multiple R-squared: 0.9762, Adjusted R-squared: 0.9656
F-statistic: 92.22 on 16 and 36 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,] 0.7941769 0.4116462 0.2058231
[2,] 0.7553996 0.4892009 0.2446004
[3,] 0.8041048 0.3917905 0.1958952
[4,] 0.7506653 0.4986695 0.2493347
[5,] 0.7196014 0.5607973 0.2803986
[6,] 0.7559407 0.4881187 0.2440593
[7,] 0.6753242 0.6493515 0.3246758
[8,] 0.6606834 0.6786332 0.3393166
[9,] 0.5865013 0.8269974 0.4134987
[10,] 0.4798443 0.9596886 0.5201557
[11,] 0.3733345 0.7466690 0.6266655
[12,] 0.3229473 0.6458945 0.6770527
[13,] 0.5056789 0.9886421 0.4943211
[14,] 0.4320187 0.8640374 0.5679813
> postscript(file="/var/www/html/rcomp/tmp/1a33a1291452723.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/2kc2d1291452723.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/3kc2d1291452723.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/4kc2d1291452723.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/5kc2d1291452723.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 = 53
Frequency = 1
1 2 3 4 5 6
-452.661236 -351.356717 65.474674 -399.904385 -60.493779 -437.365495
7 8 9 10 11 12
104.846164 5.115524 242.963906 189.299600 568.875803 66.814317
13 14 15 16 17 18
568.678385 503.018914 79.335445 244.394209 -198.160916 735.940447
19 20 21 22 23 24
171.343841 151.823546 -365.058414 -499.500066 -268.209111 232.991362
25 26 27 28 29 30
-334.339671 2.327988 132.692136 6.555952 35.399630 -386.267212
31 32 33 34 35 36
-378.832640 447.763773 -295.206622 56.616425 -129.875036 -50.315460
37 38 39 40 41 42
-166.295156 358.323506 -220.577660 -159.007298 -97.943696 87.692261
43 44 45 46 47 48
102.642636 -604.702843 417.301129 253.584040 -170.791656 -249.490220
49 50 51 52 53
384.617678 -512.313691 -56.924595 307.961522 321.198761
> postscript(file="/var/www/html/rcomp/tmp/6d32g1291452723.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 = 53
Frequency = 1
lag(myerror, k = 1) myerror
0 -452.661236 NA
1 -351.356717 -452.661236
2 65.474674 -351.356717
3 -399.904385 65.474674
4 -60.493779 -399.904385
5 -437.365495 -60.493779
6 104.846164 -437.365495
7 5.115524 104.846164
8 242.963906 5.115524
9 189.299600 242.963906
10 568.875803 189.299600
11 66.814317 568.875803
12 568.678385 66.814317
13 503.018914 568.678385
14 79.335445 503.018914
15 244.394209 79.335445
16 -198.160916 244.394209
17 735.940447 -198.160916
18 171.343841 735.940447
19 151.823546 171.343841
20 -365.058414 151.823546
21 -499.500066 -365.058414
22 -268.209111 -499.500066
23 232.991362 -268.209111
24 -334.339671 232.991362
25 2.327988 -334.339671
26 132.692136 2.327988
27 6.555952 132.692136
28 35.399630 6.555952
29 -386.267212 35.399630
30 -378.832640 -386.267212
31 447.763773 -378.832640
32 -295.206622 447.763773
33 56.616425 -295.206622
34 -129.875036 56.616425
35 -50.315460 -129.875036
36 -166.295156 -50.315460
37 358.323506 -166.295156
38 -220.577660 358.323506
39 -159.007298 -220.577660
40 -97.943696 -159.007298
41 87.692261 -97.943696
42 102.642636 87.692261
43 -604.702843 102.642636
44 417.301129 -604.702843
45 253.584040 417.301129
46 -170.791656 253.584040
47 -249.490220 -170.791656
48 384.617678 -249.490220
49 -512.313691 384.617678
50 -56.924595 -512.313691
51 307.961522 -56.924595
52 321.198761 307.961522
53 NA 321.198761
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -351.356717 -452.661236
[2,] 65.474674 -351.356717
[3,] -399.904385 65.474674
[4,] -60.493779 -399.904385
[5,] -437.365495 -60.493779
[6,] 104.846164 -437.365495
[7,] 5.115524 104.846164
[8,] 242.963906 5.115524
[9,] 189.299600 242.963906
[10,] 568.875803 189.299600
[11,] 66.814317 568.875803
[12,] 568.678385 66.814317
[13,] 503.018914 568.678385
[14,] 79.335445 503.018914
[15,] 244.394209 79.335445
[16,] -198.160916 244.394209
[17,] 735.940447 -198.160916
[18,] 171.343841 735.940447
[19,] 151.823546 171.343841
[20,] -365.058414 151.823546
[21,] -499.500066 -365.058414
[22,] -268.209111 -499.500066
[23,] 232.991362 -268.209111
[24,] -334.339671 232.991362
[25,] 2.327988 -334.339671
[26,] 132.692136 2.327988
[27,] 6.555952 132.692136
[28,] 35.399630 6.555952
[29,] -386.267212 35.399630
[30,] -378.832640 -386.267212
[31,] 447.763773 -378.832640
[32,] -295.206622 447.763773
[33,] 56.616425 -295.206622
[34,] -129.875036 56.616425
[35,] -50.315460 -129.875036
[36,] -166.295156 -50.315460
[37,] 358.323506 -166.295156
[38,] -220.577660 358.323506
[39,] -159.007298 -220.577660
[40,] -97.943696 -159.007298
[41,] 87.692261 -97.943696
[42,] 102.642636 87.692261
[43,] -604.702843 102.642636
[44,] 417.301129 -604.702843
[45,] 253.584040 417.301129
[46,] -170.791656 253.584040
[47,] -249.490220 -170.791656
[48,] 384.617678 -249.490220
[49,] -512.313691 384.617678
[50,] -56.924595 -512.313691
[51,] 307.961522 -56.924595
[52,] 321.198761 307.961522
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -351.356717 -452.661236
2 65.474674 -351.356717
3 -399.904385 65.474674
4 -60.493779 -399.904385
5 -437.365495 -60.493779
6 104.846164 -437.365495
7 5.115524 104.846164
8 242.963906 5.115524
9 189.299600 242.963906
10 568.875803 189.299600
11 66.814317 568.875803
12 568.678385 66.814317
13 503.018914 568.678385
14 79.335445 503.018914
15 244.394209 79.335445
16 -198.160916 244.394209
17 735.940447 -198.160916
18 171.343841 735.940447
19 151.823546 171.343841
20 -365.058414 151.823546
21 -499.500066 -365.058414
22 -268.209111 -499.500066
23 232.991362 -268.209111
24 -334.339671 232.991362
25 2.327988 -334.339671
26 132.692136 2.327988
27 6.555952 132.692136
28 35.399630 6.555952
29 -386.267212 35.399630
30 -378.832640 -386.267212
31 447.763773 -378.832640
32 -295.206622 447.763773
33 56.616425 -295.206622
34 -129.875036 56.616425
35 -50.315460 -129.875036
36 -166.295156 -50.315460
37 358.323506 -166.295156
38 -220.577660 358.323506
39 -159.007298 -220.577660
40 -97.943696 -159.007298
41 87.692261 -97.943696
42 102.642636 87.692261
43 -604.702843 102.642636
44 417.301129 -604.702843
45 253.584040 417.301129
46 -170.791656 253.584040
47 -249.490220 -170.791656
48 384.617678 -249.490220
49 -512.313691 384.617678
50 -56.924595 -512.313691
51 307.961522 -56.924595
52 321.198761 307.961522
> 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/7ocjj1291452723.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/8ocjj1291452723.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/9ocjj1291452723.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/10z40m1291452723.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/112mya1291452723.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/12n5fy1291452723.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/13ked71291452723.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/14u6ua1291452723.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/15g6tx1291452723.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/16uy8o1291452723.tab")
+ }
>
> try(system("convert tmp/1a33a1291452723.ps tmp/1a33a1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/2kc2d1291452723.ps tmp/2kc2d1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/3kc2d1291452723.ps tmp/3kc2d1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/4kc2d1291452723.ps tmp/4kc2d1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/5kc2d1291452723.ps tmp/5kc2d1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/6d32g1291452723.ps tmp/6d32g1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/7ocjj1291452723.ps tmp/7ocjj1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/8ocjj1291452723.ps tmp/8ocjj1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/9ocjj1291452723.ps tmp/9ocjj1291452723.png",intern=TRUE))
character(0)
> try(system("convert tmp/10z40m1291452723.ps tmp/10z40m1291452723.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.396 1.661 6.411