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(101.68
+ ,0
+ ,102.11
+ ,102.71
+ ,101.09
+ ,101.7
+ ,0
+ ,101.68
+ ,102.11
+ ,102.71
+ ,101.53
+ ,0
+ ,101.7
+ ,101.68
+ ,102.11
+ ,101.76
+ ,0
+ ,101.53
+ ,101.7
+ ,101.68
+ ,101.15
+ ,0
+ ,101.76
+ ,101.53
+ ,101.7
+ ,100.92
+ ,0
+ ,101.15
+ ,101.76
+ ,101.53
+ ,100.73
+ ,0
+ ,100.92
+ ,101.15
+ ,101.76
+ ,100.55
+ ,0
+ ,100.73
+ ,100.92
+ ,101.15
+ ,102.15
+ ,0
+ ,100.55
+ ,100.73
+ ,100.92
+ ,100.79
+ ,0
+ ,102.15
+ ,100.55
+ ,100.73
+ ,99.93
+ ,0
+ ,100.79
+ ,102.15
+ ,100.55
+ ,100.03
+ ,0
+ ,99.93
+ ,100.79
+ ,102.15
+ ,100.25
+ ,0
+ ,100.03
+ ,99.93
+ ,100.79
+ ,99.6
+ ,0
+ ,100.25
+ ,100.03
+ ,99.93
+ ,100.16
+ ,0
+ ,99.6
+ ,100.25
+ ,100.03
+ ,100.49
+ ,0
+ ,100.16
+ ,99.6
+ ,100.25
+ ,99.72
+ ,0
+ ,100.49
+ ,100.16
+ ,99.6
+ ,100.14
+ ,0
+ ,99.72
+ ,100.49
+ ,100.16
+ ,98.48
+ ,0
+ ,100.14
+ ,99.72
+ ,100.49
+ ,100.38
+ ,0
+ ,98.48
+ ,100.14
+ ,99.72
+ ,101.45
+ ,0
+ ,100.38
+ ,98.48
+ ,100.14
+ ,98.42
+ ,0
+ ,101.45
+ ,100.38
+ ,98.48
+ ,98.6
+ ,0
+ ,98.42
+ ,101.45
+ ,100.38
+ ,100.06
+ ,0
+ ,98.6
+ ,98.42
+ ,101.45
+ ,98.62
+ ,0
+ ,100.06
+ ,98.6
+ ,98.42
+ ,100.84
+ ,0
+ ,98.62
+ ,100.06
+ ,98.6
+ ,100.02
+ ,0
+ ,100.84
+ ,98.62
+ ,100.06
+ ,97.95
+ ,0
+ ,100.02
+ ,100.84
+ ,98.62
+ ,98.32
+ ,0
+ ,97.95
+ ,100.02
+ ,100.84
+ ,98.27
+ ,0
+ ,98.32
+ ,97.95
+ ,100.02
+ ,97.22
+ ,0
+ ,98.27
+ ,98.32
+ ,97.95
+ ,99.28
+ ,0
+ ,97.22
+ ,98.27
+ ,98.32
+ ,100.38
+ ,0
+ ,99.28
+ ,97.22
+ ,98.27
+ ,99.02
+ ,0
+ ,100.38
+ ,99.28
+ ,97.22
+ ,100.32
+ ,0
+ ,99.02
+ ,100.38
+ ,99.28
+ ,99.81
+ ,0
+ ,100.32
+ ,99.02
+ ,100.38
+ ,100.6
+ ,0
+ ,99.81
+ ,100.32
+ ,99.02
+ ,101.19
+ ,0
+ ,100.6
+ ,99.81
+ ,100.32
+ ,100.47
+ ,0
+ ,101.19
+ ,100.6
+ ,99.81
+ ,101.77
+ ,0
+ ,100.47
+ ,101.19
+ ,100.6
+ ,102.32
+ ,0
+ ,101.77
+ ,100.47
+ ,101.19
+ ,102.39
+ ,0
+ ,102.32
+ ,101.77
+ ,100.47
+ ,101.16
+ ,0
+ ,102.39
+ ,102.32
+ ,101.77
+ ,100.63
+ ,0
+ ,101.16
+ ,102.39
+ ,102.32
+ ,101.48
+ ,0
+ ,100.63
+ ,101.16
+ ,102.39
+ ,101.44
+ ,1
+ ,101.48
+ ,100.63
+ ,101.16
+ ,100.09
+ ,1
+ ,101.44
+ ,101.48
+ ,100.63
+ ,100.7
+ ,1
+ ,100.09
+ ,101.44
+ ,101.48
+ ,100.78
+ ,1
+ ,100.7
+ ,100.09
+ ,101.44
+ ,99.81
+ ,1
+ ,100.78
+ ,100.7
+ ,100.09
+ ,98.45
+ ,1
+ ,99.81
+ ,100.78
+ ,100.7
+ ,98.49
+ ,1
+ ,98.45
+ ,99.81
+ ,100.78
+ ,97.48
+ ,1
+ ,98.49
+ ,98.45
+ ,99.81
+ ,97.91
+ ,1
+ ,97.48
+ ,98.49
+ ,98.45
+ ,96.94
+ ,1
+ ,97.91
+ ,97.48
+ ,98.49
+ ,98.53
+ ,1
+ ,96.94
+ ,97.91
+ ,97.48
+ ,96.82
+ ,1
+ ,98.53
+ ,96.94
+ ,97.91
+ ,95.76
+ ,1
+ ,96.82
+ ,98.53
+ ,96.94)
+ ,dim=c(5
+ ,58)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3')
+ ,1:58))
> y <- array(NA,dim=c(5,58),dimnames=list(c('Y','X','Y1','Y2','Y3'),1:58))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 101.68 0 102.11 102.71 101.09 1 0 0 0 0 0 0 0 0 0 0 1
2 101.70 0 101.68 102.11 102.71 0 1 0 0 0 0 0 0 0 0 0 2
3 101.53 0 101.70 101.68 102.11 0 0 1 0 0 0 0 0 0 0 0 3
4 101.76 0 101.53 101.70 101.68 0 0 0 1 0 0 0 0 0 0 0 4
5 101.15 0 101.76 101.53 101.70 0 0 0 0 1 0 0 0 0 0 0 5
6 100.92 0 101.15 101.76 101.53 0 0 0 0 0 1 0 0 0 0 0 6
7 100.73 0 100.92 101.15 101.76 0 0 0 0 0 0 1 0 0 0 0 7
8 100.55 0 100.73 100.92 101.15 0 0 0 0 0 0 0 1 0 0 0 8
9 102.15 0 100.55 100.73 100.92 0 0 0 0 0 0 0 0 1 0 0 9
10 100.79 0 102.15 100.55 100.73 0 0 0 0 0 0 0 0 0 1 0 10
11 99.93 0 100.79 102.15 100.55 0 0 0 0 0 0 0 0 0 0 1 11
12 100.03 0 99.93 100.79 102.15 0 0 0 0 0 0 0 0 0 0 0 12
13 100.25 0 100.03 99.93 100.79 1 0 0 0 0 0 0 0 0 0 0 13
14 99.60 0 100.25 100.03 99.93 0 1 0 0 0 0 0 0 0 0 0 14
15 100.16 0 99.60 100.25 100.03 0 0 1 0 0 0 0 0 0 0 0 15
16 100.49 0 100.16 99.60 100.25 0 0 0 1 0 0 0 0 0 0 0 16
17 99.72 0 100.49 100.16 99.60 0 0 0 0 1 0 0 0 0 0 0 17
18 100.14 0 99.72 100.49 100.16 0 0 0 0 0 1 0 0 0 0 0 18
19 98.48 0 100.14 99.72 100.49 0 0 0 0 0 0 1 0 0 0 0 19
20 100.38 0 98.48 100.14 99.72 0 0 0 0 0 0 0 1 0 0 0 20
21 101.45 0 100.38 98.48 100.14 0 0 0 0 0 0 0 0 1 0 0 21
22 98.42 0 101.45 100.38 98.48 0 0 0 0 0 0 0 0 0 1 0 22
23 98.60 0 98.42 101.45 100.38 0 0 0 0 0 0 0 0 0 0 1 23
24 100.06 0 98.60 98.42 101.45 0 0 0 0 0 0 0 0 0 0 0 24
25 98.62 0 100.06 98.60 98.42 1 0 0 0 0 0 0 0 0 0 0 25
26 100.84 0 98.62 100.06 98.60 0 1 0 0 0 0 0 0 0 0 0 26
27 100.02 0 100.84 98.62 100.06 0 0 1 0 0 0 0 0 0 0 0 27
28 97.95 0 100.02 100.84 98.62 0 0 0 1 0 0 0 0 0 0 0 28
29 98.32 0 97.95 100.02 100.84 0 0 0 0 1 0 0 0 0 0 0 29
30 98.27 0 98.32 97.95 100.02 0 0 0 0 0 1 0 0 0 0 0 30
31 97.22 0 98.27 98.32 97.95 0 0 0 0 0 0 1 0 0 0 0 31
32 99.28 0 97.22 98.27 98.32 0 0 0 0 0 0 0 1 0 0 0 32
33 100.38 0 99.28 97.22 98.27 0 0 0 0 0 0 0 0 1 0 0 33
34 99.02 0 100.38 99.28 97.22 0 0 0 0 0 0 0 0 0 1 0 34
35 100.32 0 99.02 100.38 99.28 0 0 0 0 0 0 0 0 0 0 1 35
36 99.81 0 100.32 99.02 100.38 0 0 0 0 0 0 0 0 0 0 0 36
37 100.60 0 99.81 100.32 99.02 1 0 0 0 0 0 0 0 0 0 0 37
38 101.19 0 100.60 99.81 100.32 0 1 0 0 0 0 0 0 0 0 0 38
39 100.47 0 101.19 100.60 99.81 0 0 1 0 0 0 0 0 0 0 0 39
40 101.77 0 100.47 101.19 100.60 0 0 0 1 0 0 0 0 0 0 0 40
41 102.32 0 101.77 100.47 101.19 0 0 0 0 1 0 0 0 0 0 0 41
42 102.39 0 102.32 101.77 100.47 0 0 0 0 0 1 0 0 0 0 0 42
43 101.16 0 102.39 102.32 101.77 0 0 0 0 0 0 1 0 0 0 0 43
44 100.63 0 101.16 102.39 102.32 0 0 0 0 0 0 0 1 0 0 0 44
45 101.48 0 100.63 101.16 102.39 0 0 0 0 0 0 0 0 1 0 0 45
46 101.44 1 101.48 100.63 101.16 0 0 0 0 0 0 0 0 0 1 0 46
47 100.09 1 101.44 101.48 100.63 0 0 0 0 0 0 0 0 0 0 1 47
48 100.70 1 100.09 101.44 101.48 0 0 0 0 0 0 0 0 0 0 0 48
49 100.78 1 100.70 100.09 101.44 1 0 0 0 0 0 0 0 0 0 0 49
50 99.81 1 100.78 100.70 100.09 0 1 0 0 0 0 0 0 0 0 0 50
51 98.45 1 99.81 100.78 100.70 0 0 1 0 0 0 0 0 0 0 0 51
52 98.49 1 98.45 99.81 100.78 0 0 0 1 0 0 0 0 0 0 0 52
53 97.48 1 98.49 98.45 99.81 0 0 0 0 1 0 0 0 0 0 0 53
54 97.91 1 97.48 98.49 98.45 0 0 0 0 0 1 0 0 0 0 0 54
55 96.94 1 97.91 97.48 98.49 0 0 0 0 0 0 1 0 0 0 0 55
56 98.53 1 96.94 97.91 97.48 0 0 0 0 0 0 0 1 0 0 0 56
57 96.82 1 98.53 96.94 97.91 0 0 0 0 0 0 0 0 1 0 0 57
58 95.76 1 96.82 98.53 96.94 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 M1
9.571636 -0.895777 0.510443 0.069926 0.322093 0.184046
M2 M3 M4 M5 M6 M7
0.424936 -0.266548 -0.019563 -0.347633 0.085924 -0.976485
M8 M9 M10 M11 t
0.589331 0.698736 -0.536922 -0.228775 0.008582
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.71306 -0.57997 0.02459 0.64784 1.52521
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.571636 11.290167 0.848 0.40148
X -0.895777 0.439234 -2.039 0.04789 *
Y1 0.510443 0.149766 3.408 0.00148 **
Y2 0.069926 0.171956 0.407 0.68638
Y3 0.322093 0.160887 2.002 0.05193 .
M1 0.184046 0.669672 0.275 0.78483
M2 0.424936 0.659722 0.644 0.52309
M3 -0.266548 0.647923 -0.411 0.68293
M4 -0.019563 0.653785 -0.030 0.97627
M5 -0.347633 0.624573 -0.557 0.58083
M6 0.085924 0.642128 0.134 0.89421
M7 -0.976485 0.637742 -1.531 0.13341
M8 0.589331 0.652546 0.903 0.37174
M9 0.698736 0.642181 1.088 0.28292
M10 -0.536922 0.752804 -0.713 0.47974
M11 -0.228775 0.740940 -0.309 0.75906
t 0.008582 0.011222 0.765 0.44880
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.9027 on 41 degrees of freedom
Multiple R-squared: 0.7415, Adjusted R-squared: 0.6406
F-statistic: 7.349 on 16 and 41 DF, p-value: 1.289e-07
> 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.04974322 0.09948643 0.9502568
[2,] 0.07691728 0.15383456 0.9230827
[3,] 0.06939735 0.13879471 0.9306026
[4,] 0.04590583 0.09181167 0.9540942
[5,] 0.04013859 0.08027717 0.9598614
[6,] 0.02313569 0.04627137 0.9768643
[7,] 0.12493644 0.24987287 0.8750636
[8,] 0.08361312 0.16722624 0.9163869
[9,] 0.19500965 0.39001930 0.8049903
[10,] 0.16820918 0.33641835 0.8317908
[11,] 0.17800399 0.35600798 0.8219960
[12,] 0.17373866 0.34747732 0.8262613
[13,] 0.12745356 0.25490712 0.8725464
[14,] 0.07782845 0.15565690 0.9221715
[15,] 0.15821609 0.31643217 0.8417839
[16,] 0.22600874 0.45201749 0.7739913
[17,] 0.24010492 0.48020984 0.7598951
[18,] 0.37243278 0.74486555 0.6275672
[19,] 0.22806031 0.45612062 0.7719397
> postscript(file="/var/www/html/rcomp/tmp/1a3zi1261292450.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/2pxry1261292450.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/3gsma1261292450.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/4o2z81261292450.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/5dcij1261292450.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 = 58
Frequency = 1
1 2 3 4 5 6
0.051881467 -0.437934795 0.288082757 0.486392559 0.083924606 -0.238170571
7 8 9 10 11 12
0.711632351 -0.733220833 0.928038766 0.052190134 -0.484240140 -0.602864529
13 14 15 16 17 18
-0.128353364 -0.870116062 0.656981658 0.420157947 -0.028598270 0.138857157
19 20 21 22 23 24
-0.734149260 0.657432281 0.620400623 -1.326882965 -0.603764814 0.394235446
25 26 27 28 29 30
-1.020284721 1.525212657 -0.114631117 -1.713056877 -0.624657027 -0.896796342
31 32 33 34 35 36
-0.226587455 0.679303092 0.699329144 0.199067469 1.136112427 -0.534023424
37 38 39 40 41 42
0.670817773 0.225036838 -0.004196624 1.112045974 1.178270020 0.666390498
43 44 45 46 47 48
-0.002693225 -1.661290695 -0.595280533 1.486931073 -0.048107473 0.742652507
49 50 51 52 53 54
0.425938845 -0.442198638 -0.826236674 -0.305539603 -0.608939329 0.329719258
55 56 57 58
0.251797589 1.057776156 -1.652488000 -0.411305711
> postscript(file="/var/www/html/rcomp/tmp/6bhdv1261292450.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 0.051881467 NA
1 -0.437934795 0.051881467
2 0.288082757 -0.437934795
3 0.486392559 0.288082757
4 0.083924606 0.486392559
5 -0.238170571 0.083924606
6 0.711632351 -0.238170571
7 -0.733220833 0.711632351
8 0.928038766 -0.733220833
9 0.052190134 0.928038766
10 -0.484240140 0.052190134
11 -0.602864529 -0.484240140
12 -0.128353364 -0.602864529
13 -0.870116062 -0.128353364
14 0.656981658 -0.870116062
15 0.420157947 0.656981658
16 -0.028598270 0.420157947
17 0.138857157 -0.028598270
18 -0.734149260 0.138857157
19 0.657432281 -0.734149260
20 0.620400623 0.657432281
21 -1.326882965 0.620400623
22 -0.603764814 -1.326882965
23 0.394235446 -0.603764814
24 -1.020284721 0.394235446
25 1.525212657 -1.020284721
26 -0.114631117 1.525212657
27 -1.713056877 -0.114631117
28 -0.624657027 -1.713056877
29 -0.896796342 -0.624657027
30 -0.226587455 -0.896796342
31 0.679303092 -0.226587455
32 0.699329144 0.679303092
33 0.199067469 0.699329144
34 1.136112427 0.199067469
35 -0.534023424 1.136112427
36 0.670817773 -0.534023424
37 0.225036838 0.670817773
38 -0.004196624 0.225036838
39 1.112045974 -0.004196624
40 1.178270020 1.112045974
41 0.666390498 1.178270020
42 -0.002693225 0.666390498
43 -1.661290695 -0.002693225
44 -0.595280533 -1.661290695
45 1.486931073 -0.595280533
46 -0.048107473 1.486931073
47 0.742652507 -0.048107473
48 0.425938845 0.742652507
49 -0.442198638 0.425938845
50 -0.826236674 -0.442198638
51 -0.305539603 -0.826236674
52 -0.608939329 -0.305539603
53 0.329719258 -0.608939329
54 0.251797589 0.329719258
55 1.057776156 0.251797589
56 -1.652488000 1.057776156
57 -0.411305711 -1.652488000
58 NA -0.411305711
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.437934795 0.051881467
[2,] 0.288082757 -0.437934795
[3,] 0.486392559 0.288082757
[4,] 0.083924606 0.486392559
[5,] -0.238170571 0.083924606
[6,] 0.711632351 -0.238170571
[7,] -0.733220833 0.711632351
[8,] 0.928038766 -0.733220833
[9,] 0.052190134 0.928038766
[10,] -0.484240140 0.052190134
[11,] -0.602864529 -0.484240140
[12,] -0.128353364 -0.602864529
[13,] -0.870116062 -0.128353364
[14,] 0.656981658 -0.870116062
[15,] 0.420157947 0.656981658
[16,] -0.028598270 0.420157947
[17,] 0.138857157 -0.028598270
[18,] -0.734149260 0.138857157
[19,] 0.657432281 -0.734149260
[20,] 0.620400623 0.657432281
[21,] -1.326882965 0.620400623
[22,] -0.603764814 -1.326882965
[23,] 0.394235446 -0.603764814
[24,] -1.020284721 0.394235446
[25,] 1.525212657 -1.020284721
[26,] -0.114631117 1.525212657
[27,] -1.713056877 -0.114631117
[28,] -0.624657027 -1.713056877
[29,] -0.896796342 -0.624657027
[30,] -0.226587455 -0.896796342
[31,] 0.679303092 -0.226587455
[32,] 0.699329144 0.679303092
[33,] 0.199067469 0.699329144
[34,] 1.136112427 0.199067469
[35,] -0.534023424 1.136112427
[36,] 0.670817773 -0.534023424
[37,] 0.225036838 0.670817773
[38,] -0.004196624 0.225036838
[39,] 1.112045974 -0.004196624
[40,] 1.178270020 1.112045974
[41,] 0.666390498 1.178270020
[42,] -0.002693225 0.666390498
[43,] -1.661290695 -0.002693225
[44,] -0.595280533 -1.661290695
[45,] 1.486931073 -0.595280533
[46,] -0.048107473 1.486931073
[47,] 0.742652507 -0.048107473
[48,] 0.425938845 0.742652507
[49,] -0.442198638 0.425938845
[50,] -0.826236674 -0.442198638
[51,] -0.305539603 -0.826236674
[52,] -0.608939329 -0.305539603
[53,] 0.329719258 -0.608939329
[54,] 0.251797589 0.329719258
[55,] 1.057776156 0.251797589
[56,] -1.652488000 1.057776156
[57,] -0.411305711 -1.652488000
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.437934795 0.051881467
2 0.288082757 -0.437934795
3 0.486392559 0.288082757
4 0.083924606 0.486392559
5 -0.238170571 0.083924606
6 0.711632351 -0.238170571
7 -0.733220833 0.711632351
8 0.928038766 -0.733220833
9 0.052190134 0.928038766
10 -0.484240140 0.052190134
11 -0.602864529 -0.484240140
12 -0.128353364 -0.602864529
13 -0.870116062 -0.128353364
14 0.656981658 -0.870116062
15 0.420157947 0.656981658
16 -0.028598270 0.420157947
17 0.138857157 -0.028598270
18 -0.734149260 0.138857157
19 0.657432281 -0.734149260
20 0.620400623 0.657432281
21 -1.326882965 0.620400623
22 -0.603764814 -1.326882965
23 0.394235446 -0.603764814
24 -1.020284721 0.394235446
25 1.525212657 -1.020284721
26 -0.114631117 1.525212657
27 -1.713056877 -0.114631117
28 -0.624657027 -1.713056877
29 -0.896796342 -0.624657027
30 -0.226587455 -0.896796342
31 0.679303092 -0.226587455
32 0.699329144 0.679303092
33 0.199067469 0.699329144
34 1.136112427 0.199067469
35 -0.534023424 1.136112427
36 0.670817773 -0.534023424
37 0.225036838 0.670817773
38 -0.004196624 0.225036838
39 1.112045974 -0.004196624
40 1.178270020 1.112045974
41 0.666390498 1.178270020
42 -0.002693225 0.666390498
43 -1.661290695 -0.002693225
44 -0.595280533 -1.661290695
45 1.486931073 -0.595280533
46 -0.048107473 1.486931073
47 0.742652507 -0.048107473
48 0.425938845 0.742652507
49 -0.442198638 0.425938845
50 -0.826236674 -0.442198638
51 -0.305539603 -0.826236674
52 -0.608939329 -0.305539603
53 0.329719258 -0.608939329
54 0.251797589 0.329719258
55 1.057776156 0.251797589
56 -1.652488000 1.057776156
57 -0.411305711 -1.652488000
> 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/7jmmd1261292451.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/8xdp51261292451.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/9tqwl1261292451.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/10t0n21261292451.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/11ecwb1261292451.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/1261yf1261292451.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/13bc971261292451.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/142tx91261292451.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/15b6dk1261292451.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/16n4881261292451.tab")
+ }
>
> try(system("convert tmp/1a3zi1261292450.ps tmp/1a3zi1261292450.png",intern=TRUE))
character(0)
> try(system("convert tmp/2pxry1261292450.ps tmp/2pxry1261292450.png",intern=TRUE))
character(0)
> try(system("convert tmp/3gsma1261292450.ps tmp/3gsma1261292450.png",intern=TRUE))
character(0)
> try(system("convert tmp/4o2z81261292450.ps tmp/4o2z81261292450.png",intern=TRUE))
character(0)
> try(system("convert tmp/5dcij1261292450.ps tmp/5dcij1261292450.png",intern=TRUE))
character(0)
> try(system("convert tmp/6bhdv1261292450.ps tmp/6bhdv1261292450.png",intern=TRUE))
character(0)
> try(system("convert tmp/7jmmd1261292451.ps tmp/7jmmd1261292451.png",intern=TRUE))
character(0)
> try(system("convert tmp/8xdp51261292451.ps tmp/8xdp51261292451.png",intern=TRUE))
character(0)
> try(system("convert tmp/9tqwl1261292451.ps tmp/9tqwl1261292451.png",intern=TRUE))
character(0)
> try(system("convert tmp/10t0n21261292451.ps tmp/10t0n21261292451.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.435 1.600 4.237