R version 2.7.0 (2008-04-22)
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(102.3,0,105.8,0,106.7,0,109.6,0,111.9,0,113.3,0,114.6,0,115.7,0,117.3,0,119.8,0,120.6,0,121.4,0,123.5,0,125.2,0,126,0,126.8,0,128.1,0,128.2,0,129.3,0,130.6,0,131.4,0,131.1,0,131.2,0,131.2,0,131.5,0,133.5,0,133.7,0,133.5,0,134,0,135.9,0,135.9,0,137.2,0,138.4,0,140.9,0,143,0,144.1,0,146.8,0,149.1,0,149.6,0,151.2,0,153.3,0,156.9,0,157.2,0,158.5,0,160,0,162.5,0,162.9,0,164.7,0,165,0,167.2,0,168.6,0,169.5,0,169.8,0,171.9,0,172,0,173.7,0,173.9,0,175.9,0,175.6,0,176.1,0,176.3,0,179.4,0,179.7,0,179.9,0,180.4,0,182.5,0,183.6,0,183.9,0,184.5,0,187.6,0,188,0,188.5,0,188.6,0,191.9,0,193.5,0,194.9,0,194.9,0,196.2,0,196.2,0,198,0,198.6,0,201.3,0,203.5,0,204.1,0,204.8,1,206.5,1,207.8,1,208.6,1,209.7,1,210,1,211.7,1,212.4,1,213.7,1,214.8,1,216.4,1,217.5,1,218.6,1,220.4,1,221.8,1,222.5,1,223.4,1,225.5,1,226.5,1,227.8,1,228.5,1,229.1,1,229.9,1),dim=c(2,107),dimnames=list(c('Y','X'),1:107))
> y <- array(NA,dim=c(2,107),dimnames=list(c('Y','X'),1:107))
> 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 = 'Linear Trend'
> par2 = 'Do not include Seasonal 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 t
1 102.3 0 1
2 105.8 0 2
3 106.7 0 3
4 109.6 0 4
5 111.9 0 5
6 113.3 0 6
7 114.6 0 7
8 115.7 0 8
9 117.3 0 9
10 119.8 0 10
11 120.6 0 11
12 121.4 0 12
13 123.5 0 13
14 125.2 0 14
15 126.0 0 15
16 126.8 0 16
17 128.1 0 17
18 128.2 0 18
19 129.3 0 19
20 130.6 0 20
21 131.4 0 21
22 131.1 0 22
23 131.2 0 23
24 131.2 0 24
25 131.5 0 25
26 133.5 0 26
27 133.7 0 27
28 133.5 0 28
29 134.0 0 29
30 135.9 0 30
31 135.9 0 31
32 137.2 0 32
33 138.4 0 33
34 140.9 0 34
35 143.0 0 35
36 144.1 0 36
37 146.8 0 37
38 149.1 0 38
39 149.6 0 39
40 151.2 0 40
41 153.3 0 41
42 156.9 0 42
43 157.2 0 43
44 158.5 0 44
45 160.0 0 45
46 162.5 0 46
47 162.9 0 47
48 164.7 0 48
49 165.0 0 49
50 167.2 0 50
51 168.6 0 51
52 169.5 0 52
53 169.8 0 53
54 171.9 0 54
55 172.0 0 55
56 173.7 0 56
57 173.9 0 57
58 175.9 0 58
59 175.6 0 59
60 176.1 0 60
61 176.3 0 61
62 179.4 0 62
63 179.7 0 63
64 179.9 0 64
65 180.4 0 65
66 182.5 0 66
67 183.6 0 67
68 183.9 0 68
69 184.5 0 69
70 187.6 0 70
71 188.0 0 71
72 188.5 0 72
73 188.6 0 73
74 191.9 0 74
75 193.5 0 75
76 194.9 0 76
77 194.9 0 77
78 196.2 0 78
79 196.2 0 79
80 198.0 0 80
81 198.6 0 81
82 201.3 0 82
83 203.5 0 83
84 204.1 0 84
85 204.8 1 85
86 206.5 1 86
87 207.8 1 87
88 208.6 1 88
89 209.7 1 89
90 210.0 1 90
91 211.7 1 91
92 212.4 1 92
93 213.7 1 93
94 214.8 1 94
95 216.4 1 95
96 217.5 1 96
97 218.6 1 97
98 220.4 1 98
99 221.8 1 99
100 222.5 1 100
101 223.4 1 101
102 225.5 1 102
103 226.5 1 103
104 227.8 1 104
105 228.5 1 105
106 229.1 1 106
107 229.9 1 107
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X t
105.2548 -0.1841 1.1736
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-5.73592 -1.02271 0.07088 1.55370 3.51502
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 105.254792 0.479850 219.35 <2e-16 ***
X -0.184144 0.735517 -0.25 0.803
t 1.173585 0.009782 119.97 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.196 on 104 degrees of freedom
Multiple R-squared: 0.9964, Adjusted R-squared: 0.9964
F-statistic: 1.453e+04 on 2 and 104 DF, p-value: < 2.2e-16
> postscript(file="/var/www/html/rcomp/tmp/16m1a1227564370.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/2615e1227564370.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/3gu5b1227564370.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/49d2y1227564370.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/5tfmd1227564370.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 = 107
Frequency = 1
1 2 3 4 5 6
-4.12837626 -1.80196100 -2.07554574 -0.34913048 0.77728479 1.00370005
7 8 9 10 11 12
1.13011531 1.05653058 1.48294584 2.80936110 2.43577636 2.06219163
13 14 15 16 17 18
2.98860689 3.51502215 3.14143742 2.76785268 2.89426794 1.82068320
19 20 21 22 23 24
1.74709847 1.87351373 1.49992899 0.02634426 -1.04724048 -2.22082522
25 26 27 28 29 30
-3.09440996 -2.26799469 -3.24157943 -4.61516417 -5.28874891 -4.56233364
31 32 33 34 35 36
-5.73591838 -5.60950312 -5.58308785 -4.25667259 -3.33025733 -3.40384207
37 38 39 40 41 42
-1.87742680 -0.75101154 -1.42459628 -0.99818101 -0.07176575 2.35464951
43 44 45 46 47 48
1.48106477 1.60748004 1.93389530 3.26031056 2.48672583 3.11314109
49 50 51 52 53 54
2.23955635 3.26597161 3.49238688 3.21880214 2.34521740 3.27163267
55 56 57 58 59 60
2.19804793 2.72446319 1.75087845 2.57729372 1.10370898 0.43012424
61 62 63 64 65 66
-0.54346050 1.38295477 0.50937003 -0.46421471 -1.13779944 -0.21138418
67 68 69 70 71 72
-0.28496892 -1.15855366 -1.73213839 0.19427687 -0.57930787 -1.25289260
73 74 75 76 77 78
-2.32647734 -0.20006208 0.22635318 0.45276845 -0.72081629 -0.59440103
79 80 81 82 83 84
-1.76798576 -1.14157050 -1.71515524 -0.18873998 0.83767529 0.26409055
85 86 87 88 89 90
-0.02535050 0.50106476 0.62748003 0.25389529 0.18031055 -0.69327419
91 92 93 94 95 96
-0.16685892 -0.64044366 -0.51402840 -0.58761313 -0.16119787 -0.23478261
97 98 99 100 101 102
-0.30836735 0.31804792 0.54446318 0.07087844 -0.20270629 0.72370897
103 104 105 106 107
0.55012423 0.67653949 0.20295476 -0.37062998 -0.74421472
> postscript(file="/var/www/html/rcomp/tmp/6tzjd1227564370.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 = 107
Frequency = 1
lag(myerror, k = 1) myerror
0 -4.12837626 NA
1 -1.80196100 -4.12837626
2 -2.07554574 -1.80196100
3 -0.34913048 -2.07554574
4 0.77728479 -0.34913048
5 1.00370005 0.77728479
6 1.13011531 1.00370005
7 1.05653058 1.13011531
8 1.48294584 1.05653058
9 2.80936110 1.48294584
10 2.43577636 2.80936110
11 2.06219163 2.43577636
12 2.98860689 2.06219163
13 3.51502215 2.98860689
14 3.14143742 3.51502215
15 2.76785268 3.14143742
16 2.89426794 2.76785268
17 1.82068320 2.89426794
18 1.74709847 1.82068320
19 1.87351373 1.74709847
20 1.49992899 1.87351373
21 0.02634426 1.49992899
22 -1.04724048 0.02634426
23 -2.22082522 -1.04724048
24 -3.09440996 -2.22082522
25 -2.26799469 -3.09440996
26 -3.24157943 -2.26799469
27 -4.61516417 -3.24157943
28 -5.28874891 -4.61516417
29 -4.56233364 -5.28874891
30 -5.73591838 -4.56233364
31 -5.60950312 -5.73591838
32 -5.58308785 -5.60950312
33 -4.25667259 -5.58308785
34 -3.33025733 -4.25667259
35 -3.40384207 -3.33025733
36 -1.87742680 -3.40384207
37 -0.75101154 -1.87742680
38 -1.42459628 -0.75101154
39 -0.99818101 -1.42459628
40 -0.07176575 -0.99818101
41 2.35464951 -0.07176575
42 1.48106477 2.35464951
43 1.60748004 1.48106477
44 1.93389530 1.60748004
45 3.26031056 1.93389530
46 2.48672583 3.26031056
47 3.11314109 2.48672583
48 2.23955635 3.11314109
49 3.26597161 2.23955635
50 3.49238688 3.26597161
51 3.21880214 3.49238688
52 2.34521740 3.21880214
53 3.27163267 2.34521740
54 2.19804793 3.27163267
55 2.72446319 2.19804793
56 1.75087845 2.72446319
57 2.57729372 1.75087845
58 1.10370898 2.57729372
59 0.43012424 1.10370898
60 -0.54346050 0.43012424
61 1.38295477 -0.54346050
62 0.50937003 1.38295477
63 -0.46421471 0.50937003
64 -1.13779944 -0.46421471
65 -0.21138418 -1.13779944
66 -0.28496892 -0.21138418
67 -1.15855366 -0.28496892
68 -1.73213839 -1.15855366
69 0.19427687 -1.73213839
70 -0.57930787 0.19427687
71 -1.25289260 -0.57930787
72 -2.32647734 -1.25289260
73 -0.20006208 -2.32647734
74 0.22635318 -0.20006208
75 0.45276845 0.22635318
76 -0.72081629 0.45276845
77 -0.59440103 -0.72081629
78 -1.76798576 -0.59440103
79 -1.14157050 -1.76798576
80 -1.71515524 -1.14157050
81 -0.18873998 -1.71515524
82 0.83767529 -0.18873998
83 0.26409055 0.83767529
84 -0.02535050 0.26409055
85 0.50106476 -0.02535050
86 0.62748003 0.50106476
87 0.25389529 0.62748003
88 0.18031055 0.25389529
89 -0.69327419 0.18031055
90 -0.16685892 -0.69327419
91 -0.64044366 -0.16685892
92 -0.51402840 -0.64044366
93 -0.58761313 -0.51402840
94 -0.16119787 -0.58761313
95 -0.23478261 -0.16119787
96 -0.30836735 -0.23478261
97 0.31804792 -0.30836735
98 0.54446318 0.31804792
99 0.07087844 0.54446318
100 -0.20270629 0.07087844
101 0.72370897 -0.20270629
102 0.55012423 0.72370897
103 0.67653949 0.55012423
104 0.20295476 0.67653949
105 -0.37062998 0.20295476
106 -0.74421472 -0.37062998
107 NA -0.74421472
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.80196100 -4.12837626
[2,] -2.07554574 -1.80196100
[3,] -0.34913048 -2.07554574
[4,] 0.77728479 -0.34913048
[5,] 1.00370005 0.77728479
[6,] 1.13011531 1.00370005
[7,] 1.05653058 1.13011531
[8,] 1.48294584 1.05653058
[9,] 2.80936110 1.48294584
[10,] 2.43577636 2.80936110
[11,] 2.06219163 2.43577636
[12,] 2.98860689 2.06219163
[13,] 3.51502215 2.98860689
[14,] 3.14143742 3.51502215
[15,] 2.76785268 3.14143742
[16,] 2.89426794 2.76785268
[17,] 1.82068320 2.89426794
[18,] 1.74709847 1.82068320
[19,] 1.87351373 1.74709847
[20,] 1.49992899 1.87351373
[21,] 0.02634426 1.49992899
[22,] -1.04724048 0.02634426
[23,] -2.22082522 -1.04724048
[24,] -3.09440996 -2.22082522
[25,] -2.26799469 -3.09440996
[26,] -3.24157943 -2.26799469
[27,] -4.61516417 -3.24157943
[28,] -5.28874891 -4.61516417
[29,] -4.56233364 -5.28874891
[30,] -5.73591838 -4.56233364
[31,] -5.60950312 -5.73591838
[32,] -5.58308785 -5.60950312
[33,] -4.25667259 -5.58308785
[34,] -3.33025733 -4.25667259
[35,] -3.40384207 -3.33025733
[36,] -1.87742680 -3.40384207
[37,] -0.75101154 -1.87742680
[38,] -1.42459628 -0.75101154
[39,] -0.99818101 -1.42459628
[40,] -0.07176575 -0.99818101
[41,] 2.35464951 -0.07176575
[42,] 1.48106477 2.35464951
[43,] 1.60748004 1.48106477
[44,] 1.93389530 1.60748004
[45,] 3.26031056 1.93389530
[46,] 2.48672583 3.26031056
[47,] 3.11314109 2.48672583
[48,] 2.23955635 3.11314109
[49,] 3.26597161 2.23955635
[50,] 3.49238688 3.26597161
[51,] 3.21880214 3.49238688
[52,] 2.34521740 3.21880214
[53,] 3.27163267 2.34521740
[54,] 2.19804793 3.27163267
[55,] 2.72446319 2.19804793
[56,] 1.75087845 2.72446319
[57,] 2.57729372 1.75087845
[58,] 1.10370898 2.57729372
[59,] 0.43012424 1.10370898
[60,] -0.54346050 0.43012424
[61,] 1.38295477 -0.54346050
[62,] 0.50937003 1.38295477
[63,] -0.46421471 0.50937003
[64,] -1.13779944 -0.46421471
[65,] -0.21138418 -1.13779944
[66,] -0.28496892 -0.21138418
[67,] -1.15855366 -0.28496892
[68,] -1.73213839 -1.15855366
[69,] 0.19427687 -1.73213839
[70,] -0.57930787 0.19427687
[71,] -1.25289260 -0.57930787
[72,] -2.32647734 -1.25289260
[73,] -0.20006208 -2.32647734
[74,] 0.22635318 -0.20006208
[75,] 0.45276845 0.22635318
[76,] -0.72081629 0.45276845
[77,] -0.59440103 -0.72081629
[78,] -1.76798576 -0.59440103
[79,] -1.14157050 -1.76798576
[80,] -1.71515524 -1.14157050
[81,] -0.18873998 -1.71515524
[82,] 0.83767529 -0.18873998
[83,] 0.26409055 0.83767529
[84,] -0.02535050 0.26409055
[85,] 0.50106476 -0.02535050
[86,] 0.62748003 0.50106476
[87,] 0.25389529 0.62748003
[88,] 0.18031055 0.25389529
[89,] -0.69327419 0.18031055
[90,] -0.16685892 -0.69327419
[91,] -0.64044366 -0.16685892
[92,] -0.51402840 -0.64044366
[93,] -0.58761313 -0.51402840
[94,] -0.16119787 -0.58761313
[95,] -0.23478261 -0.16119787
[96,] -0.30836735 -0.23478261
[97,] 0.31804792 -0.30836735
[98,] 0.54446318 0.31804792
[99,] 0.07087844 0.54446318
[100,] -0.20270629 0.07087844
[101,] 0.72370897 -0.20270629
[102,] 0.55012423 0.72370897
[103,] 0.67653949 0.55012423
[104,] 0.20295476 0.67653949
[105,] -0.37062998 0.20295476
[106,] -0.74421472 -0.37062998
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.80196100 -4.12837626
2 -2.07554574 -1.80196100
3 -0.34913048 -2.07554574
4 0.77728479 -0.34913048
5 1.00370005 0.77728479
6 1.13011531 1.00370005
7 1.05653058 1.13011531
8 1.48294584 1.05653058
9 2.80936110 1.48294584
10 2.43577636 2.80936110
11 2.06219163 2.43577636
12 2.98860689 2.06219163
13 3.51502215 2.98860689
14 3.14143742 3.51502215
15 2.76785268 3.14143742
16 2.89426794 2.76785268
17 1.82068320 2.89426794
18 1.74709847 1.82068320
19 1.87351373 1.74709847
20 1.49992899 1.87351373
21 0.02634426 1.49992899
22 -1.04724048 0.02634426
23 -2.22082522 -1.04724048
24 -3.09440996 -2.22082522
25 -2.26799469 -3.09440996
26 -3.24157943 -2.26799469
27 -4.61516417 -3.24157943
28 -5.28874891 -4.61516417
29 -4.56233364 -5.28874891
30 -5.73591838 -4.56233364
31 -5.60950312 -5.73591838
32 -5.58308785 -5.60950312
33 -4.25667259 -5.58308785
34 -3.33025733 -4.25667259
35 -3.40384207 -3.33025733
36 -1.87742680 -3.40384207
37 -0.75101154 -1.87742680
38 -1.42459628 -0.75101154
39 -0.99818101 -1.42459628
40 -0.07176575 -0.99818101
41 2.35464951 -0.07176575
42 1.48106477 2.35464951
43 1.60748004 1.48106477
44 1.93389530 1.60748004
45 3.26031056 1.93389530
46 2.48672583 3.26031056
47 3.11314109 2.48672583
48 2.23955635 3.11314109
49 3.26597161 2.23955635
50 3.49238688 3.26597161
51 3.21880214 3.49238688
52 2.34521740 3.21880214
53 3.27163267 2.34521740
54 2.19804793 3.27163267
55 2.72446319 2.19804793
56 1.75087845 2.72446319
57 2.57729372 1.75087845
58 1.10370898 2.57729372
59 0.43012424 1.10370898
60 -0.54346050 0.43012424
61 1.38295477 -0.54346050
62 0.50937003 1.38295477
63 -0.46421471 0.50937003
64 -1.13779944 -0.46421471
65 -0.21138418 -1.13779944
66 -0.28496892 -0.21138418
67 -1.15855366 -0.28496892
68 -1.73213839 -1.15855366
69 0.19427687 -1.73213839
70 -0.57930787 0.19427687
71 -1.25289260 -0.57930787
72 -2.32647734 -1.25289260
73 -0.20006208 -2.32647734
74 0.22635318 -0.20006208
75 0.45276845 0.22635318
76 -0.72081629 0.45276845
77 -0.59440103 -0.72081629
78 -1.76798576 -0.59440103
79 -1.14157050 -1.76798576
80 -1.71515524 -1.14157050
81 -0.18873998 -1.71515524
82 0.83767529 -0.18873998
83 0.26409055 0.83767529
84 -0.02535050 0.26409055
85 0.50106476 -0.02535050
86 0.62748003 0.50106476
87 0.25389529 0.62748003
88 0.18031055 0.25389529
89 -0.69327419 0.18031055
90 -0.16685892 -0.69327419
91 -0.64044366 -0.16685892
92 -0.51402840 -0.64044366
93 -0.58761313 -0.51402840
94 -0.16119787 -0.58761313
95 -0.23478261 -0.16119787
96 -0.30836735 -0.23478261
97 0.31804792 -0.30836735
98 0.54446318 0.31804792
99 0.07087844 0.54446318
100 -0.20270629 0.07087844
101 0.72370897 -0.20270629
102 0.55012423 0.72370897
103 0.67653949 0.55012423
104 0.20295476 0.67653949
105 -0.37062998 0.20295476
106 -0.74421472 -0.37062998
> 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/7754y1227564370.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/8fz5c1227564370.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/9hq8y1227564370.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/10bvk41227564370.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/11mesh1227564370.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/1228971227564371.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/134okv1227564371.tab")
>
> system("convert tmp/16m1a1227564370.ps tmp/16m1a1227564370.png")
> system("convert tmp/2615e1227564370.ps tmp/2615e1227564370.png")
> system("convert tmp/3gu5b1227564370.ps tmp/3gu5b1227564370.png")
> system("convert tmp/49d2y1227564370.ps tmp/49d2y1227564370.png")
> system("convert tmp/5tfmd1227564370.ps tmp/5tfmd1227564370.png")
> system("convert tmp/6tzjd1227564370.ps tmp/6tzjd1227564370.png")
> system("convert tmp/7754y1227564370.ps tmp/7754y1227564370.png")
> system("convert tmp/8fz5c1227564370.ps tmp/8fz5c1227564370.png")
> system("convert tmp/9hq8y1227564370.ps tmp/9hq8y1227564370.png")
>
>
> proc.time()
user system elapsed
4.201 2.542 4.552