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(121.6
+ ,0
+ ,118.8
+ ,121.6
+ ,118.8
+ ,0
+ ,114.0
+ ,118.8
+ ,114.0
+ ,1
+ ,111.5
+ ,114.0
+ ,111.5
+ ,1
+ ,97.2
+ ,111.5
+ ,97.2
+ ,1
+ ,102.5
+ ,97.2
+ ,102.5
+ ,1
+ ,113.4
+ ,102.5
+ ,113.4
+ ,1
+ ,109.8
+ ,113.4
+ ,109.8
+ ,1
+ ,104.9
+ ,109.8
+ ,104.9
+ ,1
+ ,126.1
+ ,104.9
+ ,126.1
+ ,1
+ ,80.0
+ ,126.1
+ ,80.0
+ ,1
+ ,96.8
+ ,80.0
+ ,96.8
+ ,1
+ ,117.2
+ ,96.8
+ ,117.2
+ ,1
+ ,112.3
+ ,117.2
+ ,112.3
+ ,1
+ ,117.3
+ ,112.3
+ ,117.3
+ ,1
+ ,111.1
+ ,117.3
+ ,111.1
+ ,0
+ ,102.2
+ ,111.1
+ ,102.2
+ ,0
+ ,104.3
+ ,102.2
+ ,104.3
+ ,0
+ ,122.9
+ ,104.3
+ ,122.9
+ ,0
+ ,107.6
+ ,122.9
+ ,107.6
+ ,0
+ ,121.3
+ ,107.6
+ ,121.3
+ ,0
+ ,131.5
+ ,121.3
+ ,131.5
+ ,0
+ ,89.0
+ ,131.5
+ ,89.0
+ ,0
+ ,104.4
+ ,89.0
+ ,104.4
+ ,0
+ ,128.9
+ ,104.4
+ ,128.9
+ ,0
+ ,135.9
+ ,128.9
+ ,135.9
+ ,0
+ ,133.3
+ ,135.9
+ ,133.3
+ ,0
+ ,121.3
+ ,133.3
+ ,121.3
+ ,0
+ ,120.5
+ ,121.3
+ ,120.5
+ ,0
+ ,120.4
+ ,120.5
+ ,120.4
+ ,0
+ ,137.9
+ ,120.4
+ ,137.9
+ ,0
+ ,126.1
+ ,137.9
+ ,126.1
+ ,0
+ ,133.2
+ ,126.1
+ ,133.2
+ ,0
+ ,151.1
+ ,133.2
+ ,151.1
+ ,0
+ ,105.0
+ ,151.1
+ ,105.0
+ ,0
+ ,119.0
+ ,105.0
+ ,119.0
+ ,0
+ ,140.4
+ ,119.0
+ ,140.4
+ ,0
+ ,156.6
+ ,140.4
+ ,156.6
+ ,0
+ ,137.1
+ ,156.6
+ ,137.1
+ ,0
+ ,122.7
+ ,137.1
+ ,122.7
+ ,0
+ ,125.8
+ ,122.7
+ ,125.8
+ ,0
+ ,139.3
+ ,125.8
+ ,139.3
+ ,0
+ ,134.9
+ ,139.3
+ ,134.9
+ ,0
+ ,149.2
+ ,134.9
+ ,149.2
+ ,1
+ ,132.3
+ ,149.2
+ ,132.3
+ ,0
+ ,149.0
+ ,132.3
+ ,149.0
+ ,1
+ ,117.2
+ ,149.0
+ ,117.2
+ ,1
+ ,119.6
+ ,117.2
+ ,119.6
+ ,1
+ ,152.0
+ ,119.6
+ ,152.0
+ ,1
+ ,149.4
+ ,152.0
+ ,149.4
+ ,1
+ ,127.3
+ ,149.4
+ ,127.3
+ ,1
+ ,114.1
+ ,127.3
+ ,114.1
+ ,1
+ ,102.1
+ ,114.1
+ ,102.1
+ ,1
+ ,107.7
+ ,102.1
+ ,107.7
+ ,1
+ ,104.4
+ ,107.7
+ ,104.4
+ ,1
+ ,102.1
+ ,104.4
+ ,102.1
+ ,1
+ ,96.0
+ ,102.1
+ ,96.0
+ ,1
+ ,109.3
+ ,96.0
+ ,109.3
+ ,1
+ ,90.0
+ ,109.3
+ ,90.0
+ ,1
+ ,83.9
+ ,90.0)
+ ,dim=c(4
+ ,59)
+ ,dimnames=list(c('X'
+ ,'Y'
+ ,'y(t)'
+ ,'y(t-1)')
+ ,1:59))
> y <- array(NA,dim=c(4,59),dimnames=list(c('X','Y','y(t)','y(t-1)'),1:59))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
X Y y(t) y(t-1) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 121.6 0 118.8 121.6 1 0 0 0 0 0 0 0 0 0 0 1
2 118.8 0 114.0 118.8 0 1 0 0 0 0 0 0 0 0 0 2
3 114.0 1 111.5 114.0 0 0 1 0 0 0 0 0 0 0 0 3
4 111.5 1 97.2 111.5 0 0 0 1 0 0 0 0 0 0 0 4
5 97.2 1 102.5 97.2 0 0 0 0 1 0 0 0 0 0 0 5
6 102.5 1 113.4 102.5 0 0 0 0 0 1 0 0 0 0 0 6
7 113.4 1 109.8 113.4 0 0 0 0 0 0 1 0 0 0 0 7
8 109.8 1 104.9 109.8 0 0 0 0 0 0 0 1 0 0 0 8
9 104.9 1 126.1 104.9 0 0 0 0 0 0 0 0 1 0 0 9
10 126.1 1 80.0 126.1 0 0 0 0 0 0 0 0 0 1 0 10
11 80.0 1 96.8 80.0 0 0 0 0 0 0 0 0 0 0 1 11
12 96.8 1 117.2 96.8 0 0 0 0 0 0 0 0 0 0 0 12
13 117.2 1 112.3 117.2 1 0 0 0 0 0 0 0 0 0 0 13
14 112.3 1 117.3 112.3 0 1 0 0 0 0 0 0 0 0 0 14
15 117.3 1 111.1 117.3 0 0 1 0 0 0 0 0 0 0 0 15
16 111.1 0 102.2 111.1 0 0 0 1 0 0 0 0 0 0 0 16
17 102.2 0 104.3 102.2 0 0 0 0 1 0 0 0 0 0 0 17
18 104.3 0 122.9 104.3 0 0 0 0 0 1 0 0 0 0 0 18
19 122.9 0 107.6 122.9 0 0 0 0 0 0 1 0 0 0 0 19
20 107.6 0 121.3 107.6 0 0 0 0 0 0 0 1 0 0 0 20
21 121.3 0 131.5 121.3 0 0 0 0 0 0 0 0 1 0 0 21
22 131.5 0 89.0 131.5 0 0 0 0 0 0 0 0 0 1 0 22
23 89.0 0 104.4 89.0 0 0 0 0 0 0 0 0 0 0 1 23
24 104.4 0 128.9 104.4 0 0 0 0 0 0 0 0 0 0 0 24
25 128.9 0 135.9 128.9 1 0 0 0 0 0 0 0 0 0 0 25
26 135.9 0 133.3 135.9 0 1 0 0 0 0 0 0 0 0 0 26
27 133.3 0 121.3 133.3 0 0 1 0 0 0 0 0 0 0 0 27
28 121.3 0 120.5 121.3 0 0 0 1 0 0 0 0 0 0 0 28
29 120.5 0 120.4 120.5 0 0 0 0 1 0 0 0 0 0 0 29
30 120.4 0 137.9 120.4 0 0 0 0 0 1 0 0 0 0 0 30
31 137.9 0 126.1 137.9 0 0 0 0 0 0 1 0 0 0 0 31
32 126.1 0 133.2 126.1 0 0 0 0 0 0 0 1 0 0 0 32
33 133.2 0 151.1 133.2 0 0 0 0 0 0 0 0 1 0 0 33
34 151.1 0 105.0 151.1 0 0 0 0 0 0 0 0 0 1 0 34
35 105.0 0 119.0 105.0 0 0 0 0 0 0 0 0 0 0 1 35
36 119.0 0 140.4 119.0 0 0 0 0 0 0 0 0 0 0 0 36
37 140.4 0 156.6 140.4 1 0 0 0 0 0 0 0 0 0 0 37
38 156.6 0 137.1 156.6 0 1 0 0 0 0 0 0 0 0 0 38
39 137.1 0 122.7 137.1 0 0 1 0 0 0 0 0 0 0 0 39
40 122.7 0 125.8 122.7 0 0 0 1 0 0 0 0 0 0 0 40
41 125.8 0 139.3 125.8 0 0 0 0 1 0 0 0 0 0 0 41
42 139.3 0 134.9 139.3 0 0 0 0 0 1 0 0 0 0 0 42
43 134.9 0 149.2 134.9 0 0 0 0 0 0 1 0 0 0 0 43
44 149.2 1 132.3 149.2 0 0 0 0 0 0 0 1 0 0 0 44
45 132.3 0 149.0 132.3 0 0 0 0 0 0 0 0 1 0 0 45
46 149.0 1 117.2 149.0 0 0 0 0 0 0 0 0 0 1 0 46
47 117.2 1 119.6 117.2 0 0 0 0 0 0 0 0 0 0 1 47
48 119.6 1 152.0 119.6 0 0 0 0 0 0 0 0 0 0 0 48
49 152.0 1 149.4 152.0 1 0 0 0 0 0 0 0 0 0 0 49
50 149.4 1 127.3 149.4 0 1 0 0 0 0 0 0 0 0 0 50
51 127.3 1 114.1 127.3 0 0 1 0 0 0 0 0 0 0 0 51
52 114.1 1 102.1 114.1 0 0 0 1 0 0 0 0 0 0 0 52
53 102.1 1 107.7 102.1 0 0 0 0 1 0 0 0 0 0 0 53
54 107.7 1 104.4 107.7 0 0 0 0 0 1 0 0 0 0 0 54
55 104.4 1 102.1 104.4 0 0 0 0 0 0 1 0 0 0 0 55
56 102.1 1 96.0 102.1 0 0 0 0 0 0 0 1 0 0 0 56
57 96.0 1 109.3 96.0 0 0 0 0 0 0 0 0 1 0 0 57
58 109.3 1 90.0 109.3 0 0 0 0 0 0 0 0 0 1 0 58
59 90.0 1 83.9 90.0 0 0 0 0 0 0 0 0 0 0 1 59
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Y `y(t)` `y(t-1)` M1 M2
2.426e-14 -1.106e-15 1.739e-16 1.000e+00 3.587e-15 1.453e-15
M3 M4 M5 M6 M7 M8
3.863e-15 -4.585e-15 1.426e-15 6.726e-16 1.801e-15 2.488e-15
M9 M10 M11 t
5.592e-17 3.139e-15 9.235e-16 6.167e-17
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2.457e-14 -1.200e-15 7.453e-18 1.261e-15 7.019e-15
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.426e-14 8.042e-15 3.016e+00 0.00429 **
Y -1.106e-15 1.486e-15 -7.440e-01 0.46072
`y(t)` 1.739e-16 8.185e-17 2.125e+00 0.03936 *
`y(t-1)` 1.000e+00 8.171e-17 1.224e+16 < 2e-16 ***
M1 3.587e-15 3.653e-15 9.820e-01 0.33161
M2 1.453e-15 4.095e-15 3.550e-01 0.72445
M3 3.863e-15 4.081e-15 9.470e-01 0.34911
M4 -4.585e-15 4.006e-15 -1.145e+00 0.25871
M5 1.426e-15 3.550e-15 4.020e-01 0.68996
M6 6.726e-16 3.416e-15 1.970e-01 0.84484
M7 1.801e-15 3.828e-15 4.700e-01 0.64051
M8 2.488e-15 3.709e-15 6.710e-01 0.50598
M9 5.592e-17 3.222e-15 1.700e-02 0.98623
M10 3.139e-15 5.639e-15 5.570e-01 0.58066
M11 9.235e-16 3.630e-15 2.540e-01 0.80040
t 6.167e-17 4.144e-17 1.488e+00 0.14405
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.687e-15 on 43 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 5.178e+31 on 15 and 43 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,] 6.914217e-01 6.171566e-01 3.085783e-01
[2,] 2.574500e-02 5.148999e-02 9.742550e-01
[3,] 5.954062e-02 1.190812e-01 9.404594e-01
[4,] 1.012014e-05 2.024028e-05 9.999899e-01
[5,] 2.533064e-04 5.066127e-04 9.997467e-01
[6,] 3.019465e-02 6.038930e-02 9.698054e-01
[7,] 2.849370e-01 5.698739e-01 7.150630e-01
[8,] 9.999918e-01 1.645136e-05 8.225679e-06
[9,] 8.683865e-01 2.632269e-01 1.316135e-01
[10,] 1.154949e-01 2.309898e-01 8.845051e-01
[11,] 9.984905e-01 3.018943e-03 1.509471e-03
[12,] 9.969144e-01 6.171150e-03 3.085575e-03
[13,] 5.976077e-01 8.047846e-01 4.023923e-01
[14,] 2.548815e-02 5.097630e-02 9.745119e-01
[15,] 9.923768e-01 1.524640e-02 7.623202e-03
[16,] 8.974147e-01 2.051706e-01 1.025853e-01
[17,] 2.560796e-06 5.121591e-06 9.999974e-01
[18,] 9.896970e-01 2.060604e-02 1.030302e-02
[19,] 9.607615e-01 7.847696e-02 3.923848e-02
[20,] 1.200536e-02 2.401072e-02 9.879946e-01
[21,] 7.100137e-01 5.799727e-01 2.899863e-01
[22,] 9.328166e-05 1.865633e-04 9.999067e-01
> postscript(file="/var/www/html/rcomp/tmp/1mrod1258623999.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/2gn5a1258623999.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/3lbiz1258623999.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/458wi1258623999.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/56fbp1258623999.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 = 59
Frequency = 1
1 2 3 4 5
5.159897e-15 -2.470485e-15 5.971014e-15 -2.456672e-14 2.633961e-15
6 7 8 9 10
1.317326e-15 2.484069e-15 1.725957e-15 6.003645e-16 2.276340e-15
11 12 13 14 15
-7.880706e-16 1.557244e-15 5.897194e-16 1.634250e-15 5.333171e-17
16 17 18 19 20
6.702890e-15 2.804885e-16 -1.325182e-15 5.013121e-16 -2.423143e-15
21 22 23 24 25
1.205351e-15 5.071287e-16 7.452983e-18 -4.802453e-16 -2.298894e-15
26 27 28 29 30
6.394638e-16 -1.458212e-15 5.930714e-15 -1.825114e-16 -9.248457e-16
31 32 33 34 35
-2.829442e-16 -1.553629e-15 3.737164e-16 -3.383000e-15 3.938220e-16
36 37 38 39 40
-5.353571e-17 -3.264706e-15 -2.224292e-16 -2.969563e-15 4.913848e-15
41 42 43 44 45
-1.731525e-15 6.641196e-16 -1.904874e-15 3.826328e-15 -3.504784e-16
46 47 48 49 50
1.674668e-15 6.241473e-16 -1.023463e-15 -1.860161e-16 4.192011e-16
51 52 53 54 55
-1.596570e-15 7.019270e-15 -1.000413e-15 2.685824e-16 -7.975630e-16
56 57 58 59
-1.575513e-15 -1.828954e-15 -1.075137e-15 -2.373517e-16
> postscript(file="/var/www/html/rcomp/tmp/6ppjc1258623999.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 = 59
Frequency = 1
lag(myerror, k = 1) myerror
0 5.159897e-15 NA
1 -2.470485e-15 5.159897e-15
2 5.971014e-15 -2.470485e-15
3 -2.456672e-14 5.971014e-15
4 2.633961e-15 -2.456672e-14
5 1.317326e-15 2.633961e-15
6 2.484069e-15 1.317326e-15
7 1.725957e-15 2.484069e-15
8 6.003645e-16 1.725957e-15
9 2.276340e-15 6.003645e-16
10 -7.880706e-16 2.276340e-15
11 1.557244e-15 -7.880706e-16
12 5.897194e-16 1.557244e-15
13 1.634250e-15 5.897194e-16
14 5.333171e-17 1.634250e-15
15 6.702890e-15 5.333171e-17
16 2.804885e-16 6.702890e-15
17 -1.325182e-15 2.804885e-16
18 5.013121e-16 -1.325182e-15
19 -2.423143e-15 5.013121e-16
20 1.205351e-15 -2.423143e-15
21 5.071287e-16 1.205351e-15
22 7.452983e-18 5.071287e-16
23 -4.802453e-16 7.452983e-18
24 -2.298894e-15 -4.802453e-16
25 6.394638e-16 -2.298894e-15
26 -1.458212e-15 6.394638e-16
27 5.930714e-15 -1.458212e-15
28 -1.825114e-16 5.930714e-15
29 -9.248457e-16 -1.825114e-16
30 -2.829442e-16 -9.248457e-16
31 -1.553629e-15 -2.829442e-16
32 3.737164e-16 -1.553629e-15
33 -3.383000e-15 3.737164e-16
34 3.938220e-16 -3.383000e-15
35 -5.353571e-17 3.938220e-16
36 -3.264706e-15 -5.353571e-17
37 -2.224292e-16 -3.264706e-15
38 -2.969563e-15 -2.224292e-16
39 4.913848e-15 -2.969563e-15
40 -1.731525e-15 4.913848e-15
41 6.641196e-16 -1.731525e-15
42 -1.904874e-15 6.641196e-16
43 3.826328e-15 -1.904874e-15
44 -3.504784e-16 3.826328e-15
45 1.674668e-15 -3.504784e-16
46 6.241473e-16 1.674668e-15
47 -1.023463e-15 6.241473e-16
48 -1.860161e-16 -1.023463e-15
49 4.192011e-16 -1.860161e-16
50 -1.596570e-15 4.192011e-16
51 7.019270e-15 -1.596570e-15
52 -1.000413e-15 7.019270e-15
53 2.685824e-16 -1.000413e-15
54 -7.975630e-16 2.685824e-16
55 -1.575513e-15 -7.975630e-16
56 -1.828954e-15 -1.575513e-15
57 -1.075137e-15 -1.828954e-15
58 -2.373517e-16 -1.075137e-15
59 NA -2.373517e-16
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.470485e-15 5.159897e-15
[2,] 5.971014e-15 -2.470485e-15
[3,] -2.456672e-14 5.971014e-15
[4,] 2.633961e-15 -2.456672e-14
[5,] 1.317326e-15 2.633961e-15
[6,] 2.484069e-15 1.317326e-15
[7,] 1.725957e-15 2.484069e-15
[8,] 6.003645e-16 1.725957e-15
[9,] 2.276340e-15 6.003645e-16
[10,] -7.880706e-16 2.276340e-15
[11,] 1.557244e-15 -7.880706e-16
[12,] 5.897194e-16 1.557244e-15
[13,] 1.634250e-15 5.897194e-16
[14,] 5.333171e-17 1.634250e-15
[15,] 6.702890e-15 5.333171e-17
[16,] 2.804885e-16 6.702890e-15
[17,] -1.325182e-15 2.804885e-16
[18,] 5.013121e-16 -1.325182e-15
[19,] -2.423143e-15 5.013121e-16
[20,] 1.205351e-15 -2.423143e-15
[21,] 5.071287e-16 1.205351e-15
[22,] 7.452983e-18 5.071287e-16
[23,] -4.802453e-16 7.452983e-18
[24,] -2.298894e-15 -4.802453e-16
[25,] 6.394638e-16 -2.298894e-15
[26,] -1.458212e-15 6.394638e-16
[27,] 5.930714e-15 -1.458212e-15
[28,] -1.825114e-16 5.930714e-15
[29,] -9.248457e-16 -1.825114e-16
[30,] -2.829442e-16 -9.248457e-16
[31,] -1.553629e-15 -2.829442e-16
[32,] 3.737164e-16 -1.553629e-15
[33,] -3.383000e-15 3.737164e-16
[34,] 3.938220e-16 -3.383000e-15
[35,] -5.353571e-17 3.938220e-16
[36,] -3.264706e-15 -5.353571e-17
[37,] -2.224292e-16 -3.264706e-15
[38,] -2.969563e-15 -2.224292e-16
[39,] 4.913848e-15 -2.969563e-15
[40,] -1.731525e-15 4.913848e-15
[41,] 6.641196e-16 -1.731525e-15
[42,] -1.904874e-15 6.641196e-16
[43,] 3.826328e-15 -1.904874e-15
[44,] -3.504784e-16 3.826328e-15
[45,] 1.674668e-15 -3.504784e-16
[46,] 6.241473e-16 1.674668e-15
[47,] -1.023463e-15 6.241473e-16
[48,] -1.860161e-16 -1.023463e-15
[49,] 4.192011e-16 -1.860161e-16
[50,] -1.596570e-15 4.192011e-16
[51,] 7.019270e-15 -1.596570e-15
[52,] -1.000413e-15 7.019270e-15
[53,] 2.685824e-16 -1.000413e-15
[54,] -7.975630e-16 2.685824e-16
[55,] -1.575513e-15 -7.975630e-16
[56,] -1.828954e-15 -1.575513e-15
[57,] -1.075137e-15 -1.828954e-15
[58,] -2.373517e-16 -1.075137e-15
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.470485e-15 5.159897e-15
2 5.971014e-15 -2.470485e-15
3 -2.456672e-14 5.971014e-15
4 2.633961e-15 -2.456672e-14
5 1.317326e-15 2.633961e-15
6 2.484069e-15 1.317326e-15
7 1.725957e-15 2.484069e-15
8 6.003645e-16 1.725957e-15
9 2.276340e-15 6.003645e-16
10 -7.880706e-16 2.276340e-15
11 1.557244e-15 -7.880706e-16
12 5.897194e-16 1.557244e-15
13 1.634250e-15 5.897194e-16
14 5.333171e-17 1.634250e-15
15 6.702890e-15 5.333171e-17
16 2.804885e-16 6.702890e-15
17 -1.325182e-15 2.804885e-16
18 5.013121e-16 -1.325182e-15
19 -2.423143e-15 5.013121e-16
20 1.205351e-15 -2.423143e-15
21 5.071287e-16 1.205351e-15
22 7.452983e-18 5.071287e-16
23 -4.802453e-16 7.452983e-18
24 -2.298894e-15 -4.802453e-16
25 6.394638e-16 -2.298894e-15
26 -1.458212e-15 6.394638e-16
27 5.930714e-15 -1.458212e-15
28 -1.825114e-16 5.930714e-15
29 -9.248457e-16 -1.825114e-16
30 -2.829442e-16 -9.248457e-16
31 -1.553629e-15 -2.829442e-16
32 3.737164e-16 -1.553629e-15
33 -3.383000e-15 3.737164e-16
34 3.938220e-16 -3.383000e-15
35 -5.353571e-17 3.938220e-16
36 -3.264706e-15 -5.353571e-17
37 -2.224292e-16 -3.264706e-15
38 -2.969563e-15 -2.224292e-16
39 4.913848e-15 -2.969563e-15
40 -1.731525e-15 4.913848e-15
41 6.641196e-16 -1.731525e-15
42 -1.904874e-15 6.641196e-16
43 3.826328e-15 -1.904874e-15
44 -3.504784e-16 3.826328e-15
45 1.674668e-15 -3.504784e-16
46 6.241473e-16 1.674668e-15
47 -1.023463e-15 6.241473e-16
48 -1.860161e-16 -1.023463e-15
49 4.192011e-16 -1.860161e-16
50 -1.596570e-15 4.192011e-16
51 7.019270e-15 -1.596570e-15
52 -1.000413e-15 7.019270e-15
53 2.685824e-16 -1.000413e-15
54 -7.975630e-16 2.685824e-16
55 -1.575513e-15 -7.975630e-16
56 -1.828954e-15 -1.575513e-15
57 -1.075137e-15 -1.828954e-15
58 -2.373517e-16 -1.075137e-15
> 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/7lmax1258623999.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/813wz1258623999.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/9a55q1258623999.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/10sdjs1258623999.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/11024t1258623999.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/126v0p1258623999.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/13od4n1258623999.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/14f6eq1258624000.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/154dkr1258624000.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/16upoy1258624000.tab")
+ }
>
> system("convert tmp/1mrod1258623999.ps tmp/1mrod1258623999.png")
> system("convert tmp/2gn5a1258623999.ps tmp/2gn5a1258623999.png")
> system("convert tmp/3lbiz1258623999.ps tmp/3lbiz1258623999.png")
> system("convert tmp/458wi1258623999.ps tmp/458wi1258623999.png")
> system("convert tmp/56fbp1258623999.ps tmp/56fbp1258623999.png")
> system("convert tmp/6ppjc1258623999.ps tmp/6ppjc1258623999.png")
> system("convert tmp/7lmax1258623999.ps tmp/7lmax1258623999.png")
> system("convert tmp/813wz1258623999.ps tmp/813wz1258623999.png")
> system("convert tmp/9a55q1258623999.ps tmp/9a55q1258623999.png")
> system("convert tmp/10sdjs1258623999.ps tmp/10sdjs1258623999.png")
>
>
> proc.time()
user system elapsed
2.415 1.593 3.536