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(1.1608
+ ,0
+ ,1.1208
+ ,0
+ ,1.0883
+ ,0
+ ,1.0704
+ ,0
+ ,1.0628
+ ,0
+ ,1.0378
+ ,0
+ ,1.0353
+ ,0
+ ,1.0604
+ ,0
+ ,1.0501
+ ,0
+ ,1.0706
+ ,0
+ ,1.0338
+ ,0
+ ,1.011
+ ,0
+ ,1.0137
+ ,0
+ ,0.9834
+ ,0
+ ,0.9643
+ ,0
+ ,0.947
+ ,0
+ ,0.906
+ ,0
+ ,0.9492
+ ,0
+ ,0.9397
+ ,0
+ ,0.9041
+ ,0
+ ,0.8721
+ ,0
+ ,0.8552
+ ,0
+ ,0.8564
+ ,0
+ ,0.8973
+ ,0
+ ,0.9383
+ ,0
+ ,0.9217
+ ,0
+ ,0.9095
+ ,0
+ ,0.892
+ ,0
+ ,0.8742
+ ,0
+ ,0.8532
+ ,0
+ ,0.8607
+ ,0
+ ,0.9005
+ ,0
+ ,0.9111
+ ,0
+ ,0.9059
+ ,0
+ ,0.8883
+ ,0
+ ,0.8924
+ ,0
+ ,0.8833
+ ,0
+ ,0.87
+ ,0
+ ,0.8758
+ ,0
+ ,0.8858
+ ,0
+ ,0.917
+ ,0
+ ,0.9554
+ ,0
+ ,0.9922
+ ,0
+ ,0.9778
+ ,0
+ ,0.9808
+ ,0
+ ,0.9811
+ ,0
+ ,1.0014
+ ,0
+ ,1.0183
+ ,0
+ ,1.0622
+ ,0
+ ,1.0773
+ ,0
+ ,1.0807
+ ,0
+ ,1.0848
+ ,0
+ ,1.1582
+ ,0
+ ,1.1663
+ ,0
+ ,1.1372
+ ,0
+ ,1.1139
+ ,0
+ ,1.1222
+ ,0
+ ,1.1692
+ ,0
+ ,1.1702
+ ,0
+ ,1.2286
+ ,0
+ ,1.2613
+ ,0
+ ,1.2646
+ ,0
+ ,1.2262
+ ,0
+ ,1.1985
+ ,0
+ ,1.2007
+ ,0
+ ,1.2138
+ ,0
+ ,1.2266
+ ,0
+ ,1.2176
+ ,0
+ ,1.2218
+ ,0
+ ,1.249
+ ,0
+ ,1.2991
+ ,0
+ ,1.3408
+ ,0
+ ,1.3119
+ ,0
+ ,1.3014
+ ,0
+ ,1.3201
+ ,0
+ ,1.2938
+ ,0
+ ,1.2694
+ ,0
+ ,1.2165
+ ,0
+ ,1.2037
+ ,0
+ ,1.2292
+ ,0
+ ,1.2256
+ ,0
+ ,1.2015
+ ,0
+ ,1.1786
+ ,0
+ ,1.1856
+ ,0
+ ,1.2103
+ ,0
+ ,1.1938
+ ,0
+ ,1.202
+ ,0
+ ,1.2271
+ ,0
+ ,1.277
+ ,0
+ ,1.265
+ ,0
+ ,1.2684
+ ,0
+ ,1.2811
+ ,0
+ ,1.2727
+ ,0
+ ,1.2611
+ ,0
+ ,1.2881
+ ,0
+ ,1.3213
+ ,0
+ ,1.2999
+ ,0
+ ,1.3074
+ ,0
+ ,1.3242
+ ,0
+ ,1.3516
+ ,0
+ ,1.3511
+ ,0
+ ,1.3419
+ ,1
+ ,1.3716
+ ,1
+ ,1.3622
+ ,1
+ ,1.3896
+ ,1
+ ,1.4227
+ ,1
+ ,1.4684
+ ,1
+ ,1.457
+ ,1
+ ,1.4718
+ ,1
+ ,1.4748
+ ,1
+ ,1.5527
+ ,1
+ ,1.5751
+ ,1
+ ,1.5557
+ ,1
+ ,1.5553
+ ,1
+ ,1.577
+ ,1)
+ ,dim=c(2
+ ,115)
+ ,dimnames=list(c('y'
+ ,'x')
+ ,1:115))
> y <- array(NA,dim=c(2,115),dimnames=list(c('y','x'),1:115))
> 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 = 'Include Monthly Dummies'
> par1 = '1'
> ylab = ''
> xlab = ''
> main = ''
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
y x M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 1.1608 0 1 0 0 0 0 0 0 0 0 0 0 1
2 1.1208 0 0 1 0 0 0 0 0 0 0 0 0 2
3 1.0883 0 0 0 1 0 0 0 0 0 0 0 0 3
4 1.0704 0 0 0 0 1 0 0 0 0 0 0 0 4
5 1.0628 0 0 0 0 0 1 0 0 0 0 0 0 5
6 1.0378 0 0 0 0 0 0 1 0 0 0 0 0 6
7 1.0353 0 0 0 0 0 0 0 1 0 0 0 0 7
8 1.0604 0 0 0 0 0 0 0 0 1 0 0 0 8
9 1.0501 0 0 0 0 0 0 0 0 0 1 0 0 9
10 1.0706 0 0 0 0 0 0 0 0 0 0 1 0 10
11 1.0338 0 0 0 0 0 0 0 0 0 0 0 1 11
12 1.0110 0 0 0 0 0 0 0 0 0 0 0 0 12
13 1.0137 0 1 0 0 0 0 0 0 0 0 0 0 13
14 0.9834 0 0 1 0 0 0 0 0 0 0 0 0 14
15 0.9643 0 0 0 1 0 0 0 0 0 0 0 0 15
16 0.9470 0 0 0 0 1 0 0 0 0 0 0 0 16
17 0.9060 0 0 0 0 0 1 0 0 0 0 0 0 17
18 0.9492 0 0 0 0 0 0 1 0 0 0 0 0 18
19 0.9397 0 0 0 0 0 0 0 1 0 0 0 0 19
20 0.9041 0 0 0 0 0 0 0 0 1 0 0 0 20
21 0.8721 0 0 0 0 0 0 0 0 0 1 0 0 21
22 0.8552 0 0 0 0 0 0 0 0 0 0 1 0 22
23 0.8564 0 0 0 0 0 0 0 0 0 0 0 1 23
24 0.8973 0 0 0 0 0 0 0 0 0 0 0 0 24
25 0.9383 0 1 0 0 0 0 0 0 0 0 0 0 25
26 0.9217 0 0 1 0 0 0 0 0 0 0 0 0 26
27 0.9095 0 0 0 1 0 0 0 0 0 0 0 0 27
28 0.8920 0 0 0 0 1 0 0 0 0 0 0 0 28
29 0.8742 0 0 0 0 0 1 0 0 0 0 0 0 29
30 0.8532 0 0 0 0 0 0 1 0 0 0 0 0 30
31 0.8607 0 0 0 0 0 0 0 1 0 0 0 0 31
32 0.9005 0 0 0 0 0 0 0 0 1 0 0 0 32
33 0.9111 0 0 0 0 0 0 0 0 0 1 0 0 33
34 0.9059 0 0 0 0 0 0 0 0 0 0 1 0 34
35 0.8883 0 0 0 0 0 0 0 0 0 0 0 1 35
36 0.8924 0 0 0 0 0 0 0 0 0 0 0 0 36
37 0.8833 0 1 0 0 0 0 0 0 0 0 0 0 37
38 0.8700 0 0 1 0 0 0 0 0 0 0 0 0 38
39 0.8758 0 0 0 1 0 0 0 0 0 0 0 0 39
40 0.8858 0 0 0 0 1 0 0 0 0 0 0 0 40
41 0.9170 0 0 0 0 0 1 0 0 0 0 0 0 41
42 0.9554 0 0 0 0 0 0 1 0 0 0 0 0 42
43 0.9922 0 0 0 0 0 0 0 1 0 0 0 0 43
44 0.9778 0 0 0 0 0 0 0 0 1 0 0 0 44
45 0.9808 0 0 0 0 0 0 0 0 0 1 0 0 45
46 0.9811 0 0 0 0 0 0 0 0 0 0 1 0 46
47 1.0014 0 0 0 0 0 0 0 0 0 0 0 1 47
48 1.0183 0 0 0 0 0 0 0 0 0 0 0 0 48
49 1.0622 0 1 0 0 0 0 0 0 0 0 0 0 49
50 1.0773 0 0 1 0 0 0 0 0 0 0 0 0 50
51 1.0807 0 0 0 1 0 0 0 0 0 0 0 0 51
52 1.0848 0 0 0 0 1 0 0 0 0 0 0 0 52
53 1.1582 0 0 0 0 0 1 0 0 0 0 0 0 53
54 1.1663 0 0 0 0 0 0 1 0 0 0 0 0 54
55 1.1372 0 0 0 0 0 0 0 1 0 0 0 0 55
56 1.1139 0 0 0 0 0 0 0 0 1 0 0 0 56
57 1.1222 0 0 0 0 0 0 0 0 0 1 0 0 57
58 1.1692 0 0 0 0 0 0 0 0 0 0 1 0 58
59 1.1702 0 0 0 0 0 0 0 0 0 0 0 1 59
60 1.2286 0 0 0 0 0 0 0 0 0 0 0 0 60
61 1.2613 0 1 0 0 0 0 0 0 0 0 0 0 61
62 1.2646 0 0 1 0 0 0 0 0 0 0 0 0 62
63 1.2262 0 0 0 1 0 0 0 0 0 0 0 0 63
64 1.1985 0 0 0 0 1 0 0 0 0 0 0 0 64
65 1.2007 0 0 0 0 0 1 0 0 0 0 0 0 65
66 1.2138 0 0 0 0 0 0 1 0 0 0 0 0 66
67 1.2266 0 0 0 0 0 0 0 1 0 0 0 0 67
68 1.2176 0 0 0 0 0 0 0 0 1 0 0 0 68
69 1.2218 0 0 0 0 0 0 0 0 0 1 0 0 69
70 1.2490 0 0 0 0 0 0 0 0 0 0 1 0 70
71 1.2991 0 0 0 0 0 0 0 0 0 0 0 1 71
72 1.3408 0 0 0 0 0 0 0 0 0 0 0 0 72
73 1.3119 0 1 0 0 0 0 0 0 0 0 0 0 73
74 1.3014 0 0 1 0 0 0 0 0 0 0 0 0 74
75 1.3201 0 0 0 1 0 0 0 0 0 0 0 0 75
76 1.2938 0 0 0 0 1 0 0 0 0 0 0 0 76
77 1.2694 0 0 0 0 0 1 0 0 0 0 0 0 77
78 1.2165 0 0 0 0 0 0 1 0 0 0 0 0 78
79 1.2037 0 0 0 0 0 0 0 1 0 0 0 0 79
80 1.2292 0 0 0 0 0 0 0 0 1 0 0 0 80
81 1.2256 0 0 0 0 0 0 0 0 0 1 0 0 81
82 1.2015 0 0 0 0 0 0 0 0 0 0 1 0 82
83 1.1786 0 0 0 0 0 0 0 0 0 0 0 1 83
84 1.1856 0 0 0 0 0 0 0 0 0 0 0 0 84
85 1.2103 0 1 0 0 0 0 0 0 0 0 0 0 85
86 1.1938 0 0 1 0 0 0 0 0 0 0 0 0 86
87 1.2020 0 0 0 1 0 0 0 0 0 0 0 0 87
88 1.2271 0 0 0 0 1 0 0 0 0 0 0 0 88
89 1.2770 0 0 0 0 0 1 0 0 0 0 0 0 89
90 1.2650 0 0 0 0 0 0 1 0 0 0 0 0 90
91 1.2684 0 0 0 0 0 0 0 1 0 0 0 0 91
92 1.2811 0 0 0 0 0 0 0 0 1 0 0 0 92
93 1.2727 0 0 0 0 0 0 0 0 0 1 0 0 93
94 1.2611 0 0 0 0 0 0 0 0 0 0 1 0 94
95 1.2881 0 0 0 0 0 0 0 0 0 0 0 1 95
96 1.3213 0 0 0 0 0 0 0 0 0 0 0 0 96
97 1.2999 0 1 0 0 0 0 0 0 0 0 0 0 97
98 1.3074 0 0 1 0 0 0 0 0 0 0 0 0 98
99 1.3242 0 0 0 1 0 0 0 0 0 0 0 0 99
100 1.3516 0 0 0 0 1 0 0 0 0 0 0 0 100
101 1.3511 0 0 0 0 0 1 0 0 0 0 0 0 101
102 1.3419 1 0 0 0 0 0 1 0 0 0 0 0 102
103 1.3716 1 0 0 0 0 0 0 1 0 0 0 0 103
104 1.3622 1 0 0 0 0 0 0 0 1 0 0 0 104
105 1.3896 1 0 0 0 0 0 0 0 0 1 0 0 105
106 1.4227 1 0 0 0 0 0 0 0 0 0 1 0 106
107 1.4684 1 0 0 0 0 0 0 0 0 0 0 1 107
108 1.4570 1 0 0 0 0 0 0 0 0 0 0 0 108
109 1.4718 1 1 0 0 0 0 0 0 0 0 0 0 109
110 1.4748 1 0 1 0 0 0 0 0 0 0 0 0 110
111 1.5527 1 0 0 1 0 0 0 0 0 0 0 0 111
112 1.5751 1 0 0 0 1 0 0 0 0 0 0 0 112
113 1.5557 1 0 0 0 0 1 0 0 0 0 0 0 113
114 1.5553 1 0 0 0 0 0 1 0 0 0 0 0 114
115 1.5770 1 0 0 0 0 0 0 1 0 0 0 0 115
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
0.883859 0.130031 0.033535 0.019506 0.018167 0.012198
M5 M6 M7 M8 M9 M10
0.012598 -0.006374 -0.004773 -0.017148 -0.021436 -0.017824
M11 t
-0.014468 0.004199
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.192932 -0.068739 0.006459 0.060845 0.239207
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.8838588 0.0370742 23.840 < 2e-16 ***
x 0.1300313 0.0338395 3.843 0.000213 ***
M1 0.0335350 0.0446681 0.751 0.454544
M2 0.0195058 0.0446586 0.437 0.663206
M3 0.0181667 0.0446516 0.407 0.684976
M4 0.0121975 0.0446470 0.273 0.785258
M5 0.0125984 0.0446449 0.282 0.778375
M6 -0.0063739 0.0447449 -0.142 0.887009
M7 -0.0047730 0.0447335 -0.107 0.915239
M8 -0.0171479 0.0458227 -0.374 0.709023
M9 -0.0214359 0.0458142 -0.468 0.640873
M10 -0.0178239 0.0458082 -0.389 0.698022
M11 -0.0144675 0.0458046 -0.316 0.752766
t 0.0041991 0.0003317 12.658 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.09716 on 101 degrees of freedom
Multiple R-squared: 0.7721, Adjusted R-squared: 0.7428
F-statistic: 26.32 on 13 and 101 DF, p-value: < 2.2e-16
> postscript(file="/var/www/html/rcomp/tmp/1mpmt1228082823.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/2qa5l1228082823.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/3qugr1228082823.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/41vph1228082823.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/56qj01228082823.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 = 115
Frequency = 1
1 2 3 4 5
0.2392070800 0.2090370800 0.1736770800 0.1575470800 0.1453470800
6 7 8 9 10
0.1351202066 0.1268202066 0.1600958770 0.1498847659 0.1625736548
11 12 13 14 15
0.1182180992 0.0767514326 0.0417173126 0.0212473126 -0.0007126874
16 17 18 19 20
-0.0162426874 -0.0618426874 -0.0038695607 -0.0191695607 -0.0465938904
21 22 23 24 25
-0.0785050015 -0.1032161126 -0.1095716682 -0.0873383348 -0.0840724548
26 27 28 29 30
-0.0908424548 -0.1059024548 -0.1216324548 -0.1440324548 -0.1502593281
31 32 33 34 35
-0.1485593281 -0.1005836578 -0.0898947689 -0.1029058800 -0.1280614356
36 37 38 39 40
-0.1426281022 -0.1894622222 -0.1929322222 -0.1899922222 -0.1782222222
41 42 43 44 45
-0.1516222222 -0.0984490955 -0.0674490955 -0.0736734252 -0.0705845363
46 47 48 49 50
-0.0780956474 -0.0653512030 -0.0671178696 -0.0609519896 -0.0360219896
51 52 53 54 55
-0.0354819896 -0.0296119896 0.0391880104 0.0620611371 0.0271611371
56 57 58 59 60
0.0120368074 0.0204256963 0.0596145852 0.0530590296 0.0927923630
61 62 63 64 65
0.0877582430 0.1008882430 0.0596282430 0.0336982430 0.0312982430
66 67 68 69 70
0.0591713697 0.0661713697 0.0653470400 0.0696359289 0.0890248178
71 72 73 74 75
0.1315692623 0.1546025956 0.0879684756 0.0872984756 0.1031384756
76 77 78 79 80
0.0786084756 0.0496084756 0.0114816023 -0.0071183977 0.0265572726
81 82 83 84 85
0.0230461615 -0.0088649496 -0.0393205051 -0.0509871718 -0.0640212918
86 87 88 89 90
-0.0706912918 -0.0653512918 -0.0384812918 0.0068187082 0.0095918349
91 92 93 94 95
0.0071918349 0.0280675052 0.0197563941 0.0003452830 0.0197897275
96 97 98 99 100
0.0343230608 -0.0248110592 -0.0074810592 0.0064589408 0.0356289408
101 102 103 104 105
0.0305289408 -0.0939291994 -0.0700291994 -0.0712535290 -0.0437646401
106 107 108 109 110
-0.0184757512 0.0196686932 -0.0103979734 -0.0333320934 -0.0205020934
111 112 113 114 115
0.0545379066 0.0787079066 0.0547079066 0.0690810332 0.0849810332
> postscript(file="/var/www/html/rcomp/tmp/6pgtu1228082823.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 = 115
Frequency = 1
lag(myerror, k = 1) myerror
0 0.2392070800 NA
1 0.2090370800 0.2392070800
2 0.1736770800 0.2090370800
3 0.1575470800 0.1736770800
4 0.1453470800 0.1575470800
5 0.1351202066 0.1453470800
6 0.1268202066 0.1351202066
7 0.1600958770 0.1268202066
8 0.1498847659 0.1600958770
9 0.1625736548 0.1498847659
10 0.1182180992 0.1625736548
11 0.0767514326 0.1182180992
12 0.0417173126 0.0767514326
13 0.0212473126 0.0417173126
14 -0.0007126874 0.0212473126
15 -0.0162426874 -0.0007126874
16 -0.0618426874 -0.0162426874
17 -0.0038695607 -0.0618426874
18 -0.0191695607 -0.0038695607
19 -0.0465938904 -0.0191695607
20 -0.0785050015 -0.0465938904
21 -0.1032161126 -0.0785050015
22 -0.1095716682 -0.1032161126
23 -0.0873383348 -0.1095716682
24 -0.0840724548 -0.0873383348
25 -0.0908424548 -0.0840724548
26 -0.1059024548 -0.0908424548
27 -0.1216324548 -0.1059024548
28 -0.1440324548 -0.1216324548
29 -0.1502593281 -0.1440324548
30 -0.1485593281 -0.1502593281
31 -0.1005836578 -0.1485593281
32 -0.0898947689 -0.1005836578
33 -0.1029058800 -0.0898947689
34 -0.1280614356 -0.1029058800
35 -0.1426281022 -0.1280614356
36 -0.1894622222 -0.1426281022
37 -0.1929322222 -0.1894622222
38 -0.1899922222 -0.1929322222
39 -0.1782222222 -0.1899922222
40 -0.1516222222 -0.1782222222
41 -0.0984490955 -0.1516222222
42 -0.0674490955 -0.0984490955
43 -0.0736734252 -0.0674490955
44 -0.0705845363 -0.0736734252
45 -0.0780956474 -0.0705845363
46 -0.0653512030 -0.0780956474
47 -0.0671178696 -0.0653512030
48 -0.0609519896 -0.0671178696
49 -0.0360219896 -0.0609519896
50 -0.0354819896 -0.0360219896
51 -0.0296119896 -0.0354819896
52 0.0391880104 -0.0296119896
53 0.0620611371 0.0391880104
54 0.0271611371 0.0620611371
55 0.0120368074 0.0271611371
56 0.0204256963 0.0120368074
57 0.0596145852 0.0204256963
58 0.0530590296 0.0596145852
59 0.0927923630 0.0530590296
60 0.0877582430 0.0927923630
61 0.1008882430 0.0877582430
62 0.0596282430 0.1008882430
63 0.0336982430 0.0596282430
64 0.0312982430 0.0336982430
65 0.0591713697 0.0312982430
66 0.0661713697 0.0591713697
67 0.0653470400 0.0661713697
68 0.0696359289 0.0653470400
69 0.0890248178 0.0696359289
70 0.1315692623 0.0890248178
71 0.1546025956 0.1315692623
72 0.0879684756 0.1546025956
73 0.0872984756 0.0879684756
74 0.1031384756 0.0872984756
75 0.0786084756 0.1031384756
76 0.0496084756 0.0786084756
77 0.0114816023 0.0496084756
78 -0.0071183977 0.0114816023
79 0.0265572726 -0.0071183977
80 0.0230461615 0.0265572726
81 -0.0088649496 0.0230461615
82 -0.0393205051 -0.0088649496
83 -0.0509871718 -0.0393205051
84 -0.0640212918 -0.0509871718
85 -0.0706912918 -0.0640212918
86 -0.0653512918 -0.0706912918
87 -0.0384812918 -0.0653512918
88 0.0068187082 -0.0384812918
89 0.0095918349 0.0068187082
90 0.0071918349 0.0095918349
91 0.0280675052 0.0071918349
92 0.0197563941 0.0280675052
93 0.0003452830 0.0197563941
94 0.0197897275 0.0003452830
95 0.0343230608 0.0197897275
96 -0.0248110592 0.0343230608
97 -0.0074810592 -0.0248110592
98 0.0064589408 -0.0074810592
99 0.0356289408 0.0064589408
100 0.0305289408 0.0356289408
101 -0.0939291994 0.0305289408
102 -0.0700291994 -0.0939291994
103 -0.0712535290 -0.0700291994
104 -0.0437646401 -0.0712535290
105 -0.0184757512 -0.0437646401
106 0.0196686932 -0.0184757512
107 -0.0103979734 0.0196686932
108 -0.0333320934 -0.0103979734
109 -0.0205020934 -0.0333320934
110 0.0545379066 -0.0205020934
111 0.0787079066 0.0545379066
112 0.0547079066 0.0787079066
113 0.0690810332 0.0547079066
114 0.0849810332 0.0690810332
115 NA 0.0849810332
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.2090370800 0.2392070800
[2,] 0.1736770800 0.2090370800
[3,] 0.1575470800 0.1736770800
[4,] 0.1453470800 0.1575470800
[5,] 0.1351202066 0.1453470800
[6,] 0.1268202066 0.1351202066
[7,] 0.1600958770 0.1268202066
[8,] 0.1498847659 0.1600958770
[9,] 0.1625736548 0.1498847659
[10,] 0.1182180992 0.1625736548
[11,] 0.0767514326 0.1182180992
[12,] 0.0417173126 0.0767514326
[13,] 0.0212473126 0.0417173126
[14,] -0.0007126874 0.0212473126
[15,] -0.0162426874 -0.0007126874
[16,] -0.0618426874 -0.0162426874
[17,] -0.0038695607 -0.0618426874
[18,] -0.0191695607 -0.0038695607
[19,] -0.0465938904 -0.0191695607
[20,] -0.0785050015 -0.0465938904
[21,] -0.1032161126 -0.0785050015
[22,] -0.1095716682 -0.1032161126
[23,] -0.0873383348 -0.1095716682
[24,] -0.0840724548 -0.0873383348
[25,] -0.0908424548 -0.0840724548
[26,] -0.1059024548 -0.0908424548
[27,] -0.1216324548 -0.1059024548
[28,] -0.1440324548 -0.1216324548
[29,] -0.1502593281 -0.1440324548
[30,] -0.1485593281 -0.1502593281
[31,] -0.1005836578 -0.1485593281
[32,] -0.0898947689 -0.1005836578
[33,] -0.1029058800 -0.0898947689
[34,] -0.1280614356 -0.1029058800
[35,] -0.1426281022 -0.1280614356
[36,] -0.1894622222 -0.1426281022
[37,] -0.1929322222 -0.1894622222
[38,] -0.1899922222 -0.1929322222
[39,] -0.1782222222 -0.1899922222
[40,] -0.1516222222 -0.1782222222
[41,] -0.0984490955 -0.1516222222
[42,] -0.0674490955 -0.0984490955
[43,] -0.0736734252 -0.0674490955
[44,] -0.0705845363 -0.0736734252
[45,] -0.0780956474 -0.0705845363
[46,] -0.0653512030 -0.0780956474
[47,] -0.0671178696 -0.0653512030
[48,] -0.0609519896 -0.0671178696
[49,] -0.0360219896 -0.0609519896
[50,] -0.0354819896 -0.0360219896
[51,] -0.0296119896 -0.0354819896
[52,] 0.0391880104 -0.0296119896
[53,] 0.0620611371 0.0391880104
[54,] 0.0271611371 0.0620611371
[55,] 0.0120368074 0.0271611371
[56,] 0.0204256963 0.0120368074
[57,] 0.0596145852 0.0204256963
[58,] 0.0530590296 0.0596145852
[59,] 0.0927923630 0.0530590296
[60,] 0.0877582430 0.0927923630
[61,] 0.1008882430 0.0877582430
[62,] 0.0596282430 0.1008882430
[63,] 0.0336982430 0.0596282430
[64,] 0.0312982430 0.0336982430
[65,] 0.0591713697 0.0312982430
[66,] 0.0661713697 0.0591713697
[67,] 0.0653470400 0.0661713697
[68,] 0.0696359289 0.0653470400
[69,] 0.0890248178 0.0696359289
[70,] 0.1315692623 0.0890248178
[71,] 0.1546025956 0.1315692623
[72,] 0.0879684756 0.1546025956
[73,] 0.0872984756 0.0879684756
[74,] 0.1031384756 0.0872984756
[75,] 0.0786084756 0.1031384756
[76,] 0.0496084756 0.0786084756
[77,] 0.0114816023 0.0496084756
[78,] -0.0071183977 0.0114816023
[79,] 0.0265572726 -0.0071183977
[80,] 0.0230461615 0.0265572726
[81,] -0.0088649496 0.0230461615
[82,] -0.0393205051 -0.0088649496
[83,] -0.0509871718 -0.0393205051
[84,] -0.0640212918 -0.0509871718
[85,] -0.0706912918 -0.0640212918
[86,] -0.0653512918 -0.0706912918
[87,] -0.0384812918 -0.0653512918
[88,] 0.0068187082 -0.0384812918
[89,] 0.0095918349 0.0068187082
[90,] 0.0071918349 0.0095918349
[91,] 0.0280675052 0.0071918349
[92,] 0.0197563941 0.0280675052
[93,] 0.0003452830 0.0197563941
[94,] 0.0197897275 0.0003452830
[95,] 0.0343230608 0.0197897275
[96,] -0.0248110592 0.0343230608
[97,] -0.0074810592 -0.0248110592
[98,] 0.0064589408 -0.0074810592
[99,] 0.0356289408 0.0064589408
[100,] 0.0305289408 0.0356289408
[101,] -0.0939291994 0.0305289408
[102,] -0.0700291994 -0.0939291994
[103,] -0.0712535290 -0.0700291994
[104,] -0.0437646401 -0.0712535290
[105,] -0.0184757512 -0.0437646401
[106,] 0.0196686932 -0.0184757512
[107,] -0.0103979734 0.0196686932
[108,] -0.0333320934 -0.0103979734
[109,] -0.0205020934 -0.0333320934
[110,] 0.0545379066 -0.0205020934
[111,] 0.0787079066 0.0545379066
[112,] 0.0547079066 0.0787079066
[113,] 0.0690810332 0.0547079066
[114,] 0.0849810332 0.0690810332
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.2090370800 0.2392070800
2 0.1736770800 0.2090370800
3 0.1575470800 0.1736770800
4 0.1453470800 0.1575470800
5 0.1351202066 0.1453470800
6 0.1268202066 0.1351202066
7 0.1600958770 0.1268202066
8 0.1498847659 0.1600958770
9 0.1625736548 0.1498847659
10 0.1182180992 0.1625736548
11 0.0767514326 0.1182180992
12 0.0417173126 0.0767514326
13 0.0212473126 0.0417173126
14 -0.0007126874 0.0212473126
15 -0.0162426874 -0.0007126874
16 -0.0618426874 -0.0162426874
17 -0.0038695607 -0.0618426874
18 -0.0191695607 -0.0038695607
19 -0.0465938904 -0.0191695607
20 -0.0785050015 -0.0465938904
21 -0.1032161126 -0.0785050015
22 -0.1095716682 -0.1032161126
23 -0.0873383348 -0.1095716682
24 -0.0840724548 -0.0873383348
25 -0.0908424548 -0.0840724548
26 -0.1059024548 -0.0908424548
27 -0.1216324548 -0.1059024548
28 -0.1440324548 -0.1216324548
29 -0.1502593281 -0.1440324548
30 -0.1485593281 -0.1502593281
31 -0.1005836578 -0.1485593281
32 -0.0898947689 -0.1005836578
33 -0.1029058800 -0.0898947689
34 -0.1280614356 -0.1029058800
35 -0.1426281022 -0.1280614356
36 -0.1894622222 -0.1426281022
37 -0.1929322222 -0.1894622222
38 -0.1899922222 -0.1929322222
39 -0.1782222222 -0.1899922222
40 -0.1516222222 -0.1782222222
41 -0.0984490955 -0.1516222222
42 -0.0674490955 -0.0984490955
43 -0.0736734252 -0.0674490955
44 -0.0705845363 -0.0736734252
45 -0.0780956474 -0.0705845363
46 -0.0653512030 -0.0780956474
47 -0.0671178696 -0.0653512030
48 -0.0609519896 -0.0671178696
49 -0.0360219896 -0.0609519896
50 -0.0354819896 -0.0360219896
51 -0.0296119896 -0.0354819896
52 0.0391880104 -0.0296119896
53 0.0620611371 0.0391880104
54 0.0271611371 0.0620611371
55 0.0120368074 0.0271611371
56 0.0204256963 0.0120368074
57 0.0596145852 0.0204256963
58 0.0530590296 0.0596145852
59 0.0927923630 0.0530590296
60 0.0877582430 0.0927923630
61 0.1008882430 0.0877582430
62 0.0596282430 0.1008882430
63 0.0336982430 0.0596282430
64 0.0312982430 0.0336982430
65 0.0591713697 0.0312982430
66 0.0661713697 0.0591713697
67 0.0653470400 0.0661713697
68 0.0696359289 0.0653470400
69 0.0890248178 0.0696359289
70 0.1315692623 0.0890248178
71 0.1546025956 0.1315692623
72 0.0879684756 0.1546025956
73 0.0872984756 0.0879684756
74 0.1031384756 0.0872984756
75 0.0786084756 0.1031384756
76 0.0496084756 0.0786084756
77 0.0114816023 0.0496084756
78 -0.0071183977 0.0114816023
79 0.0265572726 -0.0071183977
80 0.0230461615 0.0265572726
81 -0.0088649496 0.0230461615
82 -0.0393205051 -0.0088649496
83 -0.0509871718 -0.0393205051
84 -0.0640212918 -0.0509871718
85 -0.0706912918 -0.0640212918
86 -0.0653512918 -0.0706912918
87 -0.0384812918 -0.0653512918
88 0.0068187082 -0.0384812918
89 0.0095918349 0.0068187082
90 0.0071918349 0.0095918349
91 0.0280675052 0.0071918349
92 0.0197563941 0.0280675052
93 0.0003452830 0.0197563941
94 0.0197897275 0.0003452830
95 0.0343230608 0.0197897275
96 -0.0248110592 0.0343230608
97 -0.0074810592 -0.0248110592
98 0.0064589408 -0.0074810592
99 0.0356289408 0.0064589408
100 0.0305289408 0.0356289408
101 -0.0939291994 0.0305289408
102 -0.0700291994 -0.0939291994
103 -0.0712535290 -0.0700291994
104 -0.0437646401 -0.0712535290
105 -0.0184757512 -0.0437646401
106 0.0196686932 -0.0184757512
107 -0.0103979734 0.0196686932
108 -0.0333320934 -0.0103979734
109 -0.0205020934 -0.0333320934
110 0.0545379066 -0.0205020934
111 0.0787079066 0.0545379066
112 0.0547079066 0.0787079066
113 0.0690810332 0.0547079066
114 0.0849810332 0.0690810332
> 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/7oljt1228082823.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/8tnaz1228082823.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/9qhe71228082823.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/10ywr41228082823.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/11a2i71228082823.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/12qqzf1228082824.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/13xah51228082824.tab")
>
> system("convert tmp/1mpmt1228082823.ps tmp/1mpmt1228082823.png")
> system("convert tmp/2qa5l1228082823.ps tmp/2qa5l1228082823.png")
> system("convert tmp/3qugr1228082823.ps tmp/3qugr1228082823.png")
> system("convert tmp/41vph1228082823.ps tmp/41vph1228082823.png")
> system("convert tmp/56qj01228082823.ps tmp/56qj01228082823.png")
> system("convert tmp/6pgtu1228082823.ps tmp/6pgtu1228082823.png")
> system("convert tmp/7oljt1228082823.ps tmp/7oljt1228082823.png")
> system("convert tmp/8tnaz1228082823.ps tmp/8tnaz1228082823.png")
> system("convert tmp/9qhe71228082823.ps tmp/9qhe71228082823.png")
>
>
> proc.time()
user system elapsed
2.275 1.527 3.090