R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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
+ ,1
+ ,3
+ ,2
+ ,3
+ ,2
+ ,1
+ ,3
+ ,2
+ ,1
+ ,3
+ ,2
+ ,2
+ ,1
+ ,1
+ ,3
+ ,2
+ ,2
+ ,4
+ ,3
+ ,3
+ ,4
+ ,4
+ ,5
+ ,3
+ ,2
+ ,2
+ ,2
+ ,2
+ ,2
+ ,1
+ ,1
+ ,3
+ ,2
+ ,4
+ ,2
+ ,2
+ ,2
+ ,2
+ ,2
+ ,3
+ ,2
+ ,3
+ ,1
+ ,1
+ ,1
+ ,2
+ ,1
+ ,4
+ ,1
+ ,3
+ ,1
+ ,1
+ ,2
+ ,4
+ ,1
+ ,4
+ ,2
+ ,2
+ ,1
+ ,2
+ ,2
+ ,2
+ ,1
+ ,4
+ ,1
+ ,1
+ ,1
+ ,1
+ ,3
+ ,1
+ ,1
+ ,2
+ ,2
+ ,3
+ ,1
+ ,2
+ ,2
+ ,2
+ ,3
+ ,4
+ ,2
+ ,3
+ ,1
+ ,3
+ ,4
+ ,1
+ ,2
+ ,4
+ ,2
+ ,2
+ ,1
+ ,1
+ ,2
+ ,1
+ ,2
+ ,4
+ ,2
+ ,4
+ ,1
+ ,3
+ ,4
+ ,3
+ ,1
+ ,3
+ ,2
+ ,3
+ ,2
+ ,3
+ ,1
+ ,1
+ ,3
+ ,3
+ ,2
+ ,2
+ ,1
+ ,2
+ ,2
+ ,3
+ ,2
+ ,4
+ ,2
+ ,2
+ ,1
+ ,1
+ ,2
+ ,3
+ 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ong'),1:55))
> 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 = '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
> 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
Life G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df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Gender Stress Depression Effort Focus
4.6132758 -0.1171177 -0.0999051 -0.8191584 0.2275689 0.0518302
Sleep Belong
-0.0008586 -0.1124101
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.4800 -0.4259 0.1914 0.4161 0.7994
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.6132758 0.4612803 10.001 3.19e-13 ***
Gender -0.1171177 0.1790477 -0.654 0.5162
Stress -0.0999051 0.1023522 -0.976 0.3340
Depression -0.8191584 0.1478131 -5.542 1.32e-06 ***
Effort 0.2275689 0.1266531 1.797 0.0788 .
Focus 0.0518302 0.1007289 0.515 0.6093
Sleep -0.0008586 0.0847973 -0.010 0.9920
Belong -0.1124101 0.0889230 -1.264 0.2124
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.6005 on 47 degrees of freedom
Multiple R-squared: 0.4775, Adjusted R-squared: 0.3996
F-statistic: 6.135 on 7 and 47 DF, p-value: 4.035e-05
> 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.3421692 0.6843384 0.6578308
[2,] 0.6079121 0.7841757 0.3920879
[3,] 0.4864693 0.9729387 0.5135307
[4,] 0.6759058 0.6481885 0.3240942
[5,] 0.6268627 0.7462745 0.3731373
[6,] 0.5443114 0.9113772 0.4556886
[7,] 0.4837630 0.9675261 0.5162370
[8,] 0.6346416 0.7307169 0.3653584
[9,] 0.6339905 0.7320190 0.3660095
[10,] 0.5876922 0.8246156 0.4123078
[11,] 0.5479156 0.9041689 0.4520844
[12,] 0.4781018 0.9562035 0.5218982
[13,] 0.4388148 0.8776296 0.5611852
[14,] 0.3653262 0.7306525 0.6346738
[15,] 0.3350514 0.6701028 0.6649486
[16,] 0.3007371 0.6014741 0.6992629
[17,] 0.3011947 0.6023894 0.6988053
[18,] 0.2718959 0.5437917 0.7281041
[19,] 0.2140491 0.4280981 0.7859509
[20,] 0.2078119 0.4156238 0.7921881
[21,] 0.1878088 0.3756177 0.8121912
[22,] 0.1602780 0.3205559 0.8397220
[23,] 0.1656222 0.3312443 0.8343778
[24,] 0.1343608 0.2687217 0.8656392
[25,] 0.1096350 0.2192701 0.8903650
[26,] 0.1450141 0.2900281 0.8549859
[27,] 0.1506247 0.3012493 0.8493753
[28,] 0.3657309 0.7314618 0.6342691
[29,] 0.2966629 0.5933258 0.7033371
[30,] 0.2509407 0.5018814 0.7490593
[31,] 0.1748243 0.3496487 0.8251757
[32,] 0.1329754 0.2659507 0.8670246
[33,] 0.1056328 0.2112656 0.8943672
[34,] 0.1292002 0.2584004 0.8707998
> postscript(file="/var/wessaorg/rcomp/tmp/1ab2s1322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2by761322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3i1ex1322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4khz41322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5b7z91322147733.ps",horizontal=F,onefile=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
-1.00640458 -0.72700548 0.15351194 0.01355680 0.32663556 -0.42543885
7 8 9 10 11 12
0.40733039 0.19525698 0.15311440 -1.48001782 0.07548426 0.53437740
13 14 15 16 17 18
0.06469638 0.16254329 -0.69147440 0.42368444 0.47379753 0.79938128
19 20 21 22 23 24
-0.52534392 0.25677479 0.47551464 0.20776198 -0.36400042 0.28910685
25 26 27 28 29 30
0.15665602 0.40671356 -0.80859207 0.57774466 0.24419041 0.63277072
31 32 33 34 35 36
-0.59713549 0.45240917 0.64850457 0.19140793 -0.40042885 -0.02373599
37 38 39 40 41 42
-0.62900431 -0.81030918 0.29430350 0.37099569 -0.42053823 0.55459977
43 44 45 46 47 48
0.70426699 0.53609451 -0.50465829 0.46994848 0.40843067 -0.95411114
49 50 51 52 53 54
-1.42919417 -0.50323069 -0.42647051 0.20776198 0.62177747 -0.16422012
55
0.40020946
> postscript(file="/var/wessaorg/rcomp/tmp/67ppb1322147733.ps",horizontal=F,onefile=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 -1.00640458 NA
1 -0.72700548 -1.00640458
2 0.15351194 -0.72700548
3 0.01355680 0.15351194
4 0.32663556 0.01355680
5 -0.42543885 0.32663556
6 0.40733039 -0.42543885
7 0.19525698 0.40733039
8 0.15311440 0.19525698
9 -1.48001782 0.15311440
10 0.07548426 -1.48001782
11 0.53437740 0.07548426
12 0.06469638 0.53437740
13 0.16254329 0.06469638
14 -0.69147440 0.16254329
15 0.42368444 -0.69147440
16 0.47379753 0.42368444
17 0.79938128 0.47379753
18 -0.52534392 0.79938128
19 0.25677479 -0.52534392
20 0.47551464 0.25677479
21 0.20776198 0.47551464
22 -0.36400042 0.20776198
23 0.28910685 -0.36400042
24 0.15665602 0.28910685
25 0.40671356 0.15665602
26 -0.80859207 0.40671356
27 0.57774466 -0.80859207
28 0.24419041 0.57774466
29 0.63277072 0.24419041
30 -0.59713549 0.63277072
31 0.45240917 -0.59713549
32 0.64850457 0.45240917
33 0.19140793 0.64850457
34 -0.40042885 0.19140793
35 -0.02373599 -0.40042885
36 -0.62900431 -0.02373599
37 -0.81030918 -0.62900431
38 0.29430350 -0.81030918
39 0.37099569 0.29430350
40 -0.42053823 0.37099569
41 0.55459977 -0.42053823
42 0.70426699 0.55459977
43 0.53609451 0.70426699
44 -0.50465829 0.53609451
45 0.46994848 -0.50465829
46 0.40843067 0.46994848
47 -0.95411114 0.40843067
48 -1.42919417 -0.95411114
49 -0.50323069 -1.42919417
50 -0.42647051 -0.50323069
51 0.20776198 -0.42647051
52 0.62177747 0.20776198
53 -0.16422012 0.62177747
54 0.40020946 -0.16422012
55 NA 0.40020946
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.72700548 -1.00640458
[2,] 0.15351194 -0.72700548
[3,] 0.01355680 0.15351194
[4,] 0.32663556 0.01355680
[5,] -0.42543885 0.32663556
[6,] 0.40733039 -0.42543885
[7,] 0.19525698 0.40733039
[8,] 0.15311440 0.19525698
[9,] -1.48001782 0.15311440
[10,] 0.07548426 -1.48001782
[11,] 0.53437740 0.07548426
[12,] 0.06469638 0.53437740
[13,] 0.16254329 0.06469638
[14,] -0.69147440 0.16254329
[15,] 0.42368444 -0.69147440
[16,] 0.47379753 0.42368444
[17,] 0.79938128 0.47379753
[18,] -0.52534392 0.79938128
[19,] 0.25677479 -0.52534392
[20,] 0.47551464 0.25677479
[21,] 0.20776198 0.47551464
[22,] -0.36400042 0.20776198
[23,] 0.28910685 -0.36400042
[24,] 0.15665602 0.28910685
[25,] 0.40671356 0.15665602
[26,] -0.80859207 0.40671356
[27,] 0.57774466 -0.80859207
[28,] 0.24419041 0.57774466
[29,] 0.63277072 0.24419041
[30,] -0.59713549 0.63277072
[31,] 0.45240917 -0.59713549
[32,] 0.64850457 0.45240917
[33,] 0.19140793 0.64850457
[34,] -0.40042885 0.19140793
[35,] -0.02373599 -0.40042885
[36,] -0.62900431 -0.02373599
[37,] -0.81030918 -0.62900431
[38,] 0.29430350 -0.81030918
[39,] 0.37099569 0.29430350
[40,] -0.42053823 0.37099569
[41,] 0.55459977 -0.42053823
[42,] 0.70426699 0.55459977
[43,] 0.53609451 0.70426699
[44,] -0.50465829 0.53609451
[45,] 0.46994848 -0.50465829
[46,] 0.40843067 0.46994848
[47,] -0.95411114 0.40843067
[48,] -1.42919417 -0.95411114
[49,] -0.50323069 -1.42919417
[50,] -0.42647051 -0.50323069
[51,] 0.20776198 -0.42647051
[52,] 0.62177747 0.20776198
[53,] -0.16422012 0.62177747
[54,] 0.40020946 -0.16422012
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.72700548 -1.00640458
2 0.15351194 -0.72700548
3 0.01355680 0.15351194
4 0.32663556 0.01355680
5 -0.42543885 0.32663556
6 0.40733039 -0.42543885
7 0.19525698 0.40733039
8 0.15311440 0.19525698
9 -1.48001782 0.15311440
10 0.07548426 -1.48001782
11 0.53437740 0.07548426
12 0.06469638 0.53437740
13 0.16254329 0.06469638
14 -0.69147440 0.16254329
15 0.42368444 -0.69147440
16 0.47379753 0.42368444
17 0.79938128 0.47379753
18 -0.52534392 0.79938128
19 0.25677479 -0.52534392
20 0.47551464 0.25677479
21 0.20776198 0.47551464
22 -0.36400042 0.20776198
23 0.28910685 -0.36400042
24 0.15665602 0.28910685
25 0.40671356 0.15665602
26 -0.80859207 0.40671356
27 0.57774466 -0.80859207
28 0.24419041 0.57774466
29 0.63277072 0.24419041
30 -0.59713549 0.63277072
31 0.45240917 -0.59713549
32 0.64850457 0.45240917
33 0.19140793 0.64850457
34 -0.40042885 0.19140793
35 -0.02373599 -0.40042885
36 -0.62900431 -0.02373599
37 -0.81030918 -0.62900431
38 0.29430350 -0.81030918
39 0.37099569 0.29430350
40 -0.42053823 0.37099569
41 0.55459977 -0.42053823
42 0.70426699 0.55459977
43 0.53609451 0.70426699
44 -0.50465829 0.53609451
45 0.46994848 -0.50465829
46 0.40843067 0.46994848
47 -0.95411114 0.40843067
48 -1.42919417 -0.95411114
49 -0.50323069 -1.42919417
50 -0.42647051 -0.50323069
51 0.20776198 -0.42647051
52 0.62177747 0.20776198
53 -0.16422012 0.62177747
54 0.40020946 -0.16422012
> 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/wessaorg/rcomp/tmp/75y561322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/87bth1322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/9mway1322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10vh4d1322147733.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11ijb31322147733.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/wessaorg/rcomp/tmp/120a7b1322147733.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/wessaorg/rcomp/tmp/13i7kp1322147733.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/wessaorg/rcomp/tmp/14wa111322147733.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/wessaorg/rcomp/tmp/15978g1322147733.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/wessaorg/rcomp/tmp/16i2x51322147733.tab")
+ }
>
> try(system("convert tmp/1ab2s1322147733.ps tmp/1ab2s1322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/2by761322147733.ps tmp/2by761322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/3i1ex1322147733.ps tmp/3i1ex1322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/4khz41322147733.ps tmp/4khz41322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/5b7z91322147733.ps tmp/5b7z91322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/67ppb1322147733.ps tmp/67ppb1322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/75y561322147733.ps tmp/75y561322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/87bth1322147733.ps tmp/87bth1322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/9mway1322147733.ps tmp/9mway1322147733.png",intern=TRUE))
character(0)
> try(system("convert tmp/10vh4d1322147733.ps tmp/10vh4d1322147733.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.233 0.489 3.776