R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(17.3,0,15.4,0,16.9,0,20.8,0,16.4,0,11.3,0,17.5,0,16.6,0,17.5,0,19.5,0,18.8,0,20.2,0,19.2,0,14.4,0,24.5,0,25.7,0,27.1,0,21,0,18.6,0,20,0,21.8,0,20.4,0,18,1,21.5,1,19.1,1,19.7,1,26,1,26.3,1,24.6,1,22.4,1,32,1,24,1,30,1,24.1,1,26.3,1,29.8,1,21.9,1,22.8,1,29.2,1,27.5,1,27.4,1,31,1,26.1,1,22.2,1,34,1,26.9,1,31.9,1,34.2,1,31.2,1,28.5,1,37.1,1,36,1,34.8,1,32.1,1,37.2,1,36.3,1,39.5,1,37.1,1,35.6,1,36.2,1,35.9,1,32.5,1,39.2,1,39.4,1,42.8,1,34.5,1,43.7,1,46.3,1,40.8,1,48.4,1,43.2,1,48.1,1,42.8,1),dim=c(2,73),dimnames=list(c('y','x'),1:73))
> y <- array(NA,dim=c(2,73),dimnames=list(c('y','x'),1:73))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par20 = ''
> par19 = ''
> par18 = ''
> par17 = ''
> par16 = ''
> par15 = ''
> par14 = ''
> par13 = ''
> par12 = ''
> par11 = ''
> par10 = ''
> par9 = ''
> par8 = ''
> par7 = ''
> par6 = ''
> par5 = ''
> par4 = ''
> par3 = 'No Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> ylab = ''
> xlab = ''
> main = ''
> #'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)
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 17.3 0 1 0 0 0 0 0 0 0 0 0 0
2 15.4 0 0 1 0 0 0 0 0 0 0 0 0
3 16.9 0 0 0 1 0 0 0 0 0 0 0 0
4 20.8 0 0 0 0 1 0 0 0 0 0 0 0
5 16.4 0 0 0 0 0 1 0 0 0 0 0 0
6 11.3 0 0 0 0 0 0 1 0 0 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- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
20.8533 12.9760 -3.3505 -7.2873 -0.6873 -0.2207
M5 M6 M7 M8 M9 M10
-0.6540 -4.1207 -0.3207 -1.9373 1.0960 -0.1040
M11
-2.7000
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-13.1293 -4.8293 0.3707 4.3340 14.6747
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 20.8533 3.2487 6.419 2.43e-08 ***
x 12.9760 1.8132 7.157 1.35e-09 ***
M1 -3.3505 3.9252 -0.854 0.397
M2 -7.2873 4.0784 -1.787 0.079 .
M3 -0.6873 4.0784 -0.169 0.867
M4 -0.2207 4.0784 -0.054 0.957
M5 -0.6540 4.0784 -0.160 0.873
M6 -4.1207 4.0784 -1.010 0.316
M7 -0.3207 4.0784 -0.079 0.938
M8 -1.9373 4.0784 -0.475 0.636
M9 1.0960 4.0784 0.269 0.789
M10 -0.1040 4.0784 -0.025 0.980
M11 -2.7000 4.0672 -0.664 0.509
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 7.045 on 60 degrees of freedom
Multiple R-squared: 0.4983, Adjusted R-squared: 0.398
F-statistic: 4.966 on 12 and 60 DF, p-value: 1.219e-05
> postscript(file="/var/www/html/rcomp/tmp/16eh51229984795.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/2x24b1229984795.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/3yawp1229984795.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/4n0pq1229984795.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/5ssm71229984795.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 73
Frequency = 1
1 2 3 4 5 6
-0.2028391 1.8340168 -3.2659832 0.1673502 -3.7993165 -5.4326498
7 8 9 10 11 12
-3.0326498 -2.3159832 -4.4493165 -1.2493165 0.6466877 -0.6533123
13 14 15 16 17 18
1.6971609 0.8340168 4.3340168 5.0673502 6.9006835 4.2673502
19 20 21 22 23 24
-1.9326498 1.0840168 -0.1493165 -0.3493165 -13.1293375 -12.3293375
25 26 27 28 29 30
-11.3788644 -6.8420084 -7.1420084 -7.3086751 -8.5753417 -7.3086751
31 32 33 34 35 36
-1.5086751 -7.8920084 -4.9253417 -9.6253417 -4.8293375 -4.0293375
37 38 39 40 41 42
-8.5788644 -3.7420084 -3.9420084 -6.1086751 -5.7753417 1.2913249
43 44 45 46 47 48
-7.4086751 -9.6920084 -0.9253417 -6.8253417 0.7706625 0.3706625
49 50 51 52 53 54
0.7211356 1.9579916 3.9579916 2.3913249 1.6246583 2.3913249
55 56 57 58 59 60
3.6913249 4.4079916 4.5746583 3.3746583 4.4706625 2.3706625
61 62 63 64 65 66
5.4211356 5.9579916 6.0579916 5.7913249 9.6246583 4.7913249
67 68 69 70 71 72
10.1913249 14.4079916 5.8746583 14.6746583 12.0706625 14.2706625
73
12.3211356
> postscript(file="/var/www/html/rcomp/tmp/6k02h1229984795.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 = 73
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.2028391 NA
1 1.8340168 -0.2028391
2 -3.2659832 1.8340168
3 0.1673502 -3.2659832
4 -3.7993165 0.1673502
5 -5.4326498 -3.7993165
6 -3.0326498 -5.4326498
7 -2.3159832 -3.0326498
8 -4.4493165 -2.3159832
9 -1.2493165 -4.4493165
10 0.6466877 -1.2493165
11 -0.6533123 0.6466877
12 1.6971609 -0.6533123
13 0.8340168 1.6971609
14 4.3340168 0.8340168
15 5.0673502 4.3340168
16 6.9006835 5.0673502
17 4.2673502 6.9006835
18 -1.9326498 4.2673502
19 1.0840168 -1.9326498
20 -0.1493165 1.0840168
21 -0.3493165 -0.1493165
22 -13.1293375 -0.3493165
23 -12.3293375 -13.1293375
24 -11.3788644 -12.3293375
25 -6.8420084 -11.3788644
26 -7.1420084 -6.8420084
27 -7.3086751 -7.1420084
28 -8.5753417 -7.3086751
29 -7.3086751 -8.5753417
30 -1.5086751 -7.3086751
31 -7.8920084 -1.5086751
32 -4.9253417 -7.8920084
33 -9.6253417 -4.9253417
34 -4.8293375 -9.6253417
35 -4.0293375 -4.8293375
36 -8.5788644 -4.0293375
37 -3.7420084 -8.5788644
38 -3.9420084 -3.7420084
39 -6.1086751 -3.9420084
40 -5.7753417 -6.1086751
41 1.2913249 -5.7753417
42 -7.4086751 1.2913249
43 -9.6920084 -7.4086751
44 -0.9253417 -9.6920084
45 -6.8253417 -0.9253417
46 0.7706625 -6.8253417
47 0.3706625 0.7706625
48 0.7211356 0.3706625
49 1.9579916 0.7211356
50 3.9579916 1.9579916
51 2.3913249 3.9579916
52 1.6246583 2.3913249
53 2.3913249 1.6246583
54 3.6913249 2.3913249
55 4.4079916 3.6913249
56 4.5746583 4.4079916
57 3.3746583 4.5746583
58 4.4706625 3.3746583
59 2.3706625 4.4706625
60 5.4211356 2.3706625
61 5.9579916 5.4211356
62 6.0579916 5.9579916
63 5.7913249 6.0579916
64 9.6246583 5.7913249
65 4.7913249 9.6246583
66 10.1913249 4.7913249
67 14.4079916 10.1913249
68 5.8746583 14.4079916
69 14.6746583 5.8746583
70 12.0706625 14.6746583
71 14.2706625 12.0706625
72 12.3211356 14.2706625
73 NA 12.3211356
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.8340168 -0.2028391
[2,] -3.2659832 1.8340168
[3,] 0.1673502 -3.2659832
[4,] -3.7993165 0.1673502
[5,] -5.4326498 -3.7993165
[6,] -3.0326498 -5.4326498
[7,] -2.3159832 -3.0326498
[8,] -4.4493165 -2.3159832
[9,] -1.2493165 -4.4493165
[10,] 0.6466877 -1.2493165
[11,] -0.6533123 0.6466877
[12,] 1.6971609 -0.6533123
[13,] 0.8340168 1.6971609
[14,] 4.3340168 0.8340168
[15,] 5.0673502 4.3340168
[16,] 6.9006835 5.0673502
[17,] 4.2673502 6.9006835
[18,] -1.9326498 4.2673502
[19,] 1.0840168 -1.9326498
[20,] -0.1493165 1.0840168
[21,] -0.3493165 -0.1493165
[22,] -13.1293375 -0.3493165
[23,] -12.3293375 -13.1293375
[24,] -11.3788644 -12.3293375
[25,] -6.8420084 -11.3788644
[26,] -7.1420084 -6.8420084
[27,] -7.3086751 -7.1420084
[28,] -8.5753417 -7.3086751
[29,] -7.3086751 -8.5753417
[30,] -1.5086751 -7.3086751
[31,] -7.8920084 -1.5086751
[32,] -4.9253417 -7.8920084
[33,] -9.6253417 -4.9253417
[34,] -4.8293375 -9.6253417
[35,] -4.0293375 -4.8293375
[36,] -8.5788644 -4.0293375
[37,] -3.7420084 -8.5788644
[38,] -3.9420084 -3.7420084
[39,] -6.1086751 -3.9420084
[40,] -5.7753417 -6.1086751
[41,] 1.2913249 -5.7753417
[42,] -7.4086751 1.2913249
[43,] -9.6920084 -7.4086751
[44,] -0.9253417 -9.6920084
[45,] -6.8253417 -0.9253417
[46,] 0.7706625 -6.8253417
[47,] 0.3706625 0.7706625
[48,] 0.7211356 0.3706625
[49,] 1.9579916 0.7211356
[50,] 3.9579916 1.9579916
[51,] 2.3913249 3.9579916
[52,] 1.6246583 2.3913249
[53,] 2.3913249 1.6246583
[54,] 3.6913249 2.3913249
[55,] 4.4079916 3.6913249
[56,] 4.5746583 4.4079916
[57,] 3.3746583 4.5746583
[58,] 4.4706625 3.3746583
[59,] 2.3706625 4.4706625
[60,] 5.4211356 2.3706625
[61,] 5.9579916 5.4211356
[62,] 6.0579916 5.9579916
[63,] 5.7913249 6.0579916
[64,] 9.6246583 5.7913249
[65,] 4.7913249 9.6246583
[66,] 10.1913249 4.7913249
[67,] 14.4079916 10.1913249
[68,] 5.8746583 14.4079916
[69,] 14.6746583 5.8746583
[70,] 12.0706625 14.6746583
[71,] 14.2706625 12.0706625
[72,] 12.3211356 14.2706625
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.8340168 -0.2028391
2 -3.2659832 1.8340168
3 0.1673502 -3.2659832
4 -3.7993165 0.1673502
5 -5.4326498 -3.7993165
6 -3.0326498 -5.4326498
7 -2.3159832 -3.0326498
8 -4.4493165 -2.3159832
9 -1.2493165 -4.4493165
10 0.6466877 -1.2493165
11 -0.6533123 0.6466877
12 1.6971609 -0.6533123
13 0.8340168 1.6971609
14 4.3340168 0.8340168
15 5.0673502 4.3340168
16 6.9006835 5.0673502
17 4.2673502 6.9006835
18 -1.9326498 4.2673502
19 1.0840168 -1.9326498
20 -0.1493165 1.0840168
21 -0.3493165 -0.1493165
22 -13.1293375 -0.3493165
23 -12.3293375 -13.1293375
24 -11.3788644 -12.3293375
25 -6.8420084 -11.3788644
26 -7.1420084 -6.8420084
27 -7.3086751 -7.1420084
28 -8.5753417 -7.3086751
29 -7.3086751 -8.5753417
30 -1.5086751 -7.3086751
31 -7.8920084 -1.5086751
32 -4.9253417 -7.8920084
33 -9.6253417 -4.9253417
34 -4.8293375 -9.6253417
35 -4.0293375 -4.8293375
36 -8.5788644 -4.0293375
37 -3.7420084 -8.5788644
38 -3.9420084 -3.7420084
39 -6.1086751 -3.9420084
40 -5.7753417 -6.1086751
41 1.2913249 -5.7753417
42 -7.4086751 1.2913249
43 -9.6920084 -7.4086751
44 -0.9253417 -9.6920084
45 -6.8253417 -0.9253417
46 0.7706625 -6.8253417
47 0.3706625 0.7706625
48 0.7211356 0.3706625
49 1.9579916 0.7211356
50 3.9579916 1.9579916
51 2.3913249 3.9579916
52 1.6246583 2.3913249
53 2.3913249 1.6246583
54 3.6913249 2.3913249
55 4.4079916 3.6913249
56 4.5746583 4.4079916
57 3.3746583 4.5746583
58 4.4706625 3.3746583
59 2.3706625 4.4706625
60 5.4211356 2.3706625
61 5.9579916 5.4211356
62 6.0579916 5.9579916
63 5.7913249 6.0579916
64 9.6246583 5.7913249
65 4.7913249 9.6246583
66 10.1913249 4.7913249
67 14.4079916 10.1913249
68 5.8746583 14.4079916
69 14.6746583 5.8746583
70 12.0706625 14.6746583
71 14.2706625 12.0706625
72 12.3211356 14.2706625
> 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/7zm5g1229984795.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/8ejzl1229984795.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/9an141229984795.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
>
> #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/10x2zo1229984795.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/11z04v1229984795.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/12ykt61229984795.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/139l021229984796.tab")
>
> system("convert tmp/16eh51229984795.ps tmp/16eh51229984795.png")
> system("convert tmp/2x24b1229984795.ps tmp/2x24b1229984795.png")
> system("convert tmp/3yawp1229984795.ps tmp/3yawp1229984795.png")
> system("convert tmp/4n0pq1229984795.ps tmp/4n0pq1229984795.png")
> system("convert tmp/5ssm71229984795.ps tmp/5ssm71229984795.png")
> system("convert tmp/6k02h1229984795.ps tmp/6k02h1229984795.png")
> system("convert tmp/7zm5g1229984795.ps tmp/7zm5g1229984795.png")
> system("convert tmp/8ejzl1229984795.ps tmp/8ejzl1229984795.png")
> system("convert tmp/9an141229984795.ps tmp/9an141229984795.png")
>
>
> proc.time()
user system elapsed
1.982 1.456 2.734