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(95.1
+ ,93.8
+ ,96.9
+ ,98.6
+ ,111.7
+ ,109.8
+ ,97
+ ,93.8
+ ,95.1
+ ,96.9
+ ,98.6
+ ,111.7
+ ,112.7
+ ,107.6
+ ,97
+ ,95.1
+ ,96.9
+ ,98.6
+ ,102.9
+ ,101
+ ,112.7
+ ,97
+ ,95.1
+ ,96.9
+ ,97.4
+ ,95.4
+ ,102.9
+ ,112.7
+ ,97
+ ,95.1
+ ,111.4
+ ,96.5
+ ,97.4
+ ,102.9
+ ,112.7
+ ,97
+ ,87.4
+ ,89.2
+ ,111.4
+ ,97.4
+ ,102.9
+ ,112.7
+ ,96.8
+ ,87.1
+ ,87.4
+ ,111.4
+ ,97.4
+ ,102.9
+ ,114.1
+ ,110.5
+ ,96.8
+ ,87.4
+ ,111.4
+ ,97.4
+ ,110.3
+ ,110.8
+ ,114.1
+ ,96.8
+ ,87.4
+ ,111.4
+ ,103.9
+ ,104.2
+ ,110.3
+ ,114.1
+ ,96.8
+ ,87.4
+ ,101.6
+ ,88.9
+ ,103.9
+ ,110.3
+ ,114.1
+ ,96.8
+ ,94.6
+ ,89.8
+ ,101.6
+ ,103.9
+ ,110.3
+ ,114.1
+ ,95.9
+ ,90
+ ,94.6
+ ,101.6
+ ,103.9
+ ,110.3
+ ,104.7
+ ,93.9
+ ,95.9
+ ,94.6
+ ,101.6
+ ,103.9
+ ,102.8
+ ,91.3
+ ,104.7
+ ,95.9
+ ,94.6
+ ,101.6
+ ,98.1
+ ,87.8
+ ,102.8
+ ,104.7
+ ,95.9
+ ,94.6
+ ,113.9
+ ,99.7
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,80.9
+ ,73.5
+ ,113.9
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.7
+ ,79.2
+ ,80.9
+ ,113.9
+ ,98.1
+ ,102.8
+ ,113.2
+ ,96.9
+ ,95.7
+ ,80.9
+ ,113.9
+ ,98.1
+ ,105.9
+ ,95.2
+ ,113.2
+ ,95.7
+ ,80.9
+ ,113.9
+ ,108.8
+ ,95.6
+ ,105.9
+ ,113.2
+ ,95.7
+ ,80.9
+ ,102.3
+ ,89.7
+ ,108.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,99
+ ,92.8
+ ,102.3
+ ,108.8
+ ,105.9
+ ,113.2
+ ,100.7
+ ,88
+ ,99
+ ,102.3
+ ,108.8
+ ,105.9
+ ,115.5
+ ,101.1
+ ,100.7
+ ,99
+ ,102.3
+ ,108.8
+ ,100.7
+ ,92.7
+ ,115.5
+ ,100.7
+ ,99
+ ,102.3
+ ,109.9
+ ,95.8
+ ,100.7
+ ,115.5
+ ,100.7
+ ,99
+ ,114.6
+ ,103.8
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.7
+ ,85.4
+ ,81.8
+ ,114.6
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.5
+ ,87.1
+ ,85.4
+ ,114.6
+ ,109.9
+ ,100.7
+ ,114.8
+ ,105.9
+ ,100.5
+ ,85.4
+ ,114.6
+ ,109.9
+ ,116.5
+ ,108.1
+ ,114.8
+ ,100.5
+ ,85.4
+ ,114.6
+ ,112.9
+ ,102.6
+ ,116.5
+ ,114.8
+ ,100.5
+ ,85.4
+ ,102
+ ,93.7
+ ,112.9
+ ,116.5
+ ,114.8
+ ,100.5
+ ,106
+ ,103.5
+ ,102
+ ,112.9
+ ,116.5
+ ,114.8
+ ,105.3
+ ,100.6
+ ,106
+ ,102
+ ,112.9
+ ,116.5
+ ,118.8
+ ,113.3
+ ,105.3
+ ,106
+ ,102
+ ,112.9
+ ,106.1
+ ,102.4
+ ,118.8
+ ,105.3
+ ,106
+ ,102
+ ,109.3
+ ,102.1
+ ,106.1
+ ,118.8
+ ,105.3
+ ,106
+ ,117.2
+ ,106.9
+ ,109.3
+ ,106.1
+ ,118.8
+ ,105.3
+ ,92.5
+ ,87.3
+ ,117.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,104.2
+ ,93.1
+ ,92.5
+ ,117.2
+ ,109.3
+ ,106.1
+ ,112.5
+ ,109.1
+ ,104.2
+ ,92.5
+ ,117.2
+ ,109.3
+ ,122.4
+ ,120.3
+ ,112.5
+ ,104.2
+ ,92.5
+ ,117.2
+ ,113.3
+ ,104.9
+ ,122.4
+ ,112.5
+ ,104.2
+ ,92.5
+ ,100
+ ,92.6
+ ,113.3
+ ,122.4
+ ,112.5
+ ,104.2
+ ,110.7
+ ,109.8
+ ,100
+ ,113.3
+ ,122.4
+ ,112.5
+ ,112.8
+ ,111.4
+ ,110.7
+ ,100
+ ,113.3
+ ,122.4
+ ,109.8
+ ,117.9
+ ,112.8
+ ,110.7
+ ,100
+ ,113.3
+ ,117.3
+ ,121.6
+ ,109.8
+ ,112.8
+ ,110.7
+ ,100
+ ,109.1
+ ,117.8
+ ,117.3
+ ,109.8
+ ,112.8
+ ,110.7
+ ,115.9
+ ,124.2
+ ,109.1
+ ,117.3
+ ,109.8
+ ,112.8
+ ,96
+ ,106.8
+ ,115.9
+ ,109.1
+ ,117.3
+ ,109.8
+ ,99.8
+ ,102.7
+ ,96
+ ,115.9
+ ,109.1
+ ,117.3
+ ,116.8
+ ,116.8
+ ,99.8
+ ,96
+ ,115.9
+ ,109.1
+ ,115.7
+ ,113.6
+ ,116.8
+ ,99.8
+ ,96
+ ,115.9
+ ,99.4
+ ,96.1
+ ,115.7
+ ,116.8
+ ,99.8
+ ,96
+ ,94.3
+ ,85
+ ,99.4
+ ,115.7
+ ,116.8
+ ,99.8)
+ ,dim=c(6
+ ,60)
+ ,dimnames=list(c('Y(t)'
+ ,'X(t)'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)')
+ ,1:60))
> y <- array(NA,dim=c(6,60),dimnames=list(c('Y(t)','X(t)','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)'),1:60))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No 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(t) X(t) Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 95.1 93.8 96.9 98.6 111.7 109.8 1 0 0 0 0 0 0 0 0 0 0
2 97.0 93.8 95.1 96.9 98.6 111.7 0 1 0 0 0 0 0 0 0 0 0
3 112.7 107.6 97.0 95.1 96.9 98.6 0 0 1 0 0 0 0 0 0 0 0
4 102.9 101.0 112.7 97.0 95.1 96.9 0 0 0 1 0 0 0 0 0 0 0
5 97.4 95.4 102.9 112.7 97.0 95.1 0 0 0 0 1 0 0 0 0 0 0
6 111.4 96.5 97.4 102.9 112.7 97.0 0 0 0 0 0 1 0 0 0 0 0
7 87.4 89.2 111.4 97.4 102.9 112.7 0 0 0 0 0 0 1 0 0 0 0
8 96.8 87.1 87.4 111.4 97.4 102.9 0 0 0 0 0 0 0 1 0 0 0
9 114.1 110.5 96.8 87.4 111.4 97.4 0 0 0 0 0 0 0 0 1 0 0
10 110.3 110.8 114.1 96.8 87.4 111.4 0 0 0 0 0 0 0 0 0 1 0
11 103.9 104.2 110.3 114.1 96.8 87.4 0 0 0 0 0 0 0 0 0 0 1
12 101.6 88.9 103.9 110.3 114.1 96.8 0 0 0 0 0 0 0 0 0 0 0
13 94.6 89.8 101.6 103.9 110.3 114.1 1 0 0 0 0 0 0 0 0 0 0
14 95.9 90.0 94.6 101.6 103.9 110.3 0 1 0 0 0 0 0 0 0 0 0
15 104.7 93.9 95.9 94.6 101.6 103.9 0 0 1 0 0 0 0 0 0 0 0
16 102.8 91.3 104.7 95.9 94.6 101.6 0 0 0 1 0 0 0 0 0 0 0
17 98.1 87.8 102.8 104.7 95.9 94.6 0 0 0 0 1 0 0 0 0 0 0
18 113.9 99.7 98.1 102.8 104.7 95.9 0 0 0 0 0 1 0 0 0 0 0
19 80.9 73.5 113.9 98.1 102.8 104.7 0 0 0 0 0 0 1 0 0 0 0
20 95.7 79.2 80.9 113.9 98.1 102.8 0 0 0 0 0 0 0 1 0 0 0
21 113.2 96.9 95.7 80.9 113.9 98.1 0 0 0 0 0 0 0 0 1 0 0
22 105.9 95.2 113.2 95.7 80.9 113.9 0 0 0 0 0 0 0 0 0 1 0
23 108.8 95.6 105.9 113.2 95.7 80.9 0 0 0 0 0 0 0 0 0 0 1
24 102.3 89.7 108.8 105.9 113.2 95.7 0 0 0 0 0 0 0 0 0 0 0
25 99.0 92.8 102.3 108.8 105.9 113.2 1 0 0 0 0 0 0 0 0 0 0
26 100.7 88.0 99.0 102.3 108.8 105.9 0 1 0 0 0 0 0 0 0 0 0
27 115.5 101.1 100.7 99.0 102.3 108.8 0 0 1 0 0 0 0 0 0 0 0
28 100.7 92.7 115.5 100.7 99.0 102.3 0 0 0 1 0 0 0 0 0 0 0
29 109.9 95.8 100.7 115.5 100.7 99.0 0 0 0 0 1 0 0 0 0 0 0
30 114.6 103.8 109.9 100.7 115.5 100.7 0 0 0 0 0 1 0 0 0 0 0
31 85.4 81.8 114.6 109.9 100.7 115.5 0 0 0 0 0 0 1 0 0 0 0
32 100.5 87.1 85.4 114.6 109.9 100.7 0 0 0 0 0 0 0 1 0 0 0
33 114.8 105.9 100.5 85.4 114.6 109.9 0 0 0 0 0 0 0 0 1 0 0
34 116.5 108.1 114.8 100.5 85.4 114.6 0 0 0 0 0 0 0 0 0 1 0
35 112.9 102.6 116.5 114.8 100.5 85.4 0 0 0 0 0 0 0 0 0 0 1
36 102.0 93.7 112.9 116.5 114.8 100.5 0 0 0 0 0 0 0 0 0 0 0
37 106.0 103.5 102.0 112.9 116.5 114.8 1 0 0 0 0 0 0 0 0 0 0
38 105.3 100.6 106.0 102.0 112.9 116.5 0 1 0 0 0 0 0 0 0 0 0
39 118.8 113.3 105.3 106.0 102.0 112.9 0 0 1 0 0 0 0 0 0 0 0
40 106.1 102.4 118.8 105.3 106.0 102.0 0 0 0 1 0 0 0 0 0 0 0
41 109.3 102.1 106.1 118.8 105.3 106.0 0 0 0 0 1 0 0 0 0 0 0
42 117.2 106.9 109.3 106.1 118.8 105.3 0 0 0 0 0 1 0 0 0 0 0
43 92.5 87.3 117.2 109.3 106.1 118.8 0 0 0 0 0 0 1 0 0 0 0
44 104.2 93.1 92.5 117.2 109.3 106.1 0 0 0 0 0 0 0 1 0 0 0
45 112.5 109.1 104.2 92.5 117.2 109.3 0 0 0 0 0 0 0 0 1 0 0
46 122.4 120.3 112.5 104.2 92.5 117.2 0 0 0 0 0 0 0 0 0 1 0
47 113.3 104.9 122.4 112.5 104.2 92.5 0 0 0 0 0 0 0 0 0 0 1
48 100.0 92.6 113.3 122.4 112.5 104.2 0 0 0 0 0 0 0 0 0 0 0
49 110.7 109.8 100.0 113.3 122.4 112.5 1 0 0 0 0 0 0 0 0 0 0
50 112.8 111.4 110.7 100.0 113.3 122.4 0 1 0 0 0 0 0 0 0 0 0
51 109.8 117.9 112.8 110.7 100.0 113.3 0 0 1 0 0 0 0 0 0 0 0
52 117.3 121.6 109.8 112.8 110.7 100.0 0 0 0 1 0 0 0 0 0 0 0
53 109.1 117.8 117.3 109.8 112.8 110.7 0 0 0 0 1 0 0 0 0 0 0
54 115.9 124.2 109.1 117.3 109.8 112.8 0 0 0 0 0 1 0 0 0 0 0
55 96.0 106.8 115.9 109.1 117.3 109.8 0 0 0 0 0 0 1 0 0 0 0
56 99.8 102.7 96.0 115.9 109.1 117.3 0 0 0 0 0 0 0 1 0 0 0
57 116.8 116.8 99.8 96.0 115.9 109.1 0 0 0 0 0 0 0 0 1 0 0
58 115.7 113.6 116.8 99.8 96.0 115.9 0 0 0 0 0 0 0 0 0 1 0
59 99.4 96.1 115.7 116.8 99.8 96.0 0 0 0 0 0 0 0 0 0 0 1
60 94.3 85.0 99.4 115.7 116.8 99.8 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) `X(t)` `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)`
39.26005 0.32005 -0.05080 0.08803 0.35457 -0.13198
M1 M2 M3 M4 M5 M6
0.82329 5.23946 13.70449 8.24671 6.11617 11.02699
M7 M8 M9 M10 M11
-5.04401 2.63092 10.96243 20.64449 8.34461
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.0818 -2.2745 0.1285 2.2363 6.1718
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 39.26005 16.55723 2.371 0.022282 *
`X(t)` 0.32005 0.08768 3.650 0.000705 ***
`Y(t-1)` -0.05080 0.14335 -0.354 0.724764
`Y(t-2)` 0.08803 0.12473 0.706 0.484118
`Y(t-3)` 0.35457 0.12642 2.805 0.007532 **
`Y(t-4)` -0.13198 0.14470 -0.912 0.366807
M1 0.82329 3.88788 0.212 0.833296
M2 5.23946 4.41795 1.186 0.242155
M3 13.70449 4.57850 2.993 0.004561 **
M4 8.24671 3.75615 2.196 0.033571 *
M5 6.11617 3.08752 1.981 0.054018 .
M6 11.02699 3.26666 3.376 0.001571 **
M7 -5.04401 3.28107 -1.537 0.131545
M8 2.63092 4.04650 0.650 0.519039
M9 10.96243 5.30287 2.067 0.044762 *
M10 20.64449 5.81005 3.553 0.000939 ***
M11 8.34461 4.16213 2.005 0.051296 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.542 on 43 degrees of freedom
Multiple R-squared: 0.8871, Adjusted R-squared: 0.8451
F-statistic: 21.12 on 16 and 43 DF, p-value: 2.615e-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.15489545 0.30979091 0.8451045
[2,] 0.10639918 0.21279836 0.8936008
[3,] 0.05756405 0.11512810 0.9424359
[4,] 0.09087793 0.18175586 0.9091221
[5,] 0.04607416 0.09214832 0.9539258
[6,] 0.06400193 0.12800386 0.9359981
[7,] 0.15381557 0.30763114 0.8461844
[8,] 0.29870073 0.59740146 0.7012993
[9,] 0.24841947 0.49683895 0.7515805
[10,] 0.39153024 0.78306047 0.6084698
[11,] 0.30663745 0.61327491 0.6933625
[12,] 0.24760483 0.49520967 0.7523952
[13,] 0.18045303 0.36090606 0.8195470
[14,] 0.11488346 0.22976692 0.8851165
[15,] 0.11163216 0.22326433 0.8883678
[16,] 0.09025174 0.18050347 0.9097483
[17,] 0.05868646 0.11737292 0.9413135
[18,] 0.03719245 0.07438489 0.9628076
[19,] 0.02822627 0.05645253 0.9717737
[20,] 0.06447997 0.12895994 0.9355200
[21,] 0.21754184 0.43508369 0.7824582
> postscript(file="/var/www/html/rcomp/tmp/1fl7v1261915030.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/2jng41261915030.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/3411y1261915030.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/4ouzh1261915030.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/545o11261915030.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 = 60
Frequency = 1
1 2 3 4 5 6
-3.87534626 -1.43766734 0.50940261 -0.67625864 -5.04469027 -1.04024267
7 8 9 10 11 12
0.10945586 0.71158623 -0.90862544 -4.07790432 -4.28221470 1.77511470
13 14 15 16 17 18
-2.25902590 -3.82462760 -4.08474603 2.81623752 -0.88907682 3.17134186
19 20 21 22 23 24
-2.32074472 1.32828345 2.26636494 -0.79933592 2.75806987 3.02929499
25 26 27 28 29 30
2.22634470 -0.54072065 4.66590376 -1.07343491 6.17184231 0.14763962
31 32 33 34 35 36
0.68958722 -0.69421314 2.14278679 3.82755088 3.90735685 0.79042619
37 38 39 40 41 42
1.87834508 0.35393171 4.32623537 -1.53681724 2.83219362 0.68664774
43 44 45 46 47 48
4.73507446 2.14273897 -2.61951148 3.20605636 3.69861381 -0.05275402
49 50 51 52 53 54
2.02968239 5.44908388 -5.41679571 0.47027328 -3.07026883 -2.96538654
55 56 57 58 59 60
-3.21337283 -3.48839551 -0.88101481 -2.15636700 -6.08182583 -5.54208186
> postscript(file="/var/www/html/rcomp/tmp/6yqxh1261915030.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.87534626 NA
1 -1.43766734 -3.87534626
2 0.50940261 -1.43766734
3 -0.67625864 0.50940261
4 -5.04469027 -0.67625864
5 -1.04024267 -5.04469027
6 0.10945586 -1.04024267
7 0.71158623 0.10945586
8 -0.90862544 0.71158623
9 -4.07790432 -0.90862544
10 -4.28221470 -4.07790432
11 1.77511470 -4.28221470
12 -2.25902590 1.77511470
13 -3.82462760 -2.25902590
14 -4.08474603 -3.82462760
15 2.81623752 -4.08474603
16 -0.88907682 2.81623752
17 3.17134186 -0.88907682
18 -2.32074472 3.17134186
19 1.32828345 -2.32074472
20 2.26636494 1.32828345
21 -0.79933592 2.26636494
22 2.75806987 -0.79933592
23 3.02929499 2.75806987
24 2.22634470 3.02929499
25 -0.54072065 2.22634470
26 4.66590376 -0.54072065
27 -1.07343491 4.66590376
28 6.17184231 -1.07343491
29 0.14763962 6.17184231
30 0.68958722 0.14763962
31 -0.69421314 0.68958722
32 2.14278679 -0.69421314
33 3.82755088 2.14278679
34 3.90735685 3.82755088
35 0.79042619 3.90735685
36 1.87834508 0.79042619
37 0.35393171 1.87834508
38 4.32623537 0.35393171
39 -1.53681724 4.32623537
40 2.83219362 -1.53681724
41 0.68664774 2.83219362
42 4.73507446 0.68664774
43 2.14273897 4.73507446
44 -2.61951148 2.14273897
45 3.20605636 -2.61951148
46 3.69861381 3.20605636
47 -0.05275402 3.69861381
48 2.02968239 -0.05275402
49 5.44908388 2.02968239
50 -5.41679571 5.44908388
51 0.47027328 -5.41679571
52 -3.07026883 0.47027328
53 -2.96538654 -3.07026883
54 -3.21337283 -2.96538654
55 -3.48839551 -3.21337283
56 -0.88101481 -3.48839551
57 -2.15636700 -0.88101481
58 -6.08182583 -2.15636700
59 -5.54208186 -6.08182583
60 NA -5.54208186
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.43766734 -3.87534626
[2,] 0.50940261 -1.43766734
[3,] -0.67625864 0.50940261
[4,] -5.04469027 -0.67625864
[5,] -1.04024267 -5.04469027
[6,] 0.10945586 -1.04024267
[7,] 0.71158623 0.10945586
[8,] -0.90862544 0.71158623
[9,] -4.07790432 -0.90862544
[10,] -4.28221470 -4.07790432
[11,] 1.77511470 -4.28221470
[12,] -2.25902590 1.77511470
[13,] -3.82462760 -2.25902590
[14,] -4.08474603 -3.82462760
[15,] 2.81623752 -4.08474603
[16,] -0.88907682 2.81623752
[17,] 3.17134186 -0.88907682
[18,] -2.32074472 3.17134186
[19,] 1.32828345 -2.32074472
[20,] 2.26636494 1.32828345
[21,] -0.79933592 2.26636494
[22,] 2.75806987 -0.79933592
[23,] 3.02929499 2.75806987
[24,] 2.22634470 3.02929499
[25,] -0.54072065 2.22634470
[26,] 4.66590376 -0.54072065
[27,] -1.07343491 4.66590376
[28,] 6.17184231 -1.07343491
[29,] 0.14763962 6.17184231
[30,] 0.68958722 0.14763962
[31,] -0.69421314 0.68958722
[32,] 2.14278679 -0.69421314
[33,] 3.82755088 2.14278679
[34,] 3.90735685 3.82755088
[35,] 0.79042619 3.90735685
[36,] 1.87834508 0.79042619
[37,] 0.35393171 1.87834508
[38,] 4.32623537 0.35393171
[39,] -1.53681724 4.32623537
[40,] 2.83219362 -1.53681724
[41,] 0.68664774 2.83219362
[42,] 4.73507446 0.68664774
[43,] 2.14273897 4.73507446
[44,] -2.61951148 2.14273897
[45,] 3.20605636 -2.61951148
[46,] 3.69861381 3.20605636
[47,] -0.05275402 3.69861381
[48,] 2.02968239 -0.05275402
[49,] 5.44908388 2.02968239
[50,] -5.41679571 5.44908388
[51,] 0.47027328 -5.41679571
[52,] -3.07026883 0.47027328
[53,] -2.96538654 -3.07026883
[54,] -3.21337283 -2.96538654
[55,] -3.48839551 -3.21337283
[56,] -0.88101481 -3.48839551
[57,] -2.15636700 -0.88101481
[58,] -6.08182583 -2.15636700
[59,] -5.54208186 -6.08182583
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.43766734 -3.87534626
2 0.50940261 -1.43766734
3 -0.67625864 0.50940261
4 -5.04469027 -0.67625864
5 -1.04024267 -5.04469027
6 0.10945586 -1.04024267
7 0.71158623 0.10945586
8 -0.90862544 0.71158623
9 -4.07790432 -0.90862544
10 -4.28221470 -4.07790432
11 1.77511470 -4.28221470
12 -2.25902590 1.77511470
13 -3.82462760 -2.25902590
14 -4.08474603 -3.82462760
15 2.81623752 -4.08474603
16 -0.88907682 2.81623752
17 3.17134186 -0.88907682
18 -2.32074472 3.17134186
19 1.32828345 -2.32074472
20 2.26636494 1.32828345
21 -0.79933592 2.26636494
22 2.75806987 -0.79933592
23 3.02929499 2.75806987
24 2.22634470 3.02929499
25 -0.54072065 2.22634470
26 4.66590376 -0.54072065
27 -1.07343491 4.66590376
28 6.17184231 -1.07343491
29 0.14763962 6.17184231
30 0.68958722 0.14763962
31 -0.69421314 0.68958722
32 2.14278679 -0.69421314
33 3.82755088 2.14278679
34 3.90735685 3.82755088
35 0.79042619 3.90735685
36 1.87834508 0.79042619
37 0.35393171 1.87834508
38 4.32623537 0.35393171
39 -1.53681724 4.32623537
40 2.83219362 -1.53681724
41 0.68664774 2.83219362
42 4.73507446 0.68664774
43 2.14273897 4.73507446
44 -2.61951148 2.14273897
45 3.20605636 -2.61951148
46 3.69861381 3.20605636
47 -0.05275402 3.69861381
48 2.02968239 -0.05275402
49 5.44908388 2.02968239
50 -5.41679571 5.44908388
51 0.47027328 -5.41679571
52 -3.07026883 0.47027328
53 -2.96538654 -3.07026883
54 -3.21337283 -2.96538654
55 -3.48839551 -3.21337283
56 -0.88101481 -3.48839551
57 -2.15636700 -0.88101481
58 -6.08182583 -2.15636700
59 -5.54208186 -6.08182583
> 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/7i16y1261915030.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/863981261915030.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/9ih5l1261915030.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/10l1cv1261915030.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/11t0pz1261915030.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/1264wt1261915030.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/1324v71261915030.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/14pu0v1261915030.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/15z8iq1261915030.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/166kdl1261915030.tab")
+ }
>
> try(system("convert tmp/1fl7v1261915030.ps tmp/1fl7v1261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/2jng41261915030.ps tmp/2jng41261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/3411y1261915030.ps tmp/3411y1261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ouzh1261915030.ps tmp/4ouzh1261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/545o11261915030.ps tmp/545o11261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/6yqxh1261915030.ps tmp/6yqxh1261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/7i16y1261915030.ps tmp/7i16y1261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/863981261915030.ps tmp/863981261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/9ih5l1261915030.ps tmp/9ih5l1261915030.png",intern=TRUE))
character(0)
> try(system("convert tmp/10l1cv1261915030.ps tmp/10l1cv1261915030.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.435 1.583 3.860