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(31/01/2005
+ ,6
+ ,100
+ ,6
+ ,28/02/2005
+ ,9
+ ,99
+ ,2
+ ,31/03/2005
+ ,7
+ ,108
+ ,4
+ ,30/04/2005
+ ,8
+ ,103
+ ,0
+ ,31/05/2005
+ ,1
+ ,99
+ ,8
+ ,30/06/2005
+ ,9
+ ,115
+ ,0
+ ,31/07/2005
+ ,9
+ ,90
+ ,8
+ ,31/08/2005
+ ,7
+ ,95
+ ,9
+ ,30/09/2005
+ ,2
+ ,114
+ ,4
+ ,31/10/2005
+ ,9
+ ,108
+ ,2
+ ,30/11/2005
+ ,8
+ ,112
+ ,6
+ ,31/12/2005
+ ,3
+ ,109
+ ,1
+ ,31/01/2006
+ ,0
+ ,105
+ ,0
+ ,28/02/2006
+ ,7
+ ,105
+ ,0
+ ,31/03/2006
+ ,5
+ ,118
+ ,5
+ ,30/04/2006
+ ,7
+ ,103
+ ,7
+ ,31/05/2006
+ ,9
+ ,112
+ ,5
+ ,30/06/2006
+ ,6
+ ,116
+ ,6
+ ,31/07/2006
+ ,4
+ ,96
+ ,6
+ ,31/08/2006
+ ,5
+ ,101
+ ,9
+ ,30/09/2006
+ ,8
+ ,116
+ ,5
+ ,31/10/2006
+ ,5
+ ,119
+ ,3
+ ,30/11/2006
+ ,9
+ ,115
+ ,4
+ ,31/12/2006
+ ,0
+ ,108
+ ,5
+ ,31/01/2007
+ ,0
+ ,111
+ ,5
+ ,28/02/2007
+ ,3
+ ,108
+ ,8
+ ,31/03/2007
+ ,8
+ ,121
+ ,8
+ ,30/04/2007
+ ,1
+ ,109
+ ,6
+ ,31/05/2007
+ ,3
+ ,112
+ ,2
+ ,30/06/2007
+ ,2
+ ,119
+ ,6
+ ,31/07/2007
+ ,5
+ ,104
+ ,1
+ ,31/08/2007
+ ,2
+ ,105
+ ,3
+ ,30/09/2007
+ ,5
+ ,115
+ ,0
+ ,31/10/2007
+ ,4
+ ,124
+ ,1
+ ,30/11/2007
+ ,3
+ ,116
+ ,8
+ ,31/12/2007
+ ,0
+ ,107
+ ,5
+ ,31/01/2008
+ ,7
+ ,115
+ ,6
+ ,29/02/2008
+ ,8
+ ,116
+ ,2
+ ,31/03/2008
+ ,8
+ ,116
+ ,3
+ ,30/04/2008
+ ,3
+ ,119
+ ,0
+ ,31/05/2008
+ ,1
+ ,111
+ ,9
+ ,30/06/2008
+ ,9
+ ,118
+ ,6
+ ,31/07/2008
+ ,0
+ ,106
+ ,9
+ ,31/08/2008
+ ,8
+ ,103
+ ,2
+ ,30/09/2008
+ ,8
+ ,118
+ ,6
+ ,31/10/2008
+ ,7
+ ,118
+ ,7
+ ,30/11/2008
+ ,4
+ ,102
+ ,8
+ ,31/12/2008
+ ,3
+ ,100
+ ,6
+ ,31/01/2009
+ ,0
+ ,94
+ ,9
+ ,28/02/2009
+ ,2
+ ,94
+ ,5
+ ,31/03/2009
+ ,1
+ ,102
+ ,9
+ ,30/04/2009
+ ,1
+ ,95
+ ,3
+ ,31/05/2009
+ ,8
+ ,92
+ ,5
+ ,30/06/2009
+ ,7
+ ,102
+ ,7
+ ,31/07/2009
+ ,6
+ ,91
+ ,5
+ ,31/08/2009
+ ,1
+ ,89
+ ,5
+ ,30/09/2009
+ ,5
+ ,104
+ ,2
+ ,31/10/2009
+ ,1
+ ,105
+ ,2
+ ,30/11/2009
+ ,1
+ ,99
+ ,0
+ ,31/12/2009
+ ,7
+ ,95
+ ,5
+ ,31/01/2010
+ ,3
+ ,90
+ ,5
+ ,28/02/2010
+ ,8
+ ,96
+ ,1
+ ,31/03/2010
+ ,5
+ ,113
+ ,0
+ ,30/04/2010
+ ,7
+ ,101
+ ,9
+ ,31/05/2010
+ ,5
+ ,101
+ ,4
+ ,30/06/2010
+ ,7
+ ,113
+ ,6
+ ,31/07/2010
+ ,2
+ ,96
+ ,6
+ ,31/08/2010
+ ,4
+ ,97
+ ,8
+ ,30/09/2010
+ ,0
+ ,114
+ ,9
+ ,31/10/2010
+ ,0
+ ,112
+ ,5
+ ,30/11/2010
+ ,5
+ ,108
+ ,4
+ ,31/12/2010
+ ,3
+ ,107
+ ,0
+ ,31/01/2011
+ ,1
+ ,103
+ ,5
+ ,28/02/2011
+ ,1
+ ,107
+ ,5
+ ,31/03/2011
+ ,3
+ ,122
+ ,3)
+ ,dim=c(4
+ ,75)
+ ,dimnames=list(c('periode'
+ ,'steenkool'
+ ,'aardolie'
+ ,'uranium')
+ ,1:75))
> y <- array(NA,dim=c(4,75),dimnames=list(c('periode','steenkool','aardolie','uranium'),1:75))
> 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 = '2'
> par3 <- 'No Linear Trend'
> par2 <- 'Do not include Seasonal Dummies'
> par1 <- '2'
> #'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)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> 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
steenkool periode aardolie uranium
1 6 0.015461347 100 6
2 9 0.006982544 99 2
3 7 0.005153782 108 4
4 8 0.003740648 103 0
5 1 0.003092269 99 8
6 9 0.002493766 115 0
7 9 0.002208764 90 8
8 7 0.001932668 95 9
9 2 0.001662510 114 4
10 9 0.001546135 108 2
11 8 0.001360236 112 6
12 3 0.001288446 109 1
13 0 0.015453639 105 0
14 7 0.006979063 105 0
15 5 0.005151213 118 5
16 7 0.003738784 103 7
17 9 0.003090728 112 5
18 6 0.002492522 116 6
19 4 0.002207663 96 6
20 5 0.001931705 101 9
21 8 0.001661682 116 5
22 5 0.001545364 119 3
23 9 0.001359558 115 4
24 0 0.001287803 108 5
25 0 0.015445939 111 5
26 3 0.006975585 108 8
27 8 0.005148646 121 8
28 1 0.003736921 109 6
29 3 0.003089188 112 2
30 2 0.002491281 119 6
31 5 0.002206563 104 1
32 2 0.001930742 105 3
33 5 0.001660854 115 0
34 4 0.001544594 124 1
35 3 0.001358880 116 8
36 0 0.001287162 107 5
37 7 0.015438247 115 6
38 8 0.007221116 116 2
39 8 0.005146082 116 3
40 3 0.003735060 119 0
41 1 0.003087649 111 9
42 9 0.002490040 118 6
43 0 0.002205464 106 9
44 8 0.001929781 103 2
45 8 0.001660027 118 6
46 7 0.001543825 118 7
47 4 0.001358204 102 8
48 3 0.001286521 100 6
49 0 0.015430562 94 9
50 2 0.006968641 94 5
51 1 0.005143521 102 9
52 1 0.003733201 95 3
53 8 0.003086112 92 5
54 7 0.002488800 102 7
55 6 0.002204366 91 5
56 1 0.001928820 89 5
57 5 0.001659200 104 2
58 1 0.001543056 105 2
59 1 0.001357527 99 0
60 7 0.001285880 95 5
61 3 0.015422886 90 5
62 8 0.006965174 96 1
63 5 0.005140962 113 0
64 7 0.003731343 101 9
65 5 0.003084577 101 4
66 7 0.002487562 113 6
67 2 0.002203269 96 6
68 4 0.001927861 97 8
69 0 0.001658375 114 9
70 0 0.001542289 112 5
71 5 0.001356852 108 4
72 3 0.001285240 107 0
73 1 0.015415216 103 5
74 1 0.006961711 107 5
75 3 0.005138405 122 3
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) periode aardolie uranium
2.54802 -102.79130 0.02756 -0.11714
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4.8909 -2.6376 -0.0864 3.0042 5.1354
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.54802 4.54588 0.561 0.577
periode -102.79130 87.56343 -1.174 0.244
aardolie 0.02756 0.04058 0.679 0.499
uranium -0.11714 0.12652 -0.926 0.358
Residual standard error: 3.01 on 71 degrees of freedom
Multiple R-squared: 0.04374, Adjusted R-squared: 0.003332
F-statistic: 1.082 on 3 and 71 DF, p-value: 0.3622
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.6297096 0.7405809 0.3702904
[2,] 0.5404597 0.9190807 0.4595403
[3,] 0.4887577 0.9775154 0.5112423
[4,] 0.4263185 0.8526370 0.5736815
[5,] 0.5444828 0.9110345 0.4555172
[6,] 0.6727893 0.6544214 0.3272107
[7,] 0.8250858 0.3498284 0.1749142
[8,] 0.7680840 0.4638319 0.2319160
[9,] 0.7001406 0.5997189 0.2998594
[10,] 0.6437786 0.7124428 0.3562214
[11,] 0.6789528 0.6420945 0.3210472
[12,] 0.6032195 0.7935610 0.3967805
[13,] 0.5933621 0.8132758 0.4066379
[14,] 0.5274746 0.9450508 0.4725254
[15,] 0.4975120 0.9950241 0.5024880
[16,] 0.4320328 0.8640656 0.5679672
[17,] 0.4481593 0.8963187 0.5518407
[18,] 0.6756322 0.6487357 0.3243678
[19,] 0.6824044 0.6351912 0.3175956
[20,] 0.6206389 0.7587223 0.3793611
[21,] 0.6636974 0.6726053 0.3363026
[22,] 0.7145355 0.5709289 0.2854645
[23,] 0.6989935 0.6020129 0.3010065
[24,] 0.6940455 0.6119089 0.3059545
[25,] 0.6402712 0.7194576 0.3597288
[26,] 0.6572980 0.6854040 0.3427020
[27,] 0.5938036 0.8123927 0.4061964
[28,] 0.5407044 0.9185912 0.4592956
[29,] 0.4924446 0.9848893 0.5075554
[30,] 0.6084468 0.7831064 0.3915532
[31,] 0.6376576 0.7246848 0.3623424
[32,] 0.6540067 0.6919867 0.3459933
[33,] 0.6735079 0.6529842 0.3264921
[34,] 0.6376319 0.7247361 0.3623681
[35,] 0.6429954 0.7140093 0.3570046
[36,] 0.7214914 0.5570171 0.2785086
[37,] 0.7719012 0.4561976 0.2280988
[38,] 0.7839668 0.4320664 0.2160332
[39,] 0.8145365 0.3709270 0.1854635
[40,] 0.8278619 0.3442761 0.1721381
[41,] 0.7784355 0.4431291 0.2215645
[42,] 0.7328148 0.5343703 0.2671852
[43,] 0.7122957 0.5754086 0.2877043
[44,] 0.6735195 0.6529610 0.3264805
[45,] 0.6609938 0.6780124 0.3390062
[46,] 0.6839119 0.6321762 0.3160881
[47,] 0.7100174 0.5799651 0.2899826
[48,] 0.7174405 0.5651191 0.2825595
[49,] 0.6696992 0.6606017 0.3303008
[50,] 0.7051882 0.5896236 0.2948118
[51,] 0.6356090 0.7287819 0.3643910
[52,] 0.6518682 0.6962637 0.3481318
[53,] 0.7629913 0.4740173 0.2370087
[54,] 0.7131294 0.5737413 0.2868706
[55,] 0.6267601 0.7464799 0.3732399
[56,] 0.6535041 0.6929918 0.3464959
[57,] 0.5948575 0.8102849 0.4051425
[58,] 0.6858453 0.6283093 0.3141547
[59,] 0.6103943 0.7792114 0.3896057
[60,] 0.8515674 0.2968652 0.1484326
[61,] 0.7634832 0.4730337 0.2365168
[62,] 0.7091786 0.5816428 0.2908214
> postscript(file="/var/fisher/rcomp/tmp/1kjul1353013709.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/28t8f1353013709.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/3dmdx1353013709.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/4z5no1353013709.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/56nda1353013709.ps",horizontal=F,onefile=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 = 75
Frequency = 1
1 2 3 4 5 6
2.987738896 4.675177998 2.473409896 2.997394422 -3.021841809 3.538457469
7 8 9 10 11 12
5.135417691 3.086361802 -3.050846608 3.868286248 3.207499085 -2.302910399
13 14 15 16 17 18
-3.853740037 2.275147222 0.314650028 2.817213732 4.268234190 1.213632224
19 20 21 22 23 24
-0.264368467 0.920878645 3.011084587 -0.317852777 3.890448468 -4.806834693
25 26 27 28 29 30
-3.434193505 -0.870746867 3.583127421 -3.465506305 -2.083357386 -2.869187495
31 32 33 34 35 36
-0.070715833 -2.892342933 -0.547158632 -1.690040881 -1.668607476 -4.779336629
37 38 39 40 41 42
3.571904148 3.231112766 3.134961825 -2.444204367 -3.235940516 4.158248994
43 44 45 46 47 48
-4.188801415 3.045541845 3.072930847 2.178130734 -0.282780752 -1.469309950
49 50 51 52 53 54
-2.498608045 -1.836997678 -2.776538628 -3.431425700 3.819040185 2.716290345
55 56 57 58 59 60
1.755968341 -3.217227325 -0.009835509 -4.049338125 -4.137313598 2.551299900
61 62 63 64 65 66
0.142281211 3.638940198 -0.134305735 3.105865822 0.453661750 2.295814416
67 68 69 70 71 72
-2.264820066 -0.086404849 -4.465549577 -4.890931899 0.083118501 -2.365256240
73 74 75
-2.216839389 -3.196042342 -2.031211417
> postscript(file="/var/fisher/rcomp/tmp/6xa731353013709.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 = 75
Frequency = 1
lag(myerror, k = 1) myerror
0 2.987738896 NA
1 4.675177998 2.987738896
2 2.473409896 4.675177998
3 2.997394422 2.473409896
4 -3.021841809 2.997394422
5 3.538457469 -3.021841809
6 5.135417691 3.538457469
7 3.086361802 5.135417691
8 -3.050846608 3.086361802
9 3.868286248 -3.050846608
10 3.207499085 3.868286248
11 -2.302910399 3.207499085
12 -3.853740037 -2.302910399
13 2.275147222 -3.853740037
14 0.314650028 2.275147222
15 2.817213732 0.314650028
16 4.268234190 2.817213732
17 1.213632224 4.268234190
18 -0.264368467 1.213632224
19 0.920878645 -0.264368467
20 3.011084587 0.920878645
21 -0.317852777 3.011084587
22 3.890448468 -0.317852777
23 -4.806834693 3.890448468
24 -3.434193505 -4.806834693
25 -0.870746867 -3.434193505
26 3.583127421 -0.870746867
27 -3.465506305 3.583127421
28 -2.083357386 -3.465506305
29 -2.869187495 -2.083357386
30 -0.070715833 -2.869187495
31 -2.892342933 -0.070715833
32 -0.547158632 -2.892342933
33 -1.690040881 -0.547158632
34 -1.668607476 -1.690040881
35 -4.779336629 -1.668607476
36 3.571904148 -4.779336629
37 3.231112766 3.571904148
38 3.134961825 3.231112766
39 -2.444204367 3.134961825
40 -3.235940516 -2.444204367
41 4.158248994 -3.235940516
42 -4.188801415 4.158248994
43 3.045541845 -4.188801415
44 3.072930847 3.045541845
45 2.178130734 3.072930847
46 -0.282780752 2.178130734
47 -1.469309950 -0.282780752
48 -2.498608045 -1.469309950
49 -1.836997678 -2.498608045
50 -2.776538628 -1.836997678
51 -3.431425700 -2.776538628
52 3.819040185 -3.431425700
53 2.716290345 3.819040185
54 1.755968341 2.716290345
55 -3.217227325 1.755968341
56 -0.009835509 -3.217227325
57 -4.049338125 -0.009835509
58 -4.137313598 -4.049338125
59 2.551299900 -4.137313598
60 0.142281211 2.551299900
61 3.638940198 0.142281211
62 -0.134305735 3.638940198
63 3.105865822 -0.134305735
64 0.453661750 3.105865822
65 2.295814416 0.453661750
66 -2.264820066 2.295814416
67 -0.086404849 -2.264820066
68 -4.465549577 -0.086404849
69 -4.890931899 -4.465549577
70 0.083118501 -4.890931899
71 -2.365256240 0.083118501
72 -2.216839389 -2.365256240
73 -3.196042342 -2.216839389
74 -2.031211417 -3.196042342
75 NA -2.031211417
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 4.675177998 2.987738896
[2,] 2.473409896 4.675177998
[3,] 2.997394422 2.473409896
[4,] -3.021841809 2.997394422
[5,] 3.538457469 -3.021841809
[6,] 5.135417691 3.538457469
[7,] 3.086361802 5.135417691
[8,] -3.050846608 3.086361802
[9,] 3.868286248 -3.050846608
[10,] 3.207499085 3.868286248
[11,] -2.302910399 3.207499085
[12,] -3.853740037 -2.302910399
[13,] 2.275147222 -3.853740037
[14,] 0.314650028 2.275147222
[15,] 2.817213732 0.314650028
[16,] 4.268234190 2.817213732
[17,] 1.213632224 4.268234190
[18,] -0.264368467 1.213632224
[19,] 0.920878645 -0.264368467
[20,] 3.011084587 0.920878645
[21,] -0.317852777 3.011084587
[22,] 3.890448468 -0.317852777
[23,] -4.806834693 3.890448468
[24,] -3.434193505 -4.806834693
[25,] -0.870746867 -3.434193505
[26,] 3.583127421 -0.870746867
[27,] -3.465506305 3.583127421
[28,] -2.083357386 -3.465506305
[29,] -2.869187495 -2.083357386
[30,] -0.070715833 -2.869187495
[31,] -2.892342933 -0.070715833
[32,] -0.547158632 -2.892342933
[33,] -1.690040881 -0.547158632
[34,] -1.668607476 -1.690040881
[35,] -4.779336629 -1.668607476
[36,] 3.571904148 -4.779336629
[37,] 3.231112766 3.571904148
[38,] 3.134961825 3.231112766
[39,] -2.444204367 3.134961825
[40,] -3.235940516 -2.444204367
[41,] 4.158248994 -3.235940516
[42,] -4.188801415 4.158248994
[43,] 3.045541845 -4.188801415
[44,] 3.072930847 3.045541845
[45,] 2.178130734 3.072930847
[46,] -0.282780752 2.178130734
[47,] -1.469309950 -0.282780752
[48,] -2.498608045 -1.469309950
[49,] -1.836997678 -2.498608045
[50,] -2.776538628 -1.836997678
[51,] -3.431425700 -2.776538628
[52,] 3.819040185 -3.431425700
[53,] 2.716290345 3.819040185
[54,] 1.755968341 2.716290345
[55,] -3.217227325 1.755968341
[56,] -0.009835509 -3.217227325
[57,] -4.049338125 -0.009835509
[58,] -4.137313598 -4.049338125
[59,] 2.551299900 -4.137313598
[60,] 0.142281211 2.551299900
[61,] 3.638940198 0.142281211
[62,] -0.134305735 3.638940198
[63,] 3.105865822 -0.134305735
[64,] 0.453661750 3.105865822
[65,] 2.295814416 0.453661750
[66,] -2.264820066 2.295814416
[67,] -0.086404849 -2.264820066
[68,] -4.465549577 -0.086404849
[69,] -4.890931899 -4.465549577
[70,] 0.083118501 -4.890931899
[71,] -2.365256240 0.083118501
[72,] -2.216839389 -2.365256240
[73,] -3.196042342 -2.216839389
[74,] -2.031211417 -3.196042342
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 4.675177998 2.987738896
2 2.473409896 4.675177998
3 2.997394422 2.473409896
4 -3.021841809 2.997394422
5 3.538457469 -3.021841809
6 5.135417691 3.538457469
7 3.086361802 5.135417691
8 -3.050846608 3.086361802
9 3.868286248 -3.050846608
10 3.207499085 3.868286248
11 -2.302910399 3.207499085
12 -3.853740037 -2.302910399
13 2.275147222 -3.853740037
14 0.314650028 2.275147222
15 2.817213732 0.314650028
16 4.268234190 2.817213732
17 1.213632224 4.268234190
18 -0.264368467 1.213632224
19 0.920878645 -0.264368467
20 3.011084587 0.920878645
21 -0.317852777 3.011084587
22 3.890448468 -0.317852777
23 -4.806834693 3.890448468
24 -3.434193505 -4.806834693
25 -0.870746867 -3.434193505
26 3.583127421 -0.870746867
27 -3.465506305 3.583127421
28 -2.083357386 -3.465506305
29 -2.869187495 -2.083357386
30 -0.070715833 -2.869187495
31 -2.892342933 -0.070715833
32 -0.547158632 -2.892342933
33 -1.690040881 -0.547158632
34 -1.668607476 -1.690040881
35 -4.779336629 -1.668607476
36 3.571904148 -4.779336629
37 3.231112766 3.571904148
38 3.134961825 3.231112766
39 -2.444204367 3.134961825
40 -3.235940516 -2.444204367
41 4.158248994 -3.235940516
42 -4.188801415 4.158248994
43 3.045541845 -4.188801415
44 3.072930847 3.045541845
45 2.178130734 3.072930847
46 -0.282780752 2.178130734
47 -1.469309950 -0.282780752
48 -2.498608045 -1.469309950
49 -1.836997678 -2.498608045
50 -2.776538628 -1.836997678
51 -3.431425700 -2.776538628
52 3.819040185 -3.431425700
53 2.716290345 3.819040185
54 1.755968341 2.716290345
55 -3.217227325 1.755968341
56 -0.009835509 -3.217227325
57 -4.049338125 -0.009835509
58 -4.137313598 -4.049338125
59 2.551299900 -4.137313598
60 0.142281211 2.551299900
61 3.638940198 0.142281211
62 -0.134305735 3.638940198
63 3.105865822 -0.134305735
64 0.453661750 3.105865822
65 2.295814416 0.453661750
66 -2.264820066 2.295814416
67 -0.086404849 -2.264820066
68 -4.465549577 -0.086404849
69 -4.890931899 -4.465549577
70 0.083118501 -4.890931899
71 -2.365256240 0.083118501
72 -2.216839389 -2.365256240
73 -3.196042342 -2.216839389
74 -2.031211417 -3.196042342
> 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/7kb641353013709.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/855co1353013709.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/9hccw1353013709.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
> if (n > n25) {
+ postscript(file="/var/fisher/rcomp/tmp/1044fl1353013709.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ 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/11pucz1353013709.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/12f0ye1353013709.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/13j7aa1353013709.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/14ynyf1353013709.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/fisher/rcomp/tmp/156pu81353013709.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/fisher/rcomp/tmp/16dxxn1353013709.tab")
+ }
>
> try(system("convert tmp/1kjul1353013709.ps tmp/1kjul1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/28t8f1353013709.ps tmp/28t8f1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/3dmdx1353013709.ps tmp/3dmdx1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/4z5no1353013709.ps tmp/4z5no1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/56nda1353013709.ps tmp/56nda1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/6xa731353013709.ps tmp/6xa731353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/7kb641353013709.ps tmp/7kb641353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/855co1353013709.ps tmp/855co1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/9hccw1353013709.ps tmp/9hccw1353013709.png",intern=TRUE))
character(0)
> try(system("convert tmp/1044fl1353013709.ps tmp/1044fl1353013709.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.397 1.292 7.685