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(94.5,0,114.2,0,104.9,0,106.2,0,99.9,0,97.6,0,103.6,0,192.4,0,113.4,0,106.5,0,104.1,0,98.8,0,92.2,0,120.8,0,97.1,0,89.7,0,105,0,86.2,0,95.1,0,155,0,116.5,0,92.6,0,96,0,82.9,0,81.7,0,106.5,0,96.2,0,84.9,0,93,0,80.9,0,73.9,0,157.4,0,98.2,0,88.3,0,92.6,0,78.4,0,79.2,0,105.5,0,80.6,0,80.9,0,84.6,0,71.2,0,71.4,0,148,0,83.7,0,83.3,0,92.3,0,74.8,0,82.1,0,100,0,71.7,0,79.1,0,86.8,0,64.2,0,75.4,0,139.3,1,77.3,1,112.4,1,98.6,1,77.3,1,73.5,1,100.1,1,76.5,1,77.7,1,80.4,1,72.2,1,65.4,1,181.2,1,96.3,1,106.4,1,90.9,1,75.3,1,71.2,1,96.1,1,80.6,1,77.7,1,83,1,67.5,1,88.5,1,167.6,1,96.4,1,91,1,90.3,1,92.3,1,84.5,1,100.9,1,90,1,84.2,1,97.4,1,78.2,1,90,1,182.4,1,100.2,1,95.1,1,105,1,86.9,1,80.7,1),dim=c(2,97),dimnames=list(c('y','x'),1:97))
> y <- array(NA,dim=c(2,97),dimnames=list(c('y','x'),1:97))
> 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 = 'Include Monthly 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)
> 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 94.5 0 1 0 0 0 0 0 0 0 0 0 0
2 114.2 0 0 1 0 0 0 0 0 0 0 0 0
3 104.9 0 0 0 1 0 0 0 0 0 0 0 0
4 106.2 0 0 0 0 1 0 0 0 0 0 0 0
5 99.9 0 0 0 0 0 1 0 0 0 0 0 0
6 97.6 0 0 0 0 0 0 1 0 0 0 0 0
7 103.6 0 0 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0 0 0 0 0 0
76 77.7 1 0 0 0 1 0 0 0 0 0 0 0
77 83.0 1 0 0 0 0 1 0 0 0 0 0 0
78 67.5 1 0 0 0 0 0 1 0 0 0 0 0
79 88.5 1 0 0 0 0 0 0 1 0 0 0 0
80 167.6 1 0 0 0 0 0 0 0 1 0 0 0
81 96.4 1 0 0 0 0 0 0 0 0 1 0 0
82 91.0 1 0 0 0 0 0 0 0 0 0 1 0
83 90.3 1 0 0 0 0 0 0 0 0 0 0 1
84 92.3 1 0 0 0 0 0 0 0 0 0 0 0
85 84.5 1 1 0 0 0 0 0 0 0 0 0 0
86 100.9 1 0 1 0 0 0 0 0 0 0 0 0
87 90.0 1 0 0 1 0 0 0 0 0 0 0 0
88 84.2 1 0 0 0 1 0 0 0 0 0 0 0
89 97.4 1 0 0 0 0 1 0 0 0 0 0 0
90 78.2 1 0 0 0 0 0 1 0 0 0 0 0
91 90.0 1 0 0 0 0 0 0 1 0 0 0 0
92 182.4 1 0 0 0 0 0 0 0 1 0 0 0
93 100.2 1 0 0 0 0 0 0 0 0 1 0 0
94 95.1 1 0 0 0 0 0 0 0 0 0 1 0
95 105.0 1 0 0 0 0 0 0 0 0 0 0 1
96 86.9 1 0 0 0 0 0 0 0 0 0 0 0
97 80.7 1 1 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
85.3926 -4.1101 -1.3881 21.6612 3.3487 1.1987
M5 M6 M7 M8 M9 M10
7.4112 -6.6013 -0.9388 82.0750 14.4125 13.6125
M11
12.8875
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-24.057 -6.993 -1.904 7.459 24.932
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 85.3926 3.9988 21.354 < 2e-16 ***
x -4.1101 2.2410 -1.834 0.070188 .
M1 -1.3881 5.2772 -0.263 0.793170
M2 21.6612 5.4359 3.985 0.000143 ***
M3 3.3487 5.4359 0.616 0.539530
M4 1.1987 5.4359 0.221 0.825998
M5 7.4112 5.4359 1.363 0.176400
M6 -6.6013 5.4359 -1.214 0.228001
M7 -0.9388 5.4359 -0.173 0.863304
M8 82.0750 5.4286 15.119 < 2e-16 ***
M9 14.4125 5.4286 2.655 0.009489 **
M10 13.6125 5.4286 2.508 0.014083 *
M11 12.8875 5.4286 2.374 0.019878 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 10.86 on 84 degrees of freedom
Multiple R-squared: 0.8308, Adjusted R-squared: 0.8067
F-statistic: 34.38 on 12 and 84 DF, p-value: < 2.2e-16
> postscript(file="/var/www/html/rcomp/tmp/1lh5n1227567249.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/2ecyf1227567249.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/3kayg1227567249.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/497n41227567249.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/5ann41227567249.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 = 97
Frequency = 1
1 2 3 4 5 6
10.4955030 7.1462056 16.1587056 19.6087056 7.0962056 18.8087056
7 8 9 10 11 12
19.1462056 24.9324408 13.5949408 7.4949408 5.8199408 13.4074408
13 14 15 16 17 18
8.1955030 13.7462056 8.3587056 3.1087056 12.1962056 7.4087056
19 20 21 22 23 24
10.6462056 -12.4675592 16.6949408 -6.4050592 -2.2800592 -2.4925592
25 26 27 28 29 30
-2.3044970 -0.5537944 7.4587056 -1.6912944 0.1962056 2.1087056
31 32 33 34 35 36
-10.5537944 -10.0675592 -1.6050592 -10.7050592 -5.6800592 -6.9925592
37 38 39 40 41 42
-4.8044970 -1.5537944 -8.1412944 -5.6912944 -8.2037944 -7.5912944
43 44 45 46 47 48
-13.0537944 -19.4675592 -16.1050592 -15.7050592 -5.9800592 -10.5925592
49 50 51 52 53 54
-1.9044970 -7.0537944 -17.0412944 -7.4912944 -6.0037944 -14.5912944
55 56 57 58 59 60
-9.0537944 -24.0574408 -18.3949408 17.5050592 4.4300592 -3.9824408
61 62 63 64 65 66
-6.3943787 -2.8436760 -8.1311760 -4.7811760 -8.2936760 -2.4811760
67 68 69 70 71 72
-14.9436760 17.8425592 0.6050592 11.5050592 -3.2699408 -5.9824408
73 74 75 76 77 78
-8.6943787 -6.8436760 -4.0311760 -4.7811760 -5.6936760 -7.1811760
79 80 81 82 83 84
8.1563240 4.2425592 0.7050592 -3.8949408 -3.8699408 11.0175592
85 86 87 88 89 90
4.6056213 -2.0436760 5.3688240 1.7188240 8.7063240 3.5188240
91 92 93 94 95 96
9.6563240 19.0425592 4.5050592 0.2050592 10.8300592 5.6175592
97
0.8056213
> postscript(file="/var/www/html/rcomp/tmp/60pk71227567249.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 = 97
Frequency = 1
lag(myerror, k = 1) myerror
0 10.4955030 NA
1 7.1462056 10.4955030
2 16.1587056 7.1462056
3 19.6087056 16.1587056
4 7.0962056 19.6087056
5 18.8087056 7.0962056
6 19.1462056 18.8087056
7 24.9324408 19.1462056
8 13.5949408 24.9324408
9 7.4949408 13.5949408
10 5.8199408 7.4949408
11 13.4074408 5.8199408
12 8.1955030 13.4074408
13 13.7462056 8.1955030
14 8.3587056 13.7462056
15 3.1087056 8.3587056
16 12.1962056 3.1087056
17 7.4087056 12.1962056
18 10.6462056 7.4087056
19 -12.4675592 10.6462056
20 16.6949408 -12.4675592
21 -6.4050592 16.6949408
22 -2.2800592 -6.4050592
23 -2.4925592 -2.2800592
24 -2.3044970 -2.4925592
25 -0.5537944 -2.3044970
26 7.4587056 -0.5537944
27 -1.6912944 7.4587056
28 0.1962056 -1.6912944
29 2.1087056 0.1962056
30 -10.5537944 2.1087056
31 -10.0675592 -10.5537944
32 -1.6050592 -10.0675592
33 -10.7050592 -1.6050592
34 -5.6800592 -10.7050592
35 -6.9925592 -5.6800592
36 -4.8044970 -6.9925592
37 -1.5537944 -4.8044970
38 -8.1412944 -1.5537944
39 -5.6912944 -8.1412944
40 -8.2037944 -5.6912944
41 -7.5912944 -8.2037944
42 -13.0537944 -7.5912944
43 -19.4675592 -13.0537944
44 -16.1050592 -19.4675592
45 -15.7050592 -16.1050592
46 -5.9800592 -15.7050592
47 -10.5925592 -5.9800592
48 -1.9044970 -10.5925592
49 -7.0537944 -1.9044970
50 -17.0412944 -7.0537944
51 -7.4912944 -17.0412944
52 -6.0037944 -7.4912944
53 -14.5912944 -6.0037944
54 -9.0537944 -14.5912944
55 -24.0574408 -9.0537944
56 -18.3949408 -24.0574408
57 17.5050592 -18.3949408
58 4.4300592 17.5050592
59 -3.9824408 4.4300592
60 -6.3943787 -3.9824408
61 -2.8436760 -6.3943787
62 -8.1311760 -2.8436760
63 -4.7811760 -8.1311760
64 -8.2936760 -4.7811760
65 -2.4811760 -8.2936760
66 -14.9436760 -2.4811760
67 17.8425592 -14.9436760
68 0.6050592 17.8425592
69 11.5050592 0.6050592
70 -3.2699408 11.5050592
71 -5.9824408 -3.2699408
72 -8.6943787 -5.9824408
73 -6.8436760 -8.6943787
74 -4.0311760 -6.8436760
75 -4.7811760 -4.0311760
76 -5.6936760 -4.7811760
77 -7.1811760 -5.6936760
78 8.1563240 -7.1811760
79 4.2425592 8.1563240
80 0.7050592 4.2425592
81 -3.8949408 0.7050592
82 -3.8699408 -3.8949408
83 11.0175592 -3.8699408
84 4.6056213 11.0175592
85 -2.0436760 4.6056213
86 5.3688240 -2.0436760
87 1.7188240 5.3688240
88 8.7063240 1.7188240
89 3.5188240 8.7063240
90 9.6563240 3.5188240
91 19.0425592 9.6563240
92 4.5050592 19.0425592
93 0.2050592 4.5050592
94 10.8300592 0.2050592
95 5.6175592 10.8300592
96 0.8056213 5.6175592
97 NA 0.8056213
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 7.1462056 10.4955030
[2,] 16.1587056 7.1462056
[3,] 19.6087056 16.1587056
[4,] 7.0962056 19.6087056
[5,] 18.8087056 7.0962056
[6,] 19.1462056 18.8087056
[7,] 24.9324408 19.1462056
[8,] 13.5949408 24.9324408
[9,] 7.4949408 13.5949408
[10,] 5.8199408 7.4949408
[11,] 13.4074408 5.8199408
[12,] 8.1955030 13.4074408
[13,] 13.7462056 8.1955030
[14,] 8.3587056 13.7462056
[15,] 3.1087056 8.3587056
[16,] 12.1962056 3.1087056
[17,] 7.4087056 12.1962056
[18,] 10.6462056 7.4087056
[19,] -12.4675592 10.6462056
[20,] 16.6949408 -12.4675592
[21,] -6.4050592 16.6949408
[22,] -2.2800592 -6.4050592
[23,] -2.4925592 -2.2800592
[24,] -2.3044970 -2.4925592
[25,] -0.5537944 -2.3044970
[26,] 7.4587056 -0.5537944
[27,] -1.6912944 7.4587056
[28,] 0.1962056 -1.6912944
[29,] 2.1087056 0.1962056
[30,] -10.5537944 2.1087056
[31,] -10.0675592 -10.5537944
[32,] -1.6050592 -10.0675592
[33,] -10.7050592 -1.6050592
[34,] -5.6800592 -10.7050592
[35,] -6.9925592 -5.6800592
[36,] -4.8044970 -6.9925592
[37,] -1.5537944 -4.8044970
[38,] -8.1412944 -1.5537944
[39,] -5.6912944 -8.1412944
[40,] -8.2037944 -5.6912944
[41,] -7.5912944 -8.2037944
[42,] -13.0537944 -7.5912944
[43,] -19.4675592 -13.0537944
[44,] -16.1050592 -19.4675592
[45,] -15.7050592 -16.1050592
[46,] -5.9800592 -15.7050592
[47,] -10.5925592 -5.9800592
[48,] -1.9044970 -10.5925592
[49,] -7.0537944 -1.9044970
[50,] -17.0412944 -7.0537944
[51,] -7.4912944 -17.0412944
[52,] -6.0037944 -7.4912944
[53,] -14.5912944 -6.0037944
[54,] -9.0537944 -14.5912944
[55,] -24.0574408 -9.0537944
[56,] -18.3949408 -24.0574408
[57,] 17.5050592 -18.3949408
[58,] 4.4300592 17.5050592
[59,] -3.9824408 4.4300592
[60,] -6.3943787 -3.9824408
[61,] -2.8436760 -6.3943787
[62,] -8.1311760 -2.8436760
[63,] -4.7811760 -8.1311760
[64,] -8.2936760 -4.7811760
[65,] -2.4811760 -8.2936760
[66,] -14.9436760 -2.4811760
[67,] 17.8425592 -14.9436760
[68,] 0.6050592 17.8425592
[69,] 11.5050592 0.6050592
[70,] -3.2699408 11.5050592
[71,] -5.9824408 -3.2699408
[72,] -8.6943787 -5.9824408
[73,] -6.8436760 -8.6943787
[74,] -4.0311760 -6.8436760
[75,] -4.7811760 -4.0311760
[76,] -5.6936760 -4.7811760
[77,] -7.1811760 -5.6936760
[78,] 8.1563240 -7.1811760
[79,] 4.2425592 8.1563240
[80,] 0.7050592 4.2425592
[81,] -3.8949408 0.7050592
[82,] -3.8699408 -3.8949408
[83,] 11.0175592 -3.8699408
[84,] 4.6056213 11.0175592
[85,] -2.0436760 4.6056213
[86,] 5.3688240 -2.0436760
[87,] 1.7188240 5.3688240
[88,] 8.7063240 1.7188240
[89,] 3.5188240 8.7063240
[90,] 9.6563240 3.5188240
[91,] 19.0425592 9.6563240
[92,] 4.5050592 19.0425592
[93,] 0.2050592 4.5050592
[94,] 10.8300592 0.2050592
[95,] 5.6175592 10.8300592
[96,] 0.8056213 5.6175592
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 7.1462056 10.4955030
2 16.1587056 7.1462056
3 19.6087056 16.1587056
4 7.0962056 19.6087056
5 18.8087056 7.0962056
6 19.1462056 18.8087056
7 24.9324408 19.1462056
8 13.5949408 24.9324408
9 7.4949408 13.5949408
10 5.8199408 7.4949408
11 13.4074408 5.8199408
12 8.1955030 13.4074408
13 13.7462056 8.1955030
14 8.3587056 13.7462056
15 3.1087056 8.3587056
16 12.1962056 3.1087056
17 7.4087056 12.1962056
18 10.6462056 7.4087056
19 -12.4675592 10.6462056
20 16.6949408 -12.4675592
21 -6.4050592 16.6949408
22 -2.2800592 -6.4050592
23 -2.4925592 -2.2800592
24 -2.3044970 -2.4925592
25 -0.5537944 -2.3044970
26 7.4587056 -0.5537944
27 -1.6912944 7.4587056
28 0.1962056 -1.6912944
29 2.1087056 0.1962056
30 -10.5537944 2.1087056
31 -10.0675592 -10.5537944
32 -1.6050592 -10.0675592
33 -10.7050592 -1.6050592
34 -5.6800592 -10.7050592
35 -6.9925592 -5.6800592
36 -4.8044970 -6.9925592
37 -1.5537944 -4.8044970
38 -8.1412944 -1.5537944
39 -5.6912944 -8.1412944
40 -8.2037944 -5.6912944
41 -7.5912944 -8.2037944
42 -13.0537944 -7.5912944
43 -19.4675592 -13.0537944
44 -16.1050592 -19.4675592
45 -15.7050592 -16.1050592
46 -5.9800592 -15.7050592
47 -10.5925592 -5.9800592
48 -1.9044970 -10.5925592
49 -7.0537944 -1.9044970
50 -17.0412944 -7.0537944
51 -7.4912944 -17.0412944
52 -6.0037944 -7.4912944
53 -14.5912944 -6.0037944
54 -9.0537944 -14.5912944
55 -24.0574408 -9.0537944
56 -18.3949408 -24.0574408
57 17.5050592 -18.3949408
58 4.4300592 17.5050592
59 -3.9824408 4.4300592
60 -6.3943787 -3.9824408
61 -2.8436760 -6.3943787
62 -8.1311760 -2.8436760
63 -4.7811760 -8.1311760
64 -8.2936760 -4.7811760
65 -2.4811760 -8.2936760
66 -14.9436760 -2.4811760
67 17.8425592 -14.9436760
68 0.6050592 17.8425592
69 11.5050592 0.6050592
70 -3.2699408 11.5050592
71 -5.9824408 -3.2699408
72 -8.6943787 -5.9824408
73 -6.8436760 -8.6943787
74 -4.0311760 -6.8436760
75 -4.7811760 -4.0311760
76 -5.6936760 -4.7811760
77 -7.1811760 -5.6936760
78 8.1563240 -7.1811760
79 4.2425592 8.1563240
80 0.7050592 4.2425592
81 -3.8949408 0.7050592
82 -3.8699408 -3.8949408
83 11.0175592 -3.8699408
84 4.6056213 11.0175592
85 -2.0436760 4.6056213
86 5.3688240 -2.0436760
87 1.7188240 5.3688240
88 8.7063240 1.7188240
89 3.5188240 8.7063240
90 9.6563240 3.5188240
91 19.0425592 9.6563240
92 4.5050592 19.0425592
93 0.2050592 4.5050592
94 10.8300592 0.2050592
95 5.6175592 10.8300592
96 0.8056213 5.6175592
> 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/7zijp1227567250.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/8zoyn1227567250.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/95lbz1227567250.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/10bew01227567250.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/11haw71227567250.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/12z61h1227567250.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/13n3r61227567250.tab")
>
> system("convert tmp/1lh5n1227567249.ps tmp/1lh5n1227567249.png")
> system("convert tmp/2ecyf1227567249.ps tmp/2ecyf1227567249.png")
> system("convert tmp/3kayg1227567249.ps tmp/3kayg1227567249.png")
> system("convert tmp/497n41227567249.ps tmp/497n41227567249.png")
> system("convert tmp/5ann41227567249.ps tmp/5ann41227567249.png")
> system("convert tmp/60pk71227567249.ps tmp/60pk71227567249.png")
> system("convert tmp/7zijp1227567250.ps tmp/7zijp1227567250.png")
> system("convert tmp/8zoyn1227567250.ps tmp/8zoyn1227567250.png")
> system("convert tmp/95lbz1227567250.ps tmp/95lbz1227567250.png")
>
>
> proc.time()
user system elapsed
2.078 1.451 2.445