R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(98.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,94.6
+ ,113.9
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,80.9
+ ,113.9
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.7
+ ,80.9
+ ,113.9
+ ,98.1
+ ,102.8
+ ,113.2
+ ,95.7
+ ,80.9
+ ,113.9
+ ,98.1
+ ,105.9
+ ,113.2
+ ,95.7
+ ,80.9
+ ,113.9
+ ,108.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,80.9
+ ,102.3
+ ,108.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,99
+ ,102.3
+ ,108.8
+ ,105.9
+ ,113.2
+ ,100.7
+ ,99
+ ,102.3
+ ,108.8
+ ,105.9
+ ,115.5
+ ,100.7
+ ,99
+ ,102.3
+ ,108.8
+ ,100.7
+ ,115.5
+ ,100.7
+ ,99
+ ,102.3
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.7
+ ,99
+ ,114.6
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.7
+ ,85.4
+ ,114.6
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.5
+ ,85.4
+ ,114.6
+ ,109.9
+ ,100.7
+ ,114.8
+ ,100.5
+ ,85.4
+ ,114.6
+ ,109.9
+ ,116.5
+ ,114.8
+ ,100.5
+ ,85.4
+ ,114.6
+ ,112.9
+ ,116.5
+ ,114.8
+ ,100.5
+ ,85.4
+ ,102
+ ,112.9
+ ,116.5
+ ,114.8
+ ,100.5
+ ,106
+ ,102
+ ,112.9
+ ,116.5
+ ,114.8
+ ,105.3
+ ,106
+ ,102
+ ,112.9
+ ,116.5
+ ,118.8
+ ,105.3
+ ,106
+ ,102
+ ,112.9
+ ,106.1
+ ,118.8
+ ,105.3
+ ,106
+ ,102
+ ,109.3
+ ,106.1
+ ,118.8
+ ,105.3
+ ,106
+ ,117.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,105.3
+ ,92.5
+ ,117.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,104.2
+ ,92.5
+ ,117.2
+ ,109.3
+ ,106.1
+ ,112.5
+ ,104.2
+ ,92.5
+ ,117.2
+ ,109.3
+ ,122.4
+ ,112.5
+ ,104.2
+ ,92.5
+ ,117.2
+ ,113.3
+ ,122.4
+ ,112.5
+ ,104.2
+ ,92.5
+ ,100
+ ,113.3
+ ,122.4
+ ,112.5
+ ,104.2
+ ,110.7
+ ,100
+ ,113.3
+ ,122.4
+ ,112.5
+ ,112.8
+ ,110.7
+ ,100
+ ,113.3
+ ,122.4
+ ,109.8
+ ,112.8
+ ,110.7
+ ,100
+ ,113.3
+ ,117.3
+ ,109.8
+ ,112.8
+ ,110.7
+ ,100
+ ,109.1
+ ,117.3
+ ,109.8
+ ,112.8
+ ,110.7
+ ,115.9
+ ,109.1
+ ,117.3
+ ,109.8
+ ,112.8
+ ,96
+ ,115.9
+ ,109.1
+ ,117.3
+ ,109.8
+ ,99.8
+ ,96
+ ,115.9
+ ,109.1
+ ,117.3
+ ,116.8
+ ,99.8
+ ,96
+ ,115.9
+ ,109.1
+ ,115.7
+ ,116.8
+ ,99.8
+ ,96
+ ,115.9
+ ,99.4
+ ,115.7
+ ,116.8
+ ,99.8
+ ,96
+ ,94.3
+ ,99.4
+ ,115.7
+ ,116.8
+ ,99.8
+ ,91
+ ,94.3
+ ,99.4
+ ,115.7
+ ,116.8
+ ,93.2
+ ,91
+ ,94.3
+ ,99.4
+ ,115.7
+ ,103.1
+ ,93.2
+ ,91
+ ,94.3
+ ,99.4
+ ,94.1
+ ,103.1
+ ,93.2
+ ,91
+ ,94.3
+ ,91.8
+ ,94.1
+ ,103.1
+ ,93.2
+ ,91
+ ,102.7
+ ,91.8
+ ,94.1
+ ,103.1
+ ,93.2
+ ,82.6
+ ,102.7
+ ,91.8
+ ,94.1
+ ,103.1
+ ,89.1
+ ,82.6
+ ,102.7
+ ,91.8
+ ,94.1
+ ,104.5
+ ,89.1
+ ,82.6
+ ,102.7
+ ,91.8
+ ,105.1
+ ,104.5
+ ,89.1
+ ,82.6
+ ,102.7
+ ,95.1
+ ,105.1
+ ,104.5
+ ,89.1
+ ,82.6
+ ,88.7
+ ,95.1
+ ,105.1
+ ,104.5
+ ,89.1
+ ,86.3
+ ,88.7
+ ,95.1
+ ,105.1
+ ,104.5
+ ,91.8
+ ,86.3
+ ,88.7
+ ,95.1
+ ,105.1
+ ,111.5
+ ,91.8
+ ,86.3
+ ,88.7
+ ,95.1
+ ,99.7
+ ,111.5
+ ,91.8
+ ,86.3
+ ,88.7
+ ,97.5
+ ,99.7
+ ,111.5
+ ,91.8
+ ,86.3
+ ,111.7
+ ,97.5
+ ,99.7
+ ,111.5
+ ,91.8
+ ,86.2
+ ,111.7
+ ,97.5
+ ,99.7
+ ,111.5
+ ,95.4
+ ,86.2
+ ,111.7
+ ,97.5
+ ,99.7)
+ ,dim=c(5
+ ,64)
+ ,dimnames=list(c('y'
+ ,'y1'
+ ,'y2'
+ ,'y3'
+ ,'y4')
+ ,1:64))
> y <- array(NA,dim=c(5,64),dimnames=list(c('y','y1','y2','y3','y4'),1:64))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No Linear Trend'
> par2 = 'Do not include Seasonal 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
> 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 y1 y2 y3 y4
1 98.1 102.8 104.7 95.9 94.6
2 113.9 98.1 102.8 104.7 95.9
3 80.9 113.9 98.1 102.8 104.7
4 95.7 80.9 113.9 98.1 102.8
5 113.2 95.7 80.9 113.9 98.1
6 105.9 113.2 95.7 80.9 113.9
7 108.8 105.9 113.2 95.7 80.9
8 102.3 108.8 105.9 113.2 95.7
9 99.0 102.3 108.8 105.9 113.2
10 100.7 99.0 102.3 108.8 105.9
11 115.5 100.7 99.0 102.3 108.8
12 100.7 115.5 100.7 99.0 102.3
13 109.9 100.7 115.5 100.7 99.0
14 114.6 109.9 100.7 115.5 100.7
15 85.4 114.6 109.9 100.7 115.5
16 100.5 85.4 114.6 109.9 100.7
17 114.8 100.5 85.4 114.6 109.9
18 116.5 114.8 100.5 85.4 114.6
19 112.9 116.5 114.8 100.5 85.4
20 102.0 112.9 116.5 114.8 100.5
21 106.0 102.0 112.9 116.5 114.8
22 105.3 106.0 102.0 112.9 116.5
23 118.8 105.3 106.0 102.0 112.9
24 106.1 118.8 105.3 106.0 102.0
25 109.3 106.1 118.8 105.3 106.0
26 117.2 109.3 106.1 118.8 105.3
27 92.5 117.2 109.3 106.1 118.8
28 104.2 92.5 117.2 109.3 106.1
29 112.5 104.2 92.5 117.2 109.3
30 122.4 112.5 104.2 92.5 117.2
31 113.3 122.4 112.5 104.2 92.5
32 100.0 113.3 122.4 112.5 104.2
33 110.7 100.0 113.3 122.4 112.5
34 112.8 110.7 100.0 113.3 122.4
35 109.8 112.8 110.7 100.0 113.3
36 117.3 109.8 112.8 110.7 100.0
37 109.1 117.3 109.8 112.8 110.7
38 115.9 109.1 117.3 109.8 112.8
39 96.0 115.9 109.1 117.3 109.8
40 99.8 96.0 115.9 109.1 117.3
41 116.8 99.8 96.0 115.9 109.1
42 115.7 116.8 99.8 96.0 115.9
43 99.4 115.7 116.8 99.8 96.0
44 94.3 99.4 115.7 116.8 99.8
45 91.0 94.3 99.4 115.7 116.8
46 93.2 91.0 94.3 99.4 115.7
47 103.1 93.2 91.0 94.3 99.4
48 94.1 103.1 93.2 91.0 94.3
49 91.8 94.1 103.1 93.2 91.0
50 102.7 91.8 94.1 103.1 93.2
51 82.6 102.7 91.8 94.1 103.1
52 89.1 82.6 102.7 91.8 94.1
53 104.5 89.1 82.6 102.7 91.8
54 105.1 104.5 89.1 82.6 102.7
55 95.1 105.1 104.5 89.1 82.6
56 88.7 95.1 105.1 104.5 89.1
57 86.3 88.7 95.1 105.1 104.5
58 91.8 86.3 88.7 95.1 105.1
59 111.5 91.8 86.3 88.7 95.1
60 99.7 111.5 91.8 86.3 88.7
61 97.5 99.7 111.5 91.8 86.3
62 111.7 97.5 99.7 111.5 91.8
63 86.2 111.7 97.5 99.7 111.5
64 95.4 86.2 111.7 97.5 99.7
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) y1 y2 y3 y4
60.59792 0.27766 -0.09684 0.22319 0.00965
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-25.7781 -5.4456 0.8431 7.5269 18.8796
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 60.59792 20.88560 2.901 0.00521 **
y1 0.27766 0.13020 2.133 0.03713 *
y2 -0.09684 0.13626 -0.711 0.48009
y3 0.22319 0.13815 1.616 0.11152
y4 0.00965 0.13496 0.072 0.94324
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 9.871 on 59 degrees of freedom
Multiple R-squared: 0.1157, Adjusted R-squared: 0.05575
F-statistic: 1.93 on 4 and 59 DF, p-value: 0.1173
> 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.8299148 0.3401704 0.1700852
[2,] 0.7980404 0.4039191 0.2019596
[3,] 0.6869967 0.6260066 0.3130033
[4,] 0.7578006 0.4843989 0.2421994
[5,] 0.6612943 0.6774113 0.3387057
[6,] 0.6540173 0.6919655 0.3459827
[7,] 0.6633095 0.6733810 0.3366905
[8,] 0.7051271 0.5897459 0.2948729
[9,] 0.6280531 0.7438938 0.3719469
[10,] 0.5752313 0.8495375 0.4247687
[11,] 0.6965387 0.6069226 0.3034613
[12,] 0.6834852 0.6330295 0.3165148
[13,] 0.6181176 0.7637649 0.3818824
[14,] 0.5793535 0.8412931 0.4206465
[15,] 0.5024399 0.9951202 0.4975601
[16,] 0.6270074 0.7459852 0.3729926
[17,] 0.5501705 0.8996591 0.4498295
[18,] 0.5159113 0.9681774 0.4840887
[19,] 0.5223645 0.9552710 0.4776355
[20,] 0.5733127 0.8533747 0.4266873
[21,] 0.5101954 0.9796092 0.4898046
[22,] 0.4467127 0.8934255 0.5532873
[23,] 0.6454124 0.7091752 0.3545876
[24,] 0.6030701 0.7938599 0.3969299
[25,] 0.5395235 0.9209530 0.4604765
[26,] 0.4975065 0.9950130 0.5024935
[27,] 0.4486620 0.8973241 0.5513380
[28,] 0.4048315 0.8096630 0.5951685
[29,] 0.4632409 0.9264817 0.5367591
[30,] 0.3963171 0.7926342 0.6036829
[31,] 0.5173245 0.9653511 0.4826755
[32,] 0.5080108 0.9839785 0.4919892
[33,] 0.4691970 0.9383940 0.5308030
[34,] 0.5709774 0.8580452 0.4290226
[35,] 0.8133168 0.3733664 0.1866832
[36,] 0.8089815 0.3820370 0.1910185
[37,] 0.7833603 0.4332794 0.2166397
[38,] 0.7710711 0.4578578 0.2289289
[39,] 0.7475406 0.5049188 0.2524594
[40,] 0.6990075 0.6019851 0.3009925
[41,] 0.6570660 0.6858681 0.3429340
[42,] 0.5997675 0.8004651 0.4002325
[43,] 0.5044079 0.9911841 0.4955921
[44,] 0.6346663 0.7306674 0.3653337
[45,] 0.5816828 0.8366344 0.4183172
[46,] 0.4653305 0.9306610 0.5346695
[47,] 0.4271235 0.8542471 0.5728765
[48,] 0.3380770 0.6761539 0.6619230
[49,] 0.4692557 0.9385114 0.5307443
> postscript(file="/var/www/rcomp/tmp/14b2p1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/24b2p1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/3ek1a1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/4ek1a1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/5ek1a1293197319.ps",horizontal=F,onefile=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 = 64
Frequency = 1
1 2 3 4 5 6
-3.2194256 11.7249459 -25.7780828 0.7820908 7.4959631 3.9829942
7 8 9 10 11 12
7.6198048 -4.4410214 -4.1949755 -2.7849590 12.6462150 -5.2992670
13 14 15 16 17 18
9.0957342 6.4883975 -19.9652680 1.7870043 7.9288605 13.5924434
19 20 21 22 23 24
7.8168005 -5.2563667 0.9040825 -1.1750129 15.3742408 -1.9295381
25 26 27 28 29 30
6.2217007 8.9969966 -14.8823717 3.8492019 4.7145632 18.8796088
31 32 33 34 35 36
5.4615483 -6.3184464 4.9034995 4.6800935 5.1894564 11.4659899
37 38 39 40 41 42
0.3210609 10.7734750 -13.4536820 -1.7119438 10.8672830 9.7909526
43 44 45 46 47 48
-5.2134528 -9.7250558 -13.1060039 -6.8349536 3.4302073 -7.3198313
49 50 51 52 53 54
-6.6213644 1.8148713 -19.6211603 -5.8844557 3.3536960 4.6881583
55 56 57 58 59 60
-5.2439003 -12.3090842 -14.1829768 -6.4102277 13.0551627 -3.0847048
61 62 63 64
-1.3049902 7.9132009 -19.2990600 -1.0387215
> postscript(file="/var/www/rcomp/tmp/6pujv1293197319.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 64
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.2194256 NA
1 11.7249459 -3.2194256
2 -25.7780828 11.7249459
3 0.7820908 -25.7780828
4 7.4959631 0.7820908
5 3.9829942 7.4959631
6 7.6198048 3.9829942
7 -4.4410214 7.6198048
8 -4.1949755 -4.4410214
9 -2.7849590 -4.1949755
10 12.6462150 -2.7849590
11 -5.2992670 12.6462150
12 9.0957342 -5.2992670
13 6.4883975 9.0957342
14 -19.9652680 6.4883975
15 1.7870043 -19.9652680
16 7.9288605 1.7870043
17 13.5924434 7.9288605
18 7.8168005 13.5924434
19 -5.2563667 7.8168005
20 0.9040825 -5.2563667
21 -1.1750129 0.9040825
22 15.3742408 -1.1750129
23 -1.9295381 15.3742408
24 6.2217007 -1.9295381
25 8.9969966 6.2217007
26 -14.8823717 8.9969966
27 3.8492019 -14.8823717
28 4.7145632 3.8492019
29 18.8796088 4.7145632
30 5.4615483 18.8796088
31 -6.3184464 5.4615483
32 4.9034995 -6.3184464
33 4.6800935 4.9034995
34 5.1894564 4.6800935
35 11.4659899 5.1894564
36 0.3210609 11.4659899
37 10.7734750 0.3210609
38 -13.4536820 10.7734750
39 -1.7119438 -13.4536820
40 10.8672830 -1.7119438
41 9.7909526 10.8672830
42 -5.2134528 9.7909526
43 -9.7250558 -5.2134528
44 -13.1060039 -9.7250558
45 -6.8349536 -13.1060039
46 3.4302073 -6.8349536
47 -7.3198313 3.4302073
48 -6.6213644 -7.3198313
49 1.8148713 -6.6213644
50 -19.6211603 1.8148713
51 -5.8844557 -19.6211603
52 3.3536960 -5.8844557
53 4.6881583 3.3536960
54 -5.2439003 4.6881583
55 -12.3090842 -5.2439003
56 -14.1829768 -12.3090842
57 -6.4102277 -14.1829768
58 13.0551627 -6.4102277
59 -3.0847048 13.0551627
60 -1.3049902 -3.0847048
61 7.9132009 -1.3049902
62 -19.2990600 7.9132009
63 -1.0387215 -19.2990600
64 NA -1.0387215
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 11.7249459 -3.2194256
[2,] -25.7780828 11.7249459
[3,] 0.7820908 -25.7780828
[4,] 7.4959631 0.7820908
[5,] 3.9829942 7.4959631
[6,] 7.6198048 3.9829942
[7,] -4.4410214 7.6198048
[8,] -4.1949755 -4.4410214
[9,] -2.7849590 -4.1949755
[10,] 12.6462150 -2.7849590
[11,] -5.2992670 12.6462150
[12,] 9.0957342 -5.2992670
[13,] 6.4883975 9.0957342
[14,] -19.9652680 6.4883975
[15,] 1.7870043 -19.9652680
[16,] 7.9288605 1.7870043
[17,] 13.5924434 7.9288605
[18,] 7.8168005 13.5924434
[19,] -5.2563667 7.8168005
[20,] 0.9040825 -5.2563667
[21,] -1.1750129 0.9040825
[22,] 15.3742408 -1.1750129
[23,] -1.9295381 15.3742408
[24,] 6.2217007 -1.9295381
[25,] 8.9969966 6.2217007
[26,] -14.8823717 8.9969966
[27,] 3.8492019 -14.8823717
[28,] 4.7145632 3.8492019
[29,] 18.8796088 4.7145632
[30,] 5.4615483 18.8796088
[31,] -6.3184464 5.4615483
[32,] 4.9034995 -6.3184464
[33,] 4.6800935 4.9034995
[34,] 5.1894564 4.6800935
[35,] 11.4659899 5.1894564
[36,] 0.3210609 11.4659899
[37,] 10.7734750 0.3210609
[38,] -13.4536820 10.7734750
[39,] -1.7119438 -13.4536820
[40,] 10.8672830 -1.7119438
[41,] 9.7909526 10.8672830
[42,] -5.2134528 9.7909526
[43,] -9.7250558 -5.2134528
[44,] -13.1060039 -9.7250558
[45,] -6.8349536 -13.1060039
[46,] 3.4302073 -6.8349536
[47,] -7.3198313 3.4302073
[48,] -6.6213644 -7.3198313
[49,] 1.8148713 -6.6213644
[50,] -19.6211603 1.8148713
[51,] -5.8844557 -19.6211603
[52,] 3.3536960 -5.8844557
[53,] 4.6881583 3.3536960
[54,] -5.2439003 4.6881583
[55,] -12.3090842 -5.2439003
[56,] -14.1829768 -12.3090842
[57,] -6.4102277 -14.1829768
[58,] 13.0551627 -6.4102277
[59,] -3.0847048 13.0551627
[60,] -1.3049902 -3.0847048
[61,] 7.9132009 -1.3049902
[62,] -19.2990600 7.9132009
[63,] -1.0387215 -19.2990600
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 11.7249459 -3.2194256
2 -25.7780828 11.7249459
3 0.7820908 -25.7780828
4 7.4959631 0.7820908
5 3.9829942 7.4959631
6 7.6198048 3.9829942
7 -4.4410214 7.6198048
8 -4.1949755 -4.4410214
9 -2.7849590 -4.1949755
10 12.6462150 -2.7849590
11 -5.2992670 12.6462150
12 9.0957342 -5.2992670
13 6.4883975 9.0957342
14 -19.9652680 6.4883975
15 1.7870043 -19.9652680
16 7.9288605 1.7870043
17 13.5924434 7.9288605
18 7.8168005 13.5924434
19 -5.2563667 7.8168005
20 0.9040825 -5.2563667
21 -1.1750129 0.9040825
22 15.3742408 -1.1750129
23 -1.9295381 15.3742408
24 6.2217007 -1.9295381
25 8.9969966 6.2217007
26 -14.8823717 8.9969966
27 3.8492019 -14.8823717
28 4.7145632 3.8492019
29 18.8796088 4.7145632
30 5.4615483 18.8796088
31 -6.3184464 5.4615483
32 4.9034995 -6.3184464
33 4.6800935 4.9034995
34 5.1894564 4.6800935
35 11.4659899 5.1894564
36 0.3210609 11.4659899
37 10.7734750 0.3210609
38 -13.4536820 10.7734750
39 -1.7119438 -13.4536820
40 10.8672830 -1.7119438
41 9.7909526 10.8672830
42 -5.2134528 9.7909526
43 -9.7250558 -5.2134528
44 -13.1060039 -9.7250558
45 -6.8349536 -13.1060039
46 3.4302073 -6.8349536
47 -7.3198313 3.4302073
48 -6.6213644 -7.3198313
49 1.8148713 -6.6213644
50 -19.6211603 1.8148713
51 -5.8844557 -19.6211603
52 3.3536960 -5.8844557
53 4.6881583 3.3536960
54 -5.2439003 4.6881583
55 -12.3090842 -5.2439003
56 -14.1829768 -12.3090842
57 -6.4102277 -14.1829768
58 13.0551627 -6.4102277
59 -3.0847048 13.0551627
60 -1.3049902 -3.0847048
61 7.9132009 -1.3049902
62 -19.2990600 7.9132009
63 -1.0387215 -19.2990600
> 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/rcomp/tmp/7pujv1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/8iliy1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/9iliy1293197319.ps",horizontal=F,onefile=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/rcomp/tmp/10sczj1293197319.ps",horizontal=F,onefile=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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11edyp1293197319.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/rcomp/tmp/12rnzp1293197320.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/rcomp/tmp/13oxfg1293197320.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/rcomp/tmp/14rgd41293197320.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/rcomp/tmp/15ugcs1293197320.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/rcomp/tmp/16yhag1293197320.tab")
+ }
>
> try(system("convert tmp/14b2p1293197319.ps tmp/14b2p1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/24b2p1293197319.ps tmp/24b2p1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/3ek1a1293197319.ps tmp/3ek1a1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ek1a1293197319.ps tmp/4ek1a1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ek1a1293197319.ps tmp/5ek1a1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/6pujv1293197319.ps tmp/6pujv1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/7pujv1293197319.ps tmp/7pujv1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/8iliy1293197319.ps tmp/8iliy1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/9iliy1293197319.ps tmp/9iliy1293197319.png",intern=TRUE))
character(0)
> try(system("convert tmp/10sczj1293197319.ps tmp/10sczj1293197319.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.200 1.690 4.887