R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-pc-linux-gnu (32-bit)
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(99.8
+ ,108.4
+ ,1.7
+ ,96.8
+ ,117
+ ,1.4
+ ,87.0
+ ,103.8
+ ,1.3
+ ,96.3
+ ,100.8
+ ,1.4
+ ,107.1
+ ,110.6
+ ,1.3
+ ,115.2
+ ,104.0
+ ,1.3
+ ,106.1
+ ,112.6
+ ,1.4
+ ,89.5
+ ,107.3
+ ,2.0
+ ,91.3
+ ,98.9
+ ,1.7
+ ,97.6
+ ,109.8
+ ,1.8
+ ,100.7
+ ,104.9
+ ,1.7
+ ,104.6
+ ,102.2
+ ,1.6
+ ,94.7
+ ,123.9
+ ,1.7
+ ,101.8
+ ,124.9
+ ,1.9
+ ,102.5
+ ,112.7
+ ,1.8
+ ,105.3
+ ,121.9
+ ,1.7
+ ,110.3
+ ,100.6
+ ,1.6
+ ,109.8
+ ,104.3
+ ,1.8
+ ,117.3
+ ,120.4
+ ,1.6
+ ,118.8
+ ,107.5
+ ,1.5
+ ,131.3
+ ,102.9
+ ,1.5
+ ,125.9
+ ,125.6
+ ,1.3
+ ,133.1
+ ,107.5
+ ,1.4
+ ,147.0
+ ,108.8
+ ,1.4
+ ,145.8
+ ,128.4
+ ,1.3
+ ,164.4
+ ,121.1
+ ,1.3
+ ,149.8
+ ,119.5
+ ,1.2
+ ,137.7
+ ,128.7
+ ,1.1
+ ,151.7
+ ,108.7
+ ,1.4
+ ,156.8
+ ,105.5
+ ,1.2
+ ,180.0
+ ,119.8
+ ,1.5
+ ,180.4
+ ,111.3
+ ,1.1
+ ,170.4
+ ,110.6
+ ,1.3
+ ,191.6
+ ,120.1
+ ,1.5
+ ,199.5
+ ,97.5
+ ,1.1
+ ,218.2
+ ,107.7
+ ,1.4
+ ,217.5
+ ,127.3
+ ,1.3
+ ,205.0
+ ,117.2
+ ,1.5
+ ,194.0
+ ,119.8
+ ,1.6
+ ,199.3
+ ,116.2
+ ,1.7
+ ,219.3
+ ,111.0
+ ,1.1
+ ,211.1
+ ,112.4
+ ,1.6
+ ,215.2
+ ,130.6
+ ,1.3
+ ,240.2
+ ,109.1
+ ,1.7
+ ,242.2
+ ,118.8
+ ,1.6
+ ,240.7
+ ,123.9
+ ,1.7
+ ,255.4
+ ,101.6
+ ,1.9
+ ,253.0
+ ,112.8
+ ,1.8
+ ,218.2
+ ,128.0
+ ,1.9
+ ,203.7
+ ,129.6
+ ,1.6
+ ,205.6
+ ,125.8
+ ,1.5
+ ,215.6
+ ,119.5
+ ,1.6
+ ,188.5
+ ,115.7
+ ,1.6
+ ,202.9
+ ,113.6
+ ,1.7
+ ,214.0
+ ,129.7
+ ,2.0
+ ,230.3
+ ,112.0
+ ,2.0
+ ,230.0
+ ,116.8
+ ,1.9
+ ,241.0
+ ,127.0
+ ,1.7
+ ,259.6
+ ,112.9
+ ,1.8
+ ,247.8
+ ,113.3
+ ,1.9
+ ,270.3
+ ,121.7
+ ,1.7)
+ ,dim=c(3
+ ,61)
+ ,dimnames=list(c('Grondstoffen'
+ ,'Consumptiegoederen'
+ ,'Inflatie
')
+ ,1:61))
> y <- array(NA,dim=c(3,61),dimnames=list(c('Grondstoffen','Consumptiegoederen','Inflatie
'),1:61))
> 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 = 'No Linear Trend'
> par2 = 'Include Monthly 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
Grondstoffen Consumptiegoederen Inflatie\r M1 M2 M3 M4 M5 M6 M7 M8 M9 M10
1 99.8 108.4 1.7 1 0 0 0 0 0 0 0 0 0
2 96.8 117.0 1.4 0 1 0 0 0 0 0 0 0 0
3 87.0 103.8 1.3 0 0 1 0 0 0 0 0 0 0
4 96.3 100.8 1.4 0 0 0 1 0 0 0 0 0 0
5 107.1 110.6 1.3 0 0 0 0 1 0 0 0 0 0
6 115.2 104.0 1.3 0 0 0 0 0 1 0 0 0 0
7 106.1 112.6 1.4 0 0 0 0 0 0 1 0 0 0
8 89.5 107.3 2.0 0 0 0 0 0 0 0 1 0 0
9 91.3 98.9 1.7 0 0 0 0 0 0 0 0 1 0
10 97.6 109.8 1.8 0 0 0 0 0 0 0 0 0 1
11 100.7 104.9 1.7 0 0 0 0 0 0 0 0 0 0
12 104.6 102.2 1.6 0 0 0 0 0 0 0 0 0 0
13 94.7 123.9 1.7 1 0 0 0 0 0 0 0 0 0
14 101.8 124.9 1.9 0 1 0 0 0 0 0 0 0 0
15 102.5 112.7 1.8 0 0 1 0 0 0 0 0 0 0
16 105.3 121.9 1.7 0 0 0 1 0 0 0 0 0 0
17 110.3 100.6 1.6 0 0 0 0 1 0 0 0 0 0
18 109.8 104.3 1.8 0 0 0 0 0 1 0 0 0 0
19 117.3 120.4 1.6 0 0 0 0 0 0 1 0 0 0
20 118.8 107.5 1.5 0 0 0 0 0 0 0 1 0 0
21 131.3 102.9 1.5 0 0 0 0 0 0 0 0 1 0
22 125.9 125.6 1.3 0 0 0 0 0 0 0 0 0 1
23 133.1 107.5 1.4 0 0 0 0 0 0 0 0 0 0
24 147.0 108.8 1.4 0 0 0 0 0 0 0 0 0 0
25 145.8 128.4 1.3 1 0 0 0 0 0 0 0 0 0
26 164.4 121.1 1.3 0 1 0 0 0 0 0 0 0 0
27 149.8 119.5 1.2 0 0 1 0 0 0 0 0 0 0
28 137.7 128.7 1.1 0 0 0 1 0 0 0 0 0 0
29 151.7 108.7 1.4 0 0 0 0 1 0 0 0 0 0
30 156.8 105.5 1.2 0 0 0 0 0 1 0 0 0 0
31 180.0 119.8 1.5 0 0 0 0 0 0 1 0 0 0
32 180.4 111.3 1.1 0 0 0 0 0 0 0 1 0 0
33 170.4 110.6 1.3 0 0 0 0 0 0 0 0 1 0
34 191.6 120.1 1.5 0 0 0 0 0 0 0 0 0 1
35 199.5 97.5 1.1 0 0 0 0 0 0 0 0 0 0
36 218.2 107.7 1.4 0 0 0 0 0 0 0 0 0 0
37 217.5 127.3 1.3 1 0 0 0 0 0 0 0 0 0
38 205.0 117.2 1.5 0 1 0 0 0 0 0 0 0 0
39 194.0 119.8 1.6 0 0 1 0 0 0 0 0 0 0
40 199.3 116.2 1.7 0 0 0 1 0 0 0 0 0 0
41 219.3 111.0 1.1 0 0 0 0 1 0 0 0 0 0
42 211.1 112.4 1.6 0 0 0 0 0 1 0 0 0 0
43 215.2 130.6 1.3 0 0 0 0 0 0 1 0 0 0
44 240.2 109.1 1.7 0 0 0 0 0 0 0 1 0 0
45 242.2 118.8 1.6 0 0 0 0 0 0 0 0 1 0
46 240.7 123.9 1.7 0 0 0 0 0 0 0 0 0 1
47 255.4 101.6 1.9 0 0 0 0 0 0 0 0 0 0
48 253.0 112.8 1.8 0 0 0 0 0 0 0 0 0 0
49 218.2 128.0 1.9 1 0 0 0 0 0 0 0 0 0
50 203.7 129.6 1.6 0 1 0 0 0 0 0 0 0 0
51 205.6 125.8 1.5 0 0 1 0 0 0 0 0 0 0
52 215.6 119.5 1.6 0 0 0 1 0 0 0 0 0 0
53 188.5 115.7 1.6 0 0 0 0 1 0 0 0 0 0
54 202.9 113.6 1.7 0 0 0 0 0 1 0 0 0 0
55 214.0 129.7 2.0 0 0 0 0 0 0 1 0 0 0
56 230.3 112.0 2.0 0 0 0 0 0 0 0 1 0 0
57 230.0 116.8 1.9 0 0 0 0 0 0 0 0 1 0
58 241.0 127.0 1.7 0 0 0 0 0 0 0 0 0 1
59 259.6 112.9 1.8 0 0 0 0 0 0 0 0 0 0
60 247.8 113.3 1.9 0 0 0 0 0 0 0 0 0 0
61 270.3 121.7 1.7 1 0 0 0 0 0 0 0 0 0
M11
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 1
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 1
24 0
25 0
26 0
27 0
28 0
29 0
30 0
31 0
32 0
33 0
34 0
35 1
36 0
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 0
45 0
46 0
47 1
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 0
56 0
57 0
58 0
59 1
60 0
61 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Consumptiegoederen `Inflatie\\r` M1
-387.888 5.018 21.757 -89.503
M2 M3 M4 M5
-103.273 -80.226 -83.121 -35.760
M6 M7 M8 M9
-27.766 -94.840 -25.559 -23.856
M10 M11
-76.147 16.884
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-91.671 -34.077 9.717 27.920 100.013
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -387.888 122.187 -3.175 0.00265 **
Consumptiegoederen 5.018 1.054 4.760 1.88e-05 ***
`Inflatie\\r` 21.757 27.640 0.787 0.43513
M1 -89.503 33.770 -2.650 0.01092 *
M2 -103.273 34.676 -2.978 0.00457 **
M3 -80.226 32.937 -2.436 0.01871 *
M4 -83.121 33.168 -2.506 0.01573 *
M5 -35.760 32.290 -1.107 0.27373
M6 -27.766 31.835 -0.872 0.38754
M7 -94.840 34.912 -2.717 0.00920 **
M8 -25.559 31.726 -0.806 0.42453
M9 -23.856 31.717 -0.752 0.45571
M10 -76.147 34.282 -2.221 0.03119 *
M11 16.884 32.003 0.528 0.60028
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 50.13 on 47 degrees of freedom
Multiple R-squared: 0.3811, Adjusted R-squared: 0.21
F-statistic: 2.227 on 13 and 47 DF, p-value: 0.02291
> postscript(file="/var/fisher/rcomp/tmp/1e5891356004747.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/2uvkh1356004747.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/3s5ex1356004747.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/457yd1356004747.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/5xa3r1356004747.ps",horizontal=F,onefile=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 = 61
Frequency = 1
1 2 3 4 5 6
-3.7471660 -29.6047140 5.9616486 31.0348683 -52.5273177 -19.3021362
7 8 9 10 11 12
-6.6584937 -78.9989341 -30.2231297 -28.5048116 -91.6712256 -55.1631810
13 14 15 16 17 18
-86.6261539 -75.1255144 -34.0771510 -72.3720791 -5.6744895 -37.0861425
19 20 21 22 23 24
-38.9503303 -39.8239274 -5.9436839 -68.6105927 -65.7908596 -41.5305332
25 26 27 28 29 30
-49.4042651 19.5972105 -7.8452178 -61.0401459 -0.5688405 16.9465863
31 32 33 34 35 36
28.9361906 11.4105608 -1.1308353 20.3369604 57.3162965 35.1892659
37 38 39 40 41 42
27.8155340 75.4159648 26.1464971 50.2305164 62.0169253 27.9195064
43 44 45 46 47 48
14.2932417 69.1958312 22.9944072 46.0171207 75.2367292 35.6945846
49 50 51 52 53 54
11.9486067 9.7170532 9.8142232 52.1468403 -3.2462776 11.5221861
55 56 57 58 59 60
2.3793918 38.2164695 14.3032417 30.7613232 24.9090594 25.8098637
61
100.0134444
> postscript(file="/var/fisher/rcomp/tmp/6noj91356004747.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 61
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.7471660 NA
1 -29.6047140 -3.7471660
2 5.9616486 -29.6047140
3 31.0348683 5.9616486
4 -52.5273177 31.0348683
5 -19.3021362 -52.5273177
6 -6.6584937 -19.3021362
7 -78.9989341 -6.6584937
8 -30.2231297 -78.9989341
9 -28.5048116 -30.2231297
10 -91.6712256 -28.5048116
11 -55.1631810 -91.6712256
12 -86.6261539 -55.1631810
13 -75.1255144 -86.6261539
14 -34.0771510 -75.1255144
15 -72.3720791 -34.0771510
16 -5.6744895 -72.3720791
17 -37.0861425 -5.6744895
18 -38.9503303 -37.0861425
19 -39.8239274 -38.9503303
20 -5.9436839 -39.8239274
21 -68.6105927 -5.9436839
22 -65.7908596 -68.6105927
23 -41.5305332 -65.7908596
24 -49.4042651 -41.5305332
25 19.5972105 -49.4042651
26 -7.8452178 19.5972105
27 -61.0401459 -7.8452178
28 -0.5688405 -61.0401459
29 16.9465863 -0.5688405
30 28.9361906 16.9465863
31 11.4105608 28.9361906
32 -1.1308353 11.4105608
33 20.3369604 -1.1308353
34 57.3162965 20.3369604
35 35.1892659 57.3162965
36 27.8155340 35.1892659
37 75.4159648 27.8155340
38 26.1464971 75.4159648
39 50.2305164 26.1464971
40 62.0169253 50.2305164
41 27.9195064 62.0169253
42 14.2932417 27.9195064
43 69.1958312 14.2932417
44 22.9944072 69.1958312
45 46.0171207 22.9944072
46 75.2367292 46.0171207
47 35.6945846 75.2367292
48 11.9486067 35.6945846
49 9.7170532 11.9486067
50 9.8142232 9.7170532
51 52.1468403 9.8142232
52 -3.2462776 52.1468403
53 11.5221861 -3.2462776
54 2.3793918 11.5221861
55 38.2164695 2.3793918
56 14.3032417 38.2164695
57 30.7613232 14.3032417
58 24.9090594 30.7613232
59 25.8098637 24.9090594
60 100.0134444 25.8098637
61 NA 100.0134444
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -29.6047140 -3.7471660
[2,] 5.9616486 -29.6047140
[3,] 31.0348683 5.9616486
[4,] -52.5273177 31.0348683
[5,] -19.3021362 -52.5273177
[6,] -6.6584937 -19.3021362
[7,] -78.9989341 -6.6584937
[8,] -30.2231297 -78.9989341
[9,] -28.5048116 -30.2231297
[10,] -91.6712256 -28.5048116
[11,] -55.1631810 -91.6712256
[12,] -86.6261539 -55.1631810
[13,] -75.1255144 -86.6261539
[14,] -34.0771510 -75.1255144
[15,] -72.3720791 -34.0771510
[16,] -5.6744895 -72.3720791
[17,] -37.0861425 -5.6744895
[18,] -38.9503303 -37.0861425
[19,] -39.8239274 -38.9503303
[20,] -5.9436839 -39.8239274
[21,] -68.6105927 -5.9436839
[22,] -65.7908596 -68.6105927
[23,] -41.5305332 -65.7908596
[24,] -49.4042651 -41.5305332
[25,] 19.5972105 -49.4042651
[26,] -7.8452178 19.5972105
[27,] -61.0401459 -7.8452178
[28,] -0.5688405 -61.0401459
[29,] 16.9465863 -0.5688405
[30,] 28.9361906 16.9465863
[31,] 11.4105608 28.9361906
[32,] -1.1308353 11.4105608
[33,] 20.3369604 -1.1308353
[34,] 57.3162965 20.3369604
[35,] 35.1892659 57.3162965
[36,] 27.8155340 35.1892659
[37,] 75.4159648 27.8155340
[38,] 26.1464971 75.4159648
[39,] 50.2305164 26.1464971
[40,] 62.0169253 50.2305164
[41,] 27.9195064 62.0169253
[42,] 14.2932417 27.9195064
[43,] 69.1958312 14.2932417
[44,] 22.9944072 69.1958312
[45,] 46.0171207 22.9944072
[46,] 75.2367292 46.0171207
[47,] 35.6945846 75.2367292
[48,] 11.9486067 35.6945846
[49,] 9.7170532 11.9486067
[50,] 9.8142232 9.7170532
[51,] 52.1468403 9.8142232
[52,] -3.2462776 52.1468403
[53,] 11.5221861 -3.2462776
[54,] 2.3793918 11.5221861
[55,] 38.2164695 2.3793918
[56,] 14.3032417 38.2164695
[57,] 30.7613232 14.3032417
[58,] 24.9090594 30.7613232
[59,] 25.8098637 24.9090594
[60,] 100.0134444 25.8098637
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -29.6047140 -3.7471660
2 5.9616486 -29.6047140
3 31.0348683 5.9616486
4 -52.5273177 31.0348683
5 -19.3021362 -52.5273177
6 -6.6584937 -19.3021362
7 -78.9989341 -6.6584937
8 -30.2231297 -78.9989341
9 -28.5048116 -30.2231297
10 -91.6712256 -28.5048116
11 -55.1631810 -91.6712256
12 -86.6261539 -55.1631810
13 -75.1255144 -86.6261539
14 -34.0771510 -75.1255144
15 -72.3720791 -34.0771510
16 -5.6744895 -72.3720791
17 -37.0861425 -5.6744895
18 -38.9503303 -37.0861425
19 -39.8239274 -38.9503303
20 -5.9436839 -39.8239274
21 -68.6105927 -5.9436839
22 -65.7908596 -68.6105927
23 -41.5305332 -65.7908596
24 -49.4042651 -41.5305332
25 19.5972105 -49.4042651
26 -7.8452178 19.5972105
27 -61.0401459 -7.8452178
28 -0.5688405 -61.0401459
29 16.9465863 -0.5688405
30 28.9361906 16.9465863
31 11.4105608 28.9361906
32 -1.1308353 11.4105608
33 20.3369604 -1.1308353
34 57.3162965 20.3369604
35 35.1892659 57.3162965
36 27.8155340 35.1892659
37 75.4159648 27.8155340
38 26.1464971 75.4159648
39 50.2305164 26.1464971
40 62.0169253 50.2305164
41 27.9195064 62.0169253
42 14.2932417 27.9195064
43 69.1958312 14.2932417
44 22.9944072 69.1958312
45 46.0171207 22.9944072
46 75.2367292 46.0171207
47 35.6945846 75.2367292
48 11.9486067 35.6945846
49 9.7170532 11.9486067
50 9.8142232 9.7170532
51 52.1468403 9.8142232
52 -3.2462776 52.1468403
53 11.5221861 -3.2462776
54 2.3793918 11.5221861
55 38.2164695 2.3793918
56 14.3032417 38.2164695
57 30.7613232 14.3032417
58 24.9090594 30.7613232
59 25.8098637 24.9090594
60 100.0134444 25.8098637
> 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/fisher/rcomp/tmp/77r2k1356004747.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/8ss0j1356004747.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/9ynz41356004747.ps",horizontal=F,onefile=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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/10q1081356004747.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/fisher/rcomp/tmp/11ruu81356004747.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/fisher/rcomp/tmp/12z7e61356004747.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/fisher/rcomp/tmp/13swo91356004747.tab")
>
> try(system("convert tmp/1e5891356004747.ps tmp/1e5891356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/2uvkh1356004747.ps tmp/2uvkh1356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/3s5ex1356004747.ps tmp/3s5ex1356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/457yd1356004747.ps tmp/457yd1356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/5xa3r1356004747.ps tmp/5xa3r1356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/6noj91356004747.ps tmp/6noj91356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/77r2k1356004747.ps tmp/77r2k1356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/8ss0j1356004747.ps tmp/8ss0j1356004747.png",intern=TRUE))
character(0)
> try(system("convert tmp/9ynz41356004747.ps tmp/9ynz41356004747.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
5.170 1.546 6.705