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(30.996
+ ,0
+ ,30.524
+ ,30.167
+ ,29.571
+ ,29.837
+ ,31.033
+ ,0
+ ,30.996
+ ,30.524
+ ,30.167
+ ,29.571
+ ,31.198
+ ,0
+ ,31.033
+ ,30.996
+ ,30.524
+ ,30.167
+ ,30.937
+ ,0
+ ,31.198
+ ,31.033
+ ,30.996
+ ,30.524
+ ,31.649
+ ,0
+ ,30.937
+ ,31.198
+ ,31.033
+ ,30.996
+ ,33.115
+ ,0
+ ,31.649
+ ,30.937
+ ,31.198
+ ,31.033
+ ,34.106
+ ,0
+ ,33.115
+ ,31.649
+ ,30.937
+ ,31.198
+ ,33.926
+ ,0
+ ,34.106
+ ,33.115
+ ,31.649
+ ,30.937
+ ,33.382
+ ,0
+ ,33.926
+ ,34.106
+ ,33.115
+ ,31.649
+ ,32.851
+ ,0
+ ,33.382
+ ,33.926
+ ,34.106
+ ,33.115
+ ,32.948
+ ,0
+ ,32.851
+ ,33.382
+ ,33.926
+ ,34.106
+ ,36.112
+ ,0
+ ,32.948
+ ,32.851
+ ,33.382
+ ,33.926
+ ,36.113
+ ,0
+ ,36.112
+ ,32.948
+ ,32.851
+ ,33.382
+ ,35.210
+ ,0
+ ,36.113
+ ,36.112
+ ,32.948
+ ,32.851
+ ,35.193
+ ,0
+ ,35.210
+ ,36.113
+ ,36.112
+ ,32.948
+ ,34.383
+ ,0
+ ,35.193
+ ,35.210
+ ,36.113
+ ,36.112
+ ,35.349
+ ,0
+ ,34.383
+ ,35.193
+ ,35.210
+ ,36.113
+ ,37.058
+ ,0
+ ,35.349
+ ,34.383
+ ,35.193
+ ,35.210
+ ,38.076
+ ,0
+ ,37.058
+ ,35.349
+ ,34.383
+ ,35.193
+ ,36.630
+ ,0
+ ,38.076
+ ,37.058
+ ,35.349
+ ,34.383
+ ,36.045
+ ,0
+ ,36.630
+ ,38.076
+ ,37.058
+ ,35.349
+ ,35.638
+ ,0
+ ,36.045
+ ,36.630
+ ,38.076
+ ,37.058
+ ,35.114
+ ,0
+ ,35.638
+ ,36.045
+ ,36.630
+ ,38.076
+ ,35.465
+ ,0
+ ,35.114
+ ,35.638
+ ,36.045
+ ,36.630
+ ,35.254
+ ,0
+ ,35.465
+ ,35.114
+ ,35.638
+ ,36.045
+ ,35.299
+ ,0
+ ,35.254
+ ,35.465
+ ,35.114
+ ,35.638
+ ,35.916
+ ,0
+ ,35.299
+ ,35.254
+ ,35.465
+ ,35.114
+ ,36.683
+ ,0
+ ,35.916
+ ,35.299
+ ,35.254
+ ,35.465
+ ,37.288
+ ,0
+ ,36.683
+ ,35.916
+ ,35.299
+ ,35.254
+ ,38.536
+ ,0
+ ,37.288
+ ,36.683
+ ,35.916
+ ,35.299
+ ,38.977
+ ,0
+ ,38.536
+ ,37.288
+ ,36.683
+ ,35.916
+ ,36.407
+ ,0
+ ,38.977
+ ,38.536
+ ,37.288
+ ,36.683
+ ,34.955
+ ,0
+ ,36.407
+ ,38.977
+ ,38.536
+ ,37.288
+ ,34.951
+ ,0
+ ,34.955
+ ,36.407
+ ,38.977
+ ,38.536
+ ,32.680
+ ,0
+ ,34.951
+ ,34.955
+ ,36.407
+ ,38.977
+ ,34.791
+ ,0
+ ,32.680
+ ,34.951
+ ,34.955
+ ,36.407
+ ,34.178
+ ,0
+ ,34.791
+ ,32.680
+ ,34.951
+ ,34.955
+ ,35.213
+ ,0
+ ,34.178
+ ,34.791
+ ,32.680
+ ,34.951
+ ,34.871
+ ,0
+ ,35.213
+ ,34.178
+ ,34.791
+ ,32.680
+ ,35.299
+ ,0
+ ,34.871
+ ,35.213
+ ,34.178
+ ,34.791
+ ,35.443
+ ,0
+ ,35.299
+ ,34.871
+ ,35.213
+ ,34.178
+ ,37.108
+ ,0
+ ,35.443
+ ,35.299
+ ,34.871
+ ,35.213
+ ,36.419
+ ,0
+ ,37.108
+ ,35.443
+ ,35.299
+ ,34.871
+ ,34.471
+ ,0
+ ,36.419
+ ,37.108
+ ,35.443
+ ,35.299
+ ,33.868
+ ,0
+ ,34.471
+ ,36.419
+ ,37.108
+ ,35.443
+ ,34.385
+ ,0
+ ,33.868
+ ,34.471
+ ,36.419
+ ,37.108
+ ,33.643
+ ,1
+ ,34.385
+ ,33.868
+ ,34.471
+ ,36.419
+ ,34.627
+ ,1
+ ,33.643
+ ,34.385
+ ,33.868
+ ,34.471
+ ,32.919
+ ,1
+ ,34.627
+ ,33.643
+ ,34.385
+ ,33.868
+ ,35.500
+ ,1
+ ,32.919
+ ,34.627
+ ,33.643
+ ,34.385
+ ,36.110
+ ,1
+ ,35.500
+ ,32.919
+ ,34.627
+ ,33.643
+ ,37.086
+ ,1
+ ,36.110
+ ,35.500
+ ,32.919
+ ,34.627
+ ,37.711
+ ,1
+ ,37.086
+ ,36.110
+ ,35.500
+ ,32.919
+ ,40.427
+ ,1
+ ,37.711
+ ,37.086
+ ,36.110
+ ,35.500
+ ,39.884
+ ,1
+ ,40.427
+ ,37.711
+ ,37.086
+ ,36.110
+ ,38.512
+ ,1
+ ,39.884
+ ,40.427
+ ,37.711
+ ,37.086
+ ,38.767
+ ,1
+ ,38.512
+ ,39.884
+ ,40.427
+ ,37.711)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('saldo_zichtrek'
+ ,'crisis'
+ ,'Yt-1'
+ ,'Yt-2'
+ ,'Yt-3'
+ ,'Yt-4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('saldo_zichtrek','crisis','Yt-1','Yt-2','Yt-3','Yt-4'),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
saldo_zichtrek crisis Yt-1 Yt-2 Yt-3 Yt-4 M1 M2 M3 M4 M5 M6 M7 M8 M9
1 30.996 0 30.524 30.167 29.571 29.837 1 0 0 0 0 0 0 0 0
2 31.033 0 30.996 30.524 30.167 29.571 0 1 0 0 0 0 0 0 0
3 31.198 0 31.033 30.996 30.524 30.167 0 0 1 0 0 0 0 0 0
4 30.937 0 31.198 31.033 30.996 30.524 0 0 0 1 0 0 0 0 0
5 31.649 0 30.937 31.198 31.033 30.996 0 0 0 0 1 0 0 0 0
6 33.115 0 31.649 30.937 31.198 31.033 0 0 0 0 0 1 0 0 0
7 34.106 0 33.115 31.649 30.937 31.198 0 0 0 0 0 0 1 0 0
8 33.926 0 34.106 33.115 31.649 30.937 0 0 0 0 0 0 0 1 0
9 33.382 0 33.926 34.106 33.115 31.649 0 0 0 0 0 0 0 0 1
10 32.851 0 33.382 33.926 34.106 33.115 0 0 0 0 0 0 0 0 0
11 32.948 0 32.851 33.382 33.926 34.106 0 0 0 0 0 0 0 0 0
12 36.112 0 32.948 32.851 33.382 33.926 0 0 0 0 0 0 0 0 0
13 36.113 0 36.112 32.948 32.851 33.382 1 0 0 0 0 0 0 0 0
14 35.210 0 36.113 36.112 32.948 32.851 0 1 0 0 0 0 0 0 0
15 35.193 0 35.210 36.113 36.112 32.948 0 0 1 0 0 0 0 0 0
16 34.383 0 35.193 35.210 36.113 36.112 0 0 0 1 0 0 0 0 0
17 35.349 0 34.383 35.193 35.210 36.113 0 0 0 0 1 0 0 0 0
18 37.058 0 35.349 34.383 35.193 35.210 0 0 0 0 0 1 0 0 0
19 38.076 0 37.058 35.349 34.383 35.193 0 0 0 0 0 0 1 0 0
20 36.630 0 38.076 37.058 35.349 34.383 0 0 0 0 0 0 0 1 0
21 36.045 0 36.630 38.076 37.058 35.349 0 0 0 0 0 0 0 0 1
22 35.638 0 36.045 36.630 38.076 37.058 0 0 0 0 0 0 0 0 0
23 35.114 0 35.638 36.045 36.630 38.076 0 0 0 0 0 0 0 0 0
24 35.465 0 35.114 35.638 36.045 36.630 0 0 0 0 0 0 0 0 0
25 35.254 0 35.465 35.114 35.638 36.045 1 0 0 0 0 0 0 0 0
26 35.299 0 35.254 35.465 35.114 35.638 0 1 0 0 0 0 0 0 0
27 35.916 0 35.299 35.254 35.465 35.114 0 0 1 0 0 0 0 0 0
28 36.683 0 35.916 35.299 35.254 35.465 0 0 0 1 0 0 0 0 0
29 37.288 0 36.683 35.916 35.299 35.254 0 0 0 0 1 0 0 0 0
30 38.536 0 37.288 36.683 35.916 35.299 0 0 0 0 0 1 0 0 0
31 38.977 0 38.536 37.288 36.683 35.916 0 0 0 0 0 0 1 0 0
32 36.407 0 38.977 38.536 37.288 36.683 0 0 0 0 0 0 0 1 0
33 34.955 0 36.407 38.977 38.536 37.288 0 0 0 0 0 0 0 0 1
34 34.951 0 34.955 36.407 38.977 38.536 0 0 0 0 0 0 0 0 0
35 32.680 0 34.951 34.955 36.407 38.977 0 0 0 0 0 0 0 0 0
36 34.791 0 32.680 34.951 34.955 36.407 0 0 0 0 0 0 0 0 0
37 34.178 0 34.791 32.680 34.951 34.955 1 0 0 0 0 0 0 0 0
38 35.213 0 34.178 34.791 32.680 34.951 0 1 0 0 0 0 0 0 0
39 34.871 0 35.213 34.178 34.791 32.680 0 0 1 0 0 0 0 0 0
40 35.299 0 34.871 35.213 34.178 34.791 0 0 0 1 0 0 0 0 0
41 35.443 0 35.299 34.871 35.213 34.178 0 0 0 0 1 0 0 0 0
42 37.108 0 35.443 35.299 34.871 35.213 0 0 0 0 0 1 0 0 0
43 36.419 0 37.108 35.443 35.299 34.871 0 0 0 0 0 0 1 0 0
44 34.471 0 36.419 37.108 35.443 35.299 0 0 0 0 0 0 0 1 0
45 33.868 0 34.471 36.419 37.108 35.443 0 0 0 0 0 0 0 0 1
46 34.385 0 33.868 34.471 36.419 37.108 0 0 0 0 0 0 0 0 0
47 33.643 1 34.385 33.868 34.471 36.419 0 0 0 0 0 0 0 0 0
48 34.627 1 33.643 34.385 33.868 34.471 0 0 0 0 0 0 0 0 0
49 32.919 1 34.627 33.643 34.385 33.868 1 0 0 0 0 0 0 0 0
50 35.500 1 32.919 34.627 33.643 34.385 0 1 0 0 0 0 0 0 0
51 36.110 1 35.500 32.919 34.627 33.643 0 0 1 0 0 0 0 0 0
52 37.086 1 36.110 35.500 32.919 34.627 0 0 0 1 0 0 0 0 0
53 37.711 1 37.086 36.110 35.500 32.919 0 0 0 0 1 0 0 0 0
54 40.427 1 37.711 37.086 36.110 35.500 0 0 0 0 0 1 0 0 0
55 39.884 1 40.427 37.711 37.086 36.110 0 0 0 0 0 0 1 0 0
56 38.512 1 39.884 40.427 37.711 37.086 0 0 0 0 0 0 0 1 0
57 38.767 1 38.512 39.884 40.427 37.711 0 0 0 0 0 0 0 0 1
M10 M11 t
1 0 0 1
2 0 0 2
3 0 0 3
4 0 0 4
5 0 0 5
6 0 0 6
7 0 0 7
8 0 0 8
9 0 0 9
10 1 0 10
11 0 1 11
12 0 0 12
13 0 0 13
14 0 0 14
15 0 0 15
16 0 0 16
17 0 0 17
18 0 0 18
19 0 0 19
20 0 0 20
21 0 0 21
22 1 0 22
23 0 1 23
24 0 0 24
25 0 0 25
26 0 0 26
27 0 0 27
28 0 0 28
29 0 0 29
30 0 0 30
31 0 0 31
32 0 0 32
33 0 0 33
34 1 0 34
35 0 1 35
36 0 0 36
37 0 0 37
38 0 0 38
39 0 0 39
40 0 0 40
41 0 0 41
42 0 0 42
43 0 0 43
44 0 0 44
45 0 0 45
46 1 0 46
47 0 1 47
48 0 0 48
49 0 0 49
50 0 0 50
51 0 0 51
52 0 0 52
53 0 0 53
54 0 0 54
55 0 0 55
56 0 0 56
57 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) crisis `Yt-1` `Yt-2` `Yt-3` `Yt-4`
4.255941 0.720235 0.856141 0.082122 -0.250362 0.228921
M1 M2 M3 M4 M5 M6
-1.709062 -1.015327 -0.767055 -1.184544 -0.537866 0.613410
M7 M8 M9 M10 M11 t
-0.685453 -2.431979 -1.442355 -1.195527 -2.557216 -0.007374
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.53968 -0.46286 0.06012 0.36860 1.62978
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.255941 2.781155 1.530 0.134020
crisis 0.720235 0.450110 1.600 0.117641
`Yt-1` 0.856141 0.154990 5.524 2.37e-06 ***
`Yt-2` 0.082122 0.194523 0.422 0.675218
`Yt-3` -0.250362 0.192694 -1.299 0.201479
`Yt-4` 0.228921 0.160764 1.424 0.162412
M1 -1.709062 0.635516 -2.689 0.010482 *
M2 -1.015327 0.596114 -1.703 0.096480 .
M3 -0.767055 0.660432 -1.161 0.252521
M4 -1.184544 0.578870 -2.046 0.047510 *
M5 -0.537866 0.604839 -0.889 0.379310
M6 0.613410 0.608885 1.007 0.319937
M7 -0.685453 0.714932 -0.959 0.343582
M8 -2.431979 0.705807 -3.446 0.001377 **
M9 -1.442355 0.686764 -2.100 0.042227 *
M10 -1.195527 0.627557 -1.905 0.064166 .
M11 -2.557216 0.609255 -4.197 0.000151 ***
t -0.007374 0.013092 -0.563 0.576502
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.798 on 39 degrees of freedom
Multiple R-squared: 0.9049, Adjusted R-squared: 0.8635
F-statistic: 21.84 on 17 and 39 DF, p-value: 8.303e-15
> 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.3093590 0.6187179 0.6906410
[2,] 0.1616141 0.3232281 0.8383859
[3,] 0.1398871 0.2797742 0.8601129
[4,] 0.4490713 0.8981425 0.5509287
[5,] 0.4982169 0.9964339 0.5017831
[6,] 0.5718290 0.8563420 0.4281710
[7,] 0.5386464 0.9227071 0.4613536
[8,] 0.5548325 0.8903349 0.4451675
[9,] 0.4748170 0.9496339 0.5251830
[10,] 0.3523339 0.7046678 0.6476661
[11,] 0.5550474 0.8899052 0.4449526
[12,] 0.5653039 0.8693922 0.4346961
[13,] 0.4429630 0.8859260 0.5570370
[14,] 0.3091419 0.6182838 0.6908581
[15,] 0.6151498 0.7697004 0.3848502
[16,] 0.6697539 0.6604923 0.3302461
> postscript(file="/var/www/html/rcomp/tmp/13zaj1259256546.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/2bhhr1259256546.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/3rh1c1259256546.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/4r9391259256546.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/5j3e41259256546.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
0.41936876 -0.45330031 -0.64669639 -0.59068951 -0.40687866 -0.64007993
7 8 9 10 11 12
0.24046618 1.08354366 -0.16594569 -0.54336755 1.15005410 1.62978192
13 14 15 16 17 18
0.62201189 -1.08219780 0.20285505 -0.81762808 -0.02236722 -0.01532300
19 20 21 22 23 24
0.56753694 0.29081258 0.08467270 -0.07854881 0.56793978 -0.96430212
25 26 27 28 29 30
0.31568198 -0.21187677 0.35085725 0.87760788 0.19554238 -0.13714134
31 32 33 34 35 36
0.54272981 -0.77753218 -0.87376070 0.16167186 -1.36198327 0.36860276
37 38 39 40 41 42
0.18261605 0.31505421 -0.05521670 0.36872557 -0.06546854 -0.02536053
43 44 45 46 47 48
-0.65997893 -0.46285845 0.06012468 0.46024451 -0.35601060 -1.03408256
49 50 51 52 53 54
-1.53967869 1.43232066 0.14820080 0.16198415 0.29917204 0.81790480
55 56 57
-0.69075400 -0.13396561 0.89490901
> postscript(file="/var/www/html/rcomp/tmp/633t51259256546.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 0.41936876 NA
1 -0.45330031 0.41936876
2 -0.64669639 -0.45330031
3 -0.59068951 -0.64669639
4 -0.40687866 -0.59068951
5 -0.64007993 -0.40687866
6 0.24046618 -0.64007993
7 1.08354366 0.24046618
8 -0.16594569 1.08354366
9 -0.54336755 -0.16594569
10 1.15005410 -0.54336755
11 1.62978192 1.15005410
12 0.62201189 1.62978192
13 -1.08219780 0.62201189
14 0.20285505 -1.08219780
15 -0.81762808 0.20285505
16 -0.02236722 -0.81762808
17 -0.01532300 -0.02236722
18 0.56753694 -0.01532300
19 0.29081258 0.56753694
20 0.08467270 0.29081258
21 -0.07854881 0.08467270
22 0.56793978 -0.07854881
23 -0.96430212 0.56793978
24 0.31568198 -0.96430212
25 -0.21187677 0.31568198
26 0.35085725 -0.21187677
27 0.87760788 0.35085725
28 0.19554238 0.87760788
29 -0.13714134 0.19554238
30 0.54272981 -0.13714134
31 -0.77753218 0.54272981
32 -0.87376070 -0.77753218
33 0.16167186 -0.87376070
34 -1.36198327 0.16167186
35 0.36860276 -1.36198327
36 0.18261605 0.36860276
37 0.31505421 0.18261605
38 -0.05521670 0.31505421
39 0.36872557 -0.05521670
40 -0.06546854 0.36872557
41 -0.02536053 -0.06546854
42 -0.65997893 -0.02536053
43 -0.46285845 -0.65997893
44 0.06012468 -0.46285845
45 0.46024451 0.06012468
46 -0.35601060 0.46024451
47 -1.03408256 -0.35601060
48 -1.53967869 -1.03408256
49 1.43232066 -1.53967869
50 0.14820080 1.43232066
51 0.16198415 0.14820080
52 0.29917204 0.16198415
53 0.81790480 0.29917204
54 -0.69075400 0.81790480
55 -0.13396561 -0.69075400
56 0.89490901 -0.13396561
57 NA 0.89490901
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.45330031 0.41936876
[2,] -0.64669639 -0.45330031
[3,] -0.59068951 -0.64669639
[4,] -0.40687866 -0.59068951
[5,] -0.64007993 -0.40687866
[6,] 0.24046618 -0.64007993
[7,] 1.08354366 0.24046618
[8,] -0.16594569 1.08354366
[9,] -0.54336755 -0.16594569
[10,] 1.15005410 -0.54336755
[11,] 1.62978192 1.15005410
[12,] 0.62201189 1.62978192
[13,] -1.08219780 0.62201189
[14,] 0.20285505 -1.08219780
[15,] -0.81762808 0.20285505
[16,] -0.02236722 -0.81762808
[17,] -0.01532300 -0.02236722
[18,] 0.56753694 -0.01532300
[19,] 0.29081258 0.56753694
[20,] 0.08467270 0.29081258
[21,] -0.07854881 0.08467270
[22,] 0.56793978 -0.07854881
[23,] -0.96430212 0.56793978
[24,] 0.31568198 -0.96430212
[25,] -0.21187677 0.31568198
[26,] 0.35085725 -0.21187677
[27,] 0.87760788 0.35085725
[28,] 0.19554238 0.87760788
[29,] -0.13714134 0.19554238
[30,] 0.54272981 -0.13714134
[31,] -0.77753218 0.54272981
[32,] -0.87376070 -0.77753218
[33,] 0.16167186 -0.87376070
[34,] -1.36198327 0.16167186
[35,] 0.36860276 -1.36198327
[36,] 0.18261605 0.36860276
[37,] 0.31505421 0.18261605
[38,] -0.05521670 0.31505421
[39,] 0.36872557 -0.05521670
[40,] -0.06546854 0.36872557
[41,] -0.02536053 -0.06546854
[42,] -0.65997893 -0.02536053
[43,] -0.46285845 -0.65997893
[44,] 0.06012468 -0.46285845
[45,] 0.46024451 0.06012468
[46,] -0.35601060 0.46024451
[47,] -1.03408256 -0.35601060
[48,] -1.53967869 -1.03408256
[49,] 1.43232066 -1.53967869
[50,] 0.14820080 1.43232066
[51,] 0.16198415 0.14820080
[52,] 0.29917204 0.16198415
[53,] 0.81790480 0.29917204
[54,] -0.69075400 0.81790480
[55,] -0.13396561 -0.69075400
[56,] 0.89490901 -0.13396561
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.45330031 0.41936876
2 -0.64669639 -0.45330031
3 -0.59068951 -0.64669639
4 -0.40687866 -0.59068951
5 -0.64007993 -0.40687866
6 0.24046618 -0.64007993
7 1.08354366 0.24046618
8 -0.16594569 1.08354366
9 -0.54336755 -0.16594569
10 1.15005410 -0.54336755
11 1.62978192 1.15005410
12 0.62201189 1.62978192
13 -1.08219780 0.62201189
14 0.20285505 -1.08219780
15 -0.81762808 0.20285505
16 -0.02236722 -0.81762808
17 -0.01532300 -0.02236722
18 0.56753694 -0.01532300
19 0.29081258 0.56753694
20 0.08467270 0.29081258
21 -0.07854881 0.08467270
22 0.56793978 -0.07854881
23 -0.96430212 0.56793978
24 0.31568198 -0.96430212
25 -0.21187677 0.31568198
26 0.35085725 -0.21187677
27 0.87760788 0.35085725
28 0.19554238 0.87760788
29 -0.13714134 0.19554238
30 0.54272981 -0.13714134
31 -0.77753218 0.54272981
32 -0.87376070 -0.77753218
33 0.16167186 -0.87376070
34 -1.36198327 0.16167186
35 0.36860276 -1.36198327
36 0.18261605 0.36860276
37 0.31505421 0.18261605
38 -0.05521670 0.31505421
39 0.36872557 -0.05521670
40 -0.06546854 0.36872557
41 -0.02536053 -0.06546854
42 -0.65997893 -0.02536053
43 -0.46285845 -0.65997893
44 0.06012468 -0.46285845
45 0.46024451 0.06012468
46 -0.35601060 0.46024451
47 -1.03408256 -0.35601060
48 -1.53967869 -1.03408256
49 1.43232066 -1.53967869
50 0.14820080 1.43232066
51 0.16198415 0.14820080
52 0.29917204 0.16198415
53 0.81790480 0.29917204
54 -0.69075400 0.81790480
55 -0.13396561 -0.69075400
56 0.89490901 -0.13396561
> 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/7mmlc1259256546.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/8g78m1259256546.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/9mwjn1259256546.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/10rqbp1259256546.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/11ebc11259256546.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/12kg701259256546.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/13qfrw1259256546.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/14lhg41259256546.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/15qr8w1259256546.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/16dn7x1259256546.tab")
+ }
>
> system("convert tmp/13zaj1259256546.ps tmp/13zaj1259256546.png")
> system("convert tmp/2bhhr1259256546.ps tmp/2bhhr1259256546.png")
> system("convert tmp/3rh1c1259256546.ps tmp/3rh1c1259256546.png")
> system("convert tmp/4r9391259256546.ps tmp/4r9391259256546.png")
> system("convert tmp/5j3e41259256546.ps tmp/5j3e41259256546.png")
> system("convert tmp/633t51259256546.ps tmp/633t51259256546.png")
> system("convert tmp/7mmlc1259256546.ps tmp/7mmlc1259256546.png")
> system("convert tmp/8g78m1259256546.ps tmp/8g78m1259256546.png")
> system("convert tmp/9mwjn1259256546.ps tmp/9mwjn1259256546.png")
> system("convert tmp/10rqbp1259256546.ps tmp/10rqbp1259256546.png")
>
>
> proc.time()
user system elapsed
2.409 1.592 2.861