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(98.6,0,98,0,106.8,0,96.6,0,100.1,0,107.7,0,91.5,0,97.8,0,107.4,1,117.5,1,105.6,1,97.4,1,99.5,1,98,1,104.3,1,100.6,1,101.1,1,103.9,1,96.9,1,95.5,1,108.4,1,117,1,103.8,1,100.8,1,110.6,1,104,1,112.6,1,107.3,1,98.9,1,109.8,1,104.9,1,102.2,1,123.9,1,124.9,1,112.7,1,121.9,1,100.6,1,104.3,1,120.4,1,107.5,1,102.9,1,125.6,1,107.5,1,108.8,1,128.4,1,121.1,1,119.5,1,128.7,1,108.7,1,105.5,1,119.8,1,111.3,1,110.6,1,120.1,1,97.5,1,107.7,1,127.3,1,117.2,1,119.8,1,116.2,1,111,1,112.4,1,130.6,1,109.1,1,118.8,1,123.9,1,101.6,1,112.8,1,128,1,129.6,1,125.8,1,119.5,1),dim=c(2,72),dimnames=list(c('x','y'),1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('x','y'),1:72))
> 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
x y M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 98.6 0 1 0 0 0 0 0 0 0 0 0 0
2 98.0 0 0 1 0 0 0 0 0 0 0 0 0
3 106.8 0 0 0 1 0 0 0 0 0 0 0 0
4 96.6 0 0 0 0 1 0 0 0 0 0 0 0
5 100.1 0 0 0 0 0 1 0 0 0 0 0 0
6 107.7 0 0 0 0 0 0 1 0 0 0 0 0
7 91.5 0 0 0 0 0 0 0 1 0 0 0 0
8 97.8 0 0 0 0 0 0 0 0 1 0 0 0
9 107.4 1 0 0 0 0 0 0 0 0 1 0 0
10 117.5 1 0 0 0 0 0 0 0 0 0 1 0
11 105.6 1 0 0 0 0 0 0 0 0 0 0 1
12 97.4 1 0 0 0 0 0 0 0 0 0 0 0
13 99.5 1 1 0 0 0 0 0 0 0 0 0 0
14 98.0 1 0 1 0 0 0 0 0 0 0 0 0
15 104.3 1 0 0 1 0 0 0 0 0 0 0 0
16 100.6 1 0 0 0 1 0 0 0 0 0 0 0
17 101.1 1 0 0 0 0 1 0 0 0 0 0 0
18 103.9 1 0 0 0 0 0 1 0 0 0 0 0
19 96.9 1 0 0 0 0 0 0 1 0 0 0 0
20 95.5 1 0 0 0 0 0 0 0 1 0 0 0
21 108.4 1 0 0 0 0 0 0 0 0 1 0 0
22 117.0 1 0 0 0 0 0 0 0 0 0 1 0
23 103.8 1 0 0 0 0 0 0 0 0 0 0 1
24 100.8 1 0 0 0 0 0 0 0 0 0 0 0
25 110.6 1 1 0 0 0 0 0 0 0 0 0 0
26 104.0 1 0 1 0 0 0 0 0 0 0 0 0
27 112.6 1 0 0 1 0 0 0 0 0 0 0 0
28 107.3 1 0 0 0 1 0 0 0 0 0 0 0
29 98.9 1 0 0 0 0 1 0 0 0 0 0 0
30 109.8 1 0 0 0 0 0 1 0 0 0 0 0
31 104.9 1 0 0 0 0 0 0 1 0 0 0 0
32 102.2 1 0 0 0 0 0 0 0 1 0 0 0
33 123.9 1 0 0 0 0 0 0 0 0 1 0 0
34 124.9 1 0 0 0 0 0 0 0 0 0 1 0
35 112.7 1 0 0 0 0 0 0 0 0 0 0 1
36 121.9 1 0 0 0 0 0 0 0 0 0 0 0
37 100.6 1 1 0 0 0 0 0 0 0 0 0 0
38 104.3 1 0 1 0 0 0 0 0 0 0 0 0
39 120.4 1 0 0 1 0 0 0 0 0 0 0 0
40 107.5 1 0 0 0 1 0 0 0 0 0 0 0
41 102.9 1 0 0 0 0 1 0 0 0 0 0 0
42 125.6 1 0 0 0 0 0 1 0 0 0 0 0
43 107.5 1 0 0 0 0 0 0 1 0 0 0 0
44 108.8 1 0 0 0 0 0 0 0 1 0 0 0
45 128.4 1 0 0 0 0 0 0 0 0 1 0 0
46 121.1 1 0 0 0 0 0 0 0 0 0 1 0
47 119.5 1 0 0 0 0 0 0 0 0 0 0 1
48 128.7 1 0 0 0 0 0 0 0 0 0 0 0
49 108.7 1 1 0 0 0 0 0 0 0 0 0 0
50 105.5 1 0 1 0 0 0 0 0 0 0 0 0
51 119.8 1 0 0 1 0 0 0 0 0 0 0 0
52 111.3 1 0 0 0 1 0 0 0 0 0 0 0
53 110.6 1 0 0 0 0 1 0 0 0 0 0 0
54 120.1 1 0 0 0 0 0 1 0 0 0 0 0
55 97.5 1 0 0 0 0 0 0 1 0 0 0 0
56 107.7 1 0 0 0 0 0 0 0 1 0 0 0
57 127.3 1 0 0 0 0 0 0 0 0 1 0 0
58 117.2 1 0 0 0 0 0 0 0 0 0 1 0
59 119.8 1 0 0 0 0 0 0 0 0 0 0 1
60 116.2 1 0 0 0 0 0 0 0 0 0 0 0
61 111.0 1 1 0 0 0 0 0 0 0 0 0 0
62 112.4 1 0 1 0 0 0 0 0 0 0 0 0
63 130.6 1 0 0 1 0 0 0 0 0 0 0 0
64 109.1 1 0 0 0 1 0 0 0 0 0 0 0
65 118.8 1 0 0 0 0 1 0 0 0 0 0 0
66 123.9 1 0 0 0 0 0 1 0 0 0 0 0
67 101.6 1 0 0 0 0 0 0 1 0 0 0 0
68 112.8 1 0 0 0 0 0 0 0 1 0 0 0
69 128.0 1 0 0 0 0 0 0 0 0 1 0 0
70 129.6 1 0 0 0 0 0 0 0 0 0 1 0
71 125.8 1 0 0 0 0 0 0 0 0 0 0 1
72 119.5 1 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) y M1 M2 M3 M4
105.493 8.590 -7.818 -8.952 3.098 -7.252
M5 M6 M7 M8 M9 M10
-7.252 2.515 -12.668 -8.518 6.483 7.133
M11
0.450
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-16.6833 -4.2912 0.7467 4.5350 14.6167
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 105.493 4.240 24.882 < 2e-16 ***
y 8.590 2.918 2.944 0.00463 **
M1 -7.818 4.377 -1.786 0.07920 .
M2 -8.952 4.377 -2.045 0.04531 *
M3 3.098 4.377 0.708 0.48182
M4 -7.252 4.377 -1.657 0.10288
M5 -7.252 4.377 -1.657 0.10288
M6 2.515 4.377 0.575 0.56776
M7 -12.668 4.377 -2.894 0.00532 **
M8 -8.518 4.377 -1.946 0.05641 .
M9 6.483 4.350 1.490 0.14144
M10 7.133 4.350 1.640 0.10636
M11 0.450 4.350 0.103 0.91796
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7.534 on 59 degrees of freedom
Multiple R-squared: 0.541, Adjusted R-squared: 0.4477
F-statistic: 5.796 on 12 and 59 DF, p-value: 1.697e-06
> 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.0231735592 0.0463471183 0.97682644
[2,] 0.0049885973 0.0099771945 0.99501140
[3,] 0.0045704950 0.0091409901 0.99542950
[4,] 0.0046736263 0.0093472525 0.99532637
[5,] 0.0023384768 0.0046769537 0.99766152
[6,] 0.0012371277 0.0024742554 0.99876287
[7,] 0.0003941527 0.0007883055 0.99960585
[8,] 0.0002398685 0.0004797370 0.99976013
[9,] 0.0005355573 0.0010711145 0.99946444
[10,] 0.0261634088 0.0523268177 0.97383659
[11,] 0.0254582810 0.0509165619 0.97454172
[12,] 0.0401802966 0.0803605931 0.95981970
[13,] 0.0546241467 0.1092482933 0.94537585
[14,] 0.0614661689 0.1229323378 0.93853383
[15,] 0.0869965783 0.1739931567 0.91300342
[16,] 0.1427914656 0.2855829312 0.85720853
[17,] 0.1427024279 0.2854048557 0.85729757
[18,] 0.4344286760 0.8688573519 0.56557132
[19,] 0.4316994316 0.8633988633 0.56830057
[20,] 0.5189138504 0.9621722992 0.48108615
[21,] 0.8441506379 0.3116987242 0.15584936
[22,] 0.8565165392 0.2869669215 0.14348346
[23,] 0.8250752113 0.3498495775 0.17492479
[24,] 0.8461562103 0.3076875794 0.15384379
[25,] 0.8054567315 0.3890865370 0.19454327
[26,] 0.8684288994 0.2631422013 0.13157110
[27,] 0.9127553554 0.1744892892 0.08724464
[28,] 0.9267061441 0.1465877118 0.07329386
[29,] 0.9047687682 0.1904624637 0.09523123
[30,] 0.9056994501 0.1886010999 0.09430055
[31,] 0.8623798873 0.2752402254 0.13762011
[32,] 0.8453987436 0.3092025127 0.15460126
[33,] 0.9455523229 0.1088953542 0.05444768
[34,] 0.9129920519 0.1740158962 0.08700795
[35,] 0.8926094777 0.2147810446 0.10739052
[36,] 0.9226853953 0.1546292094 0.07731460
[37,] 0.8736863885 0.2526272230 0.12631361
[38,] 0.8724818183 0.2550363634 0.12751818
[39,] 0.8031675461 0.3936649077 0.19683245
[40,] 0.7034107765 0.5931784470 0.29658922
[41,] 0.5852653783 0.8294692433 0.41473462
> postscript(file="/var/www/html/freestat/rcomp/tmp/19f5f1227777357.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/2rzd51227777357.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/3iyhf1227777357.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/4s3wl1227777357.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/52um11227777357.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 = 72
Frequency = 1
1 2 3 4 5 6
0.9250000 1.4583333 -1.7916667 -1.6416667 1.8583333 -0.3083333
7 8 9 10 11 12
-1.3250000 0.8250000 -13.1666667 -3.7166667 -8.9333333 -16.6833333
13 14 15 16 17 18
-6.7650000 -7.1316667 -12.8816667 -6.2316667 -5.7316667 -12.6983333
19 20 21 22 23 24
-4.5150000 -10.0650000 -12.1666667 -4.2166667 -10.7333333 -13.2833333
25 26 27 28 29 30
4.3350000 -1.1316667 -4.5816667 0.4683333 -7.9316667 -6.7983333
31 32 33 34 35 36
3.4850000 -3.3650000 3.3333333 3.6833333 -1.8333333 7.8166667
37 38 39 40 41 42
-5.6650000 -0.8316667 3.2183333 0.6683333 -3.9316667 9.0016667
43 44 45 46 47 48
6.0850000 3.2350000 7.8333333 -0.1166667 4.9666667 14.6166667
49 50 51 52 53 54
2.4350000 0.3683333 2.6183333 4.4683333 3.7683333 3.5016667
55 56 57 58 59 60
-3.9150000 2.1350000 6.7333333 -4.0166667 5.2666667 2.1166667
61 62 63 64 65 66
4.7350000 7.2683333 13.4183333 2.2683333 11.9683333 7.3016667
67 68 69 70 71 72
0.1850000 7.2350000 7.4333333 8.3833333 11.2666667 5.4166667
> postscript(file="/var/www/html/freestat/rcomp/tmp/60cyg1227777357.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 0.9250000 NA
1 1.4583333 0.9250000
2 -1.7916667 1.4583333
3 -1.6416667 -1.7916667
4 1.8583333 -1.6416667
5 -0.3083333 1.8583333
6 -1.3250000 -0.3083333
7 0.8250000 -1.3250000
8 -13.1666667 0.8250000
9 -3.7166667 -13.1666667
10 -8.9333333 -3.7166667
11 -16.6833333 -8.9333333
12 -6.7650000 -16.6833333
13 -7.1316667 -6.7650000
14 -12.8816667 -7.1316667
15 -6.2316667 -12.8816667
16 -5.7316667 -6.2316667
17 -12.6983333 -5.7316667
18 -4.5150000 -12.6983333
19 -10.0650000 -4.5150000
20 -12.1666667 -10.0650000
21 -4.2166667 -12.1666667
22 -10.7333333 -4.2166667
23 -13.2833333 -10.7333333
24 4.3350000 -13.2833333
25 -1.1316667 4.3350000
26 -4.5816667 -1.1316667
27 0.4683333 -4.5816667
28 -7.9316667 0.4683333
29 -6.7983333 -7.9316667
30 3.4850000 -6.7983333
31 -3.3650000 3.4850000
32 3.3333333 -3.3650000
33 3.6833333 3.3333333
34 -1.8333333 3.6833333
35 7.8166667 -1.8333333
36 -5.6650000 7.8166667
37 -0.8316667 -5.6650000
38 3.2183333 -0.8316667
39 0.6683333 3.2183333
40 -3.9316667 0.6683333
41 9.0016667 -3.9316667
42 6.0850000 9.0016667
43 3.2350000 6.0850000
44 7.8333333 3.2350000
45 -0.1166667 7.8333333
46 4.9666667 -0.1166667
47 14.6166667 4.9666667
48 2.4350000 14.6166667
49 0.3683333 2.4350000
50 2.6183333 0.3683333
51 4.4683333 2.6183333
52 3.7683333 4.4683333
53 3.5016667 3.7683333
54 -3.9150000 3.5016667
55 2.1350000 -3.9150000
56 6.7333333 2.1350000
57 -4.0166667 6.7333333
58 5.2666667 -4.0166667
59 2.1166667 5.2666667
60 4.7350000 2.1166667
61 7.2683333 4.7350000
62 13.4183333 7.2683333
63 2.2683333 13.4183333
64 11.9683333 2.2683333
65 7.3016667 11.9683333
66 0.1850000 7.3016667
67 7.2350000 0.1850000
68 7.4333333 7.2350000
69 8.3833333 7.4333333
70 11.2666667 8.3833333
71 5.4166667 11.2666667
72 NA 5.4166667
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.4583333 0.9250000
[2,] -1.7916667 1.4583333
[3,] -1.6416667 -1.7916667
[4,] 1.8583333 -1.6416667
[5,] -0.3083333 1.8583333
[6,] -1.3250000 -0.3083333
[7,] 0.8250000 -1.3250000
[8,] -13.1666667 0.8250000
[9,] -3.7166667 -13.1666667
[10,] -8.9333333 -3.7166667
[11,] -16.6833333 -8.9333333
[12,] -6.7650000 -16.6833333
[13,] -7.1316667 -6.7650000
[14,] -12.8816667 -7.1316667
[15,] -6.2316667 -12.8816667
[16,] -5.7316667 -6.2316667
[17,] -12.6983333 -5.7316667
[18,] -4.5150000 -12.6983333
[19,] -10.0650000 -4.5150000
[20,] -12.1666667 -10.0650000
[21,] -4.2166667 -12.1666667
[22,] -10.7333333 -4.2166667
[23,] -13.2833333 -10.7333333
[24,] 4.3350000 -13.2833333
[25,] -1.1316667 4.3350000
[26,] -4.5816667 -1.1316667
[27,] 0.4683333 -4.5816667
[28,] -7.9316667 0.4683333
[29,] -6.7983333 -7.9316667
[30,] 3.4850000 -6.7983333
[31,] -3.3650000 3.4850000
[32,] 3.3333333 -3.3650000
[33,] 3.6833333 3.3333333
[34,] -1.8333333 3.6833333
[35,] 7.8166667 -1.8333333
[36,] -5.6650000 7.8166667
[37,] -0.8316667 -5.6650000
[38,] 3.2183333 -0.8316667
[39,] 0.6683333 3.2183333
[40,] -3.9316667 0.6683333
[41,] 9.0016667 -3.9316667
[42,] 6.0850000 9.0016667
[43,] 3.2350000 6.0850000
[44,] 7.8333333 3.2350000
[45,] -0.1166667 7.8333333
[46,] 4.9666667 -0.1166667
[47,] 14.6166667 4.9666667
[48,] 2.4350000 14.6166667
[49,] 0.3683333 2.4350000
[50,] 2.6183333 0.3683333
[51,] 4.4683333 2.6183333
[52,] 3.7683333 4.4683333
[53,] 3.5016667 3.7683333
[54,] -3.9150000 3.5016667
[55,] 2.1350000 -3.9150000
[56,] 6.7333333 2.1350000
[57,] -4.0166667 6.7333333
[58,] 5.2666667 -4.0166667
[59,] 2.1166667 5.2666667
[60,] 4.7350000 2.1166667
[61,] 7.2683333 4.7350000
[62,] 13.4183333 7.2683333
[63,] 2.2683333 13.4183333
[64,] 11.9683333 2.2683333
[65,] 7.3016667 11.9683333
[66,] 0.1850000 7.3016667
[67,] 7.2350000 0.1850000
[68,] 7.4333333 7.2350000
[69,] 8.3833333 7.4333333
[70,] 11.2666667 8.3833333
[71,] 5.4166667 11.2666667
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.4583333 0.9250000
2 -1.7916667 1.4583333
3 -1.6416667 -1.7916667
4 1.8583333 -1.6416667
5 -0.3083333 1.8583333
6 -1.3250000 -0.3083333
7 0.8250000 -1.3250000
8 -13.1666667 0.8250000
9 -3.7166667 -13.1666667
10 -8.9333333 -3.7166667
11 -16.6833333 -8.9333333
12 -6.7650000 -16.6833333
13 -7.1316667 -6.7650000
14 -12.8816667 -7.1316667
15 -6.2316667 -12.8816667
16 -5.7316667 -6.2316667
17 -12.6983333 -5.7316667
18 -4.5150000 -12.6983333
19 -10.0650000 -4.5150000
20 -12.1666667 -10.0650000
21 -4.2166667 -12.1666667
22 -10.7333333 -4.2166667
23 -13.2833333 -10.7333333
24 4.3350000 -13.2833333
25 -1.1316667 4.3350000
26 -4.5816667 -1.1316667
27 0.4683333 -4.5816667
28 -7.9316667 0.4683333
29 -6.7983333 -7.9316667
30 3.4850000 -6.7983333
31 -3.3650000 3.4850000
32 3.3333333 -3.3650000
33 3.6833333 3.3333333
34 -1.8333333 3.6833333
35 7.8166667 -1.8333333
36 -5.6650000 7.8166667
37 -0.8316667 -5.6650000
38 3.2183333 -0.8316667
39 0.6683333 3.2183333
40 -3.9316667 0.6683333
41 9.0016667 -3.9316667
42 6.0850000 9.0016667
43 3.2350000 6.0850000
44 7.8333333 3.2350000
45 -0.1166667 7.8333333
46 4.9666667 -0.1166667
47 14.6166667 4.9666667
48 2.4350000 14.6166667
49 0.3683333 2.4350000
50 2.6183333 0.3683333
51 4.4683333 2.6183333
52 3.7683333 4.4683333
53 3.5016667 3.7683333
54 -3.9150000 3.5016667
55 2.1350000 -3.9150000
56 6.7333333 2.1350000
57 -4.0166667 6.7333333
58 5.2666667 -4.0166667
59 2.1166667 5.2666667
60 4.7350000 2.1166667
61 7.2683333 4.7350000
62 13.4183333 7.2683333
63 2.2683333 13.4183333
64 11.9683333 2.2683333
65 7.3016667 11.9683333
66 0.1850000 7.3016667
67 7.2350000 0.1850000
68 7.4333333 7.2350000
69 8.3833333 7.4333333
70 11.2666667 8.3833333
71 5.4166667 11.2666667
> 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/7owuz1227777357.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/8lopd1227777357.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/9iadv1227777357.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/10xkhi1227777357.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/11f9ej1227777357.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/12725k1227777357.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/13n73h1227777357.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/14r3ho1227777357.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/151p6l1227777357.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/16qty21227777357.tab")
+ }
>
> system("convert tmp/19f5f1227777357.ps tmp/19f5f1227777357.png")
> system("convert tmp/2rzd51227777357.ps tmp/2rzd51227777357.png")
> system("convert tmp/3iyhf1227777357.ps tmp/3iyhf1227777357.png")
> system("convert tmp/4s3wl1227777357.ps tmp/4s3wl1227777357.png")
> system("convert tmp/52um11227777357.ps tmp/52um11227777357.png")
> system("convert tmp/60cyg1227777357.ps tmp/60cyg1227777357.png")
> system("convert tmp/7owuz1227777357.ps tmp/7owuz1227777357.png")
> system("convert tmp/8lopd1227777357.ps tmp/8lopd1227777357.png")
> system("convert tmp/9iadv1227777357.ps tmp/9iadv1227777357.png")
> system("convert tmp/10xkhi1227777357.ps tmp/10xkhi1227777357.png")
>
>
> proc.time()
user system elapsed
3.865 2.531 4.475