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(1.5
+ ,7.2
+ ,1.5
+ ,1.6
+ ,1.8
+ ,1.6
+ ,1.3
+ ,7.4
+ ,1.5
+ ,1.5
+ ,1.6
+ ,1.8
+ ,1.4
+ ,8.8
+ ,1.3
+ ,1.5
+ ,1.5
+ ,1.6
+ ,1.4
+ ,9.3
+ ,1.4
+ ,1.3
+ ,1.5
+ ,1.5
+ ,1.3
+ ,9.3
+ ,1.4
+ ,1.4
+ ,1.3
+ ,1.5
+ ,1.3
+ ,8.7
+ ,1.3
+ ,1.4
+ ,1.4
+ ,1.3
+ ,1.2
+ ,8.2
+ ,1.3
+ ,1.3
+ ,1.4
+ ,1.4
+ ,1.1
+ ,8.3
+ ,1.2
+ ,1.3
+ ,1.3
+ ,1.4
+ ,1.4
+ ,8.5
+ ,1.1
+ ,1.2
+ ,1.3
+ ,1.3
+ ,1.2
+ ,8.6
+ ,1.4
+ ,1.1
+ ,1.2
+ ,1.3
+ ,1.5
+ ,8.5
+ ,1.2
+ ,1.4
+ ,1.1
+ ,1.2
+ ,1.1
+ ,8.2
+ ,1.5
+ ,1.2
+ ,1.4
+ ,1.1
+ ,1.3
+ ,8.1
+ ,1.1
+ ,1.5
+ ,1.2
+ ,1.4
+ ,1.5
+ ,7.9
+ ,1.3
+ ,1.1
+ ,1.5
+ ,1.2
+ ,1.1
+ ,8.6
+ ,1.5
+ ,1.3
+ ,1.1
+ ,1.5
+ ,1.4
+ ,8.7
+ ,1.1
+ ,1.5
+ ,1.3
+ ,1.1
+ ,1.3
+ ,8.7
+ ,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numeric(x[i,j])
+ }
+ }
> par3 = '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)[k+1] <- 't'
+ }
> x
Y X Y1 Y2 Y3 Y4 t
1 1.5 7.2 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37
38 1.7 7.2 1.9 2.0 2.0 1.7 38
39 1.8 7.5 1.7 1.9 2.0 2.0 39
40 1.9 7.3 1.8 1.7 1.9 2.0 40
41 1.7 7.0 1.9 1.8 1.7 1.9 41
42 2.0 7.0 1.7 1.9 1.8 1.7 42
43 2.1 7.0 2.0 1.7 1.9 1.8 43
44 2.4 7.2 2.1 2.0 1.7 1.9 44
45 2.5 7.3 2.4 2.1 2.0 1.7 45
46 2.5 7.1 2.5 2.4 2.1 2.0 46
47 2.6 6.8 2.5 2.5 2.4 2.1 47
48 2.2 6.4 2.6 2.5 2.5 2.4 48
49 2.5 6.1 2.2 2.6 2.5 2.5 49
50 2.8 6.5 2.5 2.2 2.6 2.5 50
51 2.8 7.7 2.8 2.5 2.2 2.6 51
52 2.9 7.9 2.8 2.8 2.5 2.2 52
53 3.0 7.5 2.9 2.8 2.8 2.5 53
54 3.1 6.9 3.0 2.9 2.8 2.8 54
55 2.9 6.6 3.1 3.0 2.9 2.8 55
56 2.7 6.9 2.9 3.1 3.0 2.9 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
0.184356 0.008188 0.379584 0.379742 -0.006031 -0.034905
t
0.009966
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.56334 -0.08161 0.01726 0.13600 0.38266
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.184356 0.593353 0.311 0.75734
X 0.008188 0.060502 0.135 0.89290
Y1 0.379584 0.147719 2.570 0.01327 *
Y2 0.379742 0.155574 2.441 0.01831 *
Y3 -0.006031 0.159721 -0.038 0.97003
Y4 -0.034905 0.145599 -0.240 0.81154
t 0.009966 0.003656 2.726 0.00887 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.1952 on 49 degrees of freedom
Multiple R-squared: 0.8889, Adjusted R-squared: 0.8753
F-statistic: 65.33 on 6 and 49 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.17007457 0.3401491 0.8299254
[2,] 0.19909309 0.3981862 0.8009069
[3,] 0.25457349 0.5091470 0.7454265
[4,] 0.15334410 0.3066882 0.8466559
[5,] 0.27003592 0.5400718 0.7299641
[6,] 0.19106591 0.3821318 0.8089341
[7,] 0.13432551 0.2686510 0.8656745
[8,] 0.08243495 0.1648699 0.9175651
[9,] 0.11327654 0.2265531 0.8867235
[10,] 0.14388758 0.2877752 0.8561124
[11,] 0.15755520 0.3151104 0.8424448
[12,] 0.58431992 0.8313602 0.4156801
[13,] 0.56336786 0.8732643 0.4366321
[14,] 0.49828848 0.9965770 0.5017115
[15,] 0.56940214 0.8611957 0.4305979
[16,] 0.53754125 0.9249175 0.4624588
[17,] 0.52534369 0.9493126 0.4746563
[18,] 0.60605566 0.7878887 0.3939443
[19,] 0.56195110 0.8760978 0.4380489
[20,] 0.65926676 0.6814665 0.3407332
[21,] 0.63994890 0.7201022 0.3600511
[22,] 0.66677708 0.6664458 0.3332229
[23,] 0.59748760 0.8050248 0.4025124
[24,] 0.50911693 0.9817661 0.4908831
[25,] 0.42108229 0.8421646 0.5789177
[26,] 0.51496672 0.9700666 0.4850333
[27,] 0.50241876 0.9951625 0.4975812
[28,] 0.44485187 0.8897037 0.5551481
[29,] 0.39900745 0.7980149 0.6009925
[30,] 0.32461432 0.6492286 0.6753857
[31,] 0.31252459 0.6250492 0.6874754
[32,] 0.32758121 0.6551624 0.6724188
[33,] 0.24810809 0.4962162 0.7518919
[34,] 0.32030607 0.6406121 0.6796939
[35,] 0.27010712 0.5402142 0.7298929
[36,] 0.22638096 0.4527619 0.7736190
[37,] 0.12944110 0.2588822 0.8705589
> postscript(file="/var/www/html/rcomp/tmp/12zid1258566698.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/2e5zq1258566698.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/3cpox1258566698.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/4e5q31258566698.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/520v31258566698.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.136463999 -0.031390758 0.115512444 0.135951606 -0.013194921 0.013332112
7 8 9 10 11 12
-0.051075399 -0.124505092 0.236333125 -0.050956017 0.197797272 -0.249320744
13 14 15 16 17 18
-0.011291630 0.251187777 -0.308315940 0.044028353 -0.019729243 0.100546816
19 20 21 22 23 24
0.141303865 0.126480575 -0.563340236 0.124053896 -0.142946944 0.171782132
25 26 27 28 29 30
0.007614607 0.001809919 0.182162538 -0.027516855 0.021639521 -0.282795492
31 32 33 34 35 36
-0.309663897 -0.070636662 -0.079724601 -0.038739622 0.211267092 0.052123188
37 38 39 40 41 42
-0.168706077 -0.331320166 -0.119380273 0.009677983 -0.278461052 0.043137382
43 44 45 46 47 48
0.099337861 0.238137493 0.170331221 0.021196302 0.081012024 -0.352562769
49 50 51 52 53 54
0.057277387 0.382660468 0.136149108 0.098469865 0.166101198 0.195586781
55 56
-0.087252546 -0.257638972
> postscript(file="/var/www/html/rcomp/tmp/6l42g1258566698.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.136463999 NA
1 -0.031390758 0.136463999
2 0.115512444 -0.031390758
3 0.135951606 0.115512444
4 -0.013194921 0.135951606
5 0.013332112 -0.013194921
6 -0.051075399 0.013332112
7 -0.124505092 -0.051075399
8 0.236333125 -0.124505092
9 -0.050956017 0.236333125
10 0.197797272 -0.050956017
11 -0.249320744 0.197797272
12 -0.011291630 -0.249320744
13 0.251187777 -0.011291630
14 -0.308315940 0.251187777
15 0.044028353 -0.308315940
16 -0.019729243 0.044028353
17 0.100546816 -0.019729243
18 0.141303865 0.100546816
19 0.126480575 0.141303865
20 -0.563340236 0.126480575
21 0.124053896 -0.563340236
22 -0.142946944 0.124053896
23 0.171782132 -0.142946944
24 0.007614607 0.171782132
25 0.001809919 0.007614607
26 0.182162538 0.001809919
27 -0.027516855 0.182162538
28 0.021639521 -0.027516855
29 -0.282795492 0.021639521
30 -0.309663897 -0.282795492
31 -0.070636662 -0.309663897
32 -0.079724601 -0.070636662
33 -0.038739622 -0.079724601
34 0.211267092 -0.038739622
35 0.052123188 0.211267092
36 -0.168706077 0.052123188
37 -0.331320166 -0.168706077
38 -0.119380273 -0.331320166
39 0.009677983 -0.119380273
40 -0.278461052 0.009677983
41 0.043137382 -0.278461052
42 0.099337861 0.043137382
43 0.238137493 0.099337861
44 0.170331221 0.238137493
45 0.021196302 0.170331221
46 0.081012024 0.021196302
47 -0.352562769 0.081012024
48 0.057277387 -0.352562769
49 0.382660468 0.057277387
50 0.136149108 0.382660468
51 0.098469865 0.136149108
52 0.166101198 0.098469865
53 0.195586781 0.166101198
54 -0.087252546 0.195586781
55 -0.257638972 -0.087252546
56 NA -0.257638972
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.031390758 0.136463999
[2,] 0.115512444 -0.031390758
[3,] 0.135951606 0.115512444
[4,] -0.013194921 0.135951606
[5,] 0.013332112 -0.013194921
[6,] -0.051075399 0.013332112
[7,] -0.124505092 -0.051075399
[8,] 0.236333125 -0.124505092
[9,] -0.050956017 0.236333125
[10,] 0.197797272 -0.050956017
[11,] -0.249320744 0.197797272
[12,] -0.011291630 -0.249320744
[13,] 0.251187777 -0.011291630
[14,] -0.308315940 0.251187777
[15,] 0.044028353 -0.308315940
[16,] -0.019729243 0.044028353
[17,] 0.100546816 -0.019729243
[18,] 0.141303865 0.100546816
[19,] 0.126480575 0.141303865
[20,] -0.563340236 0.126480575
[21,] 0.124053896 -0.563340236
[22,] -0.142946944 0.124053896
[23,] 0.171782132 -0.142946944
[24,] 0.007614607 0.171782132
[25,] 0.001809919 0.007614607
[26,] 0.182162538 0.001809919
[27,] -0.027516855 0.182162538
[28,] 0.021639521 -0.027516855
[29,] -0.282795492 0.021639521
[30,] -0.309663897 -0.282795492
[31,] -0.070636662 -0.309663897
[32,] -0.079724601 -0.070636662
[33,] -0.038739622 -0.079724601
[34,] 0.211267092 -0.038739622
[35,] 0.052123188 0.211267092
[36,] -0.168706077 0.052123188
[37,] -0.331320166 -0.168706077
[38,] -0.119380273 -0.331320166
[39,] 0.009677983 -0.119380273
[40,] -0.278461052 0.009677983
[41,] 0.043137382 -0.278461052
[42,] 0.099337861 0.043137382
[43,] 0.238137493 0.099337861
[44,] 0.170331221 0.238137493
[45,] 0.021196302 0.170331221
[46,] 0.081012024 0.021196302
[47,] -0.352562769 0.081012024
[48,] 0.057277387 -0.352562769
[49,] 0.382660468 0.057277387
[50,] 0.136149108 0.382660468
[51,] 0.098469865 0.136149108
[52,] 0.166101198 0.098469865
[53,] 0.195586781 0.166101198
[54,] -0.087252546 0.195586781
[55,] -0.257638972 -0.087252546
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.031390758 0.136463999
2 0.115512444 -0.031390758
3 0.135951606 0.115512444
4 -0.013194921 0.135951606
5 0.013332112 -0.013194921
6 -0.051075399 0.013332112
7 -0.124505092 -0.051075399
8 0.236333125 -0.124505092
9 -0.050956017 0.236333125
10 0.197797272 -0.050956017
11 -0.249320744 0.197797272
12 -0.011291630 -0.249320744
13 0.251187777 -0.011291630
14 -0.308315940 0.251187777
15 0.044028353 -0.308315940
16 -0.019729243 0.044028353
17 0.100546816 -0.019729243
18 0.141303865 0.100546816
19 0.126480575 0.141303865
20 -0.563340236 0.126480575
21 0.124053896 -0.563340236
22 -0.142946944 0.124053896
23 0.171782132 -0.142946944
24 0.007614607 0.171782132
25 0.001809919 0.007614607
26 0.182162538 0.001809919
27 -0.027516855 0.182162538
28 0.021639521 -0.027516855
29 -0.282795492 0.021639521
30 -0.309663897 -0.282795492
31 -0.070636662 -0.309663897
32 -0.079724601 -0.070636662
33 -0.038739622 -0.079724601
34 0.211267092 -0.038739622
35 0.052123188 0.211267092
36 -0.168706077 0.052123188
37 -0.331320166 -0.168706077
38 -0.119380273 -0.331320166
39 0.009677983 -0.119380273
40 -0.278461052 0.009677983
41 0.043137382 -0.278461052
42 0.099337861 0.043137382
43 0.238137493 0.099337861
44 0.170331221 0.238137493
45 0.021196302 0.170331221
46 0.081012024 0.021196302
47 -0.352562769 0.081012024
48 0.057277387 -0.352562769
49 0.382660468 0.057277387
50 0.136149108 0.382660468
51 0.098469865 0.136149108
52 0.166101198 0.098469865
53 0.195586781 0.166101198
54 -0.087252546 0.195586781
55 -0.257638972 -0.087252546
> 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/7f5ux1258566698.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/8fvh41258566698.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/9g92u1258566698.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/10mkee1258566698.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/1199h41258566698.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/12ka3s1258566698.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/131ino1258566698.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/14rja91258566698.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/15puke1258566698.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/16ruvw1258566698.tab")
+ }
>
> system("convert tmp/12zid1258566698.ps tmp/12zid1258566698.png")
> system("convert tmp/2e5zq1258566698.ps tmp/2e5zq1258566698.png")
> system("convert tmp/3cpox1258566698.ps tmp/3cpox1258566698.png")
> system("convert tmp/4e5q31258566698.ps tmp/4e5q31258566698.png")
> system("convert tmp/520v31258566698.ps tmp/520v31258566698.png")
> system("convert tmp/6l42g1258566698.ps tmp/6l42g1258566698.png")
> system("convert tmp/7f5ux1258566698.ps tmp/7f5ux1258566698.png")
> system("convert tmp/8fvh41258566698.ps tmp/8fvh41258566698.png")
> system("convert tmp/9g92u1258566698.ps tmp/9g92u1258566698.png")
> system("convert tmp/10mkee1258566698.ps tmp/10mkee1258566698.png")
>
>
> proc.time()
user system elapsed
2.461 1.604 3.105