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(114.1
+ ,0
+ ,87.4
+ ,111.4
+ ,110.3
+ ,0
+ ,96.8
+ ,87.4
+ ,103.9
+ ,0
+ ,114.1
+ ,96.8
+ ,101.6
+ ,0
+ ,110.3
+ ,114.1
+ ,94.6
+ ,0
+ ,103.9
+ ,110.3
+ ,95.9
+ ,0
+ ,101.6
+ ,103.9
+ ,104.7
+ ,0
+ ,94.6
+ ,101.6
+ ,102.8
+ ,0
+ ,95.9
+ ,94.6
+ ,98.1
+ ,0
+ ,104.7
+ ,95.9
+ ,113.9
+ ,0
+ ,102.8
+ ,104.7
+ ,80.9
+ ,0
+ ,98.1
+ ,102.8
+ ,95.7
+ ,0
+ ,113.9
+ ,98.1
+ ,113.2
+ ,0
+ ,80.9
+ ,113.9
+ ,105.9
+ ,0
+ ,95.7
+ ,80.9
+ ,108.8
+ ,0
+ ,113.2
+ ,95.7
+ ,102.3
+ ,0
+ ,105.9
+ ,113.2
+ ,99
+ ,0
+ ,108.8
+ ,105.9
+ ,100.7
+ ,0
+ ,102.3
+ ,108.8
+ ,115.5
+ ,0
+ ,99
+ ,102.3
+ ,100.7
+ ,0
+ ,100.7
+ ,99
+ ,109.9
+ ,0
+ ,115.5
+ ,100.7
+ ,114.6
+ ,0
+ ,100.7
+ ,115.5
+ ,85.4
+ ,0
+ ,109.9
+ ,100.7
+ ,100.5
+ ,0
+ ,114.6
+ ,109.9
+ ,114.8
+ ,0
+ ,85.4
+ ,114.6
+ ,116.5
+ ,0
+ ,100.5
+ ,85.4
+ ,112.9
+ ,0
+ ,114.8
+ ,100.5
+ ,102
+ ,0
+ ,116.5
+ ,114.8
+ ,106
+ ,0
+ ,112.9
+ ,116.5
+ ,105.3
+ ,0
+ ,102
+ ,112.9
+ ,118.8
+ ,0
+ ,106
+ ,102
+ ,106.1
+ ,0
+ ,105.3
+ ,106
+ ,109.3
+ ,0
+ ,118.8
+ ,105.3
+ ,117.2
+ ,0
+ ,106.1
+ ,118.8
+ ,92.5
+ ,0
+ ,109.3
+ ,106.1
+ ,104.2
+ ,0
+ ,117.2
+ ,109.3
+ ,112.5
+ ,0
+ ,92.5
+ ,117.2
+ ,122.4
+ ,0
+ ,104.2
+ ,92.5
+ ,113.3
+ ,0
+ ,112.5
+ ,104.2
+ ,100
+ ,0
+ ,122.4
+ ,112.5
+ ,110.7
+ ,0
+ ,113.3
+ ,122.4
+ ,112.8
+ ,0
+ ,100
+ ,113.3
+ ,109.8
+ ,0
+ ,110.7
+ ,100
+ ,117.3
+ ,0
+ ,112.8
+ ,110.7
+ ,109.1
+ ,0
+ ,109.8
+ ,112.8
+ ,115.9
+ ,0
+ ,117.3
+ ,109.8
+ ,96
+ ,0
+ ,109.1
+ ,117.3
+ ,99.8
+ ,0
+ ,115.9
+ ,109.1
+ ,116.8
+ ,1
+ ,96
+ ,115.9
+ ,115.7
+ ,1
+ ,99.8
+ ,96
+ ,99.4
+ ,1
+ ,116.8
+ ,99.8
+ ,94.3
+ ,1
+ ,115.7
+ ,116.8
+ ,91
+ ,1
+ ,99.4
+ ,115.7
+ ,93.2
+ ,1
+ ,94.3
+ ,99.4
+ ,103.1
+ ,1
+ ,91
+ ,94.3
+ ,94.1
+ ,1
+ ,93.2
+ ,91
+ ,91.8
+ ,1
+ ,103.1
+ ,93.2
+ ,102.7
+ ,1
+ ,94.1
+ ,103.1)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y2'
+ ,'Y3')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('Y','X','Y2','Y3'),1:58))
> 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
Y X Y2 Y3 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 114.1 0 87.4 111.4 1 0 0 0 0 0 0 0 0 0 0 1
2 110.3 0 96.8 87.4 0 1 0 0 0 0 0 0 0 0 0 2
3 103.9 0 114.1 96.8 0 0 1 0 0 0 0 0 0 0 0 3
4 101.6 0 110.3 114.1 0 0 0 1 0 0 0 0 0 0 0 4
5 94.6 0 103.9 110.3 0 0 0 0 1 0 0 0 0 0 0 5
6 95.9 0 101.6 103.9 0 0 0 0 0 1 0 0 0 0 0 6
7 104.7 0 94.6 101.6 0 0 0 0 0 0 1 0 0 0 0 7
8 102.8 0 95.9 94.6 0 0 0 0 0 0 0 1 0 0 0 8
9 98.1 0 104.7 95.9 0 0 0 0 0 0 0 0 1 0 0 9
10 113.9 0 102.8 104.7 0 0 0 0 0 0 0 0 0 1 0 10
11 80.9 0 98.1 102.8 0 0 0 0 0 0 0 0 0 0 1 11
12 95.7 0 113.9 98.1 0 0 0 0 0 0 0 0 0 0 0 12
13 113.2 0 80.9 113.9 1 0 0 0 0 0 0 0 0 0 0 13
14 105.9 0 95.7 80.9 0 1 0 0 0 0 0 0 0 0 0 14
15 108.8 0 113.2 95.7 0 0 1 0 0 0 0 0 0 0 0 15
16 102.3 0 105.9 113.2 0 0 0 1 0 0 0 0 0 0 0 16
17 99.0 0 108.8 105.9 0 0 0 0 1 0 0 0 0 0 0 17
18 100.7 0 102.3 108.8 0 0 0 0 0 1 0 0 0 0 0 18
19 115.5 0 99.0 102.3 0 0 0 0 0 0 1 0 0 0 0 19
20 100.7 0 100.7 99.0 0 0 0 0 0 0 0 1 0 0 0 20
21 109.9 0 115.5 100.7 0 0 0 0 0 0 0 0 1 0 0 21
22 114.6 0 100.7 115.5 0 0 0 0 0 0 0 0 0 1 0 22
23 85.4 0 109.9 100.7 0 0 0 0 0 0 0 0 0 0 1 23
24 100.5 0 114.6 109.9 0 0 0 0 0 0 0 0 0 0 0 24
25 114.8 0 85.4 114.6 1 0 0 0 0 0 0 0 0 0 0 25
26 116.5 0 100.5 85.4 0 1 0 0 0 0 0 0 0 0 0 26
27 112.9 0 114.8 100.5 0 0 1 0 0 0 0 0 0 0 0 27
28 102.0 0 116.5 114.8 0 0 0 1 0 0 0 0 0 0 0 28
29 106.0 0 112.9 116.5 0 0 0 0 1 0 0 0 0 0 0 29
30 105.3 0 102.0 112.9 0 0 0 0 0 1 0 0 0 0 0 30
31 118.8 0 106.0 102.0 0 0 0 0 0 0 1 0 0 0 0 31
32 106.1 0 105.3 106.0 0 0 0 0 0 0 0 1 0 0 0 32
33 109.3 0 118.8 105.3 0 0 0 0 0 0 0 0 1 0 0 33
34 117.2 0 106.1 118.8 0 0 0 0 0 0 0 0 0 1 0 34
35 92.5 0 109.3 106.1 0 0 0 0 0 0 0 0 0 0 1 35
36 104.2 0 117.2 109.3 0 0 0 0 0 0 0 0 0 0 0 36
37 112.5 0 92.5 117.2 1 0 0 0 0 0 0 0 0 0 0 37
38 122.4 0 104.2 92.5 0 1 0 0 0 0 0 0 0 0 0 38
39 113.3 0 112.5 104.2 0 0 1 0 0 0 0 0 0 0 0 39
40 100.0 0 122.4 112.5 0 0 0 1 0 0 0 0 0 0 0 40
41 110.7 0 113.3 122.4 0 0 0 0 1 0 0 0 0 0 0 41
42 112.8 0 100.0 113.3 0 0 0 0 0 1 0 0 0 0 0 42
43 109.8 0 110.7 100.0 0 0 0 0 0 0 1 0 0 0 0 43
44 117.3 0 112.8 110.7 0 0 0 0 0 0 0 1 0 0 0 44
45 109.1 0 109.8 112.8 0 0 0 0 0 0 0 0 1 0 0 45
46 115.9 0 117.3 109.8 0 0 0 0 0 0 0 0 0 1 0 46
47 96.0 0 109.1 117.3 0 0 0 0 0 0 0 0 0 0 1 47
48 99.8 0 115.9 109.1 0 0 0 0 0 0 0 0 0 0 0 48
49 116.8 1 96.0 115.9 1 0 0 0 0 0 0 0 0 0 0 49
50 115.7 1 99.8 96.0 0 1 0 0 0 0 0 0 0 0 0 50
51 99.4 1 116.8 99.8 0 0 1 0 0 0 0 0 0 0 0 51
52 94.3 1 115.7 116.8 0 0 0 1 0 0 0 0 0 0 0 52
53 91.0 1 99.4 115.7 0 0 0 0 1 0 0 0 0 0 0 53
54 93.2 1 94.3 99.4 0 0 0 0 0 1 0 0 0 0 0 54
55 103.1 1 91.0 94.3 0 0 0 0 0 0 1 0 0 0 0 55
56 94.1 1 93.2 91.0 0 0 0 0 0 0 0 1 0 0 0 56
57 91.8 1 103.1 93.2 0 0 0 0 0 0 0 0 1 0 0 57
58 102.7 1 94.1 103.1 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y2 Y3 M1 M2
18.54100 -8.01365 0.22568 0.49889 18.30646 28.68798
M3 M4 M5 M6 M7 M8
13.28591 -1.80668 -0.13604 6.07029 18.54609 11.88231
M9 M10 M11 t
8.60169 14.74997 -9.35028 0.07613
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.5096 -2.5475 0.1857 2.4705 5.8990
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 18.54100 15.85215 1.170 0.248749
X -8.01365 2.36590 -3.387 0.001544 **
Y2 0.22568 0.11275 2.002 0.051823 .
Y3 0.49889 0.11590 4.305 9.81e-05 ***
M1 18.30646 3.91496 4.676 3.03e-05 ***
M2 28.68798 3.19845 8.969 2.60e-11 ***
M3 13.28591 2.45603 5.409 2.79e-06 ***
M4 -1.80668 2.65766 -0.680 0.500361
M5 -0.13604 2.73368 -0.050 0.960545
M6 6.07029 2.83901 2.138 0.038365 *
M7 18.54609 2.80739 6.606 5.33e-08 ***
M8 11.88231 2.74625 4.327 9.15e-05 ***
M9 8.60169 2.42535 3.547 0.000975 ***
M10 14.74997 2.70026 5.462 2.35e-06 ***
M11 -9.35028 2.66126 -3.513 0.001073 **
t 0.07613 0.05205 1.463 0.151043
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.503 on 42 degrees of freedom
Multiple R-squared: 0.8909, Adjusted R-squared: 0.8519
F-statistic: 22.86 on 15 and 42 DF, p-value: 1.839e-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.28769675 0.5753935 0.7123033
[2,] 0.73918810 0.5216238 0.2608119
[3,] 0.66028232 0.6794354 0.3397177
[4,] 0.54470240 0.9105952 0.4552976
[5,] 0.49279284 0.9855857 0.5072072
[6,] 0.37373187 0.7474637 0.6262681
[7,] 0.28921165 0.5784233 0.7107883
[8,] 0.23692236 0.4738447 0.7630776
[9,] 0.18359473 0.3671895 0.8164053
[10,] 0.25270884 0.5054177 0.7472912
[11,] 0.18237676 0.3647535 0.8176232
[12,] 0.16882388 0.3376478 0.8311761
[13,] 0.14936486 0.2987297 0.8506351
[14,] 0.18049090 0.3609818 0.8195091
[15,] 0.12342972 0.2468594 0.8765703
[16,] 0.12150155 0.2430031 0.8784985
[17,] 0.08429018 0.1685804 0.9157098
[18,] 0.04594850 0.0918970 0.9540515
[19,] 0.46094346 0.9218869 0.5390565
[20,] 0.34483677 0.6896735 0.6551632
[21,] 0.21057989 0.4211598 0.7894201
> postscript(file="/var/www/html/rcomp/tmp/1myja1258736915.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/2q8tm1258736915.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/3gycx1258736915.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/4ti2z1258736915.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/5yp4t1258736915.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 = 58
Frequency = 1
1 2 3 4 5 6
1.87552198 -2.53003334 -2.19789606 2.74527033 -2.66136811 -3.93185630
7 8 9 10 11 12
-4.95658725 2.92993955 -1.20008257 4.41402215 -2.55327633 1.59942756
13 14 15 16 17 18
0.28164083 -4.35252318 2.54045227 3.97370753 1.91440626 -2.64795315
19 20 21 22 23 24
3.58766696 -3.36198391 4.85437764 -0.71365404 -0.58212533 -0.55903654
25 26 27 28 29 30
-0.39667261 2.00566398 2.97113598 -0.43023678 1.78731474 -0.93925848
31 32 33 34 35 36
4.54405615 -3.40589597 0.30119012 -1.89220019 3.04571033 1.93999725
37 38 39 40 41 42
-6.50964310 2.61497136 1.13074110 -3.52781587 2.54002703 5.89899325
43 44 45 46 47 48
-5.43237932 2.84318597 -2.52296888 -2.14327606 0.08969133 -2.98038826
49 50 51 52 53 54
4.74915290 2.26192119 -4.44443328 -2.76092521 -3.58037991 1.62007468
55 56 57 58
2.25724345 0.99475435 -1.43251631 0.33510814
> postscript(file="/var/www/html/rcomp/tmp/6b4hf1258736915.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 1.87552198 NA
1 -2.53003334 1.87552198
2 -2.19789606 -2.53003334
3 2.74527033 -2.19789606
4 -2.66136811 2.74527033
5 -3.93185630 -2.66136811
6 -4.95658725 -3.93185630
7 2.92993955 -4.95658725
8 -1.20008257 2.92993955
9 4.41402215 -1.20008257
10 -2.55327633 4.41402215
11 1.59942756 -2.55327633
12 0.28164083 1.59942756
13 -4.35252318 0.28164083
14 2.54045227 -4.35252318
15 3.97370753 2.54045227
16 1.91440626 3.97370753
17 -2.64795315 1.91440626
18 3.58766696 -2.64795315
19 -3.36198391 3.58766696
20 4.85437764 -3.36198391
21 -0.71365404 4.85437764
22 -0.58212533 -0.71365404
23 -0.55903654 -0.58212533
24 -0.39667261 -0.55903654
25 2.00566398 -0.39667261
26 2.97113598 2.00566398
27 -0.43023678 2.97113598
28 1.78731474 -0.43023678
29 -0.93925848 1.78731474
30 4.54405615 -0.93925848
31 -3.40589597 4.54405615
32 0.30119012 -3.40589597
33 -1.89220019 0.30119012
34 3.04571033 -1.89220019
35 1.93999725 3.04571033
36 -6.50964310 1.93999725
37 2.61497136 -6.50964310
38 1.13074110 2.61497136
39 -3.52781587 1.13074110
40 2.54002703 -3.52781587
41 5.89899325 2.54002703
42 -5.43237932 5.89899325
43 2.84318597 -5.43237932
44 -2.52296888 2.84318597
45 -2.14327606 -2.52296888
46 0.08969133 -2.14327606
47 -2.98038826 0.08969133
48 4.74915290 -2.98038826
49 2.26192119 4.74915290
50 -4.44443328 2.26192119
51 -2.76092521 -4.44443328
52 -3.58037991 -2.76092521
53 1.62007468 -3.58037991
54 2.25724345 1.62007468
55 0.99475435 2.25724345
56 -1.43251631 0.99475435
57 0.33510814 -1.43251631
58 NA 0.33510814
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.53003334 1.87552198
[2,] -2.19789606 -2.53003334
[3,] 2.74527033 -2.19789606
[4,] -2.66136811 2.74527033
[5,] -3.93185630 -2.66136811
[6,] -4.95658725 -3.93185630
[7,] 2.92993955 -4.95658725
[8,] -1.20008257 2.92993955
[9,] 4.41402215 -1.20008257
[10,] -2.55327633 4.41402215
[11,] 1.59942756 -2.55327633
[12,] 0.28164083 1.59942756
[13,] -4.35252318 0.28164083
[14,] 2.54045227 -4.35252318
[15,] 3.97370753 2.54045227
[16,] 1.91440626 3.97370753
[17,] -2.64795315 1.91440626
[18,] 3.58766696 -2.64795315
[19,] -3.36198391 3.58766696
[20,] 4.85437764 -3.36198391
[21,] -0.71365404 4.85437764
[22,] -0.58212533 -0.71365404
[23,] -0.55903654 -0.58212533
[24,] -0.39667261 -0.55903654
[25,] 2.00566398 -0.39667261
[26,] 2.97113598 2.00566398
[27,] -0.43023678 2.97113598
[28,] 1.78731474 -0.43023678
[29,] -0.93925848 1.78731474
[30,] 4.54405615 -0.93925848
[31,] -3.40589597 4.54405615
[32,] 0.30119012 -3.40589597
[33,] -1.89220019 0.30119012
[34,] 3.04571033 -1.89220019
[35,] 1.93999725 3.04571033
[36,] -6.50964310 1.93999725
[37,] 2.61497136 -6.50964310
[38,] 1.13074110 2.61497136
[39,] -3.52781587 1.13074110
[40,] 2.54002703 -3.52781587
[41,] 5.89899325 2.54002703
[42,] -5.43237932 5.89899325
[43,] 2.84318597 -5.43237932
[44,] -2.52296888 2.84318597
[45,] -2.14327606 -2.52296888
[46,] 0.08969133 -2.14327606
[47,] -2.98038826 0.08969133
[48,] 4.74915290 -2.98038826
[49,] 2.26192119 4.74915290
[50,] -4.44443328 2.26192119
[51,] -2.76092521 -4.44443328
[52,] -3.58037991 -2.76092521
[53,] 1.62007468 -3.58037991
[54,] 2.25724345 1.62007468
[55,] 0.99475435 2.25724345
[56,] -1.43251631 0.99475435
[57,] 0.33510814 -1.43251631
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.53003334 1.87552198
2 -2.19789606 -2.53003334
3 2.74527033 -2.19789606
4 -2.66136811 2.74527033
5 -3.93185630 -2.66136811
6 -4.95658725 -3.93185630
7 2.92993955 -4.95658725
8 -1.20008257 2.92993955
9 4.41402215 -1.20008257
10 -2.55327633 4.41402215
11 1.59942756 -2.55327633
12 0.28164083 1.59942756
13 -4.35252318 0.28164083
14 2.54045227 -4.35252318
15 3.97370753 2.54045227
16 1.91440626 3.97370753
17 -2.64795315 1.91440626
18 3.58766696 -2.64795315
19 -3.36198391 3.58766696
20 4.85437764 -3.36198391
21 -0.71365404 4.85437764
22 -0.58212533 -0.71365404
23 -0.55903654 -0.58212533
24 -0.39667261 -0.55903654
25 2.00566398 -0.39667261
26 2.97113598 2.00566398
27 -0.43023678 2.97113598
28 1.78731474 -0.43023678
29 -0.93925848 1.78731474
30 4.54405615 -0.93925848
31 -3.40589597 4.54405615
32 0.30119012 -3.40589597
33 -1.89220019 0.30119012
34 3.04571033 -1.89220019
35 1.93999725 3.04571033
36 -6.50964310 1.93999725
37 2.61497136 -6.50964310
38 1.13074110 2.61497136
39 -3.52781587 1.13074110
40 2.54002703 -3.52781587
41 5.89899325 2.54002703
42 -5.43237932 5.89899325
43 2.84318597 -5.43237932
44 -2.52296888 2.84318597
45 -2.14327606 -2.52296888
46 0.08969133 -2.14327606
47 -2.98038826 0.08969133
48 4.74915290 -2.98038826
49 2.26192119 4.74915290
50 -4.44443328 2.26192119
51 -2.76092521 -4.44443328
52 -3.58037991 -2.76092521
53 1.62007468 -3.58037991
54 2.25724345 1.62007468
55 0.99475435 2.25724345
56 -1.43251631 0.99475435
57 0.33510814 -1.43251631
> 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/7fad21258736915.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/8jse41258736915.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/9l8s91258736915.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/1050uu1258736915.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/11x64f1258736915.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/12wiy21258736915.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/13g85m1258736915.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/14op9v1258736915.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/159qiy1258736915.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/16dfxw1258736915.tab")
+ }
>
> system("convert tmp/1myja1258736915.ps tmp/1myja1258736915.png")
> system("convert tmp/2q8tm1258736915.ps tmp/2q8tm1258736915.png")
> system("convert tmp/3gycx1258736915.ps tmp/3gycx1258736915.png")
> system("convert tmp/4ti2z1258736915.ps tmp/4ti2z1258736915.png")
> system("convert tmp/5yp4t1258736915.ps tmp/5yp4t1258736915.png")
> system("convert tmp/6b4hf1258736915.ps tmp/6b4hf1258736915.png")
> system("convert tmp/7fad21258736915.ps tmp/7fad21258736915.png")
> system("convert tmp/8jse41258736915.ps tmp/8jse41258736915.png")
> system("convert tmp/9l8s91258736915.ps tmp/9l8s91258736915.png")
> system("convert tmp/1050uu1258736915.ps tmp/1050uu1258736915.png")
>
>
> proc.time()
user system elapsed
2.386 1.586 2.930