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(7.5,0,7.2,0,6.9,0,6.7,0,6.4,0,6.3,0,6.8,0,7.3,0,7.1,0,7.1,0,6.8,0,6.5,0,6.3,0,6.1,0,6.1,0,6.3,0,6.3,0,6,0,6.2,0,6.4,0,6.8,0,7.5,0,7.5,0,7.6,0,7.6,1,7.4,1,7.3,1,7.1,1,6.9,1,6.8,1,7.5,1,7.6,1,7.8,1,8,1,8.1,1,8.2,1,8.3,1,8.2,1,8,1,7.9,1,7.6,1,7.6,1,8.2,1,8.3,1,8.4,1,8.4,1,8.4,1,8.6,1,8.9,1,8.8,1,8.3,1,7.5,1,7.2,1,7.5,1,8.8,1,9.3,1,9.3,1,8.7,1,8.2,1,8.3,1,8.5,1,8.6,1,8.6,1,8.2,1,8.1,1,8,1,8.6,1,8.7,1,8.8,1,8.5,1,8.4,1,8.5,1,8.7,1,8.7,1,8.6,1,8.5,1,8.3,1,8.1,1,8.2,1,8.1,1,8.1,1,7.9,1,7.9,1,7.9,1,8,1,8,1,7.9,1,8,1,7.7,1,7.2,1,7.5,1,7.3,1,7,1,7,1,7,1,7.2,1,7.3,1,7.1,1,6.8,1,6.6,1,6.2,1,6.2,1,6.8,1,6.9,1,6.8,1),dim=c(2,105),dimnames=list(c('y','x'),1:105))
> y <- array(NA,dim=c(2,105),dimnames=list(c('y','x'),1:105))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = '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 t
1 7.5 0 1 0 0 0 0 0 0 0 0 0 0 1
2 7.2 0 0 1 0 0 0 0 0 0 0 0 0 2
3 6.9 0 0 0 1 0 0 0 0 0 0 0 0 3
4 6.7 0 0 0 0 1 0 0 0 0 0 0 0 4
5 6.4 0 0 0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 0 0 1 0 0 0 0 0 0 101
102 6.2 1 0 0 0 0 0 1 0 0 0 0 0 102
103 6.8 1 0 0 0 0 0 0 1 0 0 0 0 103
104 6.9 1 0 0 0 0 0 0 0 1 0 0 0 104
105 6.8 1 0 0 0 0 0 0 0 0 1 0 0 105
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
7.108984 1.669010 -0.043652 -0.145305 -0.313625 -0.493056
M5 M6 M7 M8 M9 M10
-0.716931 -0.818584 -0.264681 -0.110778 -0.079098 0.018584
M11 t
-0.071958 -0.009458
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.9868 -0.4955 0.0520 0.4339 1.1624
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.108984 0.239730 29.654 < 2e-16 ***
x 1.669010 0.203693 8.194 1.52e-12 ***
M1 -0.043652 0.291677 -0.150 0.88136
M2 -0.145305 0.291513 -0.498 0.61937
M3 -0.313625 0.291377 -1.076 0.28461
M4 -0.493056 0.291268 -1.693 0.09392 .
M5 -0.716931 0.291187 -2.462 0.01570 *
M6 -0.818584 0.291133 -2.812 0.00604 **
M7 -0.264681 0.291106 -0.909 0.36563
M8 -0.110778 0.291108 -0.381 0.70443
M9 -0.079098 0.291136 -0.272 0.78648
M10 0.018584 0.299570 0.062 0.95067
M11 -0.071958 0.299530 -0.240 0.81069
t -0.009458 0.002829 -3.343 0.00120 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.599 on 91 degrees of freedom
Multiple R-squared: 0.5292, Adjusted R-squared: 0.4619
F-statistic: 7.868 on 13 and 91 DF, p-value: 2.914e-10
> postscript(file="/var/www/html/rcomp/tmp/1xzs01227798385.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/2jei31227798385.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/3ulpf1227798385.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/4lcgp1227798385.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/5ylmm1227798385.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 = 105
Frequency = 1
1 2 3 4 5 6
0.44412616 0.25523727 0.13301505 0.12190394 0.05523727 0.06634838
7 8 9 10 11 12
0.02190394 0.37745949 0.15523727 0.06701389 -0.13298611 -0.49548611
13 14 15 16 17 18
-0.64237558 -0.73126447 -0.55348669 -0.16459780 0.06873553 -0.12015336
19 20 21 22 23 24
-0.46459780 -0.40904225 -0.03126447 0.58051215 0.68051215 0.71801215
25 26 27 28 29 30
-0.89788773 -0.98677662 -0.90899884 -0.92010995 -0.88677662 -0.87566551
31 32 33 34 35 36
-0.72010995 -0.76455440 -0.58677662 -0.47500000 -0.27500000 -0.23750000
37 38 39 40 41 42
-0.08438947 -0.07327836 -0.09550058 -0.00661169 -0.07327836 0.03783275
43 44 45 46 47 48
0.09338831 0.04894387 0.12672164 0.03849826 0.13849826 0.27599826
49 50 51 52 53 54
0.62910880 0.64021991 0.31799769 -0.29311343 -0.35978009 0.05133102
55 56 57 58 59 60
0.80688657 1.16244213 1.14021991 0.45199653 0.05199653 0.08949653
61 62 63 64 65 66
0.34260706 0.55371817 0.73149595 0.52038484 0.65371817 0.66482928
67 68 69 70 71 72
0.72038484 0.67594039 0.75371817 0.36549479 0.36549479 0.40299479
73 74 75 76 77 78
0.65610532 0.76721644 0.84499421 0.93388310 0.96721644 0.87832755
79 80 81 82 83 84
0.43388310 0.18943866 0.16721644 -0.12100694 -0.02100694 -0.08350694
85 86 87 88 89 90
0.06960359 0.18071470 0.25849248 0.54738137 0.48071470 0.09182581
91 92 93 94 95 96
-0.15261863 -0.49706308 -0.81928530 -0.90750868 -0.80750868 -0.67000868
97 98 99 100 101 102
-0.51689815 -0.60578704 -0.72800926 -0.73912037 -0.90578704 -0.79467593
103 104 105
-0.73912037 -0.78356481 -0.90578704
> postscript(file="/var/www/html/rcomp/tmp/6to461227798385.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 = 105
Frequency = 1
lag(myerror, k = 1) myerror
0 0.44412616 NA
1 0.25523727 0.44412616
2 0.13301505 0.25523727
3 0.12190394 0.13301505
4 0.05523727 0.12190394
5 0.06634838 0.05523727
6 0.02190394 0.06634838
7 0.37745949 0.02190394
8 0.15523727 0.37745949
9 0.06701389 0.15523727
10 -0.13298611 0.06701389
11 -0.49548611 -0.13298611
12 -0.64237558 -0.49548611
13 -0.73126447 -0.64237558
14 -0.55348669 -0.73126447
15 -0.16459780 -0.55348669
16 0.06873553 -0.16459780
17 -0.12015336 0.06873553
18 -0.46459780 -0.12015336
19 -0.40904225 -0.46459780
20 -0.03126447 -0.40904225
21 0.58051215 -0.03126447
22 0.68051215 0.58051215
23 0.71801215 0.68051215
24 -0.89788773 0.71801215
25 -0.98677662 -0.89788773
26 -0.90899884 -0.98677662
27 -0.92010995 -0.90899884
28 -0.88677662 -0.92010995
29 -0.87566551 -0.88677662
30 -0.72010995 -0.87566551
31 -0.76455440 -0.72010995
32 -0.58677662 -0.76455440
33 -0.47500000 -0.58677662
34 -0.27500000 -0.47500000
35 -0.23750000 -0.27500000
36 -0.08438947 -0.23750000
37 -0.07327836 -0.08438947
38 -0.09550058 -0.07327836
39 -0.00661169 -0.09550058
40 -0.07327836 -0.00661169
41 0.03783275 -0.07327836
42 0.09338831 0.03783275
43 0.04894387 0.09338831
44 0.12672164 0.04894387
45 0.03849826 0.12672164
46 0.13849826 0.03849826
47 0.27599826 0.13849826
48 0.62910880 0.27599826
49 0.64021991 0.62910880
50 0.31799769 0.64021991
51 -0.29311343 0.31799769
52 -0.35978009 -0.29311343
53 0.05133102 -0.35978009
54 0.80688657 0.05133102
55 1.16244213 0.80688657
56 1.14021991 1.16244213
57 0.45199653 1.14021991
58 0.05199653 0.45199653
59 0.08949653 0.05199653
60 0.34260706 0.08949653
61 0.55371817 0.34260706
62 0.73149595 0.55371817
63 0.52038484 0.73149595
64 0.65371817 0.52038484
65 0.66482928 0.65371817
66 0.72038484 0.66482928
67 0.67594039 0.72038484
68 0.75371817 0.67594039
69 0.36549479 0.75371817
70 0.36549479 0.36549479
71 0.40299479 0.36549479
72 0.65610532 0.40299479
73 0.76721644 0.65610532
74 0.84499421 0.76721644
75 0.93388310 0.84499421
76 0.96721644 0.93388310
77 0.87832755 0.96721644
78 0.43388310 0.87832755
79 0.18943866 0.43388310
80 0.16721644 0.18943866
81 -0.12100694 0.16721644
82 -0.02100694 -0.12100694
83 -0.08350694 -0.02100694
84 0.06960359 -0.08350694
85 0.18071470 0.06960359
86 0.25849248 0.18071470
87 0.54738137 0.25849248
88 0.48071470 0.54738137
89 0.09182581 0.48071470
90 -0.15261863 0.09182581
91 -0.49706308 -0.15261863
92 -0.81928530 -0.49706308
93 -0.90750868 -0.81928530
94 -0.80750868 -0.90750868
95 -0.67000868 -0.80750868
96 -0.51689815 -0.67000868
97 -0.60578704 -0.51689815
98 -0.72800926 -0.60578704
99 -0.73912037 -0.72800926
100 -0.90578704 -0.73912037
101 -0.79467593 -0.90578704
102 -0.73912037 -0.79467593
103 -0.78356481 -0.73912037
104 -0.90578704 -0.78356481
105 NA -0.90578704
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.25523727 0.44412616
[2,] 0.13301505 0.25523727
[3,] 0.12190394 0.13301505
[4,] 0.05523727 0.12190394
[5,] 0.06634838 0.05523727
[6,] 0.02190394 0.06634838
[7,] 0.37745949 0.02190394
[8,] 0.15523727 0.37745949
[9,] 0.06701389 0.15523727
[10,] -0.13298611 0.06701389
[11,] -0.49548611 -0.13298611
[12,] -0.64237558 -0.49548611
[13,] -0.73126447 -0.64237558
[14,] -0.55348669 -0.73126447
[15,] -0.16459780 -0.55348669
[16,] 0.06873553 -0.16459780
[17,] -0.12015336 0.06873553
[18,] -0.46459780 -0.12015336
[19,] -0.40904225 -0.46459780
[20,] -0.03126447 -0.40904225
[21,] 0.58051215 -0.03126447
[22,] 0.68051215 0.58051215
[23,] 0.71801215 0.68051215
[24,] -0.89788773 0.71801215
[25,] -0.98677662 -0.89788773
[26,] -0.90899884 -0.98677662
[27,] -0.92010995 -0.90899884
[28,] -0.88677662 -0.92010995
[29,] -0.87566551 -0.88677662
[30,] -0.72010995 -0.87566551
[31,] -0.76455440 -0.72010995
[32,] -0.58677662 -0.76455440
[33,] -0.47500000 -0.58677662
[34,] -0.27500000 -0.47500000
[35,] -0.23750000 -0.27500000
[36,] -0.08438947 -0.23750000
[37,] -0.07327836 -0.08438947
[38,] -0.09550058 -0.07327836
[39,] -0.00661169 -0.09550058
[40,] -0.07327836 -0.00661169
[41,] 0.03783275 -0.07327836
[42,] 0.09338831 0.03783275
[43,] 0.04894387 0.09338831
[44,] 0.12672164 0.04894387
[45,] 0.03849826 0.12672164
[46,] 0.13849826 0.03849826
[47,] 0.27599826 0.13849826
[48,] 0.62910880 0.27599826
[49,] 0.64021991 0.62910880
[50,] 0.31799769 0.64021991
[51,] -0.29311343 0.31799769
[52,] -0.35978009 -0.29311343
[53,] 0.05133102 -0.35978009
[54,] 0.80688657 0.05133102
[55,] 1.16244213 0.80688657
[56,] 1.14021991 1.16244213
[57,] 0.45199653 1.14021991
[58,] 0.05199653 0.45199653
[59,] 0.08949653 0.05199653
[60,] 0.34260706 0.08949653
[61,] 0.55371817 0.34260706
[62,] 0.73149595 0.55371817
[63,] 0.52038484 0.73149595
[64,] 0.65371817 0.52038484
[65,] 0.66482928 0.65371817
[66,] 0.72038484 0.66482928
[67,] 0.67594039 0.72038484
[68,] 0.75371817 0.67594039
[69,] 0.36549479 0.75371817
[70,] 0.36549479 0.36549479
[71,] 0.40299479 0.36549479
[72,] 0.65610532 0.40299479
[73,] 0.76721644 0.65610532
[74,] 0.84499421 0.76721644
[75,] 0.93388310 0.84499421
[76,] 0.96721644 0.93388310
[77,] 0.87832755 0.96721644
[78,] 0.43388310 0.87832755
[79,] 0.18943866 0.43388310
[80,] 0.16721644 0.18943866
[81,] -0.12100694 0.16721644
[82,] -0.02100694 -0.12100694
[83,] -0.08350694 -0.02100694
[84,] 0.06960359 -0.08350694
[85,] 0.18071470 0.06960359
[86,] 0.25849248 0.18071470
[87,] 0.54738137 0.25849248
[88,] 0.48071470 0.54738137
[89,] 0.09182581 0.48071470
[90,] -0.15261863 0.09182581
[91,] -0.49706308 -0.15261863
[92,] -0.81928530 -0.49706308
[93,] -0.90750868 -0.81928530
[94,] -0.80750868 -0.90750868
[95,] -0.67000868 -0.80750868
[96,] -0.51689815 -0.67000868
[97,] -0.60578704 -0.51689815
[98,] -0.72800926 -0.60578704
[99,] -0.73912037 -0.72800926
[100,] -0.90578704 -0.73912037
[101,] -0.79467593 -0.90578704
[102,] -0.73912037 -0.79467593
[103,] -0.78356481 -0.73912037
[104,] -0.90578704 -0.78356481
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.25523727 0.44412616
2 0.13301505 0.25523727
3 0.12190394 0.13301505
4 0.05523727 0.12190394
5 0.06634838 0.05523727
6 0.02190394 0.06634838
7 0.37745949 0.02190394
8 0.15523727 0.37745949
9 0.06701389 0.15523727
10 -0.13298611 0.06701389
11 -0.49548611 -0.13298611
12 -0.64237558 -0.49548611
13 -0.73126447 -0.64237558
14 -0.55348669 -0.73126447
15 -0.16459780 -0.55348669
16 0.06873553 -0.16459780
17 -0.12015336 0.06873553
18 -0.46459780 -0.12015336
19 -0.40904225 -0.46459780
20 -0.03126447 -0.40904225
21 0.58051215 -0.03126447
22 0.68051215 0.58051215
23 0.71801215 0.68051215
24 -0.89788773 0.71801215
25 -0.98677662 -0.89788773
26 -0.90899884 -0.98677662
27 -0.92010995 -0.90899884
28 -0.88677662 -0.92010995
29 -0.87566551 -0.88677662
30 -0.72010995 -0.87566551
31 -0.76455440 -0.72010995
32 -0.58677662 -0.76455440
33 -0.47500000 -0.58677662
34 -0.27500000 -0.47500000
35 -0.23750000 -0.27500000
36 -0.08438947 -0.23750000
37 -0.07327836 -0.08438947
38 -0.09550058 -0.07327836
39 -0.00661169 -0.09550058
40 -0.07327836 -0.00661169
41 0.03783275 -0.07327836
42 0.09338831 0.03783275
43 0.04894387 0.09338831
44 0.12672164 0.04894387
45 0.03849826 0.12672164
46 0.13849826 0.03849826
47 0.27599826 0.13849826
48 0.62910880 0.27599826
49 0.64021991 0.62910880
50 0.31799769 0.64021991
51 -0.29311343 0.31799769
52 -0.35978009 -0.29311343
53 0.05133102 -0.35978009
54 0.80688657 0.05133102
55 1.16244213 0.80688657
56 1.14021991 1.16244213
57 0.45199653 1.14021991
58 0.05199653 0.45199653
59 0.08949653 0.05199653
60 0.34260706 0.08949653
61 0.55371817 0.34260706
62 0.73149595 0.55371817
63 0.52038484 0.73149595
64 0.65371817 0.52038484
65 0.66482928 0.65371817
66 0.72038484 0.66482928
67 0.67594039 0.72038484
68 0.75371817 0.67594039
69 0.36549479 0.75371817
70 0.36549479 0.36549479
71 0.40299479 0.36549479
72 0.65610532 0.40299479
73 0.76721644 0.65610532
74 0.84499421 0.76721644
75 0.93388310 0.84499421
76 0.96721644 0.93388310
77 0.87832755 0.96721644
78 0.43388310 0.87832755
79 0.18943866 0.43388310
80 0.16721644 0.18943866
81 -0.12100694 0.16721644
82 -0.02100694 -0.12100694
83 -0.08350694 -0.02100694
84 0.06960359 -0.08350694
85 0.18071470 0.06960359
86 0.25849248 0.18071470
87 0.54738137 0.25849248
88 0.48071470 0.54738137
89 0.09182581 0.48071470
90 -0.15261863 0.09182581
91 -0.49706308 -0.15261863
92 -0.81928530 -0.49706308
93 -0.90750868 -0.81928530
94 -0.80750868 -0.90750868
95 -0.67000868 -0.80750868
96 -0.51689815 -0.67000868
97 -0.60578704 -0.51689815
98 -0.72800926 -0.60578704
99 -0.73912037 -0.72800926
100 -0.90578704 -0.73912037
101 -0.79467593 -0.90578704
102 -0.73912037 -0.79467593
103 -0.78356481 -0.73912037
104 -0.90578704 -0.78356481
> 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/7hhbg1227798385.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/8bdg11227798385.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/9stsk1227798385.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/10hrlo1227798385.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/11c24m1227798385.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/12bmyz1227798385.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/131c3x1227798385.tab")
>
> system("convert tmp/1xzs01227798385.ps tmp/1xzs01227798385.png")
> system("convert tmp/2jei31227798385.ps tmp/2jei31227798385.png")
> system("convert tmp/3ulpf1227798385.ps tmp/3ulpf1227798385.png")
> system("convert tmp/4lcgp1227798385.ps tmp/4lcgp1227798385.png")
> system("convert tmp/5ylmm1227798385.ps tmp/5ylmm1227798385.png")
> system("convert tmp/6to461227798385.ps tmp/6to461227798385.png")
> system("convert tmp/7hhbg1227798385.ps tmp/7hhbg1227798385.png")
> system("convert tmp/8bdg11227798385.ps tmp/8bdg11227798385.png")
> system("convert tmp/9stsk1227798385.ps tmp/9stsk1227798385.png")
>
>
> proc.time()
user system elapsed
2.073 1.445 2.836