R version 2.12.0 (2010-10-15)
Copyright (C) 2010 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(6.3
+ ,2.0
+ ,4.5
+ ,1.000
+ ,6.600
+ ,42.0
+ ,3
+ ,1
+ ,3
+ ,2.1
+ ,1.8
+ ,69.0
+ ,2547.000
+ ,44.500
+ ,624.0
+ ,3
+ ,5
+ ,4
+ ,9.1
+ ,0.7
+ ,27.0
+ ,10.55
+ ,179.500
+ ,180.0
+ ,4
+ ,4
+ ,4
+ ,15.8
+ ,3.9
+ ,19.0
+ ,0.023
+ ,0.300
+ ,35.0
+ ,1
+ ,1
+ ,1
+ ,5.2
+ ,1.0
+ ,30.4
+ ,160.000
+ ,169.000
+ ,392.0
+ ,4
+ ,5
+ ,4
+ ,10.9
+ ,3.6
+ ,28.0
+ ,3.300
+ ,25.600
+ ,63.0
+ ,1
+ ,2
+ ,1
+ ,8.3
+ ,1.4
+ ,50.0
+ ,52.16
+ ,440.000
+ ,230.0
+ ,1
+ ,1
+ ,1
+ ,11.0
+ ,1.5
+ ,7.0
+ ,0.425
+ ,6.400
+ ,112.0
+ ,5
+ ,4
+ ,4
+ ,3.2
+ ,0.7
+ ,30.0
+ ,465.000
+ ,423.000
+ ,281.0
+ ,5
+ ,5
+ ,5
+ ,6.3
+ ,2.1
+ ,3.5
+ ,0.075
+ ,1.200
+ ,42.0
+ ,1
+ ,1
+ ,1
+ ,6.6
+ ,4.1
+ ,6.0
+ ,0.785
+ ,3.500
+ ,42.0
+ ,2
+ ,2
+ ,2
+ ,9.5
+ ,1.2
+ ,10.4
+ ,0.200
+ ,5.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(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
SWS PS L Wb Wbr Tg P S D
1 6.3 2.0 4.5 1.000 6.60 42 3 1 3
2 2.1 1.8 69.0 2547.000 44.50 624 3 5 4
3 9.1 0.7 27.0 10.550 179.50 180 4 4 4
4 15.8 3.9 19.0 0.023 0.30 35 1 1 1
5 5.2 1.0 30.4 160.000 169.00 392 4 5 4
6 10.9 3.6 28.0 3.300 25.60 63 1 2 1
7 8.3 1.4 50.0 52.160 440.00 230 1 1 1
8 11.0 1.5 7.0 0.425 6.40 112 5 4 4
9 3.2 0.7 30.0 465.000 423.00 281 5 5 5
10 6.3 2.1 3.5 0.075 1.20 42 1 1 1
11 6.6 4.1 6.0 0.785 3.50 42 2 2 2
12 9.5 1.2 10.4 0.200 5.00 120 2 2 2
13 3.3 0.5 20.0 27.660 115.00 148 5 5 5
14 11.0 3.4 3.9 0.120 1.00 16 3 1 2
15 4.7 1.5 41.0 85.000 325.00 310 1 3 1
16 10.4 3.4 9.0 0.101 4.00 28 5 1 3
17 7.4 0.8 7.6 1.040 5.50 68 5 3 4
18 2.1 0.8 46.0 521.000 655.00 336 5 5 5
19 17.9 2.0 24.0 0.010 0.25 50 1 1 1
20 6.1 1.9 100.0 62.000 1320.00 267 1 1 1
21 11.9 1.3 3.2 0.023 0.40 19 4 1 3
22 13.8 5.6 5.0 1.700 6.30 12 2 1 1
23 14.3 3.1 6.5 3.500 10.80 120 2 1 1
24 15.2 1.8 12.0 0.480 15.50 140 2 2 2
25 10.0 0.9 20.2 10.000 115.00 170 4 4 4
26 11.9 1.8 13.0 1.620 11.40 17 2 1 2
27 6.5 1.9 27.0 192.000 180.00 115 4 4 4
28 7.5 0.9 18.0 2.500 12.30 31 5 5 5
29 10.6 2.6 4.7 0.280 1.90 21 3 1 3
30 7.4 2.4 9.8 4.235 50.40 52 1 1 1
31 8.4 1.2 29.0 6.800 179.00 164 2 3 2
32 5.7 0.9 7.0 0.750 12.30 225 2 2 2
33 4.9 0.5 6.0 3.600 21.00 225 3 2 3
34 3.2 0.6 20.0 55.500 175.00 151 5 5 5
35 11.0 2.3 4.5 0.900 2.60 60 2 1 2
36 4.9 0.5 7.5 2.000 12.30 200 3 1 3
37 13.2 2.6 2.3 0.104 2.50 46 3 2 2
38 9.7 0.6 24.0 4.190 58.00 210 4 3 4
39 12.8 6.6 3.0 3.500 3.90 14 2 1 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) PS L Wb Wbr Tg
10.15919 0.19638 0.16770 -0.00252 -0.01304 -0.01110
P S D
1.96413 -0.23619 -2.57507
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3.5295 -2.1296 -0.0603 1.8407 6.1262
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.159193 2.727578 3.725 0.000809 ***
PS 0.196377 0.560304 0.350 0.728425
L 0.167700 0.069236 2.422 0.021681 *
Wb -0.002520 0.002376 -1.061 0.297365
Wbr -0.013038 0.004686 -2.782 0.009242 **
Tg -0.011098 0.007921 -1.401 0.171442
P 1.964131 1.109124 1.771 0.086741 .
S -0.236195 0.644834 -0.366 0.716721
D -2.575065 1.514544 -1.700 0.099435 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.684 on 30 degrees of freedom
Multiple R-squared: 0.6389, Adjusted R-squared: 0.5426
F-statistic: 6.635 on 8 and 30 DF, p-value: 5.479e-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.7364308 0.5271384 0.2635692
[2,] 0.7459161 0.5081678 0.2540839
[3,] 0.6428553 0.7142895 0.3571447
[4,] 0.6628078 0.6743843 0.3371922
[5,] 0.7301842 0.5396317 0.2698158
[6,] 0.6738305 0.6523390 0.3261695
[7,] 0.6249780 0.7500440 0.3750220
[8,] 0.7334654 0.5330693 0.2665346
[9,] 0.6440623 0.7118754 0.3559377
[10,] 0.5405960 0.9188081 0.4594040
[11,] 0.4627012 0.9254025 0.5372988
[12,] 0.4080149 0.8160298 0.5919851
[13,] 0.7863016 0.4273969 0.2136984
[14,] 0.8665197 0.2669606 0.1334803
[15,] 0.7499798 0.5000404 0.2500202
[16,] 0.5926763 0.8146475 0.4073237
> postscript(file="/var/www/rcomp/tmp/1cxz11292249041.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/www/rcomp/tmp/25oy41292249041.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/www/rcomp/tmp/35oy41292249041.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/www/rcomp/tmp/45oy41292249041.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/www/rcomp/tmp/5fyf71292249041.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 = 39
Frequency = 1
1 2 3 4 5 6
-2.38292623 -0.47109809 2.02845239 2.92814989 0.32801095 -2.53718779
7 8 9 10 11 12
-1.25135150 2.12418253 1.91339787 -3.52946814 -3.16256770 0.45275035
13 14 15 16 17 18
-2.86420031 -0.79607109 -3.41808841 -3.43230092 -2.17365238 1.88687891
19 20 21 22 23 24
4.72854668 -0.02568947 1.26987121 0.80518713 2.80634126 6.12616282
25 26 27 28 29 30
3.07622362 1.00666514 -1.06474802 -1.10819532 1.46956204 -2.78196159
31 32 33 34 35 36
-0.75673269 -1.45633128 -1.27853297 -2.09810273 1.79458154 -2.16118410
37 38 39
2.41799421 1.64778131 -0.06034913
> postscript(file="/var/www/rcomp/tmp/6fyf71292249041.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 = 39
Frequency = 1
lag(myerror, k = 1) myerror
0 -2.38292623 NA
1 -0.47109809 -2.38292623
2 2.02845239 -0.47109809
3 2.92814989 2.02845239
4 0.32801095 2.92814989
5 -2.53718779 0.32801095
6 -1.25135150 -2.53718779
7 2.12418253 -1.25135150
8 1.91339787 2.12418253
9 -3.52946814 1.91339787
10 -3.16256770 -3.52946814
11 0.45275035 -3.16256770
12 -2.86420031 0.45275035
13 -0.79607109 -2.86420031
14 -3.41808841 -0.79607109
15 -3.43230092 -3.41808841
16 -2.17365238 -3.43230092
17 1.88687891 -2.17365238
18 4.72854668 1.88687891
19 -0.02568947 4.72854668
20 1.26987121 -0.02568947
21 0.80518713 1.26987121
22 2.80634126 0.80518713
23 6.12616282 2.80634126
24 3.07622362 6.12616282
25 1.00666514 3.07622362
26 -1.06474802 1.00666514
27 -1.10819532 -1.06474802
28 1.46956204 -1.10819532
29 -2.78196159 1.46956204
30 -0.75673269 -2.78196159
31 -1.45633128 -0.75673269
32 -1.27853297 -1.45633128
33 -2.09810273 -1.27853297
34 1.79458154 -2.09810273
35 -2.16118410 1.79458154
36 2.41799421 -2.16118410
37 1.64778131 2.41799421
38 -0.06034913 1.64778131
39 NA -0.06034913
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.47109809 -2.38292623
[2,] 2.02845239 -0.47109809
[3,] 2.92814989 2.02845239
[4,] 0.32801095 2.92814989
[5,] -2.53718779 0.32801095
[6,] -1.25135150 -2.53718779
[7,] 2.12418253 -1.25135150
[8,] 1.91339787 2.12418253
[9,] -3.52946814 1.91339787
[10,] -3.16256770 -3.52946814
[11,] 0.45275035 -3.16256770
[12,] -2.86420031 0.45275035
[13,] -0.79607109 -2.86420031
[14,] -3.41808841 -0.79607109
[15,] -3.43230092 -3.41808841
[16,] -2.17365238 -3.43230092
[17,] 1.88687891 -2.17365238
[18,] 4.72854668 1.88687891
[19,] -0.02568947 4.72854668
[20,] 1.26987121 -0.02568947
[21,] 0.80518713 1.26987121
[22,] 2.80634126 0.80518713
[23,] 6.12616282 2.80634126
[24,] 3.07622362 6.12616282
[25,] 1.00666514 3.07622362
[26,] -1.06474802 1.00666514
[27,] -1.10819532 -1.06474802
[28,] 1.46956204 -1.10819532
[29,] -2.78196159 1.46956204
[30,] -0.75673269 -2.78196159
[31,] -1.45633128 -0.75673269
[32,] -1.27853297 -1.45633128
[33,] -2.09810273 -1.27853297
[34,] 1.79458154 -2.09810273
[35,] -2.16118410 1.79458154
[36,] 2.41799421 -2.16118410
[37,] 1.64778131 2.41799421
[38,] -0.06034913 1.64778131
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.47109809 -2.38292623
2 2.02845239 -0.47109809
3 2.92814989 2.02845239
4 0.32801095 2.92814989
5 -2.53718779 0.32801095
6 -1.25135150 -2.53718779
7 2.12418253 -1.25135150
8 1.91339787 2.12418253
9 -3.52946814 1.91339787
10 -3.16256770 -3.52946814
11 0.45275035 -3.16256770
12 -2.86420031 0.45275035
13 -0.79607109 -2.86420031
14 -3.41808841 -0.79607109
15 -3.43230092 -3.41808841
16 -2.17365238 -3.43230092
17 1.88687891 -2.17365238
18 4.72854668 1.88687891
19 -0.02568947 4.72854668
20 1.26987121 -0.02568947
21 0.80518713 1.26987121
22 2.80634126 0.80518713
23 6.12616282 2.80634126
24 3.07622362 6.12616282
25 1.00666514 3.07622362
26 -1.06474802 1.00666514
27 -1.10819532 -1.06474802
28 1.46956204 -1.10819532
29 -2.78196159 1.46956204
30 -0.75673269 -2.78196159
31 -1.45633128 -0.75673269
32 -1.27853297 -1.45633128
33 -2.09810273 -1.27853297
34 1.79458154 -2.09810273
35 -2.16118410 1.79458154
36 2.41799421 -2.16118410
37 1.64778131 2.41799421
38 -0.06034913 1.64778131
> 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/rcomp/tmp/7qpxa1292249041.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/www/rcomp/tmp/8qpxa1292249041.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/www/rcomp/tmp/91ged1292249041.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')
Warning messages:
1: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced
2: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/rcomp/tmp/101ged1292249041.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11mhc11292249041.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/rcomp/tmp/128zbp1292249041.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/rcomp/tmp/137asd1292249042.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/rcomp/tmp/14iksg1292249042.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/rcomp/tmp/15l2841292249042.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/rcomp/tmp/16hc6d1292249042.tab")
+ }
>
> try(system("convert tmp/1cxz11292249041.ps tmp/1cxz11292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/25oy41292249041.ps tmp/25oy41292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/35oy41292249041.ps tmp/35oy41292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/45oy41292249041.ps tmp/45oy41292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/5fyf71292249041.ps tmp/5fyf71292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/6fyf71292249041.ps tmp/6fyf71292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/7qpxa1292249041.ps tmp/7qpxa1292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/8qpxa1292249041.ps tmp/8qpxa1292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/91ged1292249041.ps tmp/91ged1292249041.png",intern=TRUE))
character(0)
> try(system("convert tmp/101ged1292249041.ps tmp/101ged1292249041.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.980 1.580 4.532