R version 2.6.0 (2007-10-03)
Copyright (C) 2007 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(36409
+ ,0
+ ,99.25
+ ,33163
+ ,0
+ ,99.36
+ ,34122
+ ,0
+ ,99.34
+ ,35225
+ ,0
+ ,99.36
+ ,28249
+ ,0
+ ,100.85
+ ,30374
+ ,0
+ ,100.86
+ ,26311
+ ,0
+ ,100.93
+ ,22069
+ ,0
+ ,101.25
+ ,23651
+ ,0
+ ,101.72
+ ,28628
+ ,0
+ ,101.54
+ ,23187
+ ,0
+ ,101.35
+ ,14727
+ ,0
+ ,101.42
+ ,43080
+ ,0
+ ,101.57
+ ,32519
+ ,0
+ ,101.76
+ ,39657
+ ,0
+ ,102.05
+ ,33614
+ ,0
+ ,102.05
+ ,28671
+ ,0
+ ,101.89
+ ,34243
+ ,0
+ ,102.06
+ ,27336
+ ,0
+ ,102
+ ,22916
+ ,0
+ ,102.14
+ ,24537
+ ,0
+ ,102.2
+ ,26128
+ ,0
+ ,102.3
+ ,22602
+ ,0
+ ,102.7
+ ,15744
+ ,0
+ ,102.77
+ ,41086
+ ,0
+ ,103.1
+ ,39690
+ ,0
+ ,103.13
+ ,43129
+ ,0
+ ,103.31
+ ,37863
+ ,0
+ ,103.52
+ ,35953
+ ,0
+ ,103.34
+ ,29133
+ ,0
+ ,103.53
+ ,24693
+ ,0
+ ,103.8
+ ,22205
+ ,0
+ ,103.9
+ ,21725
+ ,0
+ ,103.91
+ ,27192
+ ,0
+ ,104.21
+ ,21790
+ ,0
+ ,104.58
+ ,13253
+ ,0
+ ,104.89
+ ,37702
+ ,0
+ ,105.15
+ ,30364
+ ,0
+ ,105.24
+ ,32609
+ ,0
+ ,105.57
+ ,30212
+ ,0
+ ,105.62
+ ,29965
+ ,0
+ ,106.17
+ ,28352
+ ,0
+ ,106.27
+ ,25814
+ ,0
+ ,106.41
+ ,22414
+ ,0
+ ,106.94
+ ,20506
+ ,0
+ ,107.16
+ ,28806
+ ,0
+ ,107.32
+ ,22228
+ ,0
+ ,107.32
+ ,13971
+ ,0
+ ,107.35
+ ,36845
+ ,0
+ ,107.55
+ ,35338
+ ,0
+ ,107.87
+ ,35022
+ ,0
+ ,108.37
+ ,34777
+ ,0
+ ,108.38
+ ,26887
+ ,0
+ ,107.92
+ ,23970
+ ,0
+ ,108.03
+ ,22780
+ ,0
+ ,108.14
+ ,17351
+ ,0
+ ,108.3
+ ,21382
+ ,0
+ ,108.64
+ ,24561
+ ,0
+ ,108.66
+ ,17409
+ ,0
+ ,109.04
+ ,11514
+ ,0
+ ,109.03
+ ,31514
+ ,0
+ ,109.03
+ ,27071
+ ,0
+ ,109.54
+ ,29462
+ ,0
+ ,109.75
+ ,26105
+ ,0
+ ,109.83
+ ,22397
+ ,0
+ ,109.65
+ ,23843
+ ,0
+ ,109.82
+ ,21705
+ ,0
+ ,109.95
+ ,18089
+ ,0
+ ,110.12
+ ,20764
+ ,0
+ ,110.15
+ ,25316
+ ,0
+ ,110.21
+ ,17704
+ ,0
+ ,109.99
+ ,15548
+ ,0
+ ,110.14
+ ,28029
+ ,0
+ ,110.14
+ ,29383
+ ,0
+ ,110.81
+ ,36438
+ ,0
+ ,110.97
+ ,32034
+ ,0
+ ,110.99
+ ,22679
+ ,0
+ ,109.73
+ ,24319
+ ,0
+ ,109.81
+ ,18004
+ ,0
+ ,110.02
+ ,17537
+ ,0
+ ,110.18
+ ,20366
+ ,0
+ ,110.21
+ ,22782
+ ,0
+ ,110.25
+ ,19169
+ ,0
+ ,110.36
+ ,13807
+ ,0
+ ,110.51
+ ,29743
+ ,0
+ ,110.6
+ ,25591
+ ,0
+ ,110.95
+ ,29096
+ ,1
+ ,111.18
+ ,26482
+ ,1
+ ,111.19
+ ,22405
+ ,1
+ ,111.69
+ ,27044
+ ,1
+ ,111.7
+ ,17970
+ ,1
+ ,111.83
+ ,18730
+ ,1
+ ,111.77
+ ,19684
+ ,1
+ ,111.73
+ ,19785
+ ,1
+ ,112.01
+ ,18479
+ ,1
+ ,111.86
+ ,10698
+ ,1
+ ,112.04)
+ ,dim=c(3
+ ,96)
+ ,dimnames=list(c('Y'
+ ,'X1'
+ ,'X2')
+ ,1:96))
> y <- array(NA,dim=c(3,96),dimnames=list(c('Y','X1','X2'),1:96))
> 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 X1 X2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 36409 0 99.25 1 0 0 0 0 0 0 0 0 0 0 1
2 33163 0 99.36 0 1 0 0 0 0 0 0 0 0 0 2
3 34122 0 99.34 0 0 1 0 0 0 0 0 0 0 0 3
4 35225 0 99.36 0 0 0 1 0 0 0 0 0 0 0 4
5 28249 0 100.85 0 0 0 0 1 0 0 0 0 0 0 5
6 30374 0 100.86 0 0 0 0 0 1 0 0 0 0 0 6
7 26311 0 100.93 0 0 0 0 0 0 1 0 0 0 0 7
8 22069 0 101.25 0 0 0 0 0 0 0 1 0 0 0 8
9 23651 0 101.72 0 0 0 0 0 0 0 0 1 0 0 9
10 28628 0 101.54 0 0 0 0 0 0 0 0 0 1 0 10
11 23187 0 101.35 0 0 0 0 0 0 0 0 0 0 1 11
12 14727 0 101.42 0 0 0 0 0 0 0 0 0 0 0 12
13 43080 0 101.57 1 0 0 0 0 0 0 0 0 0 0 13
14 32519 0 101.76 0 1 0 0 0 0 0 0 0 0 0 14
15 39657 0 102.05 0 0 1 0 0 0 0 0 0 0 0 15
16 33614 0 102.05 0 0 0 1 0 0 0 0 0 0 0 16
17 28671 0 101.89 0 0 0 0 1 0 0 0 0 0 0 17
18 34243 0 102.06 0 0 0 0 0 1 0 0 0 0 0 18
19 27336 0 102.00 0 0 0 0 0 0 1 0 0 0 0 19
20 22916 0 102.14 0 0 0 0 0 0 0 1 0 0 0 20
21 24537 0 102.20 0 0 0 0 0 0 0 0 1 0 0 21
22 26128 0 102.30 0 0 0 0 0 0 0 0 0 1 0 22
23 22602 0 102.70 0 0 0 0 0 0 0 0 0 0 1 23
24 15744 0 102.77 0 0 0 0 0 0 0 0 0 0 0 24
25 41086 0 103.10 1 0 0 0 0 0 0 0 0 0 0 25
26 39690 0 103.13 0 1 0 0 0 0 0 0 0 0 0 26
27 43129 0 103.31 0 0 1 0 0 0 0 0 0 0 0 27
28 37863 0 103.52 0 0 0 1 0 0 0 0 0 0 0 28
29 35953 0 103.34 0 0 0 0 1 0 0 0 0 0 0 29
30 29133 0 103.53 0 0 0 0 0 1 0 0 0 0 0 30
31 24693 0 103.80 0 0 0 0 0 0 1 0 0 0 0 31
32 22205 0 103.90 0 0 0 0 0 0 0 1 0 0 0 32
33 21725 0 103.91 0 0 0 0 0 0 0 0 1 0 0 33
34 27192 0 104.21 0 0 0 0 0 0 0 0 0 1 0 34
35 21790 0 104.58 0 0 0 0 0 0 0 0 0 0 1 35
36 13253 0 104.89 0 0 0 0 0 0 0 0 0 0 0 36
37 37702 0 105.15 1 0 0 0 0 0 0 0 0 0 0 37
38 30364 0 105.24 0 1 0 0 0 0 0 0 0 0 0 38
39 32609 0 105.57 0 0 1 0 0 0 0 0 0 0 0 39
40 30212 0 105.62 0 0 0 1 0 0 0 0 0 0 0 40
41 29965 0 106.17 0 0 0 0 1 0 0 0 0 0 0 41
42 28352 0 106.27 0 0 0 0 0 1 0 0 0 0 0 42
43 25814 0 106.41 0 0 0 0 0 0 1 0 0 0 0 43
44 22414 0 106.94 0 0 0 0 0 0 0 1 0 0 0 44
45 20506 0 107.16 0 0 0 0 0 0 0 0 1 0 0 45
46 28806 0 107.32 0 0 0 0 0 0 0 0 0 1 0 46
47 22228 0 107.32 0 0 0 0 0 0 0 0 0 0 1 47
48 13971 0 107.35 0 0 0 0 0 0 0 0 0 0 0 48
49 36845 0 107.55 1 0 0 0 0 0 0 0 0 0 0 49
50 35338 0 107.87 0 1 0 0 0 0 0 0 0 0 0 50
51 35022 0 108.37 0 0 1 0 0 0 0 0 0 0 0 51
52 34777 0 108.38 0 0 0 1 0 0 0 0 0 0 0 52
53 26887 0 107.92 0 0 0 0 1 0 0 0 0 0 0 53
54 23970 0 108.03 0 0 0 0 0 1 0 0 0 0 0 54
55 22780 0 108.14 0 0 0 0 0 0 1 0 0 0 0 55
56 17351 0 108.30 0 0 0 0 0 0 0 1 0 0 0 56
57 21382 0 108.64 0 0 0 0 0 0 0 0 1 0 0 57
58 24561 0 108.66 0 0 0 0 0 0 0 0 0 1 0 58
59 17409 0 109.04 0 0 0 0 0 0 0 0 0 0 1 59
60 11514 0 109.03 0 0 0 0 0 0 0 0 0 0 0 60
61 31514 0 109.03 1 0 0 0 0 0 0 0 0 0 0 61
62 27071 0 109.54 0 1 0 0 0 0 0 0 0 0 0 62
63 29462 0 109.75 0 0 1 0 0 0 0 0 0 0 0 63
64 26105 0 109.83 0 0 0 1 0 0 0 0 0 0 0 64
65 22397 0 109.65 0 0 0 0 1 0 0 0 0 0 0 65
66 23843 0 109.82 0 0 0 0 0 1 0 0 0 0 0 66
67 21705 0 109.95 0 0 0 0 0 0 1 0 0 0 0 67
68 18089 0 110.12 0 0 0 0 0 0 0 1 0 0 0 68
69 20764 0 110.15 0 0 0 0 0 0 0 0 1 0 0 69
70 25316 0 110.21 0 0 0 0 0 0 0 0 0 1 0 70
71 17704 0 109.99 0 0 0 0 0 0 0 0 0 0 1 71
72 15548 0 110.14 0 0 0 0 0 0 0 0 0 0 0 72
73 28029 0 110.14 1 0 0 0 0 0 0 0 0 0 0 73
74 29383 0 110.81 0 1 0 0 0 0 0 0 0 0 0 74
75 36438 0 110.97 0 0 1 0 0 0 0 0 0 0 0 75
76 32034 0 110.99 0 0 0 1 0 0 0 0 0 0 0 76
77 22679 0 109.73 0 0 0 0 1 0 0 0 0 0 0 77
78 24319 0 109.81 0 0 0 0 0 1 0 0 0 0 0 78
79 18004 0 110.02 0 0 0 0 0 0 1 0 0 0 0 79
80 17537 0 110.18 0 0 0 0 0 0 0 1 0 0 0 80
81 20366 0 110.21 0 0 0 0 0 0 0 0 1 0 0 81
82 22782 0 110.25 0 0 0 0 0 0 0 0 0 1 0 82
83 19169 0 110.36 0 0 0 0 0 0 0 0 0 0 1 83
84 13807 0 110.51 0 0 0 0 0 0 0 0 0 0 0 84
85 29743 0 110.60 1 0 0 0 0 0 0 0 0 0 0 85
86 25591 0 110.95 0 1 0 0 0 0 0 0 0 0 0 86
87 29096 1 111.18 0 0 1 0 0 0 0 0 0 0 0 87
88 26482 1 111.19 0 0 0 1 0 0 0 0 0 0 0 88
89 22405 1 111.69 0 0 0 0 1 0 0 0 0 0 0 89
90 27044 1 111.70 0 0 0 0 0 1 0 0 0 0 0 90
91 17970 1 111.83 0 0 0 0 0 0 1 0 0 0 0 91
92 18730 1 111.77 0 0 0 0 0 0 0 1 0 0 0 92
93 19684 1 111.73 0 0 0 0 0 0 0 0 1 0 0 93
94 19785 1 112.01 0 0 0 0 0 0 0 0 0 1 0 94
95 18479 1 111.86 0 0 0 0 0 0 0 0 0 0 1 95
96 10698 1 112.04 0 0 0 0 0 0 0 0 0 0 0 96
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X1 X2 M1 M2 M3
28380.82 146.76 -99.08 20928.00 17121.16 20504.28
M4 M5 M6 M7 M8 M9
17682.53 12874.18 13469.76 8975.20 6157.45 7660.50
M10 M11 t
11569.21 6575.31 -76.18
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4806.5 -1997.0 -190.0 1620.6 7145.7
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 28380.82 43551.77 0.652 0.516
X1 146.76 1202.44 0.122 0.903
X2 -99.08 436.91 -0.227 0.821
M1 20928.00 1351.06 15.490 < 2e-16 ***
M2 17121.16 1351.13 12.672 < 2e-16 ***
M3 20504.28 1357.39 15.106 < 2e-16 ***
M4 17682.53 1352.58 13.073 < 2e-16 ***
M5 12874.18 1348.84 9.545 6.68e-15 ***
M6 13469.76 1347.49 9.996 8.63e-16 ***
M7 8975.20 1346.67 6.665 2.97e-09 ***
M8 6157.45 1346.92 4.572 1.72e-05 ***
M9 7660.50 1346.48 5.689 1.96e-07 ***
M10 11569.21 1345.54 8.598 4.95e-13 ***
M11 6575.31 1344.95 4.889 5.05e-06 ***
t -76.18 64.00 -1.190 0.237
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2690 on 81 degrees of freedom
Multiple R-Squared: 0.8847, Adjusted R-squared: 0.8648
F-statistic: 44.41 on 14 and 81 DF, p-value: < 2.2e-16
> postscript(file="/var/www/html/rcomp/tmp/1aark1199525320.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/2e2dk1199525320.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/39ln31199525320.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/4m1ni1199525320.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/5lu5v1199525320.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 = 96
Frequency = 1
1 2 3 4 5 6
-2990.297373 -2342.386913 -4692.306860 -689.404154 -2633.245551 -1026.657818
7 8 9 10 11 12
-511.982025 -1828.352081 -1626.656839 -500.025565 -889.769291 -2691.349270
13 14 15 16 17 18
4824.694430 -1834.468991 2025.324775 -1119.754050 -1194.071657 3875.368315
19 20 21 22 23 24
1533.164164 20.960339 221.034220 -2010.593089 -426.881685 -626.461664
25 26 27 28 29 30
3896.415805 6386.400145 6536.295497 4189.022735 7145.723598 -174.854900
31 32 33 34 35 36
-17.363809 398.469307 -1507.410637 156.777353 -138.483539 -1993.285160
37 38 39 40 41 42
1629.656955 -1816.414115 -2845.657290 -2339.782290 2352.244412 229.749029
43 44 45 46 47 48
2276.360176 1822.796183 -1490.277697 2993.039583 1485.120390 -117.422648
49 50 51 52 53 54
1924.574877 4332.291400 758.891228 3412.803169 361.762614 -3063.742003
55 56 57 58 59 60
327.896849 -2191.325445 446.489853 -205.063575 -2249.333702 -1493.839800
61 62 63 64 65 66
-2345.657573 -2855.116517 -3750.248871 -4201.401576 -3042.700713 -2099.260741
67 68 69 70 71 72
346.359641 -358.871888 892.229698 1617.639329 -946.076692 3564.269449
73 74 75 76 77 78
-4806.548325 496.844970 4260.758792 2756.661497 -1838.640251 -710.117163
79 80 81 82 83 84
-2433.570661 9.207044 1414.308630 1.736732 1469.715953 2774.062093
85 86 87 88 89 90
-2132.838796 -2367.149978 -2293.057270 -2008.145330 -1151.072453 2969.515281
91 92 93 94 95 96
-1520.864337 2127.116540 1650.282772 -2053.510768 1695.708565 584.027000
> postscript(file="/var/www/html/rcomp/tmp/66bf81199525320.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 = 96
Frequency = 1
lag(myerror, k = 1) myerror
0 -2990.297373 NA
1 -2342.386913 -2990.297373
2 -4692.306860 -2342.386913
3 -689.404154 -4692.306860
4 -2633.245551 -689.404154
5 -1026.657818 -2633.245551
6 -511.982025 -1026.657818
7 -1828.352081 -511.982025
8 -1626.656839 -1828.352081
9 -500.025565 -1626.656839
10 -889.769291 -500.025565
11 -2691.349270 -889.769291
12 4824.694430 -2691.349270
13 -1834.468991 4824.694430
14 2025.324775 -1834.468991
15 -1119.754050 2025.324775
16 -1194.071657 -1119.754050
17 3875.368315 -1194.071657
18 1533.164164 3875.368315
19 20.960339 1533.164164
20 221.034220 20.960339
21 -2010.593089 221.034220
22 -426.881685 -2010.593089
23 -626.461664 -426.881685
24 3896.415805 -626.461664
25 6386.400145 3896.415805
26 6536.295497 6386.400145
27 4189.022735 6536.295497
28 7145.723598 4189.022735
29 -174.854900 7145.723598
30 -17.363809 -174.854900
31 398.469307 -17.363809
32 -1507.410637 398.469307
33 156.777353 -1507.410637
34 -138.483539 156.777353
35 -1993.285160 -138.483539
36 1629.656955 -1993.285160
37 -1816.414115 1629.656955
38 -2845.657290 -1816.414115
39 -2339.782290 -2845.657290
40 2352.244412 -2339.782290
41 229.749029 2352.244412
42 2276.360176 229.749029
43 1822.796183 2276.360176
44 -1490.277697 1822.796183
45 2993.039583 -1490.277697
46 1485.120390 2993.039583
47 -117.422648 1485.120390
48 1924.574877 -117.422648
49 4332.291400 1924.574877
50 758.891228 4332.291400
51 3412.803169 758.891228
52 361.762614 3412.803169
53 -3063.742003 361.762614
54 327.896849 -3063.742003
55 -2191.325445 327.896849
56 446.489853 -2191.325445
57 -205.063575 446.489853
58 -2249.333702 -205.063575
59 -1493.839800 -2249.333702
60 -2345.657573 -1493.839800
61 -2855.116517 -2345.657573
62 -3750.248871 -2855.116517
63 -4201.401576 -3750.248871
64 -3042.700713 -4201.401576
65 -2099.260741 -3042.700713
66 346.359641 -2099.260741
67 -358.871888 346.359641
68 892.229698 -358.871888
69 1617.639329 892.229698
70 -946.076692 1617.639329
71 3564.269449 -946.076692
72 -4806.548325 3564.269449
73 496.844970 -4806.548325
74 4260.758792 496.844970
75 2756.661497 4260.758792
76 -1838.640251 2756.661497
77 -710.117163 -1838.640251
78 -2433.570661 -710.117163
79 9.207044 -2433.570661
80 1414.308630 9.207044
81 1.736732 1414.308630
82 1469.715953 1.736732
83 2774.062093 1469.715953
84 -2132.838796 2774.062093
85 -2367.149978 -2132.838796
86 -2293.057270 -2367.149978
87 -2008.145330 -2293.057270
88 -1151.072453 -2008.145330
89 2969.515281 -1151.072453
90 -1520.864337 2969.515281
91 2127.116540 -1520.864337
92 1650.282772 2127.116540
93 -2053.510768 1650.282772
94 1695.708565 -2053.510768
95 584.027000 1695.708565
96 NA 584.027000
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2342.386913 -2990.297373
[2,] -4692.306860 -2342.386913
[3,] -689.404154 -4692.306860
[4,] -2633.245551 -689.404154
[5,] -1026.657818 -2633.245551
[6,] -511.982025 -1026.657818
[7,] -1828.352081 -511.982025
[8,] -1626.656839 -1828.352081
[9,] -500.025565 -1626.656839
[10,] -889.769291 -500.025565
[11,] -2691.349270 -889.769291
[12,] 4824.694430 -2691.349270
[13,] -1834.468991 4824.694430
[14,] 2025.324775 -1834.468991
[15,] -1119.754050 2025.324775
[16,] -1194.071657 -1119.754050
[17,] 3875.368315 -1194.071657
[18,] 1533.164164 3875.368315
[19,] 20.960339 1533.164164
[20,] 221.034220 20.960339
[21,] -2010.593089 221.034220
[22,] -426.881685 -2010.593089
[23,] -626.461664 -426.881685
[24,] 3896.415805 -626.461664
[25,] 6386.400145 3896.415805
[26,] 6536.295497 6386.400145
[27,] 4189.022735 6536.295497
[28,] 7145.723598 4189.022735
[29,] -174.854900 7145.723598
[30,] -17.363809 -174.854900
[31,] 398.469307 -17.363809
[32,] -1507.410637 398.469307
[33,] 156.777353 -1507.410637
[34,] -138.483539 156.777353
[35,] -1993.285160 -138.483539
[36,] 1629.656955 -1993.285160
[37,] -1816.414115 1629.656955
[38,] -2845.657290 -1816.414115
[39,] -2339.782290 -2845.657290
[40,] 2352.244412 -2339.782290
[41,] 229.749029 2352.244412
[42,] 2276.360176 229.749029
[43,] 1822.796183 2276.360176
[44,] -1490.277697 1822.796183
[45,] 2993.039583 -1490.277697
[46,] 1485.120390 2993.039583
[47,] -117.422648 1485.120390
[48,] 1924.574877 -117.422648
[49,] 4332.291400 1924.574877
[50,] 758.891228 4332.291400
[51,] 3412.803169 758.891228
[52,] 361.762614 3412.803169
[53,] -3063.742003 361.762614
[54,] 327.896849 -3063.742003
[55,] -2191.325445 327.896849
[56,] 446.489853 -2191.325445
[57,] -205.063575 446.489853
[58,] -2249.333702 -205.063575
[59,] -1493.839800 -2249.333702
[60,] -2345.657573 -1493.839800
[61,] -2855.116517 -2345.657573
[62,] -3750.248871 -2855.116517
[63,] -4201.401576 -3750.248871
[64,] -3042.700713 -4201.401576
[65,] -2099.260741 -3042.700713
[66,] 346.359641 -2099.260741
[67,] -358.871888 346.359641
[68,] 892.229698 -358.871888
[69,] 1617.639329 892.229698
[70,] -946.076692 1617.639329
[71,] 3564.269449 -946.076692
[72,] -4806.548325 3564.269449
[73,] 496.844970 -4806.548325
[74,] 4260.758792 496.844970
[75,] 2756.661497 4260.758792
[76,] -1838.640251 2756.661497
[77,] -710.117163 -1838.640251
[78,] -2433.570661 -710.117163
[79,] 9.207044 -2433.570661
[80,] 1414.308630 9.207044
[81,] 1.736732 1414.308630
[82,] 1469.715953 1.736732
[83,] 2774.062093 1469.715953
[84,] -2132.838796 2774.062093
[85,] -2367.149978 -2132.838796
[86,] -2293.057270 -2367.149978
[87,] -2008.145330 -2293.057270
[88,] -1151.072453 -2008.145330
[89,] 2969.515281 -1151.072453
[90,] -1520.864337 2969.515281
[91,] 2127.116540 -1520.864337
[92,] 1650.282772 2127.116540
[93,] -2053.510768 1650.282772
[94,] 1695.708565 -2053.510768
[95,] 584.027000 1695.708565
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2342.386913 -2990.297373
2 -4692.306860 -2342.386913
3 -689.404154 -4692.306860
4 -2633.245551 -689.404154
5 -1026.657818 -2633.245551
6 -511.982025 -1026.657818
7 -1828.352081 -511.982025
8 -1626.656839 -1828.352081
9 -500.025565 -1626.656839
10 -889.769291 -500.025565
11 -2691.349270 -889.769291
12 4824.694430 -2691.349270
13 -1834.468991 4824.694430
14 2025.324775 -1834.468991
15 -1119.754050 2025.324775
16 -1194.071657 -1119.754050
17 3875.368315 -1194.071657
18 1533.164164 3875.368315
19 20.960339 1533.164164
20 221.034220 20.960339
21 -2010.593089 221.034220
22 -426.881685 -2010.593089
23 -626.461664 -426.881685
24 3896.415805 -626.461664
25 6386.400145 3896.415805
26 6536.295497 6386.400145
27 4189.022735 6536.295497
28 7145.723598 4189.022735
29 -174.854900 7145.723598
30 -17.363809 -174.854900
31 398.469307 -17.363809
32 -1507.410637 398.469307
33 156.777353 -1507.410637
34 -138.483539 156.777353
35 -1993.285160 -138.483539
36 1629.656955 -1993.285160
37 -1816.414115 1629.656955
38 -2845.657290 -1816.414115
39 -2339.782290 -2845.657290
40 2352.244412 -2339.782290
41 229.749029 2352.244412
42 2276.360176 229.749029
43 1822.796183 2276.360176
44 -1490.277697 1822.796183
45 2993.039583 -1490.277697
46 1485.120390 2993.039583
47 -117.422648 1485.120390
48 1924.574877 -117.422648
49 4332.291400 1924.574877
50 758.891228 4332.291400
51 3412.803169 758.891228
52 361.762614 3412.803169
53 -3063.742003 361.762614
54 327.896849 -3063.742003
55 -2191.325445 327.896849
56 446.489853 -2191.325445
57 -205.063575 446.489853
58 -2249.333702 -205.063575
59 -1493.839800 -2249.333702
60 -2345.657573 -1493.839800
61 -2855.116517 -2345.657573
62 -3750.248871 -2855.116517
63 -4201.401576 -3750.248871
64 -3042.700713 -4201.401576
65 -2099.260741 -3042.700713
66 346.359641 -2099.260741
67 -358.871888 346.359641
68 892.229698 -358.871888
69 1617.639329 892.229698
70 -946.076692 1617.639329
71 3564.269449 -946.076692
72 -4806.548325 3564.269449
73 496.844970 -4806.548325
74 4260.758792 496.844970
75 2756.661497 4260.758792
76 -1838.640251 2756.661497
77 -710.117163 -1838.640251
78 -2433.570661 -710.117163
79 9.207044 -2433.570661
80 1414.308630 9.207044
81 1.736732 1414.308630
82 1469.715953 1.736732
83 2774.062093 1469.715953
84 -2132.838796 2774.062093
85 -2367.149978 -2132.838796
86 -2293.057270 -2367.149978
87 -2008.145330 -2293.057270
88 -1151.072453 -2008.145330
89 2969.515281 -1151.072453
90 -1520.864337 2969.515281
91 2127.116540 -1520.864337
92 1650.282772 2127.116540
93 -2053.510768 1650.282772
94 1695.708565 -2053.510768
95 584.027000 1695.708565
> 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/7ionq1199525321.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/8hx261199525321.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/9t6jw1199525321.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
> 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/10x4r61199525321.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/11f73u1199525321.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/12acwd1199525321.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/13gkma1199525321.tab")
>
> system("convert tmp/1aark1199525320.ps tmp/1aark1199525320.png")
> system("convert tmp/2e2dk1199525320.ps tmp/2e2dk1199525320.png")
> system("convert tmp/39ln31199525320.ps tmp/39ln31199525320.png")
> system("convert tmp/4m1ni1199525320.ps tmp/4m1ni1199525320.png")
> system("convert tmp/5lu5v1199525320.ps tmp/5lu5v1199525320.png")
> system("convert tmp/66bf81199525320.ps tmp/66bf81199525320.png")
> system("convert tmp/7ionq1199525321.ps tmp/7ionq1199525321.png")
> system("convert tmp/8hx261199525321.ps tmp/8hx261199525321.png")
> system("convert tmp/9t6jw1199525321.ps tmp/9t6jw1199525321.png")
>
>
> proc.time()
user system elapsed
2.459 1.507 3.106