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(2.40
+ ,2.00
+ ,1.70
+ ,1.00
+ ,1.20
+ ,1.40
+ ,2.00
+ ,2.00
+ ,2.40
+ ,1.70
+ ,1.00
+ ,1.20
+ ,2.10
+ ,2.00
+ ,2.00
+ ,2.40
+ ,1.70
+ ,1.00
+ ,2.00
+ ,2.00
+ ,2.10
+ ,2.00
+ ,2.40
+ ,1.70
+ ,1.80
+ ,2.00
+ ,2.00
+ ,2.10
+ ,2.00
+ ,2.40
+ ,2.70
+ ,2.00
+ ,1.80
+ ,2.00
+ ,2.10
+ ,2.00
+ ,2.30
+ ,2.00
+ ,2.70
+ ,1.80
+ ,2.00
+ ,2.10
+ ,1.90
+ ,2.00
+ ,2.30
+ ,2.70
+ ,1.80
+ ,2.00
+ ,2.00
+ ,2.00
+ ,1.90
+ ,2.30
+ ,2.70
+ ,1.80
+ ,2.30
+ ,2.00
+ ,2.00
+ ,1.90
+ ,2.30
+ ,2.70
+ ,2.80
+ ,2.00
+ ,2.30
+ ,2.00
+ ,1.90
+ ,2.30
+ ,2.40
+ ,2.00
+ ,2.80
+ ,2.30
+ ,2.00
+ ,1.90
+ ,2.30
+ ,2.00
+ ,2.40
+ ,2.80
+ ,2.30
+ ,2.00
+ ,2.70
+ ,2.00
+ ,2.30
+ ,2.40
+ ,2.80
+ ,2.30
+ ,2.70
+ ,2.00
+ ,2.70
+ ,2.30
+ ,2.40
+ ,2.80
+ ,2.90
+ ,2.00
+ ,2.70
+ ,2.70
+ ,2.30
+ ,2.40
+ ,3.00
+ ,2.00
+ ,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: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
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)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39 1.3 4.00 1.3 1.3 1.8 1.8
40 1.2 4.00 1.3 1.3 1.3 1.8
41 1.4 4.00 1.2 1.3 1.3 1.3
42 2.2 4.00 1.4 1.2 1.3 1.3
43 2.9 4.00 2.2 1.4 1.2 1.3
44 3.1 4.00 2.9 2.2 1.4 1.2
45 3.5 4.00 3.1 2.9 2.2 1.4
46 3.6 4.00 3.5 3.1 2.9 2.2
47 4.4 4.00 3.6 3.5 3.1 2.9
48 4.1 4.00 4.4 3.6 3.5 3.1
49 5.1 4.00 4.1 4.4 3.6 3.5
50 5.8 4.00 5.1 4.1 4.4 3.6
51 5.9 4.18 5.8 5.1 4.1 4.4
52 5.4 4.25 5.9 5.8 5.1 4.1
53 5.5 4.25 5.4 5.9 5.8 5.1
54 4.8 3.97 5.5 5.4 5.9 5.8
55 3.2 3.42 4.8 5.5 5.4 5.9
56 2.7 2.75 3.2 4.8 5.5 5.4
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X2 X3 X4 X5 X6
0.18504 0.07358 1.11584 -0.25694 0.27843 -0.29308
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.9539 -0.2401 -0.0617 0.3120 1.1997
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.18504 0.23166 0.799 0.4282
X2 0.07358 0.07253 1.014 0.3152
X3 1.11584 0.13542 8.240 7.1e-11 ***
X4 -0.25694 0.20705 -1.241 0.2204
X5 0.27843 0.21116 1.319 0.1933
X6 -0.29308 0.15631 -1.875 0.0666 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4429 on 50 degrees of freedom
Multiple R-squared: 0.8656, Adjusted R-squared: 0.8522
F-statistic: 64.41 on 5 and 50 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.4969747687 0.9939495374 0.5030252
[2,] 0.3352581250 0.6705162501 0.6647419
[3,] 0.4833349297 0.9666698595 0.5166651
[4,] 0.4050261405 0.8100522809 0.5949739
[5,] 0.3130670856 0.6261341713 0.6869329
[6,] 0.2917029574 0.5834059148 0.7082970
[7,] 0.2164662962 0.4329325924 0.7835337
[8,] 0.2385704096 0.4771408193 0.7614296
[9,] 0.2100696132 0.4201392264 0.7899304
[10,] 0.2582764157 0.5165528313 0.7417236
[11,] 0.1910797201 0.3821594403 0.8089203
[12,] 0.1594327534 0.3188655069 0.8405672
[13,] 0.1137352533 0.2274705066 0.8862647
[14,] 0.0782806326 0.1565612652 0.9217194
[15,] 0.1151780837 0.2303561674 0.8848219
[16,] 0.1049468138 0.2098936276 0.8950532
[17,] 0.0799646058 0.1599292115 0.9200354
[18,] 0.0547237147 0.1094474293 0.9452763
[19,] 0.0341851064 0.0683702127 0.9658149
[20,] 0.0233631030 0.0467262061 0.9766369
[21,] 0.0233175188 0.0466350376 0.9766825
[22,] 0.0161936103 0.0323872205 0.9838064
[23,] 0.0125892433 0.0251784867 0.9874108
[24,] 0.0084842139 0.0169684279 0.9915158
[25,] 0.0056513212 0.0113026424 0.9943487
[26,] 0.0031886777 0.0063773554 0.9968113
[27,] 0.0016028453 0.0032056906 0.9983972
[28,] 0.0007822916 0.0015645832 0.9992177
[29,] 0.0012987338 0.0025974677 0.9987013
[30,] 0.0006935433 0.0013870867 0.9993065
[31,] 0.0004024076 0.0008048152 0.9995976
[32,] 0.0002947663 0.0005895327 0.9997052
[33,] 0.0003223672 0.0006447345 0.9996776
[34,] 0.0008310852 0.0016621704 0.9991689
[35,] 0.0023524691 0.0047049382 0.9976475
[36,] 0.0031773723 0.0063547446 0.9968226
[37,] 0.0039530308 0.0079060616 0.9960470
[38,] 0.0089832389 0.0179664778 0.9910168
[39,] 0.0082241634 0.0164483267 0.9917758
> postscript(file="/var/www/html/rcomp/tmp/1uhru1259095530.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/2r86j1259095530.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/3eqy51259095530.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/4glh01259095530.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/5f7ib1259095530.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 = 56
Frequency = 1
1 2 3 4 5 6
0.50400587 -0.50015405 -0.02747483 -0.33158269 -0.07777662 0.87462312
7 8 9 10 11 12
-0.52387293 -0.21990937 -0.08555289 0.37522921 0.56031153 -0.46560181
13 14 15 16 17 18
-0.04501498 0.31250045 0.09838089 0.31176942 0.04792053 -0.69504380
19 20 21 22 23 24
0.26763849 0.46582127 0.18270364 0.04886869 -0.67575494 0.53661115
25 26 27 28 29 30
0.13610863 -0.12752552 -0.13669766 -0.15389514 -0.33101059 -0.18295674
31 32 33 34 35 36
0.23008378 0.01570587 -0.48843477 -0.05854848 -0.22386613 -0.06484956
37 38 39 40 41 42
-0.70992416 -0.13373182 -0.26956094 -0.23034539 -0.06530047 0.48583673
43 44 45 46 47 48
0.37239401 -0.08813625 0.10442564 -0.15096183 0.78969969 -0.43003707
49 50 51 52 53 54
1.19965801 0.51329545 0.39389571 -0.40933429 0.37245832 -0.36968278
55 56
-0.95390626 0.02649865
> postscript(file="/var/www/html/rcomp/tmp/6nmpk1259095530.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 0.50400587 NA
1 -0.50015405 0.50400587
2 -0.02747483 -0.50015405
3 -0.33158269 -0.02747483
4 -0.07777662 -0.33158269
5 0.87462312 -0.07777662
6 -0.52387293 0.87462312
7 -0.21990937 -0.52387293
8 -0.08555289 -0.21990937
9 0.37522921 -0.08555289
10 0.56031153 0.37522921
11 -0.46560181 0.56031153
12 -0.04501498 -0.46560181
13 0.31250045 -0.04501498
14 0.09838089 0.31250045
15 0.31176942 0.09838089
16 0.04792053 0.31176942
17 -0.69504380 0.04792053
18 0.26763849 -0.69504380
19 0.46582127 0.26763849
20 0.18270364 0.46582127
21 0.04886869 0.18270364
22 -0.67575494 0.04886869
23 0.53661115 -0.67575494
24 0.13610863 0.53661115
25 -0.12752552 0.13610863
26 -0.13669766 -0.12752552
27 -0.15389514 -0.13669766
28 -0.33101059 -0.15389514
29 -0.18295674 -0.33101059
30 0.23008378 -0.18295674
31 0.01570587 0.23008378
32 -0.48843477 0.01570587
33 -0.05854848 -0.48843477
34 -0.22386613 -0.05854848
35 -0.06484956 -0.22386613
36 -0.70992416 -0.06484956
37 -0.13373182 -0.70992416
38 -0.26956094 -0.13373182
39 -0.23034539 -0.26956094
40 -0.06530047 -0.23034539
41 0.48583673 -0.06530047
42 0.37239401 0.48583673
43 -0.08813625 0.37239401
44 0.10442564 -0.08813625
45 -0.15096183 0.10442564
46 0.78969969 -0.15096183
47 -0.43003707 0.78969969
48 1.19965801 -0.43003707
49 0.51329545 1.19965801
50 0.39389571 0.51329545
51 -0.40933429 0.39389571
52 0.37245832 -0.40933429
53 -0.36968278 0.37245832
54 -0.95390626 -0.36968278
55 0.02649865 -0.95390626
56 NA 0.02649865
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.50015405 0.50400587
[2,] -0.02747483 -0.50015405
[3,] -0.33158269 -0.02747483
[4,] -0.07777662 -0.33158269
[5,] 0.87462312 -0.07777662
[6,] -0.52387293 0.87462312
[7,] -0.21990937 -0.52387293
[8,] -0.08555289 -0.21990937
[9,] 0.37522921 -0.08555289
[10,] 0.56031153 0.37522921
[11,] -0.46560181 0.56031153
[12,] -0.04501498 -0.46560181
[13,] 0.31250045 -0.04501498
[14,] 0.09838089 0.31250045
[15,] 0.31176942 0.09838089
[16,] 0.04792053 0.31176942
[17,] -0.69504380 0.04792053
[18,] 0.26763849 -0.69504380
[19,] 0.46582127 0.26763849
[20,] 0.18270364 0.46582127
[21,] 0.04886869 0.18270364
[22,] -0.67575494 0.04886869
[23,] 0.53661115 -0.67575494
[24,] 0.13610863 0.53661115
[25,] -0.12752552 0.13610863
[26,] -0.13669766 -0.12752552
[27,] -0.15389514 -0.13669766
[28,] -0.33101059 -0.15389514
[29,] -0.18295674 -0.33101059
[30,] 0.23008378 -0.18295674
[31,] 0.01570587 0.23008378
[32,] -0.48843477 0.01570587
[33,] -0.05854848 -0.48843477
[34,] -0.22386613 -0.05854848
[35,] -0.06484956 -0.22386613
[36,] -0.70992416 -0.06484956
[37,] -0.13373182 -0.70992416
[38,] -0.26956094 -0.13373182
[39,] -0.23034539 -0.26956094
[40,] -0.06530047 -0.23034539
[41,] 0.48583673 -0.06530047
[42,] 0.37239401 0.48583673
[43,] -0.08813625 0.37239401
[44,] 0.10442564 -0.08813625
[45,] -0.15096183 0.10442564
[46,] 0.78969969 -0.15096183
[47,] -0.43003707 0.78969969
[48,] 1.19965801 -0.43003707
[49,] 0.51329545 1.19965801
[50,] 0.39389571 0.51329545
[51,] -0.40933429 0.39389571
[52,] 0.37245832 -0.40933429
[53,] -0.36968278 0.37245832
[54,] -0.95390626 -0.36968278
[55,] 0.02649865 -0.95390626
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.50015405 0.50400587
2 -0.02747483 -0.50015405
3 -0.33158269 -0.02747483
4 -0.07777662 -0.33158269
5 0.87462312 -0.07777662
6 -0.52387293 0.87462312
7 -0.21990937 -0.52387293
8 -0.08555289 -0.21990937
9 0.37522921 -0.08555289
10 0.56031153 0.37522921
11 -0.46560181 0.56031153
12 -0.04501498 -0.46560181
13 0.31250045 -0.04501498
14 0.09838089 0.31250045
15 0.31176942 0.09838089
16 0.04792053 0.31176942
17 -0.69504380 0.04792053
18 0.26763849 -0.69504380
19 0.46582127 0.26763849
20 0.18270364 0.46582127
21 0.04886869 0.18270364
22 -0.67575494 0.04886869
23 0.53661115 -0.67575494
24 0.13610863 0.53661115
25 -0.12752552 0.13610863
26 -0.13669766 -0.12752552
27 -0.15389514 -0.13669766
28 -0.33101059 -0.15389514
29 -0.18295674 -0.33101059
30 0.23008378 -0.18295674
31 0.01570587 0.23008378
32 -0.48843477 0.01570587
33 -0.05854848 -0.48843477
34 -0.22386613 -0.05854848
35 -0.06484956 -0.22386613
36 -0.70992416 -0.06484956
37 -0.13373182 -0.70992416
38 -0.26956094 -0.13373182
39 -0.23034539 -0.26956094
40 -0.06530047 -0.23034539
41 0.48583673 -0.06530047
42 0.37239401 0.48583673
43 -0.08813625 0.37239401
44 0.10442564 -0.08813625
45 -0.15096183 0.10442564
46 0.78969969 -0.15096183
47 -0.43003707 0.78969969
48 1.19965801 -0.43003707
49 0.51329545 1.19965801
50 0.39389571 0.51329545
51 -0.40933429 0.39389571
52 0.37245832 -0.40933429
53 -0.36968278 0.37245832
54 -0.95390626 -0.36968278
55 0.02649865 -0.95390626
> 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/7cltl1259095530.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/8x46o1259095530.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/9fm2u1259095530.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/10tqvy1259095530.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/111h611259095530.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/12vrjg1259095531.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/134n9p1259095531.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/1456x71259095531.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/15y4v21259095531.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/16y98c1259095531.tab")
+ }
>
> system("convert tmp/1uhru1259095530.ps tmp/1uhru1259095530.png")
> system("convert tmp/2r86j1259095530.ps tmp/2r86j1259095530.png")
> system("convert tmp/3eqy51259095530.ps tmp/3eqy51259095530.png")
> system("convert tmp/4glh01259095530.ps tmp/4glh01259095530.png")
> system("convert tmp/5f7ib1259095530.ps tmp/5f7ib1259095530.png")
> system("convert tmp/6nmpk1259095530.ps tmp/6nmpk1259095530.png")
> system("convert tmp/7cltl1259095530.ps tmp/7cltl1259095530.png")
> system("convert tmp/8x46o1259095530.ps tmp/8x46o1259095530.png")
> system("convert tmp/9fm2u1259095530.ps tmp/9fm2u1259095530.png")
> system("convert tmp/10tqvy1259095530.ps tmp/10tqvy1259095530.png")
>
>
> proc.time()
user system elapsed
2.399 1.544 4.327