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(117.33
+ ,102.7
+ ,111.1
+ ,107.47
+ ,103.86
+ ,104.08
+ ,119.04
+ ,103.1
+ ,117.33
+ ,111.1
+ ,107.47
+ ,103.86
+ ,123.68
+ ,100
+ ,119.04
+ ,117.33
+ ,111.1
+ ,107.47
+ ,125.9
+ ,107.2
+ ,123.68
+ ,119.04
+ ,117.33
+ ,111.1
+ ,124.54
+ ,107
+ ,125.9
+ ,123.68
+ ,119.04
+ ,117.33
+ ,119.39
+ ,119
+ ,124.54
+ ,125.9
+ ,123.68
+ ,119.04
+ ,118.8
+ ,110.4
+ ,119.39
+ ,124.54
+ ,125.9
+ ,123.68
+ ,114.81
+ ,101.7
+ ,118.8
+ ,119.39
+ ,124.54
+ ,125.9
+ ,117.9
+ ,102.4
+ ,114.81
+ ,118.8
+ ,119.39
+ ,124.54
+ ,120.53
+ ,98.8
+ ,117.9
+ ,114.81
+ ,118.8
+ ,119.39
+ ,125.15
+ ,105.6
+ ,120.53
+ ,117.9
+ ,114.81
+ ,118.8
+ ,126.49
+ ,104.4
+ ,125.15
+ ,120.53
+ ,117.9
+ ,114.81
+ ,131.85
+ ,106.3
+ ,126.49
+ ,125.15
+ ,120.53
+ ,117.9
+ ,127.4
+ ,107.2
+ ,131.85
+ ,126.49
+ ,125.15
+ ,120.53
+ ,131.08
+ ,108.5
+ ,127.4
+ ,131.85
+ ,126.49
+ ,125.15
+ ,122.37
+ ,106.9
+ ,131.08
+ ,127.4
+ ,131.85
+ ,126.49
+ ,124.34
+ ,114.2
+ ,122.37
+ ,131.08
+ ,127.4
+ ,131.85
+ ,119.61
+ ,125.9
+ ,124.34
+ ,122.37
+ ,131.08
+ ,127.4
+ ,119.97
+ ,110.6
+ ,119.61
+ ,124.34
+ ,122.37
+ ,131.08
+ ,116.46
+ ,110.5
+ ,119.97
+ ,119.61
+ ,124.34
+ ,122.37
+ ,117.03
+ ,106.7
+ ,116.46
+ ,119.97
+ ,119.61
+ ,124.34
+ ,120.96
+ ,104.7
+ ,117.03
+ ,116.46
+ ,119.97
+ ,119.61
+ ,124.71
+ ,107.4
+ ,120.96
+ ,117.03
+ ,116.46
+ ,119.97
+ ,127.08
+ ,109.8
+ ,124.71
+ ,120.96
+ ,117.03
+ ,116.46
+ ,131.91
+ ,103.4
+ ,127.08
+ ,124.71
+ ,120.96
+ ,117.03
+ ,137.69
+ ,114.8
+ ,131.91
+ ,127.08
+ ,124.71
+ ,120.96
+ ,142.46
+ ,114.3
+ ,137.69
+ ,131.91
+ ,127.08
+ ,124.71
+ ,144.32
+ ,109.6
+ ,142.46
+ ,137.69
+ ,131.91
+ ,127.08
+ ,138.06
+ ,118.3
+ ,144.32
+ ,142.46
+ ,137.69
+ ,131.91
+ ,124.45
+ ,127.3
+ ,138.06
+ ,144.32
+ ,142.46
+ ,137.69
+ ,126.71
+ ,112.3
+ ,124.45
+ ,138.06
+ ,144.32
+ ,142.46
+ ,121.83
+ ,114.9
+ ,126.71
+ ,124.45
+ ,138.06
+ ,144.32
+ ,122.51
+ ,108.2
+ ,121.83
+ ,126.71
+ ,124.45
+ ,138.06
+ ,125.48
+ ,105.4
+ ,122.51
+ ,121.83
+ ,126.71
+ ,124.45
+ ,127.77
+ ,122.1
+ ,125.48
+ ,122.51
+ ,121.83
+ ,126.71
+ ,128.03
+ ,113.5
+ ,127.77
+ ,125.48
+ ,122.51
+ ,121.83
+ ,132.84
+ ,110
+ ,128.03
+ ,127.77
+ ,125.48
+ ,122.51
+ ,133.41
+ ,125.3
+ ,132.84
+ ,128.03
+ ,127.77
+ ,125.48
+ ,139.99
+ ,114.3
+ ,133.41
+ ,132.84
+ ,128.03
+ ,127.77
+ ,138.53
+ ,115.6
+ ,139.99
+ ,133.41
+ ,132.84
+ ,128.03
+ ,136.12
+ ,127.1
+ ,138.53
+ ,139.99
+ ,133.41
+ ,132.84
+ ,124.75
+ ,123
+ ,136.12
+ ,138.53
+ ,139.99
+ ,133.41
+ ,122.88
+ ,122.2
+ ,124.75
+ ,136.12
+ ,138.53
+ ,139.99
+ ,121.46
+ ,126.4
+ ,122.88
+ ,124.75
+ ,136.12
+ ,138.53
+ ,118.4
+ ,112.7
+ ,121.46
+ ,122.88
+ ,124.75
+ ,136.12
+ ,122.45
+ ,105.8
+ ,118.4
+ ,121.46
+ ,122.88
+ ,124.75
+ ,128.94
+ ,120.9
+ ,122.45
+ ,118.4
+ ,121.46
+ ,122.88
+ ,133.25
+ ,116.3
+ ,128.94
+ ,122.45
+ ,118.4
+ ,121.46
+ ,137.94
+ ,115.7
+ ,133.25
+ ,128.94
+ ,122.45
+ ,118.4
+ ,140.04
+ ,127.9
+ ,137.94
+ ,133.25
+ ,128.94
+ ,122.45
+ ,130.74
+ ,108.3
+ ,140.04
+ ,137.94
+ ,133.25
+ ,128.94
+ ,131.55
+ ,121.1
+ ,130.74
+ ,140.04
+ ,137.94
+ ,133.25
+ ,129.47
+ ,128.6
+ ,131.55
+ ,130.74
+ ,140.04
+ ,137.94
+ ,125.45
+ ,123.1
+ ,129.47
+ ,131.55
+ ,130.74
+ ,140.04
+ ,127.87
+ ,127.7
+ ,125.45
+ ,129.47
+ ,131.55
+ ,130.74
+ ,124.68
+ ,126.6
+ ,127.87
+ ,125.45
+ ,129.47
+ ,131.55)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),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 = '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 X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 117.33 102.7 111.10 107.47 103.86 104.08 1 0 0 0 0 0 0 0 0 0 0
2 119.04 103.1 117.33 111.10 107.47 103.86 0 1 0 0 0 0 0 0 0 0 0
3 123.68 100.0 119.04 117.33 111.10 107.47 0 0 1 0 0 0 0 0 0 0 0
4 125.90 107.2 123.68 119.04 117.33 111.10 0 0 0 1 0 0 0 0 0 0 0
5 124.54 107.0 125.90 123.68 119.04 117.33 0 0 0 0 1 0 0 0 0 0 0
6 119.39 119.0 124.54 125.90 123.68 119.04 0 0 0 0 0 1 0 0 0 0 0
7 118.80 110.4 119.39 124.54 125.90 123.68 0 0 0 0 0 0 1 0 0 0 0
8 114.81 101.7 118.80 119.39 124.54 125.90 0 0 0 0 0 0 0 1 0 0 0
9 117.90 102.4 114.81 118.80 119.39 124.54 0 0 0 0 0 0 0 0 1 0 0
10 120.53 98.8 117.90 114.81 118.80 119.39 0 0 0 0 0 0 0 0 0 1 0
11 125.15 105.6 120.53 117.90 114.81 118.80 0 0 0 0 0 0 0 0 0 0 1
12 126.49 104.4 125.15 120.53 117.90 114.81 0 0 0 0 0 0 0 0 0 0 0
13 131.85 106.3 126.49 125.15 120.53 117.90 1 0 0 0 0 0 0 0 0 0 0
14 127.40 107.2 131.85 126.49 125.15 120.53 0 1 0 0 0 0 0 0 0 0 0
15 131.08 108.5 127.40 131.85 126.49 125.15 0 0 1 0 0 0 0 0 0 0 0
16 122.37 106.9 131.08 127.40 131.85 126.49 0 0 0 1 0 0 0 0 0 0 0
17 124.34 114.2 122.37 131.08 127.40 131.85 0 0 0 0 1 0 0 0 0 0 0
18 119.61 125.9 124.34 122.37 131.08 127.40 0 0 0 0 0 1 0 0 0 0 0
19 119.97 110.6 119.61 124.34 122.37 131.08 0 0 0 0 0 0 1 0 0 0 0
20 116.46 110.5 119.97 119.61 124.34 122.37 0 0 0 0 0 0 0 1 0 0 0
21 117.03 106.7 116.46 119.97 119.61 124.34 0 0 0 0 0 0 0 0 1 0 0
22 120.96 104.7 117.03 116.46 119.97 119.61 0 0 0 0 0 0 0 0 0 1 0
23 124.71 107.4 120.96 117.03 116.46 119.97 0 0 0 0 0 0 0 0 0 0 1
24 127.08 109.8 124.71 120.96 117.03 116.46 0 0 0 0 0 0 0 0 0 0 0
25 131.91 103.4 127.08 124.71 120.96 117.03 1 0 0 0 0 0 0 0 0 0 0
26 137.69 114.8 131.91 127.08 124.71 120.96 0 1 0 0 0 0 0 0 0 0 0
27 142.46 114.3 137.69 131.91 127.08 124.71 0 0 1 0 0 0 0 0 0 0 0
28 144.32 109.6 142.46 137.69 131.91 127.08 0 0 0 1 0 0 0 0 0 0 0
29 138.06 118.3 144.32 142.46 137.69 131.91 0 0 0 0 1 0 0 0 0 0 0
30 124.45 127.3 138.06 144.32 142.46 137.69 0 0 0 0 0 1 0 0 0 0 0
31 126.71 112.3 124.45 138.06 144.32 142.46 0 0 0 0 0 0 1 0 0 0 0
32 121.83 114.9 126.71 124.45 138.06 144.32 0 0 0 0 0 0 0 1 0 0 0
33 122.51 108.2 121.83 126.71 124.45 138.06 0 0 0 0 0 0 0 0 1 0 0
34 125.48 105.4 122.51 121.83 126.71 124.45 0 0 0 0 0 0 0 0 0 1 0
35 127.77 122.1 125.48 122.51 121.83 126.71 0 0 0 0 0 0 0 0 0 0 1
36 128.03 113.5 127.77 125.48 122.51 121.83 0 0 0 0 0 0 0 0 0 0 0
37 132.84 110.0 128.03 127.77 125.48 122.51 1 0 0 0 0 0 0 0 0 0 0
38 133.41 125.3 132.84 128.03 127.77 125.48 0 1 0 0 0 0 0 0 0 0 0
39 139.99 114.3 133.41 132.84 128.03 127.77 0 0 1 0 0 0 0 0 0 0 0
40 138.53 115.6 139.99 133.41 132.84 128.03 0 0 0 1 0 0 0 0 0 0 0
41 136.12 127.1 138.53 139.99 133.41 132.84 0 0 0 0 1 0 0 0 0 0 0
42 124.75 123.0 136.12 138.53 139.99 133.41 0 0 0 0 0 1 0 0 0 0 0
43 122.88 122.2 124.75 136.12 138.53 139.99 0 0 0 0 0 0 1 0 0 0 0
44 121.46 126.4 122.88 124.75 136.12 138.53 0 0 0 0 0 0 0 1 0 0 0
45 118.40 112.7 121.46 122.88 124.75 136.12 0 0 0 0 0 0 0 0 1 0 0
46 122.45 105.8 118.40 121.46 122.88 124.75 0 0 0 0 0 0 0 0 0 1 0
47 128.94 120.9 122.45 118.40 121.46 122.88 0 0 0 0 0 0 0 0 0 0 1
48 133.25 116.3 128.94 122.45 118.40 121.46 0 0 0 0 0 0 0 0 0 0 0
49 137.94 115.7 133.25 128.94 122.45 118.40 1 0 0 0 0 0 0 0 0 0 0
50 140.04 127.9 137.94 133.25 128.94 122.45 0 1 0 0 0 0 0 0 0 0 0
51 130.74 108.3 140.04 137.94 133.25 128.94 0 0 1 0 0 0 0 0 0 0 0
52 131.55 121.1 130.74 140.04 137.94 133.25 0 0 0 1 0 0 0 0 0 0 0
53 129.47 128.6 131.55 130.74 140.04 137.94 0 0 0 0 1 0 0 0 0 0 0
54 125.45 123.1 129.47 131.55 130.74 140.04 0 0 0 0 0 1 0 0 0 0 0
55 127.87 127.7 125.45 129.47 131.55 130.74 0 0 0 0 0 0 1 0 0 0 0
56 124.68 126.6 127.87 125.45 129.47 131.55 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) X Y1 Y2 Y3 Y4
10.85622 0.26490 0.74118 0.16987 -0.36224 0.15214
M1 M2 M3 M4 M5 M6
3.65823 -0.44046 1.91916 -0.10881 -3.88665 -10.58798
M7 M8 M9 M10 M11 t
-2.76413 -5.59499 -3.68967 2.44621 0.21061 -0.03844
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-7.3372 -1.1322 0.3509 0.8782 5.2808
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.85622 17.66767 0.614 0.542568
X 0.26490 0.11356 2.333 0.025061 *
Y1 0.74118 0.15045 4.927 1.67e-05 ***
Y2 0.16987 0.18357 0.925 0.360617
Y3 -0.36224 0.18667 -1.941 0.059764 .
Y4 0.15214 0.15063 1.010 0.318898
M1 3.65823 2.01009 1.820 0.076653 .
M2 -0.44046 2.12444 -0.207 0.836858
M3 1.91916 2.10270 0.913 0.367148
M4 -0.10881 2.22602 -0.049 0.961272
M5 -3.88665 2.48006 -1.567 0.125368
M6 -10.58798 2.74286 -3.860 0.000427 ***
M7 -2.76413 2.77127 -0.997 0.324867
M8 -5.59499 2.63421 -2.124 0.040240 *
M9 -3.68967 2.69117 -1.371 0.178410
M10 2.44621 2.51892 0.971 0.337624
M11 0.21061 2.20913 0.095 0.924550
t -0.03844 0.05534 -0.695 0.491555
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.898 on 38 degrees of freedom
Multiple R-squared: 0.888, Adjusted R-squared: 0.8379
F-statistic: 17.72 on 17 and 38 DF, p-value: 4.547e-13
> 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.4589469 0.9178939 0.5410531
[2,] 0.3341104 0.6682207 0.6658896
[3,] 0.2743819 0.5487639 0.7256181
[4,] 0.1950048 0.3900097 0.8049952
[5,] 0.3330293 0.6660585 0.6669707
[6,] 0.5292753 0.9414495 0.4707247
[7,] 0.4049705 0.8099409 0.5950295
[8,] 0.3705000 0.7409999 0.6295000
[9,] 0.3662408 0.7324816 0.6337592
[10,] 0.4567319 0.9134639 0.5432681
[11,] 0.6835579 0.6328842 0.3164421
[12,] 0.6403572 0.7192857 0.3596428
[13,] 0.6701343 0.6597315 0.3298657
[14,] 0.5328653 0.9342694 0.4671347
[15,] 0.6120267 0.7759466 0.3879733
> postscript(file="/var/www/html/rcomp/tmp/17yid1258763723.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/2frl71258763723.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/38mn71258763723.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/4rayv1258763723.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/5c4gx1258763723.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
-3.16323320 -1.31506301 0.26496560 0.61909419 0.36637884 0.82895715
7 8 9 10 11 12
-1.12198627 0.54362267 2.98019259 -0.57632353 0.68663263 0.44889680
13 14 15 16 17 18
0.39042702 -3.08774375 0.09700270 -6.35662687 0.89904553 1.83902818
19 20 21 22 23 24
-2.07735029 -0.11619775 0.12079238 -0.49308557 0.47982625 -0.24341594
25 26 27 28 29 30
1.60541540 5.28077443 3.04556307 5.08877768 -0.48944358 -4.57134390
31 32 33 34 35 36
4.97559612 0.36238674 0.20558631 1.03403956 -3.25406958 -1.67999283
37 38 39 40 41 42
0.82805023 -1.74926280 3.92965518 0.92073814 -1.28018429 -0.49324546
43 44 45 46 47 48
-2.63007338 0.37317904 -3.30657129 0.03536954 2.08761070 1.47451198
49 50 51 52 53 54
0.33934055 0.87129513 -7.33718655 -0.27198314 0.50420350 2.39660403
55 56
0.85381381 -1.16299070
> postscript(file="/var/www/html/rcomp/tmp/6fhyz1258763723.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 -3.16323320 NA
1 -1.31506301 -3.16323320
2 0.26496560 -1.31506301
3 0.61909419 0.26496560
4 0.36637884 0.61909419
5 0.82895715 0.36637884
6 -1.12198627 0.82895715
7 0.54362267 -1.12198627
8 2.98019259 0.54362267
9 -0.57632353 2.98019259
10 0.68663263 -0.57632353
11 0.44889680 0.68663263
12 0.39042702 0.44889680
13 -3.08774375 0.39042702
14 0.09700270 -3.08774375
15 -6.35662687 0.09700270
16 0.89904553 -6.35662687
17 1.83902818 0.89904553
18 -2.07735029 1.83902818
19 -0.11619775 -2.07735029
20 0.12079238 -0.11619775
21 -0.49308557 0.12079238
22 0.47982625 -0.49308557
23 -0.24341594 0.47982625
24 1.60541540 -0.24341594
25 5.28077443 1.60541540
26 3.04556307 5.28077443
27 5.08877768 3.04556307
28 -0.48944358 5.08877768
29 -4.57134390 -0.48944358
30 4.97559612 -4.57134390
31 0.36238674 4.97559612
32 0.20558631 0.36238674
33 1.03403956 0.20558631
34 -3.25406958 1.03403956
35 -1.67999283 -3.25406958
36 0.82805023 -1.67999283
37 -1.74926280 0.82805023
38 3.92965518 -1.74926280
39 0.92073814 3.92965518
40 -1.28018429 0.92073814
41 -0.49324546 -1.28018429
42 -2.63007338 -0.49324546
43 0.37317904 -2.63007338
44 -3.30657129 0.37317904
45 0.03536954 -3.30657129
46 2.08761070 0.03536954
47 1.47451198 2.08761070
48 0.33934055 1.47451198
49 0.87129513 0.33934055
50 -7.33718655 0.87129513
51 -0.27198314 -7.33718655
52 0.50420350 -0.27198314
53 2.39660403 0.50420350
54 0.85381381 2.39660403
55 -1.16299070 0.85381381
56 NA -1.16299070
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.31506301 -3.16323320
[2,] 0.26496560 -1.31506301
[3,] 0.61909419 0.26496560
[4,] 0.36637884 0.61909419
[5,] 0.82895715 0.36637884
[6,] -1.12198627 0.82895715
[7,] 0.54362267 -1.12198627
[8,] 2.98019259 0.54362267
[9,] -0.57632353 2.98019259
[10,] 0.68663263 -0.57632353
[11,] 0.44889680 0.68663263
[12,] 0.39042702 0.44889680
[13,] -3.08774375 0.39042702
[14,] 0.09700270 -3.08774375
[15,] -6.35662687 0.09700270
[16,] 0.89904553 -6.35662687
[17,] 1.83902818 0.89904553
[18,] -2.07735029 1.83902818
[19,] -0.11619775 -2.07735029
[20,] 0.12079238 -0.11619775
[21,] -0.49308557 0.12079238
[22,] 0.47982625 -0.49308557
[23,] -0.24341594 0.47982625
[24,] 1.60541540 -0.24341594
[25,] 5.28077443 1.60541540
[26,] 3.04556307 5.28077443
[27,] 5.08877768 3.04556307
[28,] -0.48944358 5.08877768
[29,] -4.57134390 -0.48944358
[30,] 4.97559612 -4.57134390
[31,] 0.36238674 4.97559612
[32,] 0.20558631 0.36238674
[33,] 1.03403956 0.20558631
[34,] -3.25406958 1.03403956
[35,] -1.67999283 -3.25406958
[36,] 0.82805023 -1.67999283
[37,] -1.74926280 0.82805023
[38,] 3.92965518 -1.74926280
[39,] 0.92073814 3.92965518
[40,] -1.28018429 0.92073814
[41,] -0.49324546 -1.28018429
[42,] -2.63007338 -0.49324546
[43,] 0.37317904 -2.63007338
[44,] -3.30657129 0.37317904
[45,] 0.03536954 -3.30657129
[46,] 2.08761070 0.03536954
[47,] 1.47451198 2.08761070
[48,] 0.33934055 1.47451198
[49,] 0.87129513 0.33934055
[50,] -7.33718655 0.87129513
[51,] -0.27198314 -7.33718655
[52,] 0.50420350 -0.27198314
[53,] 2.39660403 0.50420350
[54,] 0.85381381 2.39660403
[55,] -1.16299070 0.85381381
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.31506301 -3.16323320
2 0.26496560 -1.31506301
3 0.61909419 0.26496560
4 0.36637884 0.61909419
5 0.82895715 0.36637884
6 -1.12198627 0.82895715
7 0.54362267 -1.12198627
8 2.98019259 0.54362267
9 -0.57632353 2.98019259
10 0.68663263 -0.57632353
11 0.44889680 0.68663263
12 0.39042702 0.44889680
13 -3.08774375 0.39042702
14 0.09700270 -3.08774375
15 -6.35662687 0.09700270
16 0.89904553 -6.35662687
17 1.83902818 0.89904553
18 -2.07735029 1.83902818
19 -0.11619775 -2.07735029
20 0.12079238 -0.11619775
21 -0.49308557 0.12079238
22 0.47982625 -0.49308557
23 -0.24341594 0.47982625
24 1.60541540 -0.24341594
25 5.28077443 1.60541540
26 3.04556307 5.28077443
27 5.08877768 3.04556307
28 -0.48944358 5.08877768
29 -4.57134390 -0.48944358
30 4.97559612 -4.57134390
31 0.36238674 4.97559612
32 0.20558631 0.36238674
33 1.03403956 0.20558631
34 -3.25406958 1.03403956
35 -1.67999283 -3.25406958
36 0.82805023 -1.67999283
37 -1.74926280 0.82805023
38 3.92965518 -1.74926280
39 0.92073814 3.92965518
40 -1.28018429 0.92073814
41 -0.49324546 -1.28018429
42 -2.63007338 -0.49324546
43 0.37317904 -2.63007338
44 -3.30657129 0.37317904
45 0.03536954 -3.30657129
46 2.08761070 0.03536954
47 1.47451198 2.08761070
48 0.33934055 1.47451198
49 0.87129513 0.33934055
50 -7.33718655 0.87129513
51 -0.27198314 -7.33718655
52 0.50420350 -0.27198314
53 2.39660403 0.50420350
54 0.85381381 2.39660403
55 -1.16299070 0.85381381
> 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/7zgs91258763723.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/87tzm1258763723.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/9ifog1258763723.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/10ggv11258763723.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/1190621258763723.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/12p5951258763723.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/13fzz91258763723.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/142pl91258763723.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/1599l81258763723.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/16qig51258763723.tab")
+ }
>
> system("convert tmp/17yid1258763723.ps tmp/17yid1258763723.png")
> system("convert tmp/2frl71258763723.ps tmp/2frl71258763723.png")
> system("convert tmp/38mn71258763723.ps tmp/38mn71258763723.png")
> system("convert tmp/4rayv1258763723.ps tmp/4rayv1258763723.png")
> system("convert tmp/5c4gx1258763723.ps tmp/5c4gx1258763723.png")
> system("convert tmp/6fhyz1258763723.ps tmp/6fhyz1258763723.png")
> system("convert tmp/7zgs91258763723.ps tmp/7zgs91258763723.png")
> system("convert tmp/87tzm1258763723.ps tmp/87tzm1258763723.png")
> system("convert tmp/9ifog1258763723.ps tmp/9ifog1258763723.png")
> system("convert tmp/10ggv11258763723.ps tmp/10ggv11258763723.png")
>
>
> proc.time()
user system elapsed
2.356 1.595 2.784