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(114.91
+ ,93.13
+ ,107.18
+ ,96.31
+ ,96.21
+ ,100.00
+ ,92.56
+ ,93.88
+ ,114.91
+ ,107.18
+ ,96.31
+ ,96.21
+ ,115.00
+ ,92.55
+ ,92.56
+ ,114.91
+ ,107.18
+ ,96.31
+ ,107.12
+ ,94.43
+ ,115.00
+ ,92.56
+ ,114.91
+ ,107.18
+ ,117.78
+ ,96.25
+ ,107.12
+ ,115.00
+ ,92.56
+ ,114.91
+ ,107.37
+ ,100.44
+ ,117.78
+ ,107.12
+ ,115.00
+ ,92.56
+ ,106.30
+ ,101.50
+ ,107.37
+ ,117.78
+ ,107.12
+ ,115.00
+ ,114.51
+ ,99.40
+ ,106.30
+ ,107.37
+ ,117.78
+ ,107.12
+ ,98.00
+ ,99.69
+ ,114.51
+ ,106.30
+ ,107.37
+ ,117.78
+ ,103.06
+ ,101.69
+ ,98.00
+ ,114.51
+ ,106.30
+ ,107.37
+ ,100.29
+ ,103.67
+ ,103.06
+ ,98.00
+ ,114.51
+ ,106.30
+ ,104.61
+ ,103.05
+ ,100.29
+ ,103.06
+ ,98.00
+ ,114.51
+ ,111.15
+ ,100.95
+ ,104.61
+ ,100.29
+ ,103.06
+ ,98.00
+ ,104.99
+ ,102.35
+ ,111.15
+ ,104.61
+ ,100.29
+ ,103.06
+ ,109.93
+ ,101.65
+ ,104.99
+ ,111.15
+ ,104.61
+ ,100.29
+ ,111.54
+ ,99.57
+ ,109.93
+ ,104.99
+ ,111.15
+ ,104.61
+ ,132.50
+ ,95.68
+ ,111.54
+ ,109.93
+ ,104.99
+ ,111.15
+ ,100.34
+ ,96.58
+ ,132.50
+ ,111.54
+ ,109.93
+ ,104.99
+ ,123.10
+ ,96.33
+ ,100.34
+ ,132.50
+ ,111.54
+ ,109.93
+ ,114.24
+ ,95.37
+ ,123.10
+ ,100.34
+ ,132.50
+ ,111.54
+ ,104.57
+ ,96.00
+ ,114.24
+ ,123.10
+ ,100.34
+ ,132.50
+ ,109.08
+ ,96.88
+ ,104.57
+ ,114.24
+ ,123.10
+ ,100.34
+ ,106.98
+ ,94.85
+ ,109.08
+ ,104.57
+ ,114.24
+ ,123.10
+ ,133.68
+ ,92.47
+ ,106.98
+ ,109.08
+ ,104.57
+ ,114.24
+ ,124.85
+ ,93.99
+ ,133.68
+ ,106.98
+ ,109.08
+ ,104.57
+ ,122.51
+ ,93.45
+ ,124.85
+ ,133.68
+ ,106.98
+ ,109.08
+ ,116.80
+ ,92.27
+ ,122.51
+ ,124.85
+ ,133.68
+ ,106.98
+ ,116.01
+ ,90.40
+ ,116.80
+ ,122.51
+ ,124.85
+ ,133.68
+ ,129.76
+ ,90.43
+ ,116.01
+ ,116.80
+ ,122.51
+ ,124.85
+ ,125.20
+ ,91.05
+ ,129.76
+ ,116.01
+ ,116.80
+ ,122.51
+ ,143.79
+ ,89.08
+ ,125.20
+ ,129.76
+ ,116.01
+ ,116.80
+ ,127.95
+ ,89.69
+ ,143.79
+ ,125.20
+ ,129.76
+ ,116.01
+ ,130.30
+ ,87.92
+ ,127.95
+ ,143.79
+ ,125.20
+ ,129.76
+ ,108.44
+ ,85.88
+ ,130.30
+ ,127.95
+ ,143.79
+ ,125.20
+ ,129.37
+ ,83.21
+ ,108.44
+ ,130.30
+ ,127.95
+ ,143.79
+ ,143.68
+ ,83.86
+ ,129.37
+ ,108.44
+ ,130.30
+ ,127.95
+ ,131.88
+ ,83.01
+ ,143.68
+ ,129.37
+ ,108.44
+ ,130.30
+ ,117.62
+ ,82.85
+ ,131.88
+ ,143.68
+ ,129.37
+ ,108.44
+ ,118.96
+ ,78.69
+ ,117.62
+ ,131.88
+ ,143.68
+ ,129.37
+ ,104.82
+ ,77.57
+ ,118.96
+ ,117.62
+ ,131.88
+ ,143.68
+ ,134.62
+ ,78.54
+ ,104.82
+ ,118.96
+ ,117.62
+ ,131.88
+ ,140.40
+ ,78.56
+ ,134.62
+ ,104.82
+ ,118.96
+ ,117.62
+ ,143.80
+ ,77.48
+ ,140.40
+ ,134.62
+ ,104.82
+ ,118.96
+ ,153.43
+ ,81.59
+ ,143.80
+ ,140.40
+ ,134.62
+ ,104.82
+ ,153.29
+ ,85.02
+ ,153.43
+ ,143.80
+ ,140.40
+ ,134.62
+ ,127.31
+ ,91.71
+ ,153.29
+ ,153.43
+ ,143.80
+ ,140.40
+ ,153.55
+ ,95.96
+ ,127.31
+ ,153.29
+ ,153.43
+ ,143.80
+ ,136.93
+ ,90.85
+ ,153.55
+ ,127.31
+ ,153.29
+ ,153.43
+ ,131.77
+ ,92.29
+ ,136.93
+ ,153.55
+ ,127.31
+ ,153.29
+ ,144.34
+ ,95.57
+ ,131.77
+ ,136.93
+ ,153.55
+ ,127.31
+ ,107.42
+ ,93.62
+ ,144.34
+ ,131.77
+ ,136.93
+ ,153.55
+ ,113.62
+ ,92.63
+ ,107.42
+ ,144.34
+ ,131.77
+ ,136.93
+ ,124.22
+ ,89.51
+ ,113.62
+ ,107.42
+ ,144.34
+ ,131.77
+ ,102.06
+ ,87.17
+ ,124.22
+ ,113.62
+ ,107.42
+ ,144.34
+ ,96.37
+ ,86.73
+ ,102.06
+ ,124.22
+ ,113.62
+ ,107.42
+ ,111.68
+ ,85.63
+ ,96.37
+ ,102.06
+ ,124.22
+ ,113.62)
+ ,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 114.91 93.13 107.18 96.31 96.21 100.00 1 0 0 0 0 0 0 0 0 0 0
2 92.56 93.88 114.91 107.18 96.31 96.21 0 1 0 0 0 0 0 0 0 0 0
3 115.00 92.55 92.56 114.91 107.18 96.31 0 0 1 0 0 0 0 0 0 0 0
4 107.12 94.43 115.00 92.56 114.91 107.18 0 0 0 1 0 0 0 0 0 0 0
5 117.78 96.25 107.12 115.00 92.56 114.91 0 0 0 0 1 0 0 0 0 0 0
6 107.37 100.44 117.78 107.12 115.00 92.56 0 0 0 0 0 1 0 0 0 0 0
7 106.30 101.50 107.37 117.78 107.12 115.00 0 0 0 0 0 0 1 0 0 0 0
8 114.51 99.40 106.30 107.37 117.78 107.12 0 0 0 0 0 0 0 1 0 0 0
9 98.00 99.69 114.51 106.30 107.37 117.78 0 0 0 0 0 0 0 0 1 0 0
10 103.06 101.69 98.00 114.51 106.30 107.37 0 0 0 0 0 0 0 0 0 1 0
11 100.29 103.67 103.06 98.00 114.51 106.30 0 0 0 0 0 0 0 0 0 0 1
12 104.61 103.05 100.29 103.06 98.00 114.51 0 0 0 0 0 0 0 0 0 0 0
13 111.15 100.95 104.61 100.29 103.06 98.00 1 0 0 0 0 0 0 0 0 0 0
14 104.99 102.35 111.15 104.61 100.29 103.06 0 1 0 0 0 0 0 0 0 0 0
15 109.93 101.65 104.99 111.15 104.61 100.29 0 0 1 0 0 0 0 0 0 0 0
16 111.54 99.57 109.93 104.99 111.15 104.61 0 0 0 1 0 0 0 0 0 0 0
17 132.50 95.68 111.54 109.93 104.99 111.15 0 0 0 0 1 0 0 0 0 0 0
18 100.34 96.58 132.50 111.54 109.93 104.99 0 0 0 0 0 1 0 0 0 0 0
19 123.10 96.33 100.34 132.50 111.54 109.93 0 0 0 0 0 0 1 0 0 0 0
20 114.24 95.37 123.10 100.34 132.50 111.54 0 0 0 0 0 0 0 1 0 0 0
21 104.57 96.00 114.24 123.10 100.34 132.50 0 0 0 0 0 0 0 0 1 0 0
22 109.08 96.88 104.57 114.24 123.10 100.34 0 0 0 0 0 0 0 0 0 1 0
23 106.98 94.85 109.08 104.57 114.24 123.10 0 0 0 0 0 0 0 0 0 0 1
24 133.68 92.47 106.98 109.08 104.57 114.24 0 0 0 0 0 0 0 0 0 0 0
25 124.85 93.99 133.68 106.98 109.08 104.57 1 0 0 0 0 0 0 0 0 0 0
26 122.51 93.45 124.85 133.68 106.98 109.08 0 1 0 0 0 0 0 0 0 0 0
27 116.80 92.27 122.51 124.85 133.68 106.98 0 0 1 0 0 0 0 0 0 0 0
28 116.01 90.40 116.80 122.51 124.85 133.68 0 0 0 1 0 0 0 0 0 0 0
29 129.76 90.43 116.01 116.80 122.51 124.85 0 0 0 0 1 0 0 0 0 0 0
30 125.20 91.05 129.76 116.01 116.80 122.51 0 0 0 0 0 1 0 0 0 0 0
31 143.79 89.08 125.20 129.76 116.01 116.80 0 0 0 0 0 0 1 0 0 0 0
32 127.95 89.69 143.79 125.20 129.76 116.01 0 0 0 0 0 0 0 1 0 0 0
33 130.30 87.92 127.95 143.79 125.20 129.76 0 0 0 0 0 0 0 0 1 0 0
34 108.44 85.88 130.30 127.95 143.79 125.20 0 0 0 0 0 0 0 0 0 1 0
35 129.37 83.21 108.44 130.30 127.95 143.79 0 0 0 0 0 0 0 0 0 0 1
36 143.68 83.86 129.37 108.44 130.30 127.95 0 0 0 0 0 0 0 0 0 0 0
37 131.88 83.01 143.68 129.37 108.44 130.30 1 0 0 0 0 0 0 0 0 0 0
38 117.62 82.85 131.88 143.68 129.37 108.44 0 1 0 0 0 0 0 0 0 0 0
39 118.96 78.69 117.62 131.88 143.68 129.37 0 0 1 0 0 0 0 0 0 0 0
40 104.82 77.57 118.96 117.62 131.88 143.68 0 0 0 1 0 0 0 0 0 0 0
41 134.62 78.54 104.82 118.96 117.62 131.88 0 0 0 0 1 0 0 0 0 0 0
42 140.40 78.56 134.62 104.82 118.96 117.62 0 0 0 0 0 1 0 0 0 0 0
43 143.80 77.48 140.40 134.62 104.82 118.96 0 0 0 0 0 0 1 0 0 0 0
44 153.43 81.59 143.80 140.40 134.62 104.82 0 0 0 0 0 0 0 1 0 0 0
45 153.29 85.02 153.43 143.80 140.40 134.62 0 0 0 0 0 0 0 0 1 0 0
46 127.31 91.71 153.29 153.43 143.80 140.40 0 0 0 0 0 0 0 0 0 1 0
47 153.55 95.96 127.31 153.29 153.43 143.80 0 0 0 0 0 0 0 0 0 0 1
48 136.93 90.85 153.55 127.31 153.29 153.43 0 0 0 0 0 0 0 0 0 0 0
49 131.77 92.29 136.93 153.55 127.31 153.29 1 0 0 0 0 0 0 0 0 0 0
50 144.34 95.57 131.77 136.93 153.55 127.31 0 1 0 0 0 0 0 0 0 0 0
51 107.42 93.62 144.34 131.77 136.93 153.55 0 0 1 0 0 0 0 0 0 0 0
52 113.62 92.63 107.42 144.34 131.77 136.93 0 0 0 1 0 0 0 0 0 0 0
53 124.22 89.51 113.62 107.42 144.34 131.77 0 0 0 0 1 0 0 0 0 0 0
54 102.06 87.17 124.22 113.62 107.42 144.34 0 0 0 0 0 1 0 0 0 0 0
55 96.37 86.73 102.06 124.22 113.62 107.42 0 0 0 0 0 0 1 0 0 0 0
56 111.68 85.63 96.37 102.06 124.22 113.62 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
106.85013 -0.53880 0.29182 0.50073 0.26069 -0.38352
M1 M2 M3 M4 M5 M6
-11.14063 -25.80524 -25.28818 -20.96957 -1.12377 -18.67289
M7 M8 M9 M10 M11 t
-16.46955 -16.13661 -17.41927 -30.11444 -8.84376 -0.06191
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-24.2806 -5.4534 -0.5872 6.8545 19.6634
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 106.85013 35.62114 3.000 0.004751 **
X -0.53880 0.28333 -1.902 0.064813 .
Y1 0.29182 0.14879 1.961 0.057200 .
Y2 0.50073 0.15754 3.179 0.002940 **
Y3 0.26069 0.16921 1.541 0.131697
Y4 -0.38352 0.17167 -2.234 0.031446 *
M1 -11.14063 7.70767 -1.445 0.156544
M2 -25.80524 8.27707 -3.118 0.003467 **
M3 -25.28818 7.81694 -3.235 0.002520 **
M4 -20.96957 7.45236 -2.814 0.007711 **
M5 -1.12377 7.44915 -0.151 0.880885
M6 -18.67289 7.63634 -2.445 0.019220 *
M7 -16.46955 8.44274 -1.951 0.058492 .
M8 -16.13661 7.91096 -2.040 0.048369 *
M9 -17.41927 8.06746 -2.159 0.037212 *
M10 -30.11444 8.31214 -3.623 0.000849 ***
M11 -8.84376 8.07702 -1.095 0.280440
t -0.06191 0.18774 -0.330 0.743390
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 10.69 on 38 degrees of freedom
Multiple R-squared: 0.6758, Adjusted R-squared: 0.5308
F-statistic: 4.659 on 17 and 38 DF, p-value: 3.973e-05
> 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.024540085 0.049080169 0.9754599
[2,] 0.005407070 0.010814139 0.9945929
[3,] 0.002481350 0.004962699 0.9975187
[4,] 0.012053622 0.024107244 0.9879464
[5,] 0.058609511 0.117219022 0.9413905
[6,] 0.033221549 0.066443097 0.9667785
[7,] 0.023335974 0.046671948 0.9766640
[8,] 0.011096898 0.022193796 0.9889031
[9,] 0.004863417 0.009726833 0.9951366
[10,] 0.004169544 0.008339087 0.9958305
[11,] 0.005527719 0.011055438 0.9944723
[12,] 0.002875496 0.005750992 0.9971245
[13,] 0.002292753 0.004585505 0.9977072
[14,] 0.011103292 0.022206584 0.9888967
[15,] 0.011099861 0.022199722 0.9889001
> postscript(file="/var/www/html/rcomp/tmp/1ewor1258748206.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/228xn1258748206.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/3xq0c1258748206.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/4j1o61258748206.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/5n0qq1258748206.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.2098459 -13.1878191 7.9365614 3.6095168 -4.6796905 -8.8075538
7 8 9 10 11 12
-3.0874650 3.4438228 -6.6233180 9.2647406 -9.4073389 -8.4759893
13 14 15 16 17 18
0.6104829 8.5223942 8.9643852 6.7918189 7.0426181 -17.5943419
19 20 21 22 23 24
3.2538967 -1.7791473 -2.1540282 4.5783266 -5.2596579 8.8535270
25 26 27 28 29 30
0.4207706 4.0006827 -5.4616657 3.8638694 -1.8406139 8.5186599
31 32 33 34 35 36
16.3674834 -6.4438268 -1.9270214 -11.4783014 3.2656051 7.2946760
37 38 39 40 41 42
-1.8170550 -18.9986617 -5.9886701 -9.6751942 3.5107166 19.4784309
43 44 45 46 47 48
7.7466610 2.2422825 10.7043675 -2.3647657 11.4013916 -7.6722137
49 50 51 52 53 54
-2.4240444 19.6634039 -5.4506108 -4.5900109 -4.0330303 -1.5951950
55 56
-24.2805761 2.5368688
> postscript(file="/var/www/html/rcomp/tmp/6oucz1258748206.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.2098459 NA
1 -13.1878191 3.2098459
2 7.9365614 -13.1878191
3 3.6095168 7.9365614
4 -4.6796905 3.6095168
5 -8.8075538 -4.6796905
6 -3.0874650 -8.8075538
7 3.4438228 -3.0874650
8 -6.6233180 3.4438228
9 9.2647406 -6.6233180
10 -9.4073389 9.2647406
11 -8.4759893 -9.4073389
12 0.6104829 -8.4759893
13 8.5223942 0.6104829
14 8.9643852 8.5223942
15 6.7918189 8.9643852
16 7.0426181 6.7918189
17 -17.5943419 7.0426181
18 3.2538967 -17.5943419
19 -1.7791473 3.2538967
20 -2.1540282 -1.7791473
21 4.5783266 -2.1540282
22 -5.2596579 4.5783266
23 8.8535270 -5.2596579
24 0.4207706 8.8535270
25 4.0006827 0.4207706
26 -5.4616657 4.0006827
27 3.8638694 -5.4616657
28 -1.8406139 3.8638694
29 8.5186599 -1.8406139
30 16.3674834 8.5186599
31 -6.4438268 16.3674834
32 -1.9270214 -6.4438268
33 -11.4783014 -1.9270214
34 3.2656051 -11.4783014
35 7.2946760 3.2656051
36 -1.8170550 7.2946760
37 -18.9986617 -1.8170550
38 -5.9886701 -18.9986617
39 -9.6751942 -5.9886701
40 3.5107166 -9.6751942
41 19.4784309 3.5107166
42 7.7466610 19.4784309
43 2.2422825 7.7466610
44 10.7043675 2.2422825
45 -2.3647657 10.7043675
46 11.4013916 -2.3647657
47 -7.6722137 11.4013916
48 -2.4240444 -7.6722137
49 19.6634039 -2.4240444
50 -5.4506108 19.6634039
51 -4.5900109 -5.4506108
52 -4.0330303 -4.5900109
53 -1.5951950 -4.0330303
54 -24.2805761 -1.5951950
55 2.5368688 -24.2805761
56 NA 2.5368688
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -13.1878191 3.2098459
[2,] 7.9365614 -13.1878191
[3,] 3.6095168 7.9365614
[4,] -4.6796905 3.6095168
[5,] -8.8075538 -4.6796905
[6,] -3.0874650 -8.8075538
[7,] 3.4438228 -3.0874650
[8,] -6.6233180 3.4438228
[9,] 9.2647406 -6.6233180
[10,] -9.4073389 9.2647406
[11,] -8.4759893 -9.4073389
[12,] 0.6104829 -8.4759893
[13,] 8.5223942 0.6104829
[14,] 8.9643852 8.5223942
[15,] 6.7918189 8.9643852
[16,] 7.0426181 6.7918189
[17,] -17.5943419 7.0426181
[18,] 3.2538967 -17.5943419
[19,] -1.7791473 3.2538967
[20,] -2.1540282 -1.7791473
[21,] 4.5783266 -2.1540282
[22,] -5.2596579 4.5783266
[23,] 8.8535270 -5.2596579
[24,] 0.4207706 8.8535270
[25,] 4.0006827 0.4207706
[26,] -5.4616657 4.0006827
[27,] 3.8638694 -5.4616657
[28,] -1.8406139 3.8638694
[29,] 8.5186599 -1.8406139
[30,] 16.3674834 8.5186599
[31,] -6.4438268 16.3674834
[32,] -1.9270214 -6.4438268
[33,] -11.4783014 -1.9270214
[34,] 3.2656051 -11.4783014
[35,] 7.2946760 3.2656051
[36,] -1.8170550 7.2946760
[37,] -18.9986617 -1.8170550
[38,] -5.9886701 -18.9986617
[39,] -9.6751942 -5.9886701
[40,] 3.5107166 -9.6751942
[41,] 19.4784309 3.5107166
[42,] 7.7466610 19.4784309
[43,] 2.2422825 7.7466610
[44,] 10.7043675 2.2422825
[45,] -2.3647657 10.7043675
[46,] 11.4013916 -2.3647657
[47,] -7.6722137 11.4013916
[48,] -2.4240444 -7.6722137
[49,] 19.6634039 -2.4240444
[50,] -5.4506108 19.6634039
[51,] -4.5900109 -5.4506108
[52,] -4.0330303 -4.5900109
[53,] -1.5951950 -4.0330303
[54,] -24.2805761 -1.5951950
[55,] 2.5368688 -24.2805761
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -13.1878191 3.2098459
2 7.9365614 -13.1878191
3 3.6095168 7.9365614
4 -4.6796905 3.6095168
5 -8.8075538 -4.6796905
6 -3.0874650 -8.8075538
7 3.4438228 -3.0874650
8 -6.6233180 3.4438228
9 9.2647406 -6.6233180
10 -9.4073389 9.2647406
11 -8.4759893 -9.4073389
12 0.6104829 -8.4759893
13 8.5223942 0.6104829
14 8.9643852 8.5223942
15 6.7918189 8.9643852
16 7.0426181 6.7918189
17 -17.5943419 7.0426181
18 3.2538967 -17.5943419
19 -1.7791473 3.2538967
20 -2.1540282 -1.7791473
21 4.5783266 -2.1540282
22 -5.2596579 4.5783266
23 8.8535270 -5.2596579
24 0.4207706 8.8535270
25 4.0006827 0.4207706
26 -5.4616657 4.0006827
27 3.8638694 -5.4616657
28 -1.8406139 3.8638694
29 8.5186599 -1.8406139
30 16.3674834 8.5186599
31 -6.4438268 16.3674834
32 -1.9270214 -6.4438268
33 -11.4783014 -1.9270214
34 3.2656051 -11.4783014
35 7.2946760 3.2656051
36 -1.8170550 7.2946760
37 -18.9986617 -1.8170550
38 -5.9886701 -18.9986617
39 -9.6751942 -5.9886701
40 3.5107166 -9.6751942
41 19.4784309 3.5107166
42 7.7466610 19.4784309
43 2.2422825 7.7466610
44 10.7043675 2.2422825
45 -2.3647657 10.7043675
46 11.4013916 -2.3647657
47 -7.6722137 11.4013916
48 -2.4240444 -7.6722137
49 19.6634039 -2.4240444
50 -5.4506108 19.6634039
51 -4.5900109 -5.4506108
52 -4.0330303 -4.5900109
53 -1.5951950 -4.0330303
54 -24.2805761 -1.5951950
55 2.5368688 -24.2805761
> 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/7jafk1258748207.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/81q8w1258748207.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/955vr1258748207.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/10s4rg1258748207.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/11cxqy1258748207.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/12827h1258748207.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/13lz6x1258748207.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/14zj2a1258748207.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/158d6o1258748207.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/16ngha1258748207.tab")
+ }
>
> system("convert tmp/1ewor1258748206.ps tmp/1ewor1258748206.png")
> system("convert tmp/228xn1258748206.ps tmp/228xn1258748206.png")
> system("convert tmp/3xq0c1258748206.ps tmp/3xq0c1258748206.png")
> system("convert tmp/4j1o61258748206.ps tmp/4j1o61258748206.png")
> system("convert tmp/5n0qq1258748206.ps tmp/5n0qq1258748206.png")
> system("convert tmp/6oucz1258748206.ps tmp/6oucz1258748206.png")
> system("convert tmp/7jafk1258748207.ps tmp/7jafk1258748207.png")
> system("convert tmp/81q8w1258748207.ps tmp/81q8w1258748207.png")
> system("convert tmp/955vr1258748207.ps tmp/955vr1258748207.png")
> system("convert tmp/10s4rg1258748207.ps tmp/10s4rg1258748207.png")
>
>
> proc.time()
user system elapsed
2.314 1.535 2.724