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
+ ,107.1
+ ,115.1
+ ,119.5
+ ,109
+ ,116.7
+ ,104.5
+ ,109.7
+ ,107.1
+ ,115.1
+ ,119.5
+ ,109
+ ,87.4
+ ,110.4
+ ,109.7
+ ,107.1
+ ,115.1
+ ,119.5
+ ,89.9
+ ,105
+ ,110.4
+ ,109.7
+ ,107.1
+ ,115.1
+ ,109.8
+ ,115.8
+ ,105
+ ,110.4
+ ,109.7
+ ,107.1
+ ,111.7
+ ,116.4
+ ,115.8
+ ,105
+ ,110.4
+ ,109.7
+ ,98.6
+ ,111.1
+ ,116.4
+ ,115.8
+ ,105
+ ,110.4
+ ,96.9
+ ,119.5
+ ,111.1
+ ,116.4
+ ,115.8
+ ,105
+ ,95.1
+ ,110.9
+ ,119.5
+ ,111.1
+ ,116.4
+ ,115.8
+ ,97
+ ,115.1
+ ,110.9
+ ,119.5
+ ,111.1
+ ,116.4
+ ,112.7
+ ,125.2
+ ,115.1
+ ,110.9
+ ,119.5
+ ,111.1
+ ,102.9
+ ,116
+ ,125.2
+ ,115.1
+ ,110.9
+ ,119.5
+ ,97.4
+ ,112.9
+ ,116
+ ,125.2
+ ,115.1
+ ,110.9
+ ,111.4
+ ,121.7
+ ,112.9
+ ,116
+ ,125.2
+ ,115.1
+ ,87.4
+ ,123.2
+ ,121.7
+ ,112.9
+ ,116
+ ,125.2
+ ,96.8
+ ,116.6
+ ,123.2
+ ,121.7
+ ,112.9
+ ,116
+ ,114.1
+ ,136.2
+ ,116.6
+ ,123.2
+ ,121.7
+ ,112.9
+ ,110.3
+ ,120.9
+ ,136.2
+ ,116.6
+ ,123.2
+ ,121.7
+ ,103.9
+ ,119.6
+ ,120.9
+ ,136.2
+ ,116.6
+ ,123.2
+ ,101.6
+ ,125.9
+ ,119.6
+ ,120.9
+ ,136.2
+ ,116.6
+ ,94.6
+ ,116.1
+ ,125.9
+ ,119.6
+ ,120.9
+ ,136.2
+ ,95.9
+ ,107.5
+ ,116.1
+ ,125.9
+ ,119.6
+ ,120.9
+ ,104.7
+ ,116.7
+ ,107.5
+ ,116.1
+ ,125.9
+ ,119.6
+ ,102.8
+ ,112.5
+ ,116.7
+ ,107.5
+ ,116.1
+ ,125.9
+ ,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)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Tip'
+ ,'ipchn'
+ ,'y(t-1)'
+ ,'y(t-2)'
+ ,'y(t-3)'
+ ,'y(t-4)')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Tip','ipchn','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
ipchn Tip y(t-1) y(t-2) y(t-3) y(t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 107.1 98.1 115.1 119.5 109.0 116.7 1 0 0 0 0 0 0 0 0 0 0
2 109.7 104.5 107.1 115.1 119.5 109.0 0 1 0 0 0 0 0 0 0 0 0
3 110.4 87.4 109.7 107.1 115.1 119.5 0 0 1 0 0 0 0 0 0 0 0
4 105.0 89.9 110.4 109.7 107.1 115.1 0 0 0 1 0 0 0 0 0 0 0
5 115.8 109.8 105.0 110.4 109.7 107.1 0 0 0 0 1 0 0 0 0 0 0
6 116.4 111.7 115.8 105.0 110.4 109.7 0 0 0 0 0 1 0 0 0 0 0
7 111.1 98.6 116.4 115.8 105.0 110.4 0 0 0 0 0 0 1 0 0 0 0
8 119.5 96.9 111.1 116.4 115.8 105.0 0 0 0 0 0 0 0 1 0 0 0
9 110.9 95.1 119.5 111.1 116.4 115.8 0 0 0 0 0 0 0 0 1 0 0
10 115.1 97.0 110.9 119.5 111.1 116.4 0 0 0 0 0 0 0 0 0 1 0
11 125.2 112.7 115.1 110.9 119.5 111.1 0 0 0 0 0 0 0 0 0 0 1
12 116.0 102.9 125.2 115.1 110.9 119.5 0 0 0 0 0 0 0 0 0 0 0
13 112.9 97.4 116.0 125.2 115.1 110.9 1 0 0 0 0 0 0 0 0 0 0
14 121.7 111.4 112.9 116.0 125.2 115.1 0 1 0 0 0 0 0 0 0 0 0
15 123.2 87.4 121.7 112.9 116.0 125.2 0 0 1 0 0 0 0 0 0 0 0
16 116.6 96.8 123.2 121.7 112.9 116.0 0 0 0 1 0 0 0 0 0 0 0
17 136.2 114.1 116.6 123.2 121.7 112.9 0 0 0 0 1 0 0 0 0 0 0
18 120.9 110.3 136.2 116.6 123.2 121.7 0 0 0 0 0 1 0 0 0 0 0
19 119.6 103.9 120.9 136.2 116.6 123.2 0 0 0 0 0 0 1 0 0 0 0
20 125.9 101.6 119.6 120.9 136.2 116.6 0 0 0 0 0 0 0 1 0 0 0
21 116.1 94.6 125.9 119.6 120.9 136.2 0 0 0 0 0 0 0 0 1 0 0
22 107.5 95.9 116.1 125.9 119.6 120.9 0 0 0 0 0 0 0 0 0 1 0
23 116.7 104.7 107.5 116.1 125.9 119.6 0 0 0 0 0 0 0 0 0 0 1
24 112.5 102.8 116.7 107.5 116.1 125.9 0 0 0 0 0 0 0 0 0 0 0
25 113.0 98.1 112.5 116.7 107.5 116.1 1 0 0 0 0 0 0 0 0 0 0
26 126.4 113.9 113.0 112.5 116.7 107.5 0 1 0 0 0 0 0 0 0 0 0
27 114.1 80.9 126.4 113.0 112.5 116.7 0 0 1 0 0 0 0 0 0 0 0
28 112.5 95.7 114.1 126.4 113.0 112.5 0 0 0 1 0 0 0 0 0 0 0
29 112.4 113.2 112.5 114.1 126.4 113.0 0 0 0 0 1 0 0 0 0 0 0
30 113.1 105.9 112.4 112.5 114.1 126.4 0 0 0 0 0 1 0 0 0 0 0
31 116.3 108.8 113.1 112.4 112.5 114.1 0 0 0 0 0 0 1 0 0 0 0
32 111.7 102.3 116.3 113.1 112.4 112.5 0 0 0 0 0 0 0 1 0 0 0
33 118.8 99.0 111.7 116.3 113.1 112.4 0 0 0 0 0 0 0 0 1 0 0
34 116.5 100.7 118.8 111.7 116.3 113.1 0 0 0 0 0 0 0 0 0 1 0
35 125.1 115.5 116.5 118.8 111.7 116.3 0 0 0 0 0 0 0 0 0 0 1
36 113.1 100.7 125.1 116.5 118.8 111.7 0 0 0 0 0 0 0 0 0 0 0
37 119.6 109.9 113.1 125.1 116.5 118.8 1 0 0 0 0 0 0 0 0 0 0
38 114.4 114.6 119.6 113.1 125.1 116.5 0 1 0 0 0 0 0 0 0 0 0
39 114.0 85.4 114.4 119.6 113.1 125.1 0 0 1 0 0 0 0 0 0 0 0
40 117.8 100.5 114.0 114.4 119.6 113.1 0 0 0 1 0 0 0 0 0 0 0
41 117.0 114.8 117.8 114.0 114.4 119.6 0 0 0 0 1 0 0 0 0 0 0
42 120.9 116.5 117.0 117.8 114.0 114.4 0 0 0 0 0 1 0 0 0 0 0
43 115.0 112.9 120.9 117.0 117.8 114.0 0 0 0 0 0 0 1 0 0 0 0
44 117.3 102.0 115.0 120.9 117.0 117.8 0 0 0 0 0 0 0 1 0 0 0
45 119.4 106.0 117.3 115.0 120.9 117.0 0 0 0 0 0 0 0 0 1 0 0
46 114.9 105.3 119.4 117.3 115.0 120.9 0 0 0 0 0 0 0 0 0 1 0
47 125.8 118.8 114.9 119.4 117.3 115.0 0 0 0 0 0 0 0 0 0 0 1
48 117.6 106.1 125.8 114.9 119.4 117.3 0 0 0 0 0 0 0 0 0 0 0
49 117.6 109.3 117.6 125.8 114.9 119.4 1 0 0 0 0 0 0 0 0 0 0
50 114.9 117.2 117.6 117.6 125.8 114.9 0 1 0 0 0 0 0 0 0 0 0
51 121.9 92.5 114.9 117.6 117.6 125.8 0 0 1 0 0 0 0 0 0 0 0
52 117.0 104.2 121.9 114.9 117.6 117.6 0 0 0 1 0 0 0 0 0 0 0
53 106.4 112.5 117.0 121.9 114.9 117.6 0 0 0 0 1 0 0 0 0 0 0
54 110.5 122.4 106.4 117.0 121.9 114.9 0 0 0 0 0 1 0 0 0 0 0
55 113.6 113.3 110.5 106.4 117.0 121.9 0 0 0 0 0 0 1 0 0 0 0
56 114.2 100.0 113.6 110.5 106.4 117.0 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) Tip `y(t-1)` `y(t-2)` `y(t-3)` `y(t-4)`
-17.70383 0.80770 0.25700 0.23372 0.04099 -0.07854
M1 M2 M3 M4 M5 M6
-1.01573 -4.08516 16.44847 3.84056 -4.00244 -5.43260
M7 M8 M9 M10 M11 t
-2.30126 6.26520 5.44073 1.70398 1.83762 -0.14774
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-8.96254 -1.56256 -0.05221 2.11225 13.37749
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -17.70383 32.81849 -0.539 0.59273
Tip 0.80770 0.22855 3.534 0.00109 **
`y(t-1)` 0.25700 0.13803 1.862 0.07035 .
`y(t-2)` 0.23372 0.14099 1.658 0.10562
`y(t-3)` 0.04099 0.14825 0.276 0.78367
`y(t-4)` -0.07854 0.15427 -0.509 0.61364
M1 -1.01573 3.79056 -0.268 0.79018
M2 -4.08516 4.11606 -0.992 0.32724
M3 16.44847 4.79149 3.433 0.00146 **
M4 3.84056 3.62921 1.058 0.29663
M5 -4.00244 4.15415 -0.963 0.34140
M6 -5.43260 4.01388 -1.353 0.18391
M7 -2.30126 3.60971 -0.638 0.52761
M8 6.26520 3.60921 1.736 0.09069 .
M9 5.44073 3.58505 1.518 0.13739
M10 1.70398 3.66801 0.465 0.64490
M11 1.83762 4.28480 0.429 0.67044
t -0.14774 0.06177 -2.392 0.02181 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.773 on 38 degrees of freedom
Multiple R-squared: 0.5025, Adjusted R-squared: 0.2799
F-statistic: 2.258 on 17 and 38 DF, p-value: 0.01847
> 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.7329034 0.5341931 0.2670966
[2,] 0.8697749 0.2604502 0.1302251
[3,] 0.7815883 0.4368233 0.2184117
[4,] 0.7409085 0.5181831 0.2590915
[5,] 0.6493498 0.7013004 0.3506502
[6,] 0.6791092 0.6417817 0.3208908
[7,] 0.6306060 0.7387879 0.3693940
[8,] 0.5387799 0.9224402 0.4612201
[9,] 0.7285271 0.5429459 0.2714729
[10,] 0.6259355 0.7481290 0.3740645
[11,] 0.5125307 0.9749386 0.4874693
[12,] 0.8697233 0.2605533 0.1302767
[13,] 0.8165270 0.3669460 0.1834730
[14,] 0.6931704 0.6136593 0.3068296
[15,] 0.5526732 0.8946536 0.4473268
> postscript(file="/var/www/html/rcomp/tmp/1wipo1259064576.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/26vt51259064576.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/33lky1259064576.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/4r1901259064576.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/5a7ra1259064576.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 = 56
Frequency = 1
1 2 3 4 5 6
-6.080711303 -3.383548337 -7.051335955 -2.520106136 0.686838497 -0.007959648
7 8 9 10 11 12
-0.112739623 1.596725941 -4.673753802 2.387505390 -0.009246843 -1.873576572
13 14 15 16 17 18
-0.211427443 3.360726783 3.492758523 -0.981578709 13.377488421 -0.140486630
19 20 21 22 23 24
0.484845591 2.812027873 0.489279290 -5.378312067 0.868365357 0.730359249
25 26 27 28 29 30
4.702117443 8.358268517 -0.339659983 -1.458890066 -4.926938152 5.203351272
31 32 33 34 35 36
2.020503097 -6.855756363 4.279639088 3.665214241 -0.302989257 -0.688696927
37 38 39 40 41 42
1.269943840 -3.908150078 -0.124744850 4.343960089 -0.174850766 2.855463878
43 44 45 46 47 48
-4.122948587 -0.501717347 -0.095164576 -0.674407564 -0.556129257 1.831914250
49 50 51 52 53 54
0.320077464 -4.427296885 4.022982264 0.616614823 -8.962538001 -7.910368872
55 56
1.730339522 2.948719896
> postscript(file="/var/www/html/rcomp/tmp/6b23x1259064576.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 -6.080711303 NA
1 -3.383548337 -6.080711303
2 -7.051335955 -3.383548337
3 -2.520106136 -7.051335955
4 0.686838497 -2.520106136
5 -0.007959648 0.686838497
6 -0.112739623 -0.007959648
7 1.596725941 -0.112739623
8 -4.673753802 1.596725941
9 2.387505390 -4.673753802
10 -0.009246843 2.387505390
11 -1.873576572 -0.009246843
12 -0.211427443 -1.873576572
13 3.360726783 -0.211427443
14 3.492758523 3.360726783
15 -0.981578709 3.492758523
16 13.377488421 -0.981578709
17 -0.140486630 13.377488421
18 0.484845591 -0.140486630
19 2.812027873 0.484845591
20 0.489279290 2.812027873
21 -5.378312067 0.489279290
22 0.868365357 -5.378312067
23 0.730359249 0.868365357
24 4.702117443 0.730359249
25 8.358268517 4.702117443
26 -0.339659983 8.358268517
27 -1.458890066 -0.339659983
28 -4.926938152 -1.458890066
29 5.203351272 -4.926938152
30 2.020503097 5.203351272
31 -6.855756363 2.020503097
32 4.279639088 -6.855756363
33 3.665214241 4.279639088
34 -0.302989257 3.665214241
35 -0.688696927 -0.302989257
36 1.269943840 -0.688696927
37 -3.908150078 1.269943840
38 -0.124744850 -3.908150078
39 4.343960089 -0.124744850
40 -0.174850766 4.343960089
41 2.855463878 -0.174850766
42 -4.122948587 2.855463878
43 -0.501717347 -4.122948587
44 -0.095164576 -0.501717347
45 -0.674407564 -0.095164576
46 -0.556129257 -0.674407564
47 1.831914250 -0.556129257
48 0.320077464 1.831914250
49 -4.427296885 0.320077464
50 4.022982264 -4.427296885
51 0.616614823 4.022982264
52 -8.962538001 0.616614823
53 -7.910368872 -8.962538001
54 1.730339522 -7.910368872
55 2.948719896 1.730339522
56 NA 2.948719896
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3.383548337 -6.080711303
[2,] -7.051335955 -3.383548337
[3,] -2.520106136 -7.051335955
[4,] 0.686838497 -2.520106136
[5,] -0.007959648 0.686838497
[6,] -0.112739623 -0.007959648
[7,] 1.596725941 -0.112739623
[8,] -4.673753802 1.596725941
[9,] 2.387505390 -4.673753802
[10,] -0.009246843 2.387505390
[11,] -1.873576572 -0.009246843
[12,] -0.211427443 -1.873576572
[13,] 3.360726783 -0.211427443
[14,] 3.492758523 3.360726783
[15,] -0.981578709 3.492758523
[16,] 13.377488421 -0.981578709
[17,] -0.140486630 13.377488421
[18,] 0.484845591 -0.140486630
[19,] 2.812027873 0.484845591
[20,] 0.489279290 2.812027873
[21,] -5.378312067 0.489279290
[22,] 0.868365357 -5.378312067
[23,] 0.730359249 0.868365357
[24,] 4.702117443 0.730359249
[25,] 8.358268517 4.702117443
[26,] -0.339659983 8.358268517
[27,] -1.458890066 -0.339659983
[28,] -4.926938152 -1.458890066
[29,] 5.203351272 -4.926938152
[30,] 2.020503097 5.203351272
[31,] -6.855756363 2.020503097
[32,] 4.279639088 -6.855756363
[33,] 3.665214241 4.279639088
[34,] -0.302989257 3.665214241
[35,] -0.688696927 -0.302989257
[36,] 1.269943840 -0.688696927
[37,] -3.908150078 1.269943840
[38,] -0.124744850 -3.908150078
[39,] 4.343960089 -0.124744850
[40,] -0.174850766 4.343960089
[41,] 2.855463878 -0.174850766
[42,] -4.122948587 2.855463878
[43,] -0.501717347 -4.122948587
[44,] -0.095164576 -0.501717347
[45,] -0.674407564 -0.095164576
[46,] -0.556129257 -0.674407564
[47,] 1.831914250 -0.556129257
[48,] 0.320077464 1.831914250
[49,] -4.427296885 0.320077464
[50,] 4.022982264 -4.427296885
[51,] 0.616614823 4.022982264
[52,] -8.962538001 0.616614823
[53,] -7.910368872 -8.962538001
[54,] 1.730339522 -7.910368872
[55,] 2.948719896 1.730339522
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3.383548337 -6.080711303
2 -7.051335955 -3.383548337
3 -2.520106136 -7.051335955
4 0.686838497 -2.520106136
5 -0.007959648 0.686838497
6 -0.112739623 -0.007959648
7 1.596725941 -0.112739623
8 -4.673753802 1.596725941
9 2.387505390 -4.673753802
10 -0.009246843 2.387505390
11 -1.873576572 -0.009246843
12 -0.211427443 -1.873576572
13 3.360726783 -0.211427443
14 3.492758523 3.360726783
15 -0.981578709 3.492758523
16 13.377488421 -0.981578709
17 -0.140486630 13.377488421
18 0.484845591 -0.140486630
19 2.812027873 0.484845591
20 0.489279290 2.812027873
21 -5.378312067 0.489279290
22 0.868365357 -5.378312067
23 0.730359249 0.868365357
24 4.702117443 0.730359249
25 8.358268517 4.702117443
26 -0.339659983 8.358268517
27 -1.458890066 -0.339659983
28 -4.926938152 -1.458890066
29 5.203351272 -4.926938152
30 2.020503097 5.203351272
31 -6.855756363 2.020503097
32 4.279639088 -6.855756363
33 3.665214241 4.279639088
34 -0.302989257 3.665214241
35 -0.688696927 -0.302989257
36 1.269943840 -0.688696927
37 -3.908150078 1.269943840
38 -0.124744850 -3.908150078
39 4.343960089 -0.124744850
40 -0.174850766 4.343960089
41 2.855463878 -0.174850766
42 -4.122948587 2.855463878
43 -0.501717347 -4.122948587
44 -0.095164576 -0.501717347
45 -0.674407564 -0.095164576
46 -0.556129257 -0.674407564
47 1.831914250 -0.556129257
48 0.320077464 1.831914250
49 -4.427296885 0.320077464
50 4.022982264 -4.427296885
51 0.616614823 4.022982264
52 -8.962538001 0.616614823
53 -7.910368872 -8.962538001
54 1.730339522 -7.910368872
55 2.948719896 1.730339522
> 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/7q5ya1259064576.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/872bo1259064576.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/9da3n1259064576.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/10qsxa1259064576.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/11k8op1259064576.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/12uhf91259064576.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/133cyl1259064576.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/14yfws1259064576.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/15p1031259064576.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/16nim21259064576.tab")
+ }
>
> system("convert tmp/1wipo1259064576.ps tmp/1wipo1259064576.png")
> system("convert tmp/26vt51259064576.ps tmp/26vt51259064576.png")
> system("convert tmp/33lky1259064576.ps tmp/33lky1259064576.png")
> system("convert tmp/4r1901259064576.ps tmp/4r1901259064576.png")
> system("convert tmp/5a7ra1259064576.ps tmp/5a7ra1259064576.png")
> system("convert tmp/6b23x1259064576.ps tmp/6b23x1259064576.png")
> system("convert tmp/7q5ya1259064576.ps tmp/7q5ya1259064576.png")
> system("convert tmp/872bo1259064576.ps tmp/872bo1259064576.png")
> system("convert tmp/9da3n1259064576.ps tmp/9da3n1259064576.png")
> system("convert tmp/10qsxa1259064576.ps tmp/10qsxa1259064576.png")
>
>
> proc.time()
user system elapsed
2.314 1.532 3.340