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(15.6
+ ,0
+ ,14.6
+ ,11.9
+ ,13.5
+ ,14.2
+ ,14.1
+ ,-0.2
+ ,15.6
+ ,14.6
+ ,11.9
+ ,13.5
+ ,14.9
+ ,1
+ ,14.1
+ ,15.6
+ ,14.6
+ ,11.9
+ ,14.2
+ ,0.4
+ ,14.9
+ ,14.1
+ ,15.6
+ ,14.6
+ ,14.6
+ ,1
+ ,14.2
+ ,14.9
+ ,14.1
+ ,15.6
+ ,17.2
+ ,1.7
+ ,14.6
+ ,14.2
+ ,14.9
+ ,14.1
+ ,15.4
+ ,3.1
+ ,17.2
+ ,14.6
+ ,14.2
+ ,14.9
+ ,14.3
+ ,3.3
+ ,15.4
+ ,17.2
+ ,14.6
+ ,14.2
+ ,17.5
+ ,3.1
+ ,14.3
+ ,15.4
+ ,17.2
+ ,14.6
+ ,14.5
+ ,3.5
+ ,17.5
+ ,14.3
+ ,15.4
+ ,17.2
+ ,14.4
+ ,6
+ ,14.5
+ ,17.5
+ ,14.3
+ ,15.4
+ ,16.6
+ ,5.7
+ ,14.4
+ ,14.5
+ ,17.5
+ ,14.3
+ ,16.7
+ ,4.7
+ ,16.6
+ ,14.4
+ ,14.5
+ ,17.5
+ ,16.6
+ ,4.2
+ ,16.7
+ ,16.6
+ ,14.4
+ ,14.5
+ ,16.9
+ ,3.6
+ ,16.6
+ ,16.7
+ ,16.6
+ ,14.4
+ ,15.7
+ ,4.4
+ ,16.9
+ ,16.6
+ ,16.7
+ ,16.6
+ ,16.4
+ ,2.5
+ ,15.7
+ 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 ,23.3
+ ,-1.1
+ ,23.7
+ ,20.3
+ ,22.8
+ ,24.3
+ ,19.6
+ ,-4.4
+ ,23.3
+ ,23.7
+ ,20.3
+ ,22.8
+ ,18
+ ,-7.5
+ ,19.6
+ ,23.3
+ ,23.7
+ ,20.3
+ ,17.3
+ ,-12.2
+ ,18
+ ,19.6
+ ,23.3
+ ,23.7
+ ,16.8
+ ,-14.5
+ ,17.3
+ ,18
+ ,19.6
+ ,23.3
+ ,18.2
+ ,-16
+ ,16.8
+ ,17.3
+ ,18
+ ,19.6
+ ,16.5
+ ,-16.7
+ ,18.2
+ ,16.8
+ ,17.3
+ ,18
+ ,16
+ ,-16.3
+ ,16.5
+ ,18.2
+ ,16.8
+ ,17.3
+ ,18.4
+ ,-16.9
+ ,16
+ ,16.5
+ ,18.2
+ ,16.8)
+ ,dim=c(6
+ ,69)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:69))
> y <- array(NA,dim=c(6,69),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:69))
> 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 t
1 15.6 0.0 14.6 11.9 13.5 14.2 1 0 0 0 0 0 0 0 0 0 0 1
2 14.1 -0.2 15.6 14.6 11.9 13.5 0 1 0 0 0 0 0 0 0 0 0 2
3 14.9 1.0 14.1 15.6 14.6 11.9 0 0 1 0 0 0 0 0 0 0 0 3
4 14.2 0.4 14.9 14.1 15.6 14.6 0 0 0 1 0 0 0 0 0 0 0 4
5 14.6 1.0 14.2 14.9 14.1 15.6 0 0 0 0 1 0 0 0 0 0 0 5
6 17.2 1.7 14.6 14.2 14.9 14.1 0 0 0 0 0 1 0 0 0 0 0 6
7 15.4 3.1 17.2 14.6 14.2 14.9 0 0 0 0 0 0 1 0 0 0 0 7
8 14.3 3.3 15.4 17.2 14.6 14.2 0 0 0 0 0 0 0 1 0 0 0 8
9 17.5 3.1 14.3 15.4 17.2 14.6 0 0 0 0 0 0 0 0 1 0 0 9
10 14.5 3.5 17.5 14.3 15.4 17.2 0 0 0 0 0 0 0 0 0 1 0 10
11 14.4 6.0 14.5 17.5 14.3 15.4 0 0 0 0 0 0 0 0 0 0 1 11
12 16.6 5.7 14.4 14.5 17.5 14.3 0 0 0 0 0 0 0 0 0 0 0 12
13 16.7 4.7 16.6 14.4 14.5 17.5 1 0 0 0 0 0 0 0 0 0 0 13
14 16.6 4.2 16.7 16.6 14.4 14.5 0 1 0 0 0 0 0 0 0 0 0 14
15 16.9 3.6 16.6 16.7 16.6 14.4 0 0 1 0 0 0 0 0 0 0 0 15
16 15.7 4.4 16.9 16.6 16.7 16.6 0 0 0 1 0 0 0 0 0 0 0 16
17 16.4 2.5 15.7 16.9 16.6 16.7 0 0 0 0 1 0 0 0 0 0 0 17
18 18.4 -0.6 16.4 15.7 16.9 16.6 0 0 0 0 0 1 0 0 0 0 0 18
19 16.9 -1.9 18.4 16.4 15.7 16.9 0 0 0 0 0 0 1 0 0 0 0 19
20 16.5 -1.9 16.9 18.4 16.4 15.7 0 0 0 0 0 0 0 1 0 0 0 20
21 18.3 0.7 16.5 16.9 18.4 16.4 0 0 0 0 0 0 0 0 1 0 0 21
22 15.1 -0.9 18.3 16.5 16.9 18.4 0 0 0 0 0 0 0 0 0 1 0 22
23 15.7 -1.7 15.1 18.3 16.5 16.9 0 0 0 0 0 0 0 0 0 0 1 23
24 18.1 -3.1 15.7 15.1 18.3 16.5 0 0 0 0 0 0 0 0 0 0 0 24
25 16.8 -2.1 18.1 15.7 15.1 18.3 1 0 0 0 0 0 0 0 0 0 0 25
26 18.9 0.2 16.8 18.1 15.7 15.1 0 1 0 0 0 0 0 0 0 0 0 26
27 19.0 1.2 18.9 16.8 18.1 15.7 0 0 1 0 0 0 0 0 0 0 0 27
28 18.1 3.8 19.0 18.9 16.8 18.1 0 0 0 1 0 0 0 0 0 0 0 28
29 17.8 4.0 18.1 19.0 18.9 16.8 0 0 0 0 1 0 0 0 0 0 0 29
30 21.5 6.6 17.8 18.1 19.0 18.9 0 0 0 0 0 1 0 0 0 0 0 30
31 17.1 5.3 21.5 17.8 18.1 19.0 0 0 0 0 0 0 1 0 0 0 0 31
32 18.7 7.6 17.1 21.5 17.8 18.1 0 0 0 0 0 0 0 1 0 0 0 32
33 19.0 4.7 18.7 17.1 21.5 17.8 0 0 0 0 0 0 0 0 1 0 0 33
34 16.4 6.6 19.0 18.7 17.1 21.5 0 0 0 0 0 0 0 0 0 1 0 34
35 16.9 4.4 16.4 19.0 18.7 17.1 0 0 0 0 0 0 0 0 0 0 1 35
36 18.6 4.6 16.9 16.4 19.0 18.7 0 0 0 0 0 0 0 0 0 0 0 36
37 19.3 6.0 18.6 16.9 16.4 19.0 1 0 0 0 0 0 0 0 0 0 0 37
38 19.4 4.8 19.3 18.6 16.9 16.4 0 1 0 0 0 0 0 0 0 0 0 38
39 17.6 4.0 19.4 19.3 18.6 16.9 0 0 1 0 0 0 0 0 0 0 0 39
40 18.6 2.7 17.6 19.4 19.3 18.6 0 0 0 1 0 0 0 0 0 0 0 40
41 18.1 3.0 18.6 17.6 19.4 19.3 0 0 0 0 1 0 0 0 0 0 0 41
42 20.4 4.1 18.1 18.6 17.6 19.4 0 0 0 0 0 1 0 0 0 0 0 42
43 18.1 4.0 20.4 18.1 18.6 17.6 0 0 0 0 0 0 1 0 0 0 0 43
44 19.6 2.7 18.1 20.4 18.1 18.6 0 0 0 0 0 0 0 1 0 0 0 44
45 19.9 2.6 19.6 18.1 20.4 18.1 0 0 0 0 0 0 0 0 1 0 0 45
46 19.2 3.1 19.9 19.6 18.1 20.4 0 0 0 0 0 0 0 0 0 1 0 46
47 17.8 4.4 19.2 19.9 19.6 18.1 0 0 0 0 0 0 0 0 0 0 1 47
48 19.2 3.0 17.8 19.2 19.9 19.6 0 0 0 0 0 0 0 0 0 0 0 48
49 22.0 2.0 19.2 17.8 19.2 19.9 1 0 0 0 0 0 0 0 0 0 0 49
50 21.1 1.3 22.0 19.2 17.8 19.2 0 1 0 0 0 0 0 0 0 0 0 50
51 19.5 1.5 21.1 22.0 19.2 17.8 0 0 1 0 0 0 0 0 0 0 0 51
52 22.2 1.3 19.5 21.1 22.0 19.2 0 0 0 1 0 0 0 0 0 0 0 52
53 20.9 3.2 22.2 19.5 21.1 22.0 0 0 0 0 1 0 0 0 0 0 0 53
54 22.2 1.8 20.9 22.2 19.5 21.1 0 0 0 0 0 1 0 0 0 0 0 54
55 23.5 3.3 22.2 20.9 22.2 19.5 0 0 0 0 0 0 1 0 0 0 0 55
56 21.5 1.0 23.5 22.2 20.9 22.2 0 0 0 0 0 0 0 1 0 0 0 56
57 24.3 2.4 21.5 23.5 22.2 20.9 0 0 0 0 0 0 0 0 1 0 0 57
58 22.8 0.4 24.3 21.5 23.5 22.2 0 0 0 0 0 0 0 0 0 1 0 58
59 20.3 -0.1 22.8 24.3 21.5 23.5 0 0 0 0 0 0 0 0 0 0 1 59
60 23.7 1.3 20.3 22.8 24.3 21.5 0 0 0 0 0 0 0 0 0 0 0 60
61 23.3 -1.1 23.7 20.3 22.8 24.3 1 0 0 0 0 0 0 0 0 0 0 61
62 19.6 -4.4 23.3 23.7 20.3 22.8 0 1 0 0 0 0 0 0 0 0 0 62
63 18.0 -7.5 19.6 23.3 23.7 20.3 0 0 1 0 0 0 0 0 0 0 0 63
64 17.3 -12.2 18.0 19.6 23.3 23.7 0 0 0 1 0 0 0 0 0 0 0 64
65 16.8 -14.5 17.3 18.0 19.6 23.3 0 0 0 0 1 0 0 0 0 0 0 65
66 18.2 -16.0 16.8 17.3 18.0 19.6 0 0 0 0 0 1 0 0 0 0 0 66
67 16.5 -16.7 18.2 16.8 17.3 18.0 0 0 0 0 0 0 1 0 0 0 0 67
68 16.0 -16.3 16.5 18.2 16.8 17.3 0 0 0 0 0 0 0 1 0 0 0 68
69 18.4 -16.9 16.0 16.5 18.2 16.8 0 0 0 0 0 0 0 0 1 0 0 69
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
6.08578 0.09372 0.35312 0.29739 0.39000 -0.41281
M1 M2 M3 M4 M5 M6
1.32709 -0.69085 -2.44667 -1.21771 -0.85322 1.39825
M7 M8 M9 M10 M11 t
-1.35047 -1.46577 -0.10852 -1.34277 -2.37860 0.04035
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2.1916 -0.4856 0.0474 0.6396 1.9110
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.08578 1.84581 3.297 0.00178 **
X 0.09372 0.03823 2.451 0.01770 *
Y1 0.35312 0.13400 2.635 0.01111 *
Y2 0.29739 0.13181 2.256 0.02837 *
Y3 0.39000 0.12451 3.132 0.00287 **
Y4 -0.41281 0.13714 -3.010 0.00405 **
M1 1.32709 0.76271 1.740 0.08790 .
M2 -0.69085 0.88978 -0.776 0.44108
M3 -2.44667 0.79069 -3.094 0.00320 **
M4 -1.21771 0.64157 -1.898 0.06336 .
M5 -0.85322 0.65687 -1.299 0.19982
M6 1.39825 0.67319 2.077 0.04285 *
M7 -1.35047 0.80955 -1.668 0.10141
M8 -1.46577 0.79724 -1.839 0.07181 .
M9 -0.10852 0.63995 -0.170 0.86602
M10 -1.34277 0.78138 -1.718 0.09178 .
M11 -2.37860 0.74278 -3.202 0.00235 **
t 0.04035 0.01778 2.269 0.02752 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.9835 on 51 degrees of freedom
Multiple R-squared: 0.8841, Adjusted R-squared: 0.8455
F-statistic: 22.89 on 17 and 51 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.020554553 0.041109107 0.9794454
[2,] 0.018852583 0.037705165 0.9811474
[3,] 0.011529681 0.023059361 0.9884703
[4,] 0.003973836 0.007947671 0.9960262
[5,] 0.003734761 0.007469522 0.9962652
[6,] 0.002485303 0.004970605 0.9975147
[7,] 0.004028699 0.008057397 0.9959713
[8,] 0.044973234 0.089946468 0.9550268
[9,] 0.025242835 0.050485670 0.9747572
[10,] 0.034612842 0.069225684 0.9653872
[11,] 0.089872482 0.179744964 0.9101275
[12,] 0.062066964 0.124133929 0.9379330
[13,] 0.100849823 0.201699645 0.8991502
[14,] 0.135540760 0.271081521 0.8644592
[15,] 0.132485614 0.264971229 0.8675144
[16,] 0.132970729 0.265941458 0.8670293
[17,] 0.091366089 0.182732179 0.9086339
[18,] 0.065352019 0.130704037 0.9346480
[19,] 0.137286603 0.274573206 0.8627134
[20,] 0.095448350 0.190896700 0.9045517
[21,] 0.059674849 0.119349697 0.9403252
[22,] 0.037965177 0.075930354 0.9620348
[23,] 0.041908628 0.083817255 0.9580914
[24,] 0.063936568 0.127873136 0.9360634
[25,] 0.042024952 0.084049905 0.9579750
[26,] 0.032346636 0.064693271 0.9676534
[27,] 0.058735834 0.117471667 0.9412642
[28,] 0.198406604 0.396813207 0.8015934
> postscript(file="/var/www/html/rcomp/tmp/1uprq1258723657.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/2ua261258723657.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/3rma01258723657.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/4aisy1258723657.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/51enn1258723657.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 = 69
Frequency = 1
1 2 3 4 5 6
0.04926672 -0.27543541 0.64634762 -0.37854877 0.56745826 -0.05426482
7 8 9 10 11 12
0.28908353 -1.33728527 0.55869867 -0.31241708 0.14239577 -0.82306444
13 14 15 16 17 18
-0.25288847 -0.21745011 0.96054240 -0.79075590 0.09727567 0.04740100
19 20 21 22 23 24
1.05505074 -0.10348338 0.15152258 -0.81064333 0.99126566 0.97617046
25 26 27 28 29 30
-0.81983425 1.23250052 1.91099042 0.33592620 -1.45526455 0.91072965
31 32 33 34 35 36
-1.48409532 0.17413399 -1.47500906 -0.39751528 -0.30734750 0.09511078
37 38 39 40 41 42
-0.31468483 -0.14569259 -0.85532210 0.03185852 -0.46895607 0.05858671
43 44 45 46 47 48
-1.32021623 1.11256122 -0.92476950 0.81673024 -1.08614711 -0.76912787
49 50 51 52 53 54
1.07597988 1.07113252 -0.47096387 1.29703564 0.44339866 -0.50863098
55 56 57 58 59 60
1.57319447 0.63964720 1.18679593 0.70384546 0.25983317 0.52091106
61 62 63 64 65 66
0.26216095 -1.66505494 -2.19159447 -0.49551569 0.81608802 -0.45382156
67 68 69
-0.11301719 -0.48557376 0.50276139
> postscript(file="/var/www/html/rcomp/tmp/6h9us1258723657.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 = 69
Frequency = 1
lag(myerror, k = 1) myerror
0 0.04926672 NA
1 -0.27543541 0.04926672
2 0.64634762 -0.27543541
3 -0.37854877 0.64634762
4 0.56745826 -0.37854877
5 -0.05426482 0.56745826
6 0.28908353 -0.05426482
7 -1.33728527 0.28908353
8 0.55869867 -1.33728527
9 -0.31241708 0.55869867
10 0.14239577 -0.31241708
11 -0.82306444 0.14239577
12 -0.25288847 -0.82306444
13 -0.21745011 -0.25288847
14 0.96054240 -0.21745011
15 -0.79075590 0.96054240
16 0.09727567 -0.79075590
17 0.04740100 0.09727567
18 1.05505074 0.04740100
19 -0.10348338 1.05505074
20 0.15152258 -0.10348338
21 -0.81064333 0.15152258
22 0.99126566 -0.81064333
23 0.97617046 0.99126566
24 -0.81983425 0.97617046
25 1.23250052 -0.81983425
26 1.91099042 1.23250052
27 0.33592620 1.91099042
28 -1.45526455 0.33592620
29 0.91072965 -1.45526455
30 -1.48409532 0.91072965
31 0.17413399 -1.48409532
32 -1.47500906 0.17413399
33 -0.39751528 -1.47500906
34 -0.30734750 -0.39751528
35 0.09511078 -0.30734750
36 -0.31468483 0.09511078
37 -0.14569259 -0.31468483
38 -0.85532210 -0.14569259
39 0.03185852 -0.85532210
40 -0.46895607 0.03185852
41 0.05858671 -0.46895607
42 -1.32021623 0.05858671
43 1.11256122 -1.32021623
44 -0.92476950 1.11256122
45 0.81673024 -0.92476950
46 -1.08614711 0.81673024
47 -0.76912787 -1.08614711
48 1.07597988 -0.76912787
49 1.07113252 1.07597988
50 -0.47096387 1.07113252
51 1.29703564 -0.47096387
52 0.44339866 1.29703564
53 -0.50863098 0.44339866
54 1.57319447 -0.50863098
55 0.63964720 1.57319447
56 1.18679593 0.63964720
57 0.70384546 1.18679593
58 0.25983317 0.70384546
59 0.52091106 0.25983317
60 0.26216095 0.52091106
61 -1.66505494 0.26216095
62 -2.19159447 -1.66505494
63 -0.49551569 -2.19159447
64 0.81608802 -0.49551569
65 -0.45382156 0.81608802
66 -0.11301719 -0.45382156
67 -0.48557376 -0.11301719
68 0.50276139 -0.48557376
69 NA 0.50276139
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.27543541 0.04926672
[2,] 0.64634762 -0.27543541
[3,] -0.37854877 0.64634762
[4,] 0.56745826 -0.37854877
[5,] -0.05426482 0.56745826
[6,] 0.28908353 -0.05426482
[7,] -1.33728527 0.28908353
[8,] 0.55869867 -1.33728527
[9,] -0.31241708 0.55869867
[10,] 0.14239577 -0.31241708
[11,] -0.82306444 0.14239577
[12,] -0.25288847 -0.82306444
[13,] -0.21745011 -0.25288847
[14,] 0.96054240 -0.21745011
[15,] -0.79075590 0.96054240
[16,] 0.09727567 -0.79075590
[17,] 0.04740100 0.09727567
[18,] 1.05505074 0.04740100
[19,] -0.10348338 1.05505074
[20,] 0.15152258 -0.10348338
[21,] -0.81064333 0.15152258
[22,] 0.99126566 -0.81064333
[23,] 0.97617046 0.99126566
[24,] -0.81983425 0.97617046
[25,] 1.23250052 -0.81983425
[26,] 1.91099042 1.23250052
[27,] 0.33592620 1.91099042
[28,] -1.45526455 0.33592620
[29,] 0.91072965 -1.45526455
[30,] -1.48409532 0.91072965
[31,] 0.17413399 -1.48409532
[32,] -1.47500906 0.17413399
[33,] -0.39751528 -1.47500906
[34,] -0.30734750 -0.39751528
[35,] 0.09511078 -0.30734750
[36,] -0.31468483 0.09511078
[37,] -0.14569259 -0.31468483
[38,] -0.85532210 -0.14569259
[39,] 0.03185852 -0.85532210
[40,] -0.46895607 0.03185852
[41,] 0.05858671 -0.46895607
[42,] -1.32021623 0.05858671
[43,] 1.11256122 -1.32021623
[44,] -0.92476950 1.11256122
[45,] 0.81673024 -0.92476950
[46,] -1.08614711 0.81673024
[47,] -0.76912787 -1.08614711
[48,] 1.07597988 -0.76912787
[49,] 1.07113252 1.07597988
[50,] -0.47096387 1.07113252
[51,] 1.29703564 -0.47096387
[52,] 0.44339866 1.29703564
[53,] -0.50863098 0.44339866
[54,] 1.57319447 -0.50863098
[55,] 0.63964720 1.57319447
[56,] 1.18679593 0.63964720
[57,] 0.70384546 1.18679593
[58,] 0.25983317 0.70384546
[59,] 0.52091106 0.25983317
[60,] 0.26216095 0.52091106
[61,] -1.66505494 0.26216095
[62,] -2.19159447 -1.66505494
[63,] -0.49551569 -2.19159447
[64,] 0.81608802 -0.49551569
[65,] -0.45382156 0.81608802
[66,] -0.11301719 -0.45382156
[67,] -0.48557376 -0.11301719
[68,] 0.50276139 -0.48557376
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.27543541 0.04926672
2 0.64634762 -0.27543541
3 -0.37854877 0.64634762
4 0.56745826 -0.37854877
5 -0.05426482 0.56745826
6 0.28908353 -0.05426482
7 -1.33728527 0.28908353
8 0.55869867 -1.33728527
9 -0.31241708 0.55869867
10 0.14239577 -0.31241708
11 -0.82306444 0.14239577
12 -0.25288847 -0.82306444
13 -0.21745011 -0.25288847
14 0.96054240 -0.21745011
15 -0.79075590 0.96054240
16 0.09727567 -0.79075590
17 0.04740100 0.09727567
18 1.05505074 0.04740100
19 -0.10348338 1.05505074
20 0.15152258 -0.10348338
21 -0.81064333 0.15152258
22 0.99126566 -0.81064333
23 0.97617046 0.99126566
24 -0.81983425 0.97617046
25 1.23250052 -0.81983425
26 1.91099042 1.23250052
27 0.33592620 1.91099042
28 -1.45526455 0.33592620
29 0.91072965 -1.45526455
30 -1.48409532 0.91072965
31 0.17413399 -1.48409532
32 -1.47500906 0.17413399
33 -0.39751528 -1.47500906
34 -0.30734750 -0.39751528
35 0.09511078 -0.30734750
36 -0.31468483 0.09511078
37 -0.14569259 -0.31468483
38 -0.85532210 -0.14569259
39 0.03185852 -0.85532210
40 -0.46895607 0.03185852
41 0.05858671 -0.46895607
42 -1.32021623 0.05858671
43 1.11256122 -1.32021623
44 -0.92476950 1.11256122
45 0.81673024 -0.92476950
46 -1.08614711 0.81673024
47 -0.76912787 -1.08614711
48 1.07597988 -0.76912787
49 1.07113252 1.07597988
50 -0.47096387 1.07113252
51 1.29703564 -0.47096387
52 0.44339866 1.29703564
53 -0.50863098 0.44339866
54 1.57319447 -0.50863098
55 0.63964720 1.57319447
56 1.18679593 0.63964720
57 0.70384546 1.18679593
58 0.25983317 0.70384546
59 0.52091106 0.25983317
60 0.26216095 0.52091106
61 -1.66505494 0.26216095
62 -2.19159447 -1.66505494
63 -0.49551569 -2.19159447
64 0.81608802 -0.49551569
65 -0.45382156 0.81608802
66 -0.11301719 -0.45382156
67 -0.48557376 -0.11301719
68 0.50276139 -0.48557376
> 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/7yuh61258723657.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/86zw91258723657.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/9mf731258723657.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/10z6ei1258723657.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/11pi5w1258723657.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/120ffw1258723657.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/13atxa1258723658.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/14d11e1258723658.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/15c92e1258723658.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/169hh91258723658.tab")
+ }
>
> system("convert tmp/1uprq1258723657.ps tmp/1uprq1258723657.png")
> system("convert tmp/2ua261258723657.ps tmp/2ua261258723657.png")
> system("convert tmp/3rma01258723657.ps tmp/3rma01258723657.png")
> system("convert tmp/4aisy1258723657.ps tmp/4aisy1258723657.png")
> system("convert tmp/51enn1258723657.ps tmp/51enn1258723657.png")
> system("convert tmp/6h9us1258723657.ps tmp/6h9us1258723657.png")
> system("convert tmp/7yuh61258723657.ps tmp/7yuh61258723657.png")
> system("convert tmp/86zw91258723657.ps tmp/86zw91258723657.png")
> system("convert tmp/9mf731258723657.ps tmp/9mf731258723657.png")
> system("convert tmp/10z6ei1258723657.ps tmp/10z6ei1258723657.png")
>
>
> proc.time()
user system elapsed
2.544 1.585 3.187