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.2
+ ,2.2
+ ,1.4
+ ,1.1
+ ,1.2
+ ,1.3
+ ,1.5
+ ,2.3
+ ,1.2
+ ,1.4
+ ,1.1
+ ,1.2
+ ,1.1
+ ,2.3
+ ,1.5
+ ,1.2
+ ,1.4
+ ,1.1
+ ,1.3
+ ,2.2
+ ,1.1
+ ,1.5
+ ,1.2
+ ,1.4
+ ,1.5
+ ,2.2
+ ,1.3
+ ,1.1
+ ,1.5
+ ,1.2
+ ,1.1
+ ,1.6
+ ,1.5
+ ,1.3
+ ,1.1
+ ,1.5
+ ,1.4
+ ,1.8
+ ,1.1
+ ,1.5
+ ,1.3
+ ,1.1
+ ,1.3
+ ,1.7
+ ,1.4
+ ,1.1
+ ,1.5
+ ,1.3
+ ,1.5
+ ,1.9
+ ,1.3
+ ,1.4
+ ,1.1
+ ,1.5
+ ,1.6
+ ,1.8
+ ,1.5
+ ,1.3
+ ,1.4
+ ,1.1
+ ,1.7
+ ,1.9
+ ,1.6
+ ,1.5
+ ,1.3
+ ,1.4
+ ,1.1
+ ,1.5
+ ,1.7
+ ,1.6
+ ,1.5
+ ,1.3
+ ,1.6
+ ,1
+ ,1.1
+ ,1.7
+ ,1.6
+ ,1.5
+ ,1.3
+ ,0.8
+ ,1.6
+ ,1.1
+ ,1.7
+ ,1.6
+ ,1.7
+ ,1.1
+ ,1.3
+ ,1.6
+ ,1.1
+ ,1.7
+ ,1.6
+ ,1.5
+ ,1.7
+ ,1.3
+ ,1.6
+ ,1.1
+ ,1.7
+ ,1.7
+ ,1.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onal 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.2 2.2 1.4 1.1 1.2 1.3 1
2 1.5 2.3 1.2 1.4 1.1 1.2 2
3 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2.5 2.4 39
40 2.5 8.5 2.2 2.6 2.5 2.5 40
41 2.8 8.7 2.5 2.2 2.6 2.5 41
42 2.8 8.7 2.8 2.5 2.2 2.6 42
43 2.9 8.5 2.8 2.8 2.5 2.2 43
44 3.0 7.9 2.9 2.8 2.8 2.5 44
45 3.1 7.0 3.0 2.9 2.8 2.8 45
46 2.9 5.8 3.1 3.0 2.9 2.8 46
47 2.7 4.5 2.9 3.1 3.0 2.9 47
48 2.2 3.7 2.7 2.9 3.1 3.0 48
49 2.5 3.1 2.2 2.7 2.9 3.1 49
50 2.3 2.7 2.5 2.2 2.7 2.9 50
51 2.6 2.3 2.3 2.5 2.2 2.7 51
52 2.3 1.8 2.6 2.3 2.5 2.2 52
53 2.2 1.5 2.3 2.6 2.3 2.5 53
54 1.8 1.2 2.2 2.3 2.6 2.3 54
55 1.8 1.0 1.8 2.2 2.3 2.6 55
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
0.445877 0.063046 0.333944 0.330677 -0.156979 0.062465
t
0.005603
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.45021 -0.09711 0.02512 0.11120 0.30529
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.445877 0.154899 2.878 0.005950 **
X 0.063046 0.015138 4.165 0.000129 ***
Y1 0.333944 0.139541 2.393 0.020664 *
Y2 0.330677 0.146354 2.259 0.028433 *
Y3 -0.156979 0.146334 -1.073 0.288750
Y4 0.062465 0.137012 0.456 0.650514
t 0.005603 0.004337 1.292 0.202532
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.1972 on 48 degrees of freedom
Multiple R-squared: 0.8778, Adjusted R-squared: 0.8625
F-statistic: 57.46 on 6 and 48 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.21142017 0.4228403 0.7885798
[2,] 0.31802406 0.6360481 0.6819759
[3,] 0.26843964 0.5368793 0.7315604
[4,] 0.54290382 0.9141924 0.4570962
[5,] 0.42227429 0.8445486 0.5777257
[6,] 0.32846788 0.6569358 0.6715321
[7,] 0.24686154 0.4937231 0.7531385
[8,] 0.18270514 0.3654103 0.8172949
[9,] 0.17620513 0.3524103 0.8237949
[10,] 0.11826493 0.2365299 0.8817351
[11,] 0.11424937 0.2284987 0.8857506
[12,] 0.17090209 0.3418042 0.8290979
[13,] 0.43298253 0.8659651 0.5670175
[14,] 0.44712164 0.8942433 0.5528784
[15,] 0.42911723 0.8582345 0.5708828
[16,] 0.41100485 0.8220097 0.5889951
[17,] 0.43897321 0.8779464 0.5610268
[18,] 0.37689493 0.7537899 0.6231051
[19,] 0.31309410 0.6261882 0.6869059
[20,] 0.28153470 0.5630694 0.7184653
[21,] 0.21472633 0.4294527 0.7852737
[22,] 0.17749029 0.3549806 0.8225097
[23,] 0.21190609 0.4238122 0.7880939
[24,] 0.16798262 0.3359652 0.8320174
[25,] 0.13348252 0.2669650 0.8665175
[26,] 0.13148594 0.2629719 0.8685141
[27,] 0.12899136 0.2579827 0.8710086
[28,] 0.09271681 0.1854336 0.9072832
[29,] 0.12583543 0.2516709 0.8741646
[30,] 0.20786171 0.4157234 0.7921383
[31,] 0.18403522 0.3680704 0.8159648
[32,] 0.23018116 0.4603623 0.7698188
[33,] 0.54982346 0.9003531 0.4501765
[34,] 0.74314242 0.5137152 0.2568576
[35,] 0.89017981 0.2196404 0.1098202
[36,] 0.85097993 0.2980401 0.1490201
> postscript(file="/var/www/html/rcomp/tmp/1mktw1261851216.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/2qc391261851216.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/37g751261851216.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/4qf611261851216.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/5e1ji1261851216.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 = 55
Frequency = 1
1 2 3 4 5 6
-0.114278910 0.131947464 -0.254363472 -0.069422652 0.250042752 -0.332187671
7 8 9 10 11 12
0.073423578 0.025115528 0.065809879 0.204869643 0.158994679 -0.450209890
13 14 15 16 17 18
0.246213874 -0.005894299 0.203999498 0.154771287 0.059356399 0.297129440
19 20 21 22 23 24
0.044681336 0.090453507 -0.190327106 -0.269614865 -0.020676128 -0.079946055
25 26 27 28 29 30
-0.034489433 0.216934021 0.052919434 -0.123579805 -0.248636806 -0.079427456
31 32 33 34 35 36
0.025707882 -0.290420687 -0.003463159 0.009595420 0.064401274 0.028391746
37 38 39 40 41 42
-0.125459876 0.001934922 -0.440104199 -0.064053222 0.265519828 -0.008507731
43 44 45 46 47 48
0.071374580 0.198559083 0.264496212 0.083784521 0.003314273 -0.309476023
49 50 51 52 53 54
0.218214043 0.084082047 0.305286673 0.075484809 -0.060359488 -0.254864620
55
-0.147046078
> postscript(file="/var/www/html/rcomp/tmp/6etjx1261851216.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 = 55
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.114278910 NA
1 0.131947464 -0.114278910
2 -0.254363472 0.131947464
3 -0.069422652 -0.254363472
4 0.250042752 -0.069422652
5 -0.332187671 0.250042752
6 0.073423578 -0.332187671
7 0.025115528 0.073423578
8 0.065809879 0.025115528
9 0.204869643 0.065809879
10 0.158994679 0.204869643
11 -0.450209890 0.158994679
12 0.246213874 -0.450209890
13 -0.005894299 0.246213874
14 0.203999498 -0.005894299
15 0.154771287 0.203999498
16 0.059356399 0.154771287
17 0.297129440 0.059356399
18 0.044681336 0.297129440
19 0.090453507 0.044681336
20 -0.190327106 0.090453507
21 -0.269614865 -0.190327106
22 -0.020676128 -0.269614865
23 -0.079946055 -0.020676128
24 -0.034489433 -0.079946055
25 0.216934021 -0.034489433
26 0.052919434 0.216934021
27 -0.123579805 0.052919434
28 -0.248636806 -0.123579805
29 -0.079427456 -0.248636806
30 0.025707882 -0.079427456
31 -0.290420687 0.025707882
32 -0.003463159 -0.290420687
33 0.009595420 -0.003463159
34 0.064401274 0.009595420
35 0.028391746 0.064401274
36 -0.125459876 0.028391746
37 0.001934922 -0.125459876
38 -0.440104199 0.001934922
39 -0.064053222 -0.440104199
40 0.265519828 -0.064053222
41 -0.008507731 0.265519828
42 0.071374580 -0.008507731
43 0.198559083 0.071374580
44 0.264496212 0.198559083
45 0.083784521 0.264496212
46 0.003314273 0.083784521
47 -0.309476023 0.003314273
48 0.218214043 -0.309476023
49 0.084082047 0.218214043
50 0.305286673 0.084082047
51 0.075484809 0.305286673
52 -0.060359488 0.075484809
53 -0.254864620 -0.060359488
54 -0.147046078 -0.254864620
55 NA -0.147046078
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.131947464 -0.114278910
[2,] -0.254363472 0.131947464
[3,] -0.069422652 -0.254363472
[4,] 0.250042752 -0.069422652
[5,] -0.332187671 0.250042752
[6,] 0.073423578 -0.332187671
[7,] 0.025115528 0.073423578
[8,] 0.065809879 0.025115528
[9,] 0.204869643 0.065809879
[10,] 0.158994679 0.204869643
[11,] -0.450209890 0.158994679
[12,] 0.246213874 -0.450209890
[13,] -0.005894299 0.246213874
[14,] 0.203999498 -0.005894299
[15,] 0.154771287 0.203999498
[16,] 0.059356399 0.154771287
[17,] 0.297129440 0.059356399
[18,] 0.044681336 0.297129440
[19,] 0.090453507 0.044681336
[20,] -0.190327106 0.090453507
[21,] -0.269614865 -0.190327106
[22,] -0.020676128 -0.269614865
[23,] -0.079946055 -0.020676128
[24,] -0.034489433 -0.079946055
[25,] 0.216934021 -0.034489433
[26,] 0.052919434 0.216934021
[27,] -0.123579805 0.052919434
[28,] -0.248636806 -0.123579805
[29,] -0.079427456 -0.248636806
[30,] 0.025707882 -0.079427456
[31,] -0.290420687 0.025707882
[32,] -0.003463159 -0.290420687
[33,] 0.009595420 -0.003463159
[34,] 0.064401274 0.009595420
[35,] 0.028391746 0.064401274
[36,] -0.125459876 0.028391746
[37,] 0.001934922 -0.125459876
[38,] -0.440104199 0.001934922
[39,] -0.064053222 -0.440104199
[40,] 0.265519828 -0.064053222
[41,] -0.008507731 0.265519828
[42,] 0.071374580 -0.008507731
[43,] 0.198559083 0.071374580
[44,] 0.264496212 0.198559083
[45,] 0.083784521 0.264496212
[46,] 0.003314273 0.083784521
[47,] -0.309476023 0.003314273
[48,] 0.218214043 -0.309476023
[49,] 0.084082047 0.218214043
[50,] 0.305286673 0.084082047
[51,] 0.075484809 0.305286673
[52,] -0.060359488 0.075484809
[53,] -0.254864620 -0.060359488
[54,] -0.147046078 -0.254864620
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.131947464 -0.114278910
2 -0.254363472 0.131947464
3 -0.069422652 -0.254363472
4 0.250042752 -0.069422652
5 -0.332187671 0.250042752
6 0.073423578 -0.332187671
7 0.025115528 0.073423578
8 0.065809879 0.025115528
9 0.204869643 0.065809879
10 0.158994679 0.204869643
11 -0.450209890 0.158994679
12 0.246213874 -0.450209890
13 -0.005894299 0.246213874
14 0.203999498 -0.005894299
15 0.154771287 0.203999498
16 0.059356399 0.154771287
17 0.297129440 0.059356399
18 0.044681336 0.297129440
19 0.090453507 0.044681336
20 -0.190327106 0.090453507
21 -0.269614865 -0.190327106
22 -0.020676128 -0.269614865
23 -0.079946055 -0.020676128
24 -0.034489433 -0.079946055
25 0.216934021 -0.034489433
26 0.052919434 0.216934021
27 -0.123579805 0.052919434
28 -0.248636806 -0.123579805
29 -0.079427456 -0.248636806
30 0.025707882 -0.079427456
31 -0.290420687 0.025707882
32 -0.003463159 -0.290420687
33 0.009595420 -0.003463159
34 0.064401274 0.009595420
35 0.028391746 0.064401274
36 -0.125459876 0.028391746
37 0.001934922 -0.125459876
38 -0.440104199 0.001934922
39 -0.064053222 -0.440104199
40 0.265519828 -0.064053222
41 -0.008507731 0.265519828
42 0.071374580 -0.008507731
43 0.198559083 0.071374580
44 0.264496212 0.198559083
45 0.083784521 0.264496212
46 0.003314273 0.083784521
47 -0.309476023 0.003314273
48 0.218214043 -0.309476023
49 0.084082047 0.218214043
50 0.305286673 0.084082047
51 0.075484809 0.305286673
52 -0.060359488 0.075484809
53 -0.254864620 -0.060359488
54 -0.147046078 -0.254864620
> 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/7jozp1261851216.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/8nl7c1261851216.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/9xz5n1261851216.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/10h2fp1261851216.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/118kzj1261851216.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/12zhpt1261851216.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/13uyna1261851216.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/14iz6b1261851216.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/15r2cg1261851216.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/16sq4j1261851216.tab")
+ }
>
> try(system("convert tmp/1mktw1261851216.ps tmp/1mktw1261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/2qc391261851216.ps tmp/2qc391261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/37g751261851216.ps tmp/37g751261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/4qf611261851216.ps tmp/4qf611261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/5e1ji1261851216.ps tmp/5e1ji1261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/6etjx1261851216.ps tmp/6etjx1261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/7jozp1261851216.ps tmp/7jozp1261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/8nl7c1261851216.ps tmp/8nl7c1261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/9xz5n1261851216.ps tmp/9xz5n1261851216.png",intern=TRUE))
character(0)
> try(system("convert tmp/10h2fp1261851216.ps tmp/10h2fp1261851216.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.338 1.552 3.938