R version 2.6.1 (2007-11-26)
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(106
+ ,87
+ ,1
+ ,65.3
+ ,170
+ ,2.2
+ ,70
+ ,1
+ ,65.73
+ ,165
+ ,62.3
+ ,75
+ ,1
+ ,69.44
+ ,168
+ ,14.7
+ ,79
+ ,1
+ ,73.74
+ ,170
+ ,5
+ ,64.5
+ ,1
+ ,74.31
+ ,157
+ ,74.4
+ ,75
+ ,0
+ ,70.53
+ ,146
+ ,66.1
+ ,70
+ ,0
+ ,69.42
+ ,149
+ ,22
+ ,67
+ ,1
+ ,69.77
+ ,159
+ ,3.4
+ ,52
+ ,0
+ ,65.47
+ ,151
+ ,0.3
+ ,67.2
+ ,1
+ ,66.2
+ ,174
+ ,53.2
+ ,47
+ ,0
+ ,70.46
+ ,156
+ ,0
+ ,46.4
+ ,0
+ ,74.44
+ ,151.5
+ ,57.2
+ ,76
+ ,0
+ ,69.28
+ ,146
+ ,9.2
+ ,71.6
+ ,1
+ ,67.67
+ ,157
+ ,15.9
+ ,63.8
+ ,1
+ ,67.22
+ ,171.5
+ ,17.6
+ ,48.2
+ ,1
+ ,64.85
+ ,150
+ ,21
+ ,64.5
+ ,1
+ ,71.35
+ ,170
+ ,7.6
+ ,75.9
+ ,1
+ ,72.28
+ ,164.5
+ ,71.6
+ ,80
+ ,1
+ ,71.87
+ ,163
+ ,12.9
+ ,56
+ ,1
+ ,67.34
+ ,162.5
+ ,10.5
+ ,75.5
+ ,0
+ ,73.5
+ ,161
+ ,25.7
+ ,77
+ ,1
+ ,64.91
+ ,166.5
+ ,26.8
+ ,88
+ ,0
+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+ ,75.67
+ ,163
+ ,43.4
+ ,73
+ ,1
+ ,76.07
+ ,168
+ ,13
+ ,56
+ ,1
+ ,82.88
+ ,165.5
+ ,27.8
+ ,49
+ ,0
+ ,77.14
+ ,147
+ ,6.5
+ ,54.7
+ ,0
+ ,77.31
+ ,158
+ ,7.1
+ ,67
+ ,1
+ ,76.58
+ ,168
+ ,6
+ ,47
+ ,0
+ ,82.86
+ ,154.5
+ ,6.5
+ ,47
+ ,0
+ ,76.64
+ ,147)
+ ,dim=c(5
+ ,117)
+ ,dimnames=list(c('y'
+ ,'weight'
+ ,'sex'
+ ,'age'
+ ,'height')
+ ,1:117))
> y <- array(NA,dim=c(5,117),dimnames=list(c('y','weight','sex','age','height'),1:117))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '1'
> 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 weight sex age height
1 106.0 87.0 1 65.30 170.0
2 2.2 70.0 1 65.73 165.0
3 62.3 75.0 1 69.44 168.0
4 14.7 79.0 1 73.74 170.0
5 5.0 64.5 1 74.31 157.0
6 74.4 75.0 0 70.53 146.0
7 66.1 70.0 0 69.42 149.0
8 22.0 67.0 1 69.77 159.0
9 3.4 52.0 0 65.47 151.0
10 0.3 67.2 1 66.20 174.0
11 53.2 47.0 0 70.46 156.0
12 0.0 46.4 0 74.44 151.5
13 57.2 76.0 0 69.28 146.0
14 9.2 71.6 1 67.67 157.0
15 15.9 63.8 1 67.22 171.5
16 17.6 48.2 1 64.85 150.0
17 21.0 64.5 1 71.35 170.0
18 7.6 75.9 1 72.28 164.5
19 71.6 80.0 1 71.87 163.0
20 12.9 56.0 1 67.34 162.5
21 10.5 75.5 0 73.50 161.0
22 25.7 77.0 1 64.91 166.5
23 26.8 88.0 0 68.13 160.0
24 7.3 48.0 0 72.50 147.0
25 17.1 73.0 1 72.36 162.5
26 27.3 72.0 1 70.59 161.0
27 16.5 64.0 1 74.76 163.5
28 5.4 76.0 0 65.63 161.0
29 5.6 67.4 1 67.04 172.5
30 36.5 73.7 1 66.72 169.5
31 1.1 59.2 0 65.80 158.0
32 3.9 53.0 0 72.44 153.5
33 34.2 41.9 1 71.83 165.5
34 40.3 65.5 1 72.67 153.5
35 15.6 63.0 1 69.56 157.5
36 15.5 54.0 0 67.00 145.5
37 52.9 77.7 0 68.86 156.0
38 1.6 47.6 0 71.25 163.0
39 14.2 53.1 1 69.88 159.0
40 7.5 55.5 1 67.18 167.0
41 2.0 64.0 1 67.47 157.5
42 71.4 75.6 1 73.20 156.0
43 3.2 57.0 0 69.60 156.5
44 20.0 63.0 0 71.24 148.5
45 2.8 59.5 1 73.83 162.5
46 15.3 84.5 1 66.07 164.0
47 8.0 59.9 0 70.68 152.0
48 36.6 60.0 1 74.01 157.5
49 3.8 64.0 0 68.53 148.0
50 25.5 54.0 0 66.72 145.5
51 3.2 53.8 0 72.69 154.5
52 33.1 84.0 1 67.46 166.5
53 42.0 63.2 0 73.81 157.0
54 16.2 54.3 1 72.96 150.0
55 0.0 60.0 0 71.65 152.0
56 22.7 68.0 1 72.79 171.0
57 36.4 74.0 1 73.83 165.5
58 69.0 74.0 1 66.74 165.0
59 11.2 68.5 1 65.62 168.5
60 12.5 76.0 0 66.18 154.0
61 51.7 83.0 0 67.78 156.5
62 3.6 62.5 0 68.84 152.0
63 22.2 57.0 1 65.27 164.5
64 39.2 85.0 1 72.84 161.0
65 27.9 50.0 1 75.36 162.0
66 58.8 53.0 1 76.88 169.0
67 1.0 57.0 0 76.51 150.0
68 4.7 46.0 1 80.63 146.0
69 25.6 65.4 1 75.27 165.0
70 5.3 71.4 1 81.19 165.5
71 38.7 41.0 1 81.30 164.0
72 31.6 66.0 1 77.77 163.0
73 19.3 69.5 1 75.51 167.5
74 26.5 59.0 1 78.64 166.0
75 12.8 80.0 1 80.68 167.5
76 18.3 72.0 1 77.40 162.0
77 13.2 73.0 0 80.71 165.0
78 36.0 66.4 0 83.16 145.0
79 34.1 37.0 0 87.99 139.0
80 71.5 70.0 1 72.21 164.0
81 43.3 75.0 1 70.24 167.0
82 47.7 54.0 1 66.06 163.0
83 74.9 76.2 1 68.67 162.5
84 0.9 74.9 1 68.77 159.5
85 35.9 98.0 1 68.07 169.0
86 45.8 86.5 0 67.33 152.5
87 54.2 72.8 1 69.47 165.0
88 34.0 65.0 1 70.81 166.0
89 7.9 50.0 1 73.17 163.0
90 54.5 81.0 1 71.28 167.5
91 8.2 52.0 0 69.47 157.5
92 49.3 68.0 1 65.31 160.0
93 46.9 58.5 1 70.23 162.0
94 16.8 65.5 1 73.23 164.5
95 2.8 62.5 0 68.67 150.0
96 60.9 64.0 1 72.66 167.0
97 5.6 55.7 0 74.79 155.0
98 6.6 84.0 1 73.04 173.5
99 22.9 63.7 1 69.95 173.0
100 51.1 65.0 0 67.51 156.0
101 23.3 87.5 0 67.50 149.5
102 11.5 79.0 1 71.32 167.0
103 79.1 58.5 0 71.23 146.0
104 53.6 75.0 1 67.49 166.0
105 1.5 52.5 0 68.62 151.5
106 40.4 57.5 1 72.53 164.0
107 25.4 70.0 1 66.67 160.0
108 6.7 72.0 1 66.19 152.5
109 76.0 88.0 1 78.40 160.0
110 0.6 58.0 1 75.67 163.0
111 43.4 73.0 1 76.07 168.0
112 13.0 56.0 1 82.88 165.5
113 27.8 49.0 0 77.14 147.0
114 6.5 54.7 0 77.31 158.0
115 7.1 67.0 1 76.58 168.0
116 6.0 47.0 0 82.86 154.5
117 6.5 47.0 0 76.64 147.0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) weight sex age height
61.5198 0.7170 10.0572 0.1191 -0.6090
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-35.44 -15.46 -6.87 12.73 67.79
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.5198 66.9729 0.919 0.360290
weight 0.7170 0.1870 3.835 0.000208 ***
sex 10.0572 5.8829 1.710 0.090113 .
age 0.1191 0.4454 0.267 0.789637
height -0.6090 0.3809 -1.599 0.112723
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 21.61 on 112 degrees of freedom
Multiple R-Squared: 0.1436, Adjusted R-squared: 0.113
F-statistic: 4.696 on 4 and 112 DF, p-value: 0.001534
> postscript(file="/var/www/html/rcomp/tmp/1mh5a1200432929.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/2awby1200432929.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/360ur1200432929.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/4359b1200432929.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/51qoh1200432929.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 117
Frequency = 1
1 2 3 4 5 6 7
67.794913 -26.912425 30.987697 -18.774454 -26.062841 39.617391 36.861510
8 9 10 11 12 13 14
-9.096584 -11.244229 -21.379949 44.591300 -11.393004 21.849288 -26.162580
15 16 17 18 19 20 21
-4.986146 -4.912059 -1.793440 -26.827320 33.368378 -7.888811 -15.860045
22 23 24 25 26 27 28
-7.420199 -8.491781 -7.749559 -16.475555 -6.261224 -10.299527 -20.381151
29 30 31 32 33 34 35
-17.236880 7.357241 -14.482944 -10.768939 24.812899 6.584052 -13.517095
36 37 38 39 40 41 42
-4.109875 22.470307 -3.270076 -6.943536 -10.170816 -27.585147 31.901803
43 44 45 46 47 48 49
-12.171664 -4.740838 -21.271291 -24.858253 -12.320014 9.103837 -21.639535
50 51 52 53 54 55 56
5.923475 -11.463320 -5.342851 21.986048 -11.651667 -20.507249 -2.165432
57 58 59 60 61 62 63
3.759328 36.899318 -14.692383 -17.609574 17.903396 -18.365025 2.158730
64 65 66 67 68 69 70
-3.950079 10.153375 42.984275 -19.153126 -20.550173 -1.350576 -26.353143
71 72 73 74 75 76 77
27.916745 2.703483 -9.096349 4.345745 -23.740529 -15.463369 -9.790398
78 79 80 81 82 83 84
5.270163 20.220422 41.006760 11.283422 28.802120 39.469592 -35.437195
85 86 87 88 89 90 91
-11.130887 7.111583 22.634537 8.476434 -8.976789 18.362107 -2.962246
92 93 94 95 96 97 98
18.626641 23.669997 -10.283786 -20.362752 36.482059 -10.371235 -28.244567
99 100 101 102 103 104 105
2.673866 29.936867 -17.952617 -23.513173 56.064336 21.301984 -13.573423
106 107 108 109 110 111 112
18.831010 -6.869326 -31.513538 29.427720 -22.310475 12.731982 -7.812804
113 114 115 116 117
11.480786 -7.227438 -19.326829 -4.999133 -8.325681
> postscript(file="/var/www/html/rcomp/tmp/68s2i1200432929.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 = 117
Frequency = 1
lag(myerror, k = 1) myerror
0 67.794913 NA
1 -26.912425 67.794913
2 30.987697 -26.912425
3 -18.774454 30.987697
4 -26.062841 -18.774454
5 39.617391 -26.062841
6 36.861510 39.617391
7 -9.096584 36.861510
8 -11.244229 -9.096584
9 -21.379949 -11.244229
10 44.591300 -21.379949
11 -11.393004 44.591300
12 21.849288 -11.393004
13 -26.162580 21.849288
14 -4.986146 -26.162580
15 -4.912059 -4.986146
16 -1.793440 -4.912059
17 -26.827320 -1.793440
18 33.368378 -26.827320
19 -7.888811 33.368378
20 -15.860045 -7.888811
21 -7.420199 -15.860045
22 -8.491781 -7.420199
23 -7.749559 -8.491781
24 -16.475555 -7.749559
25 -6.261224 -16.475555
26 -10.299527 -6.261224
27 -20.381151 -10.299527
28 -17.236880 -20.381151
29 7.357241 -17.236880
30 -14.482944 7.357241
31 -10.768939 -14.482944
32 24.812899 -10.768939
33 6.584052 24.812899
34 -13.517095 6.584052
35 -4.109875 -13.517095
36 22.470307 -4.109875
37 -3.270076 22.470307
38 -6.943536 -3.270076
39 -10.170816 -6.943536
40 -27.585147 -10.170816
41 31.901803 -27.585147
42 -12.171664 31.901803
43 -4.740838 -12.171664
44 -21.271291 -4.740838
45 -24.858253 -21.271291
46 -12.320014 -24.858253
47 9.103837 -12.320014
48 -21.639535 9.103837
49 5.923475 -21.639535
50 -11.463320 5.923475
51 -5.342851 -11.463320
52 21.986048 -5.342851
53 -11.651667 21.986048
54 -20.507249 -11.651667
55 -2.165432 -20.507249
56 3.759328 -2.165432
57 36.899318 3.759328
58 -14.692383 36.899318
59 -17.609574 -14.692383
60 17.903396 -17.609574
61 -18.365025 17.903396
62 2.158730 -18.365025
63 -3.950079 2.158730
64 10.153375 -3.950079
65 42.984275 10.153375
66 -19.153126 42.984275
67 -20.550173 -19.153126
68 -1.350576 -20.550173
69 -26.353143 -1.350576
70 27.916745 -26.353143
71 2.703483 27.916745
72 -9.096349 2.703483
73 4.345745 -9.096349
74 -23.740529 4.345745
75 -15.463369 -23.740529
76 -9.790398 -15.463369
77 5.270163 -9.790398
78 20.220422 5.270163
79 41.006760 20.220422
80 11.283422 41.006760
81 28.802120 11.283422
82 39.469592 28.802120
83 -35.437195 39.469592
84 -11.130887 -35.437195
85 7.111583 -11.130887
86 22.634537 7.111583
87 8.476434 22.634537
88 -8.976789 8.476434
89 18.362107 -8.976789
90 -2.962246 18.362107
91 18.626641 -2.962246
92 23.669997 18.626641
93 -10.283786 23.669997
94 -20.362752 -10.283786
95 36.482059 -20.362752
96 -10.371235 36.482059
97 -28.244567 -10.371235
98 2.673866 -28.244567
99 29.936867 2.673866
100 -17.952617 29.936867
101 -23.513173 -17.952617
102 56.064336 -23.513173
103 21.301984 56.064336
104 -13.573423 21.301984
105 18.831010 -13.573423
106 -6.869326 18.831010
107 -31.513538 -6.869326
108 29.427720 -31.513538
109 -22.310475 29.427720
110 12.731982 -22.310475
111 -7.812804 12.731982
112 11.480786 -7.812804
113 -7.227438 11.480786
114 -19.326829 -7.227438
115 -4.999133 -19.326829
116 -8.325681 -4.999133
117 NA -8.325681
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -26.912425 67.794913
[2,] 30.987697 -26.912425
[3,] -18.774454 30.987697
[4,] -26.062841 -18.774454
[5,] 39.617391 -26.062841
[6,] 36.861510 39.617391
[7,] -9.096584 36.861510
[8,] -11.244229 -9.096584
[9,] -21.379949 -11.244229
[10,] 44.591300 -21.379949
[11,] -11.393004 44.591300
[12,] 21.849288 -11.393004
[13,] -26.162580 21.849288
[14,] -4.986146 -26.162580
[15,] -4.912059 -4.986146
[16,] -1.793440 -4.912059
[17,] -26.827320 -1.793440
[18,] 33.368378 -26.827320
[19,] -7.888811 33.368378
[20,] -15.860045 -7.888811
[21,] -7.420199 -15.860045
[22,] -8.491781 -7.420199
[23,] -7.749559 -8.491781
[24,] -16.475555 -7.749559
[25,] -6.261224 -16.475555
[26,] -10.299527 -6.261224
[27,] -20.381151 -10.299527
[28,] -17.236880 -20.381151
[29,] 7.357241 -17.236880
[30,] -14.482944 7.357241
[31,] -10.768939 -14.482944
[32,] 24.812899 -10.768939
[33,] 6.584052 24.812899
[34,] -13.517095 6.584052
[35,] -4.109875 -13.517095
[36,] 22.470307 -4.109875
[37,] -3.270076 22.470307
[38,] -6.943536 -3.270076
[39,] -10.170816 -6.943536
[40,] -27.585147 -10.170816
[41,] 31.901803 -27.585147
[42,] -12.171664 31.901803
[43,] -4.740838 -12.171664
[44,] -21.271291 -4.740838
[45,] -24.858253 -21.271291
[46,] -12.320014 -24.858253
[47,] 9.103837 -12.320014
[48,] -21.639535 9.103837
[49,] 5.923475 -21.639535
[50,] -11.463320 5.923475
[51,] -5.342851 -11.463320
[52,] 21.986048 -5.342851
[53,] -11.651667 21.986048
[54,] -20.507249 -11.651667
[55,] -2.165432 -20.507249
[56,] 3.759328 -2.165432
[57,] 36.899318 3.759328
[58,] -14.692383 36.899318
[59,] -17.609574 -14.692383
[60,] 17.903396 -17.609574
[61,] -18.365025 17.903396
[62,] 2.158730 -18.365025
[63,] -3.950079 2.158730
[64,] 10.153375 -3.950079
[65,] 42.984275 10.153375
[66,] -19.153126 42.984275
[67,] -20.550173 -19.153126
[68,] -1.350576 -20.550173
[69,] -26.353143 -1.350576
[70,] 27.916745 -26.353143
[71,] 2.703483 27.916745
[72,] -9.096349 2.703483
[73,] 4.345745 -9.096349
[74,] -23.740529 4.345745
[75,] -15.463369 -23.740529
[76,] -9.790398 -15.463369
[77,] 5.270163 -9.790398
[78,] 20.220422 5.270163
[79,] 41.006760 20.220422
[80,] 11.283422 41.006760
[81,] 28.802120 11.283422
[82,] 39.469592 28.802120
[83,] -35.437195 39.469592
[84,] -11.130887 -35.437195
[85,] 7.111583 -11.130887
[86,] 22.634537 7.111583
[87,] 8.476434 22.634537
[88,] -8.976789 8.476434
[89,] 18.362107 -8.976789
[90,] -2.962246 18.362107
[91,] 18.626641 -2.962246
[92,] 23.669997 18.626641
[93,] -10.283786 23.669997
[94,] -20.362752 -10.283786
[95,] 36.482059 -20.362752
[96,] -10.371235 36.482059
[97,] -28.244567 -10.371235
[98,] 2.673866 -28.244567
[99,] 29.936867 2.673866
[100,] -17.952617 29.936867
[101,] -23.513173 -17.952617
[102,] 56.064336 -23.513173
[103,] 21.301984 56.064336
[104,] -13.573423 21.301984
[105,] 18.831010 -13.573423
[106,] -6.869326 18.831010
[107,] -31.513538 -6.869326
[108,] 29.427720 -31.513538
[109,] -22.310475 29.427720
[110,] 12.731982 -22.310475
[111,] -7.812804 12.731982
[112,] 11.480786 -7.812804
[113,] -7.227438 11.480786
[114,] -19.326829 -7.227438
[115,] -4.999133 -19.326829
[116,] -8.325681 -4.999133
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -26.912425 67.794913
2 30.987697 -26.912425
3 -18.774454 30.987697
4 -26.062841 -18.774454
5 39.617391 -26.062841
6 36.861510 39.617391
7 -9.096584 36.861510
8 -11.244229 -9.096584
9 -21.379949 -11.244229
10 44.591300 -21.379949
11 -11.393004 44.591300
12 21.849288 -11.393004
13 -26.162580 21.849288
14 -4.986146 -26.162580
15 -4.912059 -4.986146
16 -1.793440 -4.912059
17 -26.827320 -1.793440
18 33.368378 -26.827320
19 -7.888811 33.368378
20 -15.860045 -7.888811
21 -7.420199 -15.860045
22 -8.491781 -7.420199
23 -7.749559 -8.491781
24 -16.475555 -7.749559
25 -6.261224 -16.475555
26 -10.299527 -6.261224
27 -20.381151 -10.299527
28 -17.236880 -20.381151
29 7.357241 -17.236880
30 -14.482944 7.357241
31 -10.768939 -14.482944
32 24.812899 -10.768939
33 6.584052 24.812899
34 -13.517095 6.584052
35 -4.109875 -13.517095
36 22.470307 -4.109875
37 -3.270076 22.470307
38 -6.943536 -3.270076
39 -10.170816 -6.943536
40 -27.585147 -10.170816
41 31.901803 -27.585147
42 -12.171664 31.901803
43 -4.740838 -12.171664
44 -21.271291 -4.740838
45 -24.858253 -21.271291
46 -12.320014 -24.858253
47 9.103837 -12.320014
48 -21.639535 9.103837
49 5.923475 -21.639535
50 -11.463320 5.923475
51 -5.342851 -11.463320
52 21.986048 -5.342851
53 -11.651667 21.986048
54 -20.507249 -11.651667
55 -2.165432 -20.507249
56 3.759328 -2.165432
57 36.899318 3.759328
58 -14.692383 36.899318
59 -17.609574 -14.692383
60 17.903396 -17.609574
61 -18.365025 17.903396
62 2.158730 -18.365025
63 -3.950079 2.158730
64 10.153375 -3.950079
65 42.984275 10.153375
66 -19.153126 42.984275
67 -20.550173 -19.153126
68 -1.350576 -20.550173
69 -26.353143 -1.350576
70 27.916745 -26.353143
71 2.703483 27.916745
72 -9.096349 2.703483
73 4.345745 -9.096349
74 -23.740529 4.345745
75 -15.463369 -23.740529
76 -9.790398 -15.463369
77 5.270163 -9.790398
78 20.220422 5.270163
79 41.006760 20.220422
80 11.283422 41.006760
81 28.802120 11.283422
82 39.469592 28.802120
83 -35.437195 39.469592
84 -11.130887 -35.437195
85 7.111583 -11.130887
86 22.634537 7.111583
87 8.476434 22.634537
88 -8.976789 8.476434
89 18.362107 -8.976789
90 -2.962246 18.362107
91 18.626641 -2.962246
92 23.669997 18.626641
93 -10.283786 23.669997
94 -20.362752 -10.283786
95 36.482059 -20.362752
96 -10.371235 36.482059
97 -28.244567 -10.371235
98 2.673866 -28.244567
99 29.936867 2.673866
100 -17.952617 29.936867
101 -23.513173 -17.952617
102 56.064336 -23.513173
103 21.301984 56.064336
104 -13.573423 21.301984
105 18.831010 -13.573423
106 -6.869326 18.831010
107 -31.513538 -6.869326
108 29.427720 -31.513538
109 -22.310475 29.427720
110 12.731982 -22.310475
111 -7.812804 12.731982
112 11.480786 -7.812804
113 -7.227438 11.480786
114 -19.326829 -7.227438
115 -4.999133 -19.326829
116 -8.325681 -4.999133
> 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/7rd541200432929.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/87cze1200432929.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/9tdz31200432929.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/10geeq1200432929.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/11gd3f1200432929.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/125p0k1200432929.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/138shh1200432929.tab")
>
> system("convert tmp/1mh5a1200432929.ps tmp/1mh5a1200432929.png")
> system("convert tmp/2awby1200432929.ps tmp/2awby1200432929.png")
> system("convert tmp/360ur1200432929.ps tmp/360ur1200432929.png")
> system("convert tmp/4359b1200432929.ps tmp/4359b1200432929.png")
> system("convert tmp/51qoh1200432929.ps tmp/51qoh1200432929.png")
> system("convert tmp/68s2i1200432929.ps tmp/68s2i1200432929.png")
> system("convert tmp/7rd541200432929.ps tmp/7rd541200432929.png")
> system("convert tmp/87cze1200432929.ps tmp/87cze1200432929.png")
> system("convert tmp/9tdz31200432929.ps tmp/9tdz31200432929.png")
>
>
> proc.time()
user system elapsed
4.439 2.579 4.770