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(98.1
+ ,113
+ ,112.5
+ ,116.7
+ ,107.5
+ ,116.1
+ ,113.9
+ ,126.4
+ ,113
+ ,112.5
+ ,116.7
+ ,107.5
+ ,80.9
+ ,114.1
+ ,126.4
+ ,113
+ ,112.5
+ ,116.7
+ ,95.7
+ ,112.5
+ ,114.1
+ ,126.4
+ ,113
+ ,112.5
+ ,113.2
+ ,112.4
+ ,112.5
+ ,114.1
+ ,126.4
+ ,113
+ ,105.9
+ ,113.1
+ ,112.4
+ ,112.5
+ ,114.1
+ ,126.4
+ ,108.8
+ ,116.3
+ ,113.1
+ ,112.4
+ ,112.5
+ ,114.1
+ ,102.3
+ ,111.7
+ ,116.3
+ ,113.1
+ ,112.4
+ ,112.5
+ ,99
+ ,118.8
+ ,111.7
+ ,116.3
+ ,113.1
+ ,112.4
+ ,100.7
+ ,116.5
+ ,118.8
+ ,111.7
+ ,116.3
+ ,113.1
+ ,115.5
+ ,125.1
+ ,116.5
+ ,118.8
+ ,111.7
+ ,116.3
+ ,100.7
+ ,113.1
+ ,125.1
+ ,116.5
+ ,118.8
+ ,111.7
+ ,109.9
+ ,119.6
+ ,113.1
+ ,125.1
+ ,116.5
+ ,118.8
+ ,114.6
+ ,114.4
+ ,119.6
+ ,113.1
+ ,125.1
+ ,116.5
+ ,85.4
+ ,114
+ ,114.4
+ ,119.6
+ ,113.1
+ ,125.1
+ ,100.5
+ ,117.8
+ ,114
+ ,114.4
+ ,119.6
+ ,113.1
+ ,114.8
+ ,117
+ ,117.8
+ ,114
+ ,114.4
+ ,119.6
+ ,116.5
+ ,120.9
+ ,117
+ ,117.8
+ ,114
+ ,114.4
+ ,112.9
+ ,115
+ ,120.9
+ ,117
+ ,117.8
+ ,114
+ ,102
+ ,117.3
+ ,115
+ ,120.9
+ ,117
+ ,117.8
+ ,106
+ ,119.4
+ ,117.3
+ ,115
+ ,120.9
+ ,117
+ ,105.3
+ ,114.9
+ ,119.4
+ ,117.3
+ ,115
+ ,120.9
+ ,118.8
+ ,125.8
+ ,114.9
+ ,119.4
+ ,117.3
+ ,115
+ ,106.1
+ ,117.6
+ ,125.8
+ ,114.9
+ ,119.4
+ ,117.3
+ ,109.3
+ ,117.6
+ ,117.6
+ ,125.8
+ ,114.9
+ ,119.4
+ ,117.2
+ ,114.9
+ ,117.6
+ ,117.6
+ ,125.8
+ ,114.9
+ ,92.5
+ ,121.9
+ ,114.9
+ ,117.6
+ ,117.6
+ ,125.8
+ ,104.2
+ ,117
+ ,121.9
+ ,114.9
+ ,117.6
+ ,117.6
+ ,112.5
+ ,106.4
+ ,117
+ ,121.9
+ ,114.9
+ ,117.6
+ ,122.4
+ ,110.5
+ ,106.4
+ ,117
+ ,121.9
+ ,114.9
+ ,113.3
+ ,113.6
+ ,110.5
+ ,106.4
+ ,117
+ ,121.9
+ ,100
+ ,114.2
+ ,113.6
+ ,110.5
+ ,106.4
+ ,117
+ ,110.7
+ ,125.4
+ ,114.2
+ ,113.6
+ ,110.5
+ ,106.4
+ ,112.8
+ ,124.6
+ ,125.4
+ ,114.2
+ ,113.6
+ ,110.5
+ ,109.8
+ ,120.2
+ ,124.6
+ ,125.4
+ ,114.2
+ ,113.6
+ ,117.3
+ ,120.8
+ ,120.2
+ ,124.6
+ ,125.4
+ ,114.2
+ ,109.1
+ ,111.4
+ ,120.8
+ ,120.2
+ ,124.6
+ ,125.4
+ ,115.9
+ ,124.1
+ ,111.4
+ ,120.8
+ ,120.2
+ ,124.6
+ ,96
+ ,120.2
+ ,124.1
+ ,111.4
+ ,120.8
+ ,120.2
+ ,99.8
+ ,125.5
+ ,120.2
+ ,124.1
+ ,111.4
+ ,120.8
+ ,116.8
+ ,116
+ ,125.5
+ ,120.2
+ ,124.1
+ ,111.4
+ ,115.7
+ ,117
+ ,116
+ ,125.5
+ ,120.2
+ ,124.1
+ ,99.4
+ ,105.7
+ ,117
+ ,116
+ ,125.5
+ ,120.2
+ ,94.3
+ ,102
+ ,105.7
+ ,117
+ ,116
+ ,125.5
+ ,91
+ ,106.4
+ ,102
+ ,105.7
+ ,117
+ ,116
+ ,93.2
+ ,96.9
+ ,106.4
+ ,102
+ ,105.7
+ ,117
+ ,103.1
+ ,107.6
+ ,96.9
+ ,106.4
+ ,102
+ ,105.7
+ ,94.1
+ ,98.8
+ ,107.6
+ ,96.9
+ ,106.4
+ ,102
+ ,91.8
+ ,101.1
+ ,98.8
+ ,107.6
+ ,96.9
+ ,106.4
+ ,102.7
+ ,105.7
+ ,101.1
+ ,98.8
+ ,107.6
+ ,96.9
+ ,82.6
+ ,104.6
+ ,105.7
+ ,101.1
+ ,98.8
+ ,107.6
+ ,89.1
+ ,103.2
+ ,104.6
+ ,105.7
+ ,101.1
+ ,98.8
+ ,104.5
+ ,101.6
+ ,103.2
+ ,104.6
+ ,105.7
+ ,101.1
+ ,105.1
+ ,106.7
+ ,101.6
+ ,103.2
+ ,104.6
+ ,105.7
+ ,95.1
+ ,99.5
+ ,106.7
+ ,101.6
+ ,103.2
+ ,104.6
+ ,88.7
+ ,101
+ ,99.5
+ ,106.7
+ ,101.6
+ ,103.2)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('T.I.P.'
+ ,'Y(t)'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('T.I.P.','Y(t)','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)'),1:56))
> 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 = '2'
> #'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(t) T.I.P. Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 113.0 98.1 112.5 116.7 107.5 116.1 1 0 0 0 0 0 0 0 0 0 0
2 126.4 113.9 113.0 112.5 116.7 107.5 0 1 0 0 0 0 0 0 0 0 0
3 114.1 80.9 126.4 113.0 112.5 116.7 0 0 1 0 0 0 0 0 0 0 0
4 112.5 95.7 114.1 126.4 113.0 112.5 0 0 0 1 0 0 0 0 0 0 0
5 112.4 113.2 112.5 114.1 126.4 113.0 0 0 0 0 1 0 0 0 0 0 0
6 113.1 105.9 112.4 112.5 114.1 126.4 0 0 0 0 0 1 0 0 0 0 0
7 116.3 108.8 113.1 112.4 112.5 114.1 0 0 0 0 0 0 1 0 0 0 0
8 111.7 102.3 116.3 113.1 112.4 112.5 0 0 0 0 0 0 0 1 0 0 0
9 118.8 99.0 111.7 116.3 113.1 112.4 0 0 0 0 0 0 0 0 1 0 0
10 116.5 100.7 118.8 111.7 116.3 113.1 0 0 0 0 0 0 0 0 0 1 0
11 125.1 115.5 116.5 118.8 111.7 116.3 0 0 0 0 0 0 0 0 0 0 1
12 113.1 100.7 125.1 116.5 118.8 111.7 0 0 0 0 0 0 0 0 0 0 0
13 119.6 109.9 113.1 125.1 116.5 118.8 1 0 0 0 0 0 0 0 0 0 0
14 114.4 114.6 119.6 113.1 125.1 116.5 0 1 0 0 0 0 0 0 0 0 0
15 114.0 85.4 114.4 119.6 113.1 125.1 0 0 1 0 0 0 0 0 0 0 0
16 117.8 100.5 114.0 114.4 119.6 113.1 0 0 0 1 0 0 0 0 0 0 0
17 117.0 114.8 117.8 114.0 114.4 119.6 0 0 0 0 1 0 0 0 0 0 0
18 120.9 116.5 117.0 117.8 114.0 114.4 0 0 0 0 0 1 0 0 0 0 0
19 115.0 112.9 120.9 117.0 117.8 114.0 0 0 0 0 0 0 1 0 0 0 0
20 117.3 102.0 115.0 120.9 117.0 117.8 0 0 0 0 0 0 0 1 0 0 0
21 119.4 106.0 117.3 115.0 120.9 117.0 0 0 0 0 0 0 0 0 1 0 0
22 114.9 105.3 119.4 117.3 115.0 120.9 0 0 0 0 0 0 0 0 0 1 0
23 125.8 118.8 114.9 119.4 117.3 115.0 0 0 0 0 0 0 0 0 0 0 1
24 117.6 106.1 125.8 114.9 119.4 117.3 0 0 0 0 0 0 0 0 0 0 0
25 117.6 109.3 117.6 125.8 114.9 119.4 1 0 0 0 0 0 0 0 0 0 0
26 114.9 117.2 117.6 117.6 125.8 114.9 0 1 0 0 0 0 0 0 0 0 0
27 121.9 92.5 114.9 117.6 117.6 125.8 0 0 1 0 0 0 0 0 0 0 0
28 117.0 104.2 121.9 114.9 117.6 117.6 0 0 0 1 0 0 0 0 0 0 0
29 106.4 112.5 117.0 121.9 114.9 117.6 0 0 0 0 1 0 0 0 0 0 0
30 110.5 122.4 106.4 117.0 121.9 114.9 0 0 0 0 0 1 0 0 0 0 0
31 113.6 113.3 110.5 106.4 117.0 121.9 0 0 0 0 0 0 1 0 0 0 0
32 114.2 100.0 113.6 110.5 106.4 117.0 0 0 0 0 0 0 0 1 0 0 0
33 125.4 110.7 114.2 113.6 110.5 106.4 0 0 0 0 0 0 0 0 1 0 0
34 124.6 112.8 125.4 114.2 113.6 110.5 0 0 0 0 0 0 0 0 0 1 0
35 120.2 109.8 124.6 125.4 114.2 113.6 0 0 0 0 0 0 0 0 0 0 1
36 120.8 117.3 120.2 124.6 125.4 114.2 0 0 0 0 0 0 0 0 0 0 0
37 111.4 109.1 120.8 120.2 124.6 125.4 1 0 0 0 0 0 0 0 0 0 0
38 124.1 115.9 111.4 120.8 120.2 124.6 0 1 0 0 0 0 0 0 0 0 0
39 120.2 96.0 124.1 111.4 120.8 120.2 0 0 1 0 0 0 0 0 0 0 0
40 125.5 99.8 120.2 124.1 111.4 120.8 0 0 0 1 0 0 0 0 0 0 0
41 116.0 116.8 125.5 120.2 124.1 111.4 0 0 0 0 1 0 0 0 0 0 0
42 117.0 115.7 116.0 125.5 120.2 124.1 0 0 0 0 0 1 0 0 0 0 0
43 105.7 99.4 117.0 116.0 125.5 120.2 0 0 0 0 0 0 1 0 0 0 0
44 102.0 94.3 105.7 117.0 116.0 125.5 0 0 0 0 0 0 0 1 0 0 0
45 106.4 91.0 102.0 105.7 117.0 116.0 0 0 0 0 0 0 0 0 1 0 0
46 96.9 93.2 106.4 102.0 105.7 117.0 0 0 0 0 0 0 0 0 0 1 0
47 107.6 103.1 96.9 106.4 102.0 105.7 0 0 0 0 0 0 0 0 0 0 1
48 98.8 94.1 107.6 96.9 106.4 102.0 0 0 0 0 0 0 0 0 0 0 0
49 101.1 91.8 98.8 107.6 96.9 106.4 1 0 0 0 0 0 0 0 0 0 0
50 105.7 102.7 101.1 98.8 107.6 96.9 0 1 0 0 0 0 0 0 0 0 0
51 104.6 82.6 105.7 101.1 98.8 107.6 0 0 1 0 0 0 0 0 0 0 0
52 103.2 89.1 104.6 105.7 101.1 98.8 0 0 0 1 0 0 0 0 0 0 0
53 101.6 104.5 103.2 104.6 105.7 101.1 0 0 0 0 1 0 0 0 0 0 0
54 106.7 105.1 101.6 103.2 104.6 105.7 0 0 0 0 0 1 0 0 0 0 0
55 99.5 95.1 106.7 101.6 103.2 104.6 0 0 0 0 0 0 1 0 0 0 0
56 101.0 88.7 99.5 106.7 101.6 103.2 0 0 0 0 0 0 0 1 0 0 0
t
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 51
52 52
53 53
54 54
55 55
56 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) T.I.P. `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)`
20.0672 0.6886 0.2785 0.1931 -0.3382 0.0707
M1 M2 M3 M4 M5 M6
-1.2762 1.0235 12.4875 5.8432 -6.6780 -3.9815
M7 M8 M9 M10 M11 t
-2.2556 1.7608 8.2324 0.5794 0.7930 -0.0935
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-7.3193 -1.5888 0.4079 1.8183 6.3072
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 20.06717 12.06357 1.663 0.104449
T.I.P. 0.68860 0.11320 6.083 4.38e-07 ***
`Y(t-1)` 0.27850 0.11864 2.347 0.024212 *
`Y(t-2)` 0.19306 0.13015 1.483 0.146220
`Y(t-3)` -0.33819 0.13320 -2.539 0.015332 *
`Y(t-4)` 0.07070 0.11484 0.616 0.541791
M1 -1.27620 2.90307 -0.440 0.662713
M2 1.02350 2.81196 0.364 0.717890
M3 12.48751 3.10138 4.026 0.000261 ***
M4 5.84324 2.68074 2.180 0.035544 *
M5 -6.67802 2.68494 -2.487 0.017381 *
M6 -3.98148 3.05842 -1.302 0.200818
M7 -2.25561 2.59802 -0.868 0.390734
M8 1.76076 2.76627 0.637 0.528260
M9 8.23239 2.71391 3.033 0.004344 **
M10 0.57938 2.70651 0.214 0.831638
M11 0.79297 3.07705 0.258 0.798025
t -0.09350 0.03591 -2.603 0.013099 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.597 on 38 degrees of freedom
Multiple R-squared: 0.8489, Adjusted R-squared: 0.7813
F-statistic: 12.56 on 17 and 38 DF, p-value: 9.742e-11
> 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.7676324 0.4647352 0.2323676
[2,] 0.6394004 0.7211993 0.3605996
[3,] 0.5438410 0.9123181 0.4561590
[4,] 0.4433579 0.8867158 0.5566421
[5,] 0.3171573 0.6343147 0.6828427
[6,] 0.3394692 0.6789384 0.6605308
[7,] 0.4809327 0.9618653 0.5190673
[8,] 0.3682015 0.7364029 0.6317985
[9,] 0.3798289 0.7596577 0.6201711
[10,] 0.6730559 0.6538883 0.3269441
[11,] 0.5433832 0.9132337 0.4566168
[12,] 0.4194066 0.8388133 0.5805934
[13,] 0.5151882 0.9696236 0.4848118
[14,] 0.3705474 0.7410949 0.6294526
[15,] 0.3120369 0.6240737 0.6879631
> postscript(file="/var/www/html/rcomp/tmp/13q9c1292673595.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/29wkr1292673595.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/39wkr1292673595.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/49wkr1292673595.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/59wkr1292673595.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 = 56
Frequency = 1
1 2 3 4 5 6
1.03737881 5.74234869 -1.10384722 -4.85263818 2.92835770 1.28165493
7 8 9 10 11 12
1.00519899 -3.98885876 -0.08749117 4.13182173 -0.09156662 -0.23859913
13 14 15 16 17 18
1.69795696 -5.36715311 -1.50368068 2.79825179 1.56685396 1.41473300
19 20 21 22 23 24
-3.25700080 2.97684658 -2.18166883 -1.75310555 1.77357317 1.58587115
25 26 27 28 29 30
-0.73887800 -5.49745878 4.34848033 -2.71884706 -7.31929612 -6.18307544
31 32 33 34 35 36
0.30328129 1.24540315 0.06972123 3.09363235 -1.31638015 0.13082836
37 38 39 40 41 42
-2.63302257 4.24893145 1.47320102 6.30720134 1.95231696 0.51246685
43 44 45 46 47 48
2.42789644 -2.31664930 2.19943877 -5.47234853 -0.36562641 -1.47810038
49 50 51 52 53 54
0.63656480 0.87333175 -3.21415345 -1.53396789 0.87176750 2.97422066
55 56
-0.47937591 2.08325833
> postscript(file="/var/www/html/rcomp/tmp/6jn1u1292673595.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 1.03737881 NA
1 5.74234869 1.03737881
2 -1.10384722 5.74234869
3 -4.85263818 -1.10384722
4 2.92835770 -4.85263818
5 1.28165493 2.92835770
6 1.00519899 1.28165493
7 -3.98885876 1.00519899
8 -0.08749117 -3.98885876
9 4.13182173 -0.08749117
10 -0.09156662 4.13182173
11 -0.23859913 -0.09156662
12 1.69795696 -0.23859913
13 -5.36715311 1.69795696
14 -1.50368068 -5.36715311
15 2.79825179 -1.50368068
16 1.56685396 2.79825179
17 1.41473300 1.56685396
18 -3.25700080 1.41473300
19 2.97684658 -3.25700080
20 -2.18166883 2.97684658
21 -1.75310555 -2.18166883
22 1.77357317 -1.75310555
23 1.58587115 1.77357317
24 -0.73887800 1.58587115
25 -5.49745878 -0.73887800
26 4.34848033 -5.49745878
27 -2.71884706 4.34848033
28 -7.31929612 -2.71884706
29 -6.18307544 -7.31929612
30 0.30328129 -6.18307544
31 1.24540315 0.30328129
32 0.06972123 1.24540315
33 3.09363235 0.06972123
34 -1.31638015 3.09363235
35 0.13082836 -1.31638015
36 -2.63302257 0.13082836
37 4.24893145 -2.63302257
38 1.47320102 4.24893145
39 6.30720134 1.47320102
40 1.95231696 6.30720134
41 0.51246685 1.95231696
42 2.42789644 0.51246685
43 -2.31664930 2.42789644
44 2.19943877 -2.31664930
45 -5.47234853 2.19943877
46 -0.36562641 -5.47234853
47 -1.47810038 -0.36562641
48 0.63656480 -1.47810038
49 0.87333175 0.63656480
50 -3.21415345 0.87333175
51 -1.53396789 -3.21415345
52 0.87176750 -1.53396789
53 2.97422066 0.87176750
54 -0.47937591 2.97422066
55 2.08325833 -0.47937591
56 NA 2.08325833
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 5.74234869 1.03737881
[2,] -1.10384722 5.74234869
[3,] -4.85263818 -1.10384722
[4,] 2.92835770 -4.85263818
[5,] 1.28165493 2.92835770
[6,] 1.00519899 1.28165493
[7,] -3.98885876 1.00519899
[8,] -0.08749117 -3.98885876
[9,] 4.13182173 -0.08749117
[10,] -0.09156662 4.13182173
[11,] -0.23859913 -0.09156662
[12,] 1.69795696 -0.23859913
[13,] -5.36715311 1.69795696
[14,] -1.50368068 -5.36715311
[15,] 2.79825179 -1.50368068
[16,] 1.56685396 2.79825179
[17,] 1.41473300 1.56685396
[18,] -3.25700080 1.41473300
[19,] 2.97684658 -3.25700080
[20,] -2.18166883 2.97684658
[21,] -1.75310555 -2.18166883
[22,] 1.77357317 -1.75310555
[23,] 1.58587115 1.77357317
[24,] -0.73887800 1.58587115
[25,] -5.49745878 -0.73887800
[26,] 4.34848033 -5.49745878
[27,] -2.71884706 4.34848033
[28,] -7.31929612 -2.71884706
[29,] -6.18307544 -7.31929612
[30,] 0.30328129 -6.18307544
[31,] 1.24540315 0.30328129
[32,] 0.06972123 1.24540315
[33,] 3.09363235 0.06972123
[34,] -1.31638015 3.09363235
[35,] 0.13082836 -1.31638015
[36,] -2.63302257 0.13082836
[37,] 4.24893145 -2.63302257
[38,] 1.47320102 4.24893145
[39,] 6.30720134 1.47320102
[40,] 1.95231696 6.30720134
[41,] 0.51246685 1.95231696
[42,] 2.42789644 0.51246685
[43,] -2.31664930 2.42789644
[44,] 2.19943877 -2.31664930
[45,] -5.47234853 2.19943877
[46,] -0.36562641 -5.47234853
[47,] -1.47810038 -0.36562641
[48,] 0.63656480 -1.47810038
[49,] 0.87333175 0.63656480
[50,] -3.21415345 0.87333175
[51,] -1.53396789 -3.21415345
[52,] 0.87176750 -1.53396789
[53,] 2.97422066 0.87176750
[54,] -0.47937591 2.97422066
[55,] 2.08325833 -0.47937591
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 5.74234869 1.03737881
2 -1.10384722 5.74234869
3 -4.85263818 -1.10384722
4 2.92835770 -4.85263818
5 1.28165493 2.92835770
6 1.00519899 1.28165493
7 -3.98885876 1.00519899
8 -0.08749117 -3.98885876
9 4.13182173 -0.08749117
10 -0.09156662 4.13182173
11 -0.23859913 -0.09156662
12 1.69795696 -0.23859913
13 -5.36715311 1.69795696
14 -1.50368068 -5.36715311
15 2.79825179 -1.50368068
16 1.56685396 2.79825179
17 1.41473300 1.56685396
18 -3.25700080 1.41473300
19 2.97684658 -3.25700080
20 -2.18166883 2.97684658
21 -1.75310555 -2.18166883
22 1.77357317 -1.75310555
23 1.58587115 1.77357317
24 -0.73887800 1.58587115
25 -5.49745878 -0.73887800
26 4.34848033 -5.49745878
27 -2.71884706 4.34848033
28 -7.31929612 -2.71884706
29 -6.18307544 -7.31929612
30 0.30328129 -6.18307544
31 1.24540315 0.30328129
32 0.06972123 1.24540315
33 3.09363235 0.06972123
34 -1.31638015 3.09363235
35 0.13082836 -1.31638015
36 -2.63302257 0.13082836
37 4.24893145 -2.63302257
38 1.47320102 4.24893145
39 6.30720134 1.47320102
40 1.95231696 6.30720134
41 0.51246685 1.95231696
42 2.42789644 0.51246685
43 -2.31664930 2.42789644
44 2.19943877 -2.31664930
45 -5.47234853 2.19943877
46 -0.36562641 -5.47234853
47 -1.47810038 -0.36562641
48 0.63656480 -1.47810038
49 0.87333175 0.63656480
50 -3.21415345 0.87333175
51 -1.53396789 -3.21415345
52 0.87176750 -1.53396789
53 2.97422066 0.87176750
54 -0.47937591 2.97422066
55 2.08325833 -0.47937591
> 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/7uwif1292673595.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/8uwif1292673595.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/9uwif1292673595.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/10nozi1292673595.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/118oy51292673595.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/12tpeb1292673595.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/137yc21292673595.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/14thb81292673595.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/15wzrw1292673595.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/16h0711292673595.tab")
+ }
>
> try(system("convert tmp/13q9c1292673595.ps tmp/13q9c1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/29wkr1292673595.ps tmp/29wkr1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/39wkr1292673595.ps tmp/39wkr1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/49wkr1292673595.ps tmp/49wkr1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/59wkr1292673595.ps tmp/59wkr1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/6jn1u1292673595.ps tmp/6jn1u1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/7uwif1292673595.ps tmp/7uwif1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/8uwif1292673595.ps tmp/8uwif1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/9uwif1292673595.ps tmp/9uwif1292673595.png",intern=TRUE))
character(0)
> try(system("convert tmp/10nozi1292673595.ps tmp/10nozi1292673595.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.402 1.649 5.699