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(.6
+ ,21.3
+ ,9.5
+ ,9.2
+ ,9.2
+ ,10
+ ,9.5
+ ,21.3
+ ,9.6
+ ,9.5
+ ,9.2
+ ,9.2
+ ,9.1
+ ,19.1
+ ,9.5
+ ,9.6
+ ,9.5
+ ,9.2
+ ,8.9
+ ,19.1
+ ,9.1
+ ,9.5
+ ,9.6
+ ,9.5
+ ,9
+ ,19.1
+ ,8.9
+ ,9.1
+ ,9.5
+ ,9.6
+ ,10.1
+ ,26.2
+ ,9
+ ,8.9
+ ,9.1
+ ,9.5
+ ,10.3
+ ,26.2
+ ,10.1
+ ,9
+ ,8.9
+ ,9.1
+ ,10.2
+ ,26.2
+ ,10.3
+ ,10.1
+ ,9
+ ,8.9
+ ,9.6
+ ,21.7
+ ,10.2
+ ,10.3
+ ,10.1
+ ,9
+ ,9.2
+ ,21.7
+ ,9.6
+ ,10.2
+ ,10.3
+ ,10.1
+ ,9.3
+ ,21.7
+ ,9.2
+ ,9.6
+ ,10.2
+ ,10.3
+ ,9.4
+ ,19.4
+ ,9.3
+ ,9.2
+ ,9.6
+ ,10.2
+ ,9.4
+ ,19.4
+ ,9.4
+ ,9.3
+ ,9.2
+ ,9.6
+ ,9.2
+ ,19.4
+ ,9.4
+ ,9.4
+ ,9.3
+ ,9.2
+ ,9
+ ,19.5
+ ,9.2
+ ,9.4
+ ,9.4
+ ,9.3
+ ,9
+ ,19.5
+ ,9
+ ,9.2
+ ,9.4
+ ,9.4
+ ,9
+ ,19.5
+ ,9
+ ,9
+ ,9.2
+ ,9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(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 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.1 7.6 0 0 0 0 1 0 0 0 0 0 0 41
42 8.2 24.1 6.9 6.5 6.8 7.1 0 0 0 0 0 1 0 0 0 0 0 42
43 8.7 24.1 8.2 6.9 6.5 6.8 0 0 0 0 0 0 1 0 0 0 0 43
44 8.3 24.1 8.7 8.2 6.9 6.5 0 0 0 0 0 0 0 1 0 0 0 44
45 7.9 19.9 8.3 8.7 8.2 6.9 0 0 0 0 0 0 0 0 1 0 0 45
46 7.5 19.9 7.9 8.3 8.7 8.2 0 0 0 0 0 0 0 0 0 1 0 46
47 7.8 19.9 7.5 7.9 8.3 8.7 0 0 0 0 0 0 0 0 0 0 1 47
48 8.3 22.3 7.8 7.5 7.9 8.3 0 0 0 0 0 0 0 0 0 0 0 48
49 8.4 22.3 8.3 7.8 7.5 7.9 1 0 0 0 0 0 0 0 0 0 0 49
50 8.2 22.3 8.4 8.3 7.8 7.5 0 1 0 0 0 0 0 0 0 0 0 50
51 7.7 20.9 8.2 8.4 8.3 7.8 0 0 1 0 0 0 0 0 0 0 0 51
52 7.2 20.9 7.7 8.2 8.4 8.3 0 0 0 1 0 0 0 0 0 0 0 52
53 7.3 20.9 7.2 7.7 8.2 8.4 0 0 0 0 1 0 0 0 0 0 0 53
54 8.1 25.5 7.3 7.2 7.7 8.2 0 0 0 0 0 1 0 0 0 0 0 54
55 8.5 25.5 8.1 7.3 7.2 7.7 0 0 0 0 0 0 1 0 0 0 0 55
56 8.4 25.5 8.5 8.1 7.3 7.2 0 0 0 0 0 0 0 1 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)`
-3.40052 -0.13454 2.11095 -0.90879 0.92880 -0.53688
M1 M2 M3 M4 M5 M6
-1.77522 -0.30326 -0.39849 -0.23313 0.27972 1.73438
M7 M8 M9 M10 M11 t
0.30510 0.18227 -0.75254 -0.32473 0.38443 0.03695
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.26463 -0.35249 0.08024 0.35698 1.92358
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.40052 5.92212 -0.574 0.5692
X -0.13454 0.15339 -0.877 0.3859
`Y(t-1)` 2.11095 1.27951 1.650 0.1072
`Y(t-2)` -0.90879 1.81483 -0.501 0.6194
`Y(t-3)` 0.92880 1.80258 0.515 0.6094
`Y(t-4)` -0.53688 1.00774 -0.533 0.5973
M1 -1.77522 0.93386 -1.901 0.0649 .
M2 -0.30326 0.98106 -0.309 0.7589
M3 -0.39849 0.99313 -0.401 0.6905
M4 -0.23313 0.97474 -0.239 0.8123
M5 0.27972 1.01000 0.277 0.7833
M6 1.73438 1.50645 1.151 0.2568
M7 0.30510 1.12250 0.272 0.7872
M8 0.18227 1.43692 0.127 0.8997
M9 -0.75254 1.30444 -0.577 0.5674
M10 -0.32473 1.04908 -0.310 0.7586
M11 0.38443 1.00227 0.384 0.7034
t 0.03695 0.03377 1.094 0.2807
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.252 on 38 degrees of freedom
Multiple R-squared: 0.4426, Adjusted R-squared: 0.1932
F-statistic: 1.775 on 17 and 38 DF, p-value: 0.07047
> 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,] 1.0000000 1.155536e-09 5.777680e-10
[2,] 1.0000000 3.627801e-11 1.813900e-11
[3,] 1.0000000 2.262003e-10 1.131002e-10
[4,] 1.0000000 8.975218e-10 4.487609e-10
[5,] 1.0000000 5.425425e-09 2.712713e-09
[6,] 1.0000000 6.445485e-09 3.222743e-09
[7,] 1.0000000 1.753978e-09 8.769888e-10
[8,] 1.0000000 4.545302e-09 2.272651e-09
[9,] 1.0000000 4.396664e-08 2.198332e-08
[10,] 1.0000000 1.079537e-08 5.397687e-09
[11,] 0.9999999 1.244186e-07 6.220932e-08
[12,] 0.9999990 1.990778e-06 9.953892e-07
[13,] 0.9999930 1.400090e-05 7.000449e-06
[14,] 0.9999904 1.929755e-05 9.648774e-06
[15,] 0.9998455 3.090829e-04 1.545414e-04
> postscript(file="/var/www/html/rcomp/tmp/10x8g1258665031.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/228p61258665031.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/37a2o1258665031.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/4xofo1258665031.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/5s9n01258665031.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
-6.264633401 0.758495717 0.144114160 0.563496913 0.318936610 0.807573573
7 8 9 10 11 12
0.139743558 0.502852482 -0.379874234 0.335879004 0.189134666 0.256139734
13 14 15 16 17 18
1.923581924 -0.002078142 0.252654796 0.344471116 -0.201329440 0.423255370
19 20 21 22 23 24
0.219448619 0.410176490 -0.259410297 0.093303300 -0.180777098 0.108905951
25 26 27 28 29 30
1.646277771 0.067185839 0.482400239 -0.277309762 -0.391852210 -1.211284486
31 32 33 34 35 36
-0.359238854 0.300453259 1.097461337 0.179330720 -0.074563063 -0.761598072
37 38 39 40 41 42
1.086023383 -0.473356378 -0.108576878 -0.207041392 0.307137029 0.394516920
43 44 45 46 47 48
0.023702872 -0.697041938 -0.458176806 -0.608513025 0.066205495 0.396552387
49 50 51 52 53 54
1.608750322 -0.350247036 -0.770592317 -0.423616875 -0.032891990 -0.414061376
55 56
-0.023656195 -0.516440293
> postscript(file="/var/www/html/rcomp/tmp/6x04m1258665031.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 -6.264633401 NA
1 0.758495717 -6.264633401
2 0.144114160 0.758495717
3 0.563496913 0.144114160
4 0.318936610 0.563496913
5 0.807573573 0.318936610
6 0.139743558 0.807573573
7 0.502852482 0.139743558
8 -0.379874234 0.502852482
9 0.335879004 -0.379874234
10 0.189134666 0.335879004
11 0.256139734 0.189134666
12 1.923581924 0.256139734
13 -0.002078142 1.923581924
14 0.252654796 -0.002078142
15 0.344471116 0.252654796
16 -0.201329440 0.344471116
17 0.423255370 -0.201329440
18 0.219448619 0.423255370
19 0.410176490 0.219448619
20 -0.259410297 0.410176490
21 0.093303300 -0.259410297
22 -0.180777098 0.093303300
23 0.108905951 -0.180777098
24 1.646277771 0.108905951
25 0.067185839 1.646277771
26 0.482400239 0.067185839
27 -0.277309762 0.482400239
28 -0.391852210 -0.277309762
29 -1.211284486 -0.391852210
30 -0.359238854 -1.211284486
31 0.300453259 -0.359238854
32 1.097461337 0.300453259
33 0.179330720 1.097461337
34 -0.074563063 0.179330720
35 -0.761598072 -0.074563063
36 1.086023383 -0.761598072
37 -0.473356378 1.086023383
38 -0.108576878 -0.473356378
39 -0.207041392 -0.108576878
40 0.307137029 -0.207041392
41 0.394516920 0.307137029
42 0.023702872 0.394516920
43 -0.697041938 0.023702872
44 -0.458176806 -0.697041938
45 -0.608513025 -0.458176806
46 0.066205495 -0.608513025
47 0.396552387 0.066205495
48 1.608750322 0.396552387
49 -0.350247036 1.608750322
50 -0.770592317 -0.350247036
51 -0.423616875 -0.770592317
52 -0.032891990 -0.423616875
53 -0.414061376 -0.032891990
54 -0.023656195 -0.414061376
55 -0.516440293 -0.023656195
56 NA -0.516440293
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.758495717 -6.264633401
[2,] 0.144114160 0.758495717
[3,] 0.563496913 0.144114160
[4,] 0.318936610 0.563496913
[5,] 0.807573573 0.318936610
[6,] 0.139743558 0.807573573
[7,] 0.502852482 0.139743558
[8,] -0.379874234 0.502852482
[9,] 0.335879004 -0.379874234
[10,] 0.189134666 0.335879004
[11,] 0.256139734 0.189134666
[12,] 1.923581924 0.256139734
[13,] -0.002078142 1.923581924
[14,] 0.252654796 -0.002078142
[15,] 0.344471116 0.252654796
[16,] -0.201329440 0.344471116
[17,] 0.423255370 -0.201329440
[18,] 0.219448619 0.423255370
[19,] 0.410176490 0.219448619
[20,] -0.259410297 0.410176490
[21,] 0.093303300 -0.259410297
[22,] -0.180777098 0.093303300
[23,] 0.108905951 -0.180777098
[24,] 1.646277771 0.108905951
[25,] 0.067185839 1.646277771
[26,] 0.482400239 0.067185839
[27,] -0.277309762 0.482400239
[28,] -0.391852210 -0.277309762
[29,] -1.211284486 -0.391852210
[30,] -0.359238854 -1.211284486
[31,] 0.300453259 -0.359238854
[32,] 1.097461337 0.300453259
[33,] 0.179330720 1.097461337
[34,] -0.074563063 0.179330720
[35,] -0.761598072 -0.074563063
[36,] 1.086023383 -0.761598072
[37,] -0.473356378 1.086023383
[38,] -0.108576878 -0.473356378
[39,] -0.207041392 -0.108576878
[40,] 0.307137029 -0.207041392
[41,] 0.394516920 0.307137029
[42,] 0.023702872 0.394516920
[43,] -0.697041938 0.023702872
[44,] -0.458176806 -0.697041938
[45,] -0.608513025 -0.458176806
[46,] 0.066205495 -0.608513025
[47,] 0.396552387 0.066205495
[48,] 1.608750322 0.396552387
[49,] -0.350247036 1.608750322
[50,] -0.770592317 -0.350247036
[51,] -0.423616875 -0.770592317
[52,] -0.032891990 -0.423616875
[53,] -0.414061376 -0.032891990
[54,] -0.023656195 -0.414061376
[55,] -0.516440293 -0.023656195
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.758495717 -6.264633401
2 0.144114160 0.758495717
3 0.563496913 0.144114160
4 0.318936610 0.563496913
5 0.807573573 0.318936610
6 0.139743558 0.807573573
7 0.502852482 0.139743558
8 -0.379874234 0.502852482
9 0.335879004 -0.379874234
10 0.189134666 0.335879004
11 0.256139734 0.189134666
12 1.923581924 0.256139734
13 -0.002078142 1.923581924
14 0.252654796 -0.002078142
15 0.344471116 0.252654796
16 -0.201329440 0.344471116
17 0.423255370 -0.201329440
18 0.219448619 0.423255370
19 0.410176490 0.219448619
20 -0.259410297 0.410176490
21 0.093303300 -0.259410297
22 -0.180777098 0.093303300
23 0.108905951 -0.180777098
24 1.646277771 0.108905951
25 0.067185839 1.646277771
26 0.482400239 0.067185839
27 -0.277309762 0.482400239
28 -0.391852210 -0.277309762
29 -1.211284486 -0.391852210
30 -0.359238854 -1.211284486
31 0.300453259 -0.359238854
32 1.097461337 0.300453259
33 0.179330720 1.097461337
34 -0.074563063 0.179330720
35 -0.761598072 -0.074563063
36 1.086023383 -0.761598072
37 -0.473356378 1.086023383
38 -0.108576878 -0.473356378
39 -0.207041392 -0.108576878
40 0.307137029 -0.207041392
41 0.394516920 0.307137029
42 0.023702872 0.394516920
43 -0.697041938 0.023702872
44 -0.458176806 -0.697041938
45 -0.608513025 -0.458176806
46 0.066205495 -0.608513025
47 0.396552387 0.066205495
48 1.608750322 0.396552387
49 -0.350247036 1.608750322
50 -0.770592317 -0.350247036
51 -0.423616875 -0.770592317
52 -0.032891990 -0.423616875
53 -0.414061376 -0.032891990
54 -0.023656195 -0.414061376
55 -0.516440293 -0.023656195
> 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/7xr991258665031.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/8mdoz1258665031.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/9i2ap1258665031.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/108sj91258665031.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/11wunm1258665032.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/12u99c1258665032.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/13g1z01258665032.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/1466qb1258665032.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/15lyjo1258665032.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/16vp9k1258665032.tab")
+ }
>
> system("convert tmp/10x8g1258665031.ps tmp/10x8g1258665031.png")
> system("convert tmp/228p61258665031.ps tmp/228p61258665031.png")
> system("convert tmp/37a2o1258665031.ps tmp/37a2o1258665031.png")
> system("convert tmp/4xofo1258665031.ps tmp/4xofo1258665031.png")
> system("convert tmp/5s9n01258665031.ps tmp/5s9n01258665031.png")
> system("convert tmp/6x04m1258665031.ps tmp/6x04m1258665031.png")
> system("convert tmp/7xr991258665031.ps tmp/7xr991258665031.png")
> system("convert tmp/8mdoz1258665031.ps tmp/8mdoz1258665031.png")
> system("convert tmp/9i2ap1258665031.ps tmp/9i2ap1258665031.png")
> system("convert tmp/108sj91258665031.ps tmp/108sj91258665031.png")
>
>
> proc.time()
user system elapsed
2.363 1.574 2.747