R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(97.7,0,101.5,0,119.6,0,108.1,0,117.8,0,125.5,0,89.2,0,92.3,0,104.6,0,122.8,0,96.0,0,94.6,0,93.3,0,101.1,0,114.2,0,104.7,0,113.3,0,118.2,0,83.6,0,73.9,0,99.5,0,97.7,0,103.0,0,106.3,0,92.2,0,101.8,0,122.8,0,111.8,0,106.3,0,121.5,0,81.9,0,85.4,0,110.9,0,117.3,0,106.3,0,105.5,0,101.3,0,105.9,0,126.3,0,111.9,0,108.9,0,127.2,0,94.2,0,85.7,0,116.2,0,107.2,0,110.6,0,112.0,0,104.5,0,112.0,0,132.8,0,110.8,0,128.7,0,136.8,0,94.9,0,88.8,0,123.2,0,125.3,0,122.7,0,125.7,0,116.3,0,118.7,0,142.0,0,127.9,0,131.9,0,152.3,0,110.8,1,99.1,1,135.0,1,133.2,1,131.0,1,133.9,1,119.9,1,136.9,1,148.9,1,145.1,1,142.4,1,159.6,1,120.7,1,109.0,1,142.0,1),dim=c(2,81),dimnames=list(c('Y','X'),1:81))
> y <- array(NA,dim=c(2,81),dimnames=list(c('Y','X'),1:81))
> 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 = '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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 97.7 0 1 0 0 0 0 0 0 0 0 0 0
2 101.5 0 0 1 0 0 0 0 0 0 0 0 0
3 119.6 0 0 0 1 0 0 0 0 0 0 0 0
4 108.1 0 0 0 0 1 0 0 0 0 0 0 0
5 117.8 0 0 0 0 0 1 0 0 0 0 0 0
6 125.5 0 0 0 0 0 0 1 0 0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 148.9 1 0 0 1 0 0 0 0 0 0 0 0
76 145.1 1 0 0 0 1 0 0 0 0 0 0 0
77 142.4 1 0 0 0 0 1 0 0 0 0 0 0
78 159.6 1 0 0 0 0 0 1 0 0 0 0 0
79 120.7 1 0 0 0 0 0 0 1 0 0 0 0
80 109.0 1 0 0 0 0 0 0 0 1 0 0 0
81 142.0 1 0 0 0 0 0 0 0 0 1 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
108.854 24.878 -8.808 -1.279 17.107 4.778
M5 M6 M7 M8 M9 M10
8.921 22.035 -19.490 -25.362 2.810 4.250
M11
-1.400
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-15.404 -5.775 -1.332 4.837 21.411
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 108.854 3.615 30.109 < 2e-16 ***
X 24.878 2.546 9.770 1.40e-14 ***
M1 -8.808 4.893 -1.800 0.076294 .
M2 -1.279 4.893 -0.261 0.794570
M3 17.107 4.893 3.496 0.000836 ***
M4 4.778 4.893 0.976 0.332284
M5 8.921 4.893 1.823 0.072675 .
M6 22.035 4.893 4.503 2.70e-05 ***
M7 -19.490 4.902 -3.976 0.000172 ***
M8 -25.362 4.902 -5.174 2.20e-06 ***
M9 2.810 4.902 0.573 0.568425
M10 4.250 5.077 0.837 0.405503
M11 -1.400 5.077 -0.276 0.783591
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 8.794 on 68 degrees of freedom
Multiple R-squared: 0.7876, Adjusted R-squared: 0.7501
F-statistic: 21.01 on 12 and 68 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.05910136 0.11820272 0.94089864
[2,] 0.02927431 0.05854863 0.97072569
[3,] 0.03117320 0.06234640 0.96882680
[4,] 0.02005468 0.04010935 0.97994532
[5,] 0.15814941 0.31629882 0.84185059
[6,] 0.12692990 0.25385980 0.87307010
[7,] 0.51571676 0.96856648 0.48428324
[8,] 0.46006395 0.92012790 0.53993605
[9,] 0.45699043 0.91398087 0.54300957
[10,] 0.40721950 0.81443901 0.59278050
[11,] 0.34651322 0.69302645 0.65348678
[12,] 0.30932355 0.61864710 0.69067645
[13,] 0.26332610 0.52665220 0.73667390
[14,] 0.31208773 0.62417546 0.68791227
[15,] 0.32232751 0.64465503 0.67767249
[16,] 0.31800246 0.63600493 0.68199754
[17,] 0.25108473 0.50216945 0.74891527
[18,] 0.25628314 0.51256628 0.74371686
[19,] 0.22307257 0.44614513 0.77692743
[20,] 0.21014420 0.42028840 0.78985580
[21,] 0.20812813 0.41625627 0.79187187
[22,] 0.19005375 0.38010749 0.80994625
[23,] 0.17996693 0.35993385 0.82003307
[24,] 0.18010668 0.36021336 0.81989332
[25,] 0.16802371 0.33604742 0.83197629
[26,] 0.27308630 0.54617260 0.72691370
[27,] 0.39199295 0.78398591 0.60800705
[28,] 0.38497961 0.76995923 0.61502039
[29,] 0.31853167 0.63706333 0.68146833
[30,] 0.35018096 0.70036192 0.64981904
[31,] 0.43098749 0.86197497 0.56901251
[32,] 0.45637365 0.91274730 0.54362635
[33,] 0.52057343 0.95885314 0.47942657
[34,] 0.51427966 0.97144068 0.48572034
[35,] 0.54836815 0.90326371 0.45163185
[36,] 0.56677264 0.86645472 0.43322736
[37,] 0.84043621 0.31912758 0.15956379
[38,] 0.85922548 0.28154904 0.14077452
[39,] 0.94906106 0.10187787 0.05093894
[40,] 0.96621712 0.06756576 0.03378288
[41,] 0.95414967 0.09170065 0.04585033
[42,] 0.95625364 0.08749273 0.04374636
[43,] 0.94059240 0.11881519 0.05940760
[44,] 0.92760472 0.14479056 0.07239528
[45,] 0.91296113 0.17407775 0.08703887
[46,] 0.91520519 0.16958962 0.08479481
[47,] 0.89809478 0.20381045 0.10190522
[48,] 0.85421087 0.29157826 0.14578913
[49,] 0.81499846 0.37000308 0.18500154
[50,] 0.69041560 0.61916881 0.30958440
> postscript(file="/var/www/html/freestat/rcomp/tmp/182u51229327094.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/freestat/rcomp/tmp/29gd91229327094.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/freestat/rcomp/tmp/3bkxg1229327094.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/freestat/rcomp/tmp/46m161229327094.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/freestat/rcomp/tmp/5hmf31229327094.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 = 81
Frequency = 1
1 2 3 4 5 6
-2.34593670 -6.07450813 -6.36022241 -5.53165098 0.02549187 -5.38879384
7 8 9 10 11 12
-0.16330197 8.80812660 -7.06330197 9.69640719 -11.45359281 -14.25359281
13 14 15 16 17 18
-6.74593670 -6.47450813 -11.76022241 -8.93165098 -4.47450813 -12.68879384
19 20 21 22 23 24
-5.76330197 -9.59187340 -12.16330197 -15.40359281 -4.45359281 -2.55359281
25 26 27 28 29 30
-7.84593670 -5.77450813 -3.16022241 -1.83165098 -11.47450813 -9.38879384
31 32 33 34 35 36
-7.46330197 1.90812660 -0.76330197 4.19640719 -1.15359281 -3.35359281
37 38 39 40 41 42
1.25406330 -1.67450813 0.33977759 -1.73165098 -8.87450813 -3.68879384
43 44 45 46 47 48
4.83669803 2.20812660 4.53669803 -5.90359281 3.14640719 3.14640719
49 50 51 52 53 54
4.45406330 4.42549187 6.83977759 -2.83165098 10.92549187 5.91120616
55 56 57 58 59 60
5.53669803 5.30812660 11.53669803 12.19640719 15.24640719 16.84640719
61 62 63 64 65 66
16.25406330 11.12549187 16.03977759 14.26834902 14.12549187 21.41120616
67 68 69 70 71 72
-3.44174508 -9.27031651 -1.54174508 -4.78203593 -1.33203593 0.16796407
73 74 75 76 77 78
-5.02437981 4.44704876 -1.93866553 6.58990590 -0.25295124 3.83276305
79 80 81
6.45825492 0.62968349 5.45825492
> postscript(file="/var/www/html/freestat/rcomp/tmp/6jhea1229327094.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 = 81
Frequency = 1
lag(myerror, k = 1) myerror
0 -2.34593670 NA
1 -6.07450813 -2.34593670
2 -6.36022241 -6.07450813
3 -5.53165098 -6.36022241
4 0.02549187 -5.53165098
5 -5.38879384 0.02549187
6 -0.16330197 -5.38879384
7 8.80812660 -0.16330197
8 -7.06330197 8.80812660
9 9.69640719 -7.06330197
10 -11.45359281 9.69640719
11 -14.25359281 -11.45359281
12 -6.74593670 -14.25359281
13 -6.47450813 -6.74593670
14 -11.76022241 -6.47450813
15 -8.93165098 -11.76022241
16 -4.47450813 -8.93165098
17 -12.68879384 -4.47450813
18 -5.76330197 -12.68879384
19 -9.59187340 -5.76330197
20 -12.16330197 -9.59187340
21 -15.40359281 -12.16330197
22 -4.45359281 -15.40359281
23 -2.55359281 -4.45359281
24 -7.84593670 -2.55359281
25 -5.77450813 -7.84593670
26 -3.16022241 -5.77450813
27 -1.83165098 -3.16022241
28 -11.47450813 -1.83165098
29 -9.38879384 -11.47450813
30 -7.46330197 -9.38879384
31 1.90812660 -7.46330197
32 -0.76330197 1.90812660
33 4.19640719 -0.76330197
34 -1.15359281 4.19640719
35 -3.35359281 -1.15359281
36 1.25406330 -3.35359281
37 -1.67450813 1.25406330
38 0.33977759 -1.67450813
39 -1.73165098 0.33977759
40 -8.87450813 -1.73165098
41 -3.68879384 -8.87450813
42 4.83669803 -3.68879384
43 2.20812660 4.83669803
44 4.53669803 2.20812660
45 -5.90359281 4.53669803
46 3.14640719 -5.90359281
47 3.14640719 3.14640719
48 4.45406330 3.14640719
49 4.42549187 4.45406330
50 6.83977759 4.42549187
51 -2.83165098 6.83977759
52 10.92549187 -2.83165098
53 5.91120616 10.92549187
54 5.53669803 5.91120616
55 5.30812660 5.53669803
56 11.53669803 5.30812660
57 12.19640719 11.53669803
58 15.24640719 12.19640719
59 16.84640719 15.24640719
60 16.25406330 16.84640719
61 11.12549187 16.25406330
62 16.03977759 11.12549187
63 14.26834902 16.03977759
64 14.12549187 14.26834902
65 21.41120616 14.12549187
66 -3.44174508 21.41120616
67 -9.27031651 -3.44174508
68 -1.54174508 -9.27031651
69 -4.78203593 -1.54174508
70 -1.33203593 -4.78203593
71 0.16796407 -1.33203593
72 -5.02437981 0.16796407
73 4.44704876 -5.02437981
74 -1.93866553 4.44704876
75 6.58990590 -1.93866553
76 -0.25295124 6.58990590
77 3.83276305 -0.25295124
78 6.45825492 3.83276305
79 0.62968349 6.45825492
80 5.45825492 0.62968349
81 NA 5.45825492
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -6.07450813 -2.34593670
[2,] -6.36022241 -6.07450813
[3,] -5.53165098 -6.36022241
[4,] 0.02549187 -5.53165098
[5,] -5.38879384 0.02549187
[6,] -0.16330197 -5.38879384
[7,] 8.80812660 -0.16330197
[8,] -7.06330197 8.80812660
[9,] 9.69640719 -7.06330197
[10,] -11.45359281 9.69640719
[11,] -14.25359281 -11.45359281
[12,] -6.74593670 -14.25359281
[13,] -6.47450813 -6.74593670
[14,] -11.76022241 -6.47450813
[15,] -8.93165098 -11.76022241
[16,] -4.47450813 -8.93165098
[17,] -12.68879384 -4.47450813
[18,] -5.76330197 -12.68879384
[19,] -9.59187340 -5.76330197
[20,] -12.16330197 -9.59187340
[21,] -15.40359281 -12.16330197
[22,] -4.45359281 -15.40359281
[23,] -2.55359281 -4.45359281
[24,] -7.84593670 -2.55359281
[25,] -5.77450813 -7.84593670
[26,] -3.16022241 -5.77450813
[27,] -1.83165098 -3.16022241
[28,] -11.47450813 -1.83165098
[29,] -9.38879384 -11.47450813
[30,] -7.46330197 -9.38879384
[31,] 1.90812660 -7.46330197
[32,] -0.76330197 1.90812660
[33,] 4.19640719 -0.76330197
[34,] -1.15359281 4.19640719
[35,] -3.35359281 -1.15359281
[36,] 1.25406330 -3.35359281
[37,] -1.67450813 1.25406330
[38,] 0.33977759 -1.67450813
[39,] -1.73165098 0.33977759
[40,] -8.87450813 -1.73165098
[41,] -3.68879384 -8.87450813
[42,] 4.83669803 -3.68879384
[43,] 2.20812660 4.83669803
[44,] 4.53669803 2.20812660
[45,] -5.90359281 4.53669803
[46,] 3.14640719 -5.90359281
[47,] 3.14640719 3.14640719
[48,] 4.45406330 3.14640719
[49,] 4.42549187 4.45406330
[50,] 6.83977759 4.42549187
[51,] -2.83165098 6.83977759
[52,] 10.92549187 -2.83165098
[53,] 5.91120616 10.92549187
[54,] 5.53669803 5.91120616
[55,] 5.30812660 5.53669803
[56,] 11.53669803 5.30812660
[57,] 12.19640719 11.53669803
[58,] 15.24640719 12.19640719
[59,] 16.84640719 15.24640719
[60,] 16.25406330 16.84640719
[61,] 11.12549187 16.25406330
[62,] 16.03977759 11.12549187
[63,] 14.26834902 16.03977759
[64,] 14.12549187 14.26834902
[65,] 21.41120616 14.12549187
[66,] -3.44174508 21.41120616
[67,] -9.27031651 -3.44174508
[68,] -1.54174508 -9.27031651
[69,] -4.78203593 -1.54174508
[70,] -1.33203593 -4.78203593
[71,] 0.16796407 -1.33203593
[72,] -5.02437981 0.16796407
[73,] 4.44704876 -5.02437981
[74,] -1.93866553 4.44704876
[75,] 6.58990590 -1.93866553
[76,] -0.25295124 6.58990590
[77,] 3.83276305 -0.25295124
[78,] 6.45825492 3.83276305
[79,] 0.62968349 6.45825492
[80,] 5.45825492 0.62968349
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -6.07450813 -2.34593670
2 -6.36022241 -6.07450813
3 -5.53165098 -6.36022241
4 0.02549187 -5.53165098
5 -5.38879384 0.02549187
6 -0.16330197 -5.38879384
7 8.80812660 -0.16330197
8 -7.06330197 8.80812660
9 9.69640719 -7.06330197
10 -11.45359281 9.69640719
11 -14.25359281 -11.45359281
12 -6.74593670 -14.25359281
13 -6.47450813 -6.74593670
14 -11.76022241 -6.47450813
15 -8.93165098 -11.76022241
16 -4.47450813 -8.93165098
17 -12.68879384 -4.47450813
18 -5.76330197 -12.68879384
19 -9.59187340 -5.76330197
20 -12.16330197 -9.59187340
21 -15.40359281 -12.16330197
22 -4.45359281 -15.40359281
23 -2.55359281 -4.45359281
24 -7.84593670 -2.55359281
25 -5.77450813 -7.84593670
26 -3.16022241 -5.77450813
27 -1.83165098 -3.16022241
28 -11.47450813 -1.83165098
29 -9.38879384 -11.47450813
30 -7.46330197 -9.38879384
31 1.90812660 -7.46330197
32 -0.76330197 1.90812660
33 4.19640719 -0.76330197
34 -1.15359281 4.19640719
35 -3.35359281 -1.15359281
36 1.25406330 -3.35359281
37 -1.67450813 1.25406330
38 0.33977759 -1.67450813
39 -1.73165098 0.33977759
40 -8.87450813 -1.73165098
41 -3.68879384 -8.87450813
42 4.83669803 -3.68879384
43 2.20812660 4.83669803
44 4.53669803 2.20812660
45 -5.90359281 4.53669803
46 3.14640719 -5.90359281
47 3.14640719 3.14640719
48 4.45406330 3.14640719
49 4.42549187 4.45406330
50 6.83977759 4.42549187
51 -2.83165098 6.83977759
52 10.92549187 -2.83165098
53 5.91120616 10.92549187
54 5.53669803 5.91120616
55 5.30812660 5.53669803
56 11.53669803 5.30812660
57 12.19640719 11.53669803
58 15.24640719 12.19640719
59 16.84640719 15.24640719
60 16.25406330 16.84640719
61 11.12549187 16.25406330
62 16.03977759 11.12549187
63 14.26834902 16.03977759
64 14.12549187 14.26834902
65 21.41120616 14.12549187
66 -3.44174508 21.41120616
67 -9.27031651 -3.44174508
68 -1.54174508 -9.27031651
69 -4.78203593 -1.54174508
70 -1.33203593 -4.78203593
71 0.16796407 -1.33203593
72 -5.02437981 0.16796407
73 4.44704876 -5.02437981
74 -1.93866553 4.44704876
75 6.58990590 -1.93866553
76 -0.25295124 6.58990590
77 3.83276305 -0.25295124
78 6.45825492 3.83276305
79 0.62968349 6.45825492
80 5.45825492 0.62968349
> 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/freestat/rcomp/tmp/77ybk1229327094.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/freestat/rcomp/tmp/874vh1229327094.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/freestat/rcomp/tmp/9pux11229327094.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/freestat/rcomp/tmp/10x9c11229327094.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11h0ig1229327094.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/freestat/rcomp/tmp/12exff1229327094.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/freestat/rcomp/tmp/135sjw1229327094.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/freestat/rcomp/tmp/14x32n1229327094.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/freestat/rcomp/tmp/15nx1m1229327094.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/freestat/rcomp/tmp/16q3rv1229327095.tab")
+ }
>
> system("convert tmp/182u51229327094.ps tmp/182u51229327094.png")
> system("convert tmp/29gd91229327094.ps tmp/29gd91229327094.png")
> system("convert tmp/3bkxg1229327094.ps tmp/3bkxg1229327094.png")
> system("convert tmp/46m161229327094.ps tmp/46m161229327094.png")
> system("convert tmp/5hmf31229327094.ps tmp/5hmf31229327094.png")
> system("convert tmp/6jhea1229327094.ps tmp/6jhea1229327094.png")
> system("convert tmp/77ybk1229327094.ps tmp/77ybk1229327094.png")
> system("convert tmp/874vh1229327094.ps tmp/874vh1229327094.png")
> system("convert tmp/9pux11229327094.ps tmp/9pux11229327094.png")
> system("convert tmp/10x9c11229327094.ps tmp/10x9c11229327094.png")
>
>
> proc.time()
user system elapsed
3.947 2.491 4.920