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(105.02
+ ,100.34
+ ,103.73
+ ,102.99
+ ,102.86
+ ,102.1
+ ,104.43
+ ,100.34
+ ,105.02
+ ,103.73
+ ,102.99
+ ,102.86
+ ,104.63
+ ,100.35
+ ,104.43
+ ,105.02
+ ,103.73
+ ,102.99
+ ,104.93
+ ,100.43
+ ,104.63
+ ,104.43
+ ,105.02
+ ,103.73
+ ,105.87
+ ,100.47
+ ,104.93
+ ,104.63
+ ,104.43
+ ,105.02
+ ,105.66
+ ,100.67
+ ,105.87
+ ,104.93
+ ,104.63
+ ,104.43
+ ,106.76
+ ,100.75
+ ,105.66
+ ,105.87
+ ,104.93
+ ,104.63
+ ,106
+ ,100.78
+ ,106.76
+ ,105.66
+ ,105.87
+ ,104.93
+ ,107.22
+ ,100.79
+ ,106
+ ,106.76
+ ,105.66
+ ,105.87
+ ,107.33
+ ,100.67
+ ,107.22
+ ,106
+ ,106.76
+ ,105.66
+ ,107.11
+ ,100.64
+ ,107.33
+ ,107.22
+ ,106
+ ,106.76
+ ,108.86
+ ,100.64
+ ,107.11
+ ,107.33
+ ,107.22
+ ,106
+ ,107.72
+ ,100.76
+ ,108.86
+ ,107.11
+ ,107.33
+ ,107.22
+ ,107.88
+ ,100.79
+ ,107.72
+ ,108.86
+ ,107.11
+ ,107.33
+ ,108.38
+ ,100.79
+ ,107.88
+ ,107.72
+ ,108.86
+ ,107.11
+ ,107.72
+ ,100.9
+ ,108.38
+ ,107.88
+ ,107.72
+ ,108.86
+ ,108.41
+ ,100.98
+ ,107.72
+ ,108.38
+ ,107.88
+ ,107.72
+ ,109.9
+ ,101.11
+ ,108.41
+ ,107.72
+ ,108.38
+ ,107.88
+ ,111.45
+ ,101.18
+ ,109.9
+ ,108.41
+ ,107.72
+ ,108.38
+ ,112.18
+ ,101.22
+ ,111.45
+ ,109.9
+ ,108.41
+ ,107.72
+ ,113.34
+ ,101.23
+ ,112.18
+ ,111.45
+ ,109.9
+ ,108.41
+ ,113.46
+ ,101.09
+ ,113.34
+ ,112.18
+ ,111.45
+ ,109.9
+ ,114.06
+ ,101.26
+ ,113.46
+ ,113.34
+ ,112.18
+ ,111.45
+ ,115.54
+ ,101.28
+ ,114.06
+ ,113.46
+ ,113.34
+ ,112.18
+ ,116.39
+ ,101.43
+ ,115.54
+ ,114.06
+ ,113.46
+ ,113.34
+ ,115.94
+ ,101.53
+ ,116.39
+ ,115.54
+ ,114.06
+ ,113.46
+ ,116.97
+ ,101.54
+ ,115.94
+ ,116.39
+ ,115.54
+ ,114.06
+ ,115.94
+ ,101.54
+ ,116.97
+ ,115.94
+ ,116.39
+ ,115.54
+ ,115.91
+ ,101.79
+ ,115.94
+ ,116.97
+ ,115.94
+ ,116.39
+ ,116.43
+ ,102.18
+ ,115.91
+ ,115.94
+ ,116.97
+ ,115.94
+ ,116.26
+ ,102.37
+ ,116.43
+ ,115.91
+ ,115.94
+ ,116.97
+ ,116.35
+ ,102.46
+ ,116.26
+ ,116.43
+ ,115.91
+ ,115.94
+ ,117.9
+ ,102.46
+ ,116.35
+ ,116.26
+ ,116.43
+ ,115.91
+ ,117.7
+ ,102.03
+ ,117.9
+ ,116.35
+ ,116.26
+ ,116.43
+ ,117.53
+ ,102.26
+ ,117.7
+ ,117.9
+ ,116.35
+ ,116.26
+ ,117.86
+ ,102.33
+ ,117.53
+ ,117.7
+ ,117.9
+ ,116.35
+ ,117.65
+ ,102.44
+ ,117.86
+ ,117.53
+ ,117.7
+ ,117.9
+ ,116.51
+ ,102.5
+ ,117.65
+ ,117.86
+ ,117.53
+ ,117.7
+ ,115.93
+ ,102.52
+ ,116.51
+ ,117.65
+ ,117.86
+ ,117.53
+ ,115.31
+ ,102.66
+ ,115.93
+ ,116.51
+ ,117.65
+ ,117.86
+ ,115
+ ,102.72
+ ,115.31
+ ,115.93
+ ,116.51
+ ,117.65)
+ ,dim=c(6
+ ,41)
+ ,dimnames=list(c('y(t)'
+ ,'x(t)'
+ ,'y(t-1)'
+ ,'y(t-2)'
+ ,'y(t-3)'
+ ,'y(t-4)')
+ ,1:41))
> y <- array(NA,dim=c(6,41),dimnames=list(c('y(t)','x(t)','y(t-1)','y(t-2)','y(t-3)','y(t-4)'),1:41))
> 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 = 'Do not include Seasonal 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)
1 105.02 100.34 103.73 102.99 102.86 102.10
2 104.43 100.34 105.02 103.73 102.99 102.86
3 104.63 100.35 104.43 105.02 103.73 102.99
4 104.93 100.43 104.63 104.43 105.02 103.73
5 105.87 100.47 104.93 104.63 104.43 105.02
6 105.66 100.67 105.87 104.93 104.63 104.43
7 106.76 100.75 105.66 105.87 104.93 104.63
8 106.00 100.78 106.76 105.66 105.87 104.93
9 107.22 100.79 106.00 106.76 105.66 105.87
10 107.33 100.67 107.22 106.00 106.76 105.66
11 107.11 100.64 107.33 107.22 106.00 106.76
12 108.86 100.64 107.11 107.33 107.22 106.00
13 107.72 100.76 108.86 107.11 107.33 107.22
14 107.88 100.79 107.72 108.86 107.11 107.33
15 108.38 100.79 107.88 107.72 108.86 107.11
16 107.72 100.90 108.38 107.88 107.72 108.86
17 108.41 100.98 107.72 108.38 107.88 107.72
18 109.90 101.11 108.41 107.72 108.38 107.88
19 111.45 101.18 109.90 108.41 107.72 108.38
20 112.18 101.22 111.45 109.90 108.41 107.72
21 113.34 101.23 112.18 111.45 109.90 108.41
22 113.46 101.09 113.34 112.18 111.45 109.90
23 114.06 101.26 113.46 113.34 112.18 111.45
24 115.54 101.28 114.06 113.46 113.34 112.18
25 116.39 101.43 115.54 114.06 113.46 113.34
26 115.94 101.53 116.39 115.54 114.06 113.46
27 116.97 101.54 115.94 116.39 115.54 114.06
28 115.94 101.54 116.97 115.94 116.39 115.54
29 115.91 101.79 115.94 116.97 115.94 116.39
30 116.43 102.18 115.91 115.94 116.97 115.94
31 116.26 102.37 116.43 115.91 115.94 116.97
32 116.35 102.46 116.26 116.43 115.91 115.94
33 117.90 102.46 116.35 116.26 116.43 115.91
34 117.70 102.03 117.90 116.35 116.26 116.43
35 117.53 102.26 117.70 117.90 116.35 116.26
36 117.86 102.33 117.53 117.70 117.90 116.35
37 117.65 102.44 117.86 117.53 117.70 117.90
38 116.51 102.50 117.65 117.86 117.53 117.70
39 115.93 102.52 116.51 117.65 117.86 117.53
40 115.31 102.66 115.93 116.51 117.65 117.86
41 115.00 102.72 115.31 115.93 116.51 117.65
> 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)`
-36.5108 0.4728 0.8785 0.2680 0.1649 -0.4132
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.34084 -0.44784 -0.01994 0.37445 1.54508
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -36.5108 51.0980 -0.715 0.4796
`x(t)` 0.4728 0.5900 0.801 0.4283
`y(t-1)` 0.8785 0.1613 5.445 4.16e-06 ***
`y(t-2)` 0.2680 0.2115 1.267 0.2135
`y(t-3)` 0.1649 0.2102 0.784 0.4381
`y(t-4)` -0.4132 0.1888 -2.188 0.0354 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.7729 on 35 degrees of freedom
Multiple R-squared: 0.9768, Adjusted R-squared: 0.9735
F-statistic: 294.6 on 5 and 35 DF, p-value: < 2.2e-16
> 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.04513564 0.09027128 0.95486436
[2,] 0.46965880 0.93931760 0.53034120
[3,] 0.32246436 0.64492873 0.67753564
[4,] 0.58635408 0.82729184 0.41364592
[5,] 0.61736725 0.76526549 0.38263275
[6,] 0.54902442 0.90195116 0.45097558
[7,] 0.49158602 0.98317203 0.50841398
[8,] 0.52726991 0.94546018 0.47273009
[9,] 0.45437225 0.90874451 0.54562775
[10,] 0.53056446 0.93887108 0.46943554
[11,] 0.77476932 0.45046135 0.22523068
[12,] 0.71475156 0.57049687 0.28524844
[13,] 0.63605268 0.72789464 0.36394732
[14,] 0.74456431 0.51087138 0.25543569
[15,] 0.74185689 0.51628623 0.25814311
[16,] 0.71263086 0.57473829 0.28736914
[17,] 0.65244715 0.69510569 0.34755285
[18,] 0.83552923 0.32894154 0.16447077
[19,] 0.75225958 0.49548084 0.24774042
[20,] 0.89819346 0.20361307 0.10180654
[21,] 0.92261473 0.15477053 0.07738527
[22,] 0.86234026 0.27531948 0.13765974
[23,] 0.76194090 0.47611820 0.23805910
[24,] 0.75720898 0.48558204 0.24279102
> postscript(file="/var/www/html/rcomp/tmp/15t8r1258762998.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/297t31258762998.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/3liys1258762998.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/4w9ps1258762998.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/5rph91258762998.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 = 41
Frequency = 1
1 2 3 4 5
0.5914896548 -1.0374845366 -0.7378614077 -0.4002357500 0.8339719354
6 7 8 9 10
-0.6535040840 0.3744461647 -1.3408435132 0.6703307014 -0.2991753179
11 12 13 14 15
-0.3487464362 1.0498940700 -1.1393316870 -0.3792366511 -0.0937515920
16 17 18 19 20
-0.3768836960 0.2237307726 1.2066256803 1.5450819096 0.1087938523
21 22 23 24 25
0.2468520220 -0.4215565087 0.2018649113 1.2235134933 1.0011334257
26 27 28 29 30
-0.6887892885 0.5079264167 -0.8350004949 0.0710357699 0.3532467071
31 32 33 34 35
0.2400165983 -0.1231440744 1.2952143560 0.1556131425 -0.4478440554
36 37 38 39 40
-0.1663757795 0.0006467791 -1.1262680799 -0.7826161608 -0.4828425311
41
-0.0199367184
> postscript(file="/var/www/html/rcomp/tmp/6q4081258762998.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 = 41
Frequency = 1
lag(myerror, k = 1) myerror
0 0.5914896548 NA
1 -1.0374845366 0.5914896548
2 -0.7378614077 -1.0374845366
3 -0.4002357500 -0.7378614077
4 0.8339719354 -0.4002357500
5 -0.6535040840 0.8339719354
6 0.3744461647 -0.6535040840
7 -1.3408435132 0.3744461647
8 0.6703307014 -1.3408435132
9 -0.2991753179 0.6703307014
10 -0.3487464362 -0.2991753179
11 1.0498940700 -0.3487464362
12 -1.1393316870 1.0498940700
13 -0.3792366511 -1.1393316870
14 -0.0937515920 -0.3792366511
15 -0.3768836960 -0.0937515920
16 0.2237307726 -0.3768836960
17 1.2066256803 0.2237307726
18 1.5450819096 1.2066256803
19 0.1087938523 1.5450819096
20 0.2468520220 0.1087938523
21 -0.4215565087 0.2468520220
22 0.2018649113 -0.4215565087
23 1.2235134933 0.2018649113
24 1.0011334257 1.2235134933
25 -0.6887892885 1.0011334257
26 0.5079264167 -0.6887892885
27 -0.8350004949 0.5079264167
28 0.0710357699 -0.8350004949
29 0.3532467071 0.0710357699
30 0.2400165983 0.3532467071
31 -0.1231440744 0.2400165983
32 1.2952143560 -0.1231440744
33 0.1556131425 1.2952143560
34 -0.4478440554 0.1556131425
35 -0.1663757795 -0.4478440554
36 0.0006467791 -0.1663757795
37 -1.1262680799 0.0006467791
38 -0.7826161608 -1.1262680799
39 -0.4828425311 -0.7826161608
40 -0.0199367184 -0.4828425311
41 NA -0.0199367184
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.0374845366 0.5914896548
[2,] -0.7378614077 -1.0374845366
[3,] -0.4002357500 -0.7378614077
[4,] 0.8339719354 -0.4002357500
[5,] -0.6535040840 0.8339719354
[6,] 0.3744461647 -0.6535040840
[7,] -1.3408435132 0.3744461647
[8,] 0.6703307014 -1.3408435132
[9,] -0.2991753179 0.6703307014
[10,] -0.3487464362 -0.2991753179
[11,] 1.0498940700 -0.3487464362
[12,] -1.1393316870 1.0498940700
[13,] -0.3792366511 -1.1393316870
[14,] -0.0937515920 -0.3792366511
[15,] -0.3768836960 -0.0937515920
[16,] 0.2237307726 -0.3768836960
[17,] 1.2066256803 0.2237307726
[18,] 1.5450819096 1.2066256803
[19,] 0.1087938523 1.5450819096
[20,] 0.2468520220 0.1087938523
[21,] -0.4215565087 0.2468520220
[22,] 0.2018649113 -0.4215565087
[23,] 1.2235134933 0.2018649113
[24,] 1.0011334257 1.2235134933
[25,] -0.6887892885 1.0011334257
[26,] 0.5079264167 -0.6887892885
[27,] -0.8350004949 0.5079264167
[28,] 0.0710357699 -0.8350004949
[29,] 0.3532467071 0.0710357699
[30,] 0.2400165983 0.3532467071
[31,] -0.1231440744 0.2400165983
[32,] 1.2952143560 -0.1231440744
[33,] 0.1556131425 1.2952143560
[34,] -0.4478440554 0.1556131425
[35,] -0.1663757795 -0.4478440554
[36,] 0.0006467791 -0.1663757795
[37,] -1.1262680799 0.0006467791
[38,] -0.7826161608 -1.1262680799
[39,] -0.4828425311 -0.7826161608
[40,] -0.0199367184 -0.4828425311
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.0374845366 0.5914896548
2 -0.7378614077 -1.0374845366
3 -0.4002357500 -0.7378614077
4 0.8339719354 -0.4002357500
5 -0.6535040840 0.8339719354
6 0.3744461647 -0.6535040840
7 -1.3408435132 0.3744461647
8 0.6703307014 -1.3408435132
9 -0.2991753179 0.6703307014
10 -0.3487464362 -0.2991753179
11 1.0498940700 -0.3487464362
12 -1.1393316870 1.0498940700
13 -0.3792366511 -1.1393316870
14 -0.0937515920 -0.3792366511
15 -0.3768836960 -0.0937515920
16 0.2237307726 -0.3768836960
17 1.2066256803 0.2237307726
18 1.5450819096 1.2066256803
19 0.1087938523 1.5450819096
20 0.2468520220 0.1087938523
21 -0.4215565087 0.2468520220
22 0.2018649113 -0.4215565087
23 1.2235134933 0.2018649113
24 1.0011334257 1.2235134933
25 -0.6887892885 1.0011334257
26 0.5079264167 -0.6887892885
27 -0.8350004949 0.5079264167
28 0.0710357699 -0.8350004949
29 0.3532467071 0.0710357699
30 0.2400165983 0.3532467071
31 -0.1231440744 0.2400165983
32 1.2952143560 -0.1231440744
33 0.1556131425 1.2952143560
34 -0.4478440554 0.1556131425
35 -0.1663757795 -0.4478440554
36 0.0006467791 -0.1663757795
37 -1.1262680799 0.0006467791
38 -0.7826161608 -1.1262680799
39 -0.4828425311 -0.7826161608
40 -0.0199367184 -0.4828425311
> 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/7jy2j1258762998.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/8acsy1258762998.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/9tajg1258762998.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/10kszt1258762998.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/11y7jw1258762998.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/12ae2v1258762998.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/13v9841258762998.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/14ytka1258762998.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/15dyyh1258762998.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/16jfu41258762998.tab")
+ }
>
> system("convert tmp/15t8r1258762998.ps tmp/15t8r1258762998.png")
> system("convert tmp/297t31258762998.ps tmp/297t31258762998.png")
> system("convert tmp/3liys1258762998.ps tmp/3liys1258762998.png")
> system("convert tmp/4w9ps1258762998.ps tmp/4w9ps1258762998.png")
> system("convert tmp/5rph91258762998.ps tmp/5rph91258762998.png")
> system("convert tmp/6q4081258762998.ps tmp/6q4081258762998.png")
> system("convert tmp/7jy2j1258762998.ps tmp/7jy2j1258762998.png")
> system("convert tmp/8acsy1258762998.ps tmp/8acsy1258762998.png")
> system("convert tmp/9tajg1258762998.ps tmp/9tajg1258762998.png")
> system("convert tmp/10kszt1258762998.ps tmp/10kszt1258762998.png")
>
>
> proc.time()
user system elapsed
2.288 1.557 2.716