Title: | Dynamic Model Averaging and Dynamic Model Selection for Continuous Outcomes |
---|---|
Description: | Allows to estimate dynamic model averaging, dynamic model selection and median probability model. The original methods are implemented, as well as, selected further modifications of these methods. In particular the user might choose between recursive moment estimation and exponentially moving average for variance updating. Inclusion probabilities might be modified in a way using 'Google Trends'. The code is written in a way which minimises the computational burden (which is quite an obstacle for dynamic model averaging if many variables are used). For example, this package allows for parallel computations and Occam's window approach. The package is designed in a way that is hoped to be especially useful in economics and finance. Main reference: Raftery, A.E., Karny, M., Ettler, P. (2010) <doi:10.1198/TECH.2009.08104>. |
Authors: | Krzysztof Drachal [aut, cre] (Faculty of Economic Sciences, University of Warsaw, Poland) |
Maintainer: | Krzysztof Drachal <[email protected]> |
License: | GPL-3 |
Version: | 2.2.7 |
Built: | 2024-11-25 06:31:14 UTC |
Source: | CRAN |
It is necessary to compare a given forecast method with some alternative ones. This function computes selected forecast quality measures for a few selected forecast methods (which might be treated as alternative ones to Dynamic Model Averaging, Dynamic Model Selection, etc.).
Naive forecast (naive) is computed in a way that all forecasts are set to be the value of the last observation.
For rolling OLS forecast (roll. OLS) for the first periods (until the size of a window
is obtained) are estimated through recursive OLS (rec. OLS).
Autoregressive models (AR(1) and AR(2)) are computed by ordinary least squares method.
Time-varying parameters models (TVP, TVP-AR(1) and TVP-AR(2)) are computed as tvp
with V=1
and lambda=0.99
.
Auto ARIMA (auto ARIMA) is computed as auto.arima
.
ME (Mean Error), RMSE (Root Mean Squared Error), MAE (Mean Absolute Error), MPE (Mean Percentage Errror) and MAPE (Mean Absolute Percentage Error) are computed as accuracy
. HR (Hit Ratio) is computed as hit.ratio
.
altf(y,x,window=NULL,initial.period=NULL,d=NULL,f=NULL,fmod=NULL,c=NULL)
altf(y,x,window=NULL,initial.period=NULL,d=NULL,f=NULL,fmod=NULL,c=NULL)
y |
|
x |
|
window |
optional, |
initial.period |
optional, |
d |
optional, |
f |
optional, |
fmod |
optional, class |
c |
optional, |
class altf
object, list
of
$summary |
|
$y.hat |
|
$y |
|
$coeff. |
|
$p.val. |
|
plot.altf
, print.altf
, summary.altf
, rec.reg
, roll.reg
, altf2
, altf3
, altf4
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=60) # models where constant term is not included in modelled equations (if applicable) a2 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,c=FALSE,initial.period=60) # compute just selected models fcomp <- c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE) a3 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,initial.period=60) m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) a4 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,fmod=m1,initial.period=60)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=60) # models where constant term is not included in modelled equations (if applicable) a2 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,c=FALSE,initial.period=60) # compute just selected models fcomp <- c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE) a3 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,initial.period=60) m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) a4 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,fmod=m1,initial.period=60)
It is necessary to compare a given forecast method with some alternative ones. This function computes selected forecast quality measures for a few selected forecast methods (which might be treated as alternative ones to Dynamic Model Averaging, Dynamic Model Selection, etc.).
ME (Mean Error), RMSE (Root Mean Squared Error), MAE (Mean Absolute Error), MPE (Mean Percentage Errror) and MAPE (Mean Absolute Percentage Error) are computed as accuracy
. HR (Hit Ratio) is computed as hit.ratio
.
altf2(y,x,mods.incl=NULL,gprob=NULL,omega=NULL,av=NULL,window=NULL, initial.period=NULL,d=NULL,f=NULL,fmod=NULL,parallel=NULL)
altf2(y,x,mods.incl=NULL,gprob=NULL,omega=NULL,av=NULL,window=NULL, initial.period=NULL,d=NULL,f=NULL,fmod=NULL,parallel=NULL)
y |
|
x |
|
mods.incl |
optional, |
gprob |
optional, |
omega |
optional, |
av |
optional, a method for model averaging, |
window |
optional, |
initial.period |
optional, |
d |
optional, |
f |
optional, |
fmod |
optional, class |
parallel |
optional, |
For each av
method, in the initial period equal weights for each model are taken, and then successively updated based on the chosen criterion. For OLS models weights are not updated. The same weight for each model (estimated from the in-sample period) is taken for each period.
If gprob
is used, then for OLS mean values from the in-sample period are taken, for rec. OLS – mean values from periods up to the current one, for roll. OLS – mean values from the last window
periods, and for TVP – values from the current period.
class altf2
object, list
of
$summary |
|
$y.hat |
|
$y |
|
$coeff. |
|
$weights |
|
$p.val. |
|
$rel.var.imp. |
|
$exp.var. |
|
Burnham, K. P., Anderson, D. R., 2004. Multimodel inference: Understanding AIC and BIC in model selection. Sociological Methods & Research 33, 261–304.
Burnham, K. P., Anderson, D. R., 2002. Model Selection and Multimodel Inference: A Practical Information-Theoretic Approach, Springer.
Gelman, A., Hwang, J., Vehtari, A., 2014. Understanding predictive information criteria for Bayesian models. Statistics and Computing 24, 997–1016.
Kapetanios, G., Labhard, V., Price, S., 2008. Forecasting using Bayesian and information-theoretic model averaging. Journal of Business & Economic Statistics 26, 33–41.
Koop, G., Onorante, L., 2014. Macroeconomic nowcasting using Google probabilities. https://goo.gl/ATsBN9
Timmermann, A., 2006. Forecast combinations. In: Elliott, G., et al. (eds.), Handbook of Economic Forecasting, Elsevier.
plot.altf2
, print.altf2
, summary.altf2
, rec.reg
, roll.reg
, tvp
, altf
, altf3
, altf4
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=60) # compute just selected models fcomp <- c(TRUE,TRUE,TRUE,FALSE) a2 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,initial.period=60) a3 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,av="aic",initial.period=60) m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) a4 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,fmod=m1,initial.period=60) # models just with one independent variable and a constant will be averaged mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) a5 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,mods.incl=mds,initial.period=60) # Google trends are available since 2004 gp <- trends/100 s1 <- ld.wti['2004-01-01/'] s2 <- ld.drivers['2004-01-01/'] a6 <- altf2(y=s1,x=s2,d=TRUE,gprob=gp,omega=0.5,initial.period=60)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=60) # compute just selected models fcomp <- c(TRUE,TRUE,TRUE,FALSE) a2 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,initial.period=60) a3 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,av="aic",initial.period=60) m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) a4 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,fmod=m1,initial.period=60) # models just with one independent variable and a constant will be averaged mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) a5 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,mods.incl=mds,initial.period=60) # Google trends are available since 2004 gp <- trends/100 s1 <- ld.wti['2004-01-01/'] s2 <- ld.drivers['2004-01-01/'] a6 <- altf2(y=s1,x=s2,d=TRUE,gprob=gp,omega=0.5,initial.period=60)
It is necessary to compare a given forecast method with some alternative ones. This function computes selected forecast quality measures for a rolling regression averaged over different window sizes (which might be treated as alternative forecasting method to Dynamic Model Averaging, Dynamic Model Selection, etc.).
ME (Mean Error), RMSE (Root Mean Squared Error), MAE (Mean Absolute Error), MPE (Mean Percentage Errror) and MAPE (Mean Absolute Percentage Error) are computed as accuracy
. HR (Hit Ratio) is computed as hit.ratio
.
altf3(y,x=NULL,windows,av=NULL,initial.period=NULL,d=NULL,fmod=NULL,parallel=NULL,c=NULL)
altf3(y,x=NULL,windows,av=NULL,initial.period=NULL,d=NULL,fmod=NULL,parallel=NULL,c=NULL)
y |
|
x |
|
windows |
|
av |
optional, a method for model averaging, |
initial.period |
optional, |
d |
optional, |
fmod |
optional, class |
parallel |
optional, |
c |
optional, see |
For each av
method, in the initial period equal weights for each model are taken, and then successively updated based on the chosen criterion.
class altf3
object, list
of
$summary |
|
$y.hat |
|
$y |
|
$coeff. |
|
$weights |
|
$p.val. |
|
$exp.win. |
|
Pesaran, M. H., Pick, A., 2011. Forecast combination across estimation windows. Journal of Business & Economic Statistics 29, 307–318.
plot.altf3
, print.altf3
, summary.altf3
, roll.reg
, altf
, altf2
, altf4
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,windows=c(36,100,150)) a2 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,av="aic",windows=c(36,100,150)) a3 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,av=-2,windows=c(36,100,150)) # models without a constant term a4 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,av=-2,windows=c(36,100,150),c=FALSE) # models only with a constant term a5 <- altf3(y=ld.wti,d=TRUE,av=-2,windows=c(36,100,150))
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,windows=c(36,100,150)) a2 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,av="aic",windows=c(36,100,150)) a3 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,av=-2,windows=c(36,100,150)) # models without a constant term a4 <- altf3(y=ld.wti,x=ld.drivers,d=TRUE,av=-2,windows=c(36,100,150),c=FALSE) # models only with a constant term a5 <- altf3(y=ld.wti,d=TRUE,av=-2,windows=c(36,100,150))
It is necessary to compare a given forecast method with some alternative ones. This function computes selected forecast quality measures for a time-varying parameters rolling regression averaged over different window sizes (which might be treated as alternative forecasting method to Dynamic Model Averaging, Dynamic Model Selection, etc.). The averaging is performed as in Raftery et al. (2010). The only difference is that the state space of the models are constructed not by chosing different combinations of independent variables, but for a fixed set of independent variables various rolling windows sizes are chosen and models constructed in such a way constitute the state space.
ME (Mean Error), RMSE (Root Mean Squared Error), MAE (Mean Absolute Error), MPE (Mean Percentage Errror) and MAPE (Mean Absolute Percentage Error) are computed as accuracy
. HR (Hit Ratio) is computed as hit.ratio
.
altf4(y,x,windows,V=NULL,alpha=NULL,lambda=NULL,initial.period=NULL, d=NULL,fmod=NULL,parallel=NULL,c=NULL,small.c=NULL)
altf4(y,x,windows,V=NULL,alpha=NULL,lambda=NULL,initial.period=NULL, d=NULL,fmod=NULL,parallel=NULL,c=NULL,small.c=NULL)
y |
|
x |
|
windows |
|
V |
optional, |
lambda |
optional, |
alpha |
optional, |
initial.period |
optional, |
d |
optional, |
fmod |
optional, class |
parallel |
optional, |
c |
optional, see |
small.c |
optional, see |
class altf4
object, list
of
$summary |
|
$y.hat |
|
$y |
|
$coeff. |
|
$weights |
|
$exp.win. |
|
Pesaran, M. H., Pick, A., 2011. Forecast combination across estimation windows. Journal of Business & Economic Statistics 29, 307–318.
Raftery, A. E., Gneiting, T., Balabdaoui, F., Polakowski, M., 2005. Using Bayesian Model Averaging to calibrate forecast ensembles. Monthly Weather Review 133, 1155–1174.
Raftery, A. E., Karny, M., Ettler, P., 2010. Online prediction under model uncertainty via Dynamic Model Averaging: Application to a cold rolling mill. Technometrics 52, 52–66.
plot.altf4
, print.altf4
, summary.altf4
, roll.reg
, tvp
, altf
, altf2
, altf3
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf4(y=ld.wti,x=ld.drivers,d=TRUE,windows=c(36,100,150)) win <- c(36,100,150) a2 <- altf4(y=ld.wti,x=ld.drivers,d=TRUE,windows=win,alpha=0.9,lambda=0.95) # models without a constant term a3 <- altf4(y=ld.wti,x=ld.drivers,d=TRUE,windows=win,alpha=0.9,lambda=0.95,c=FALSE) # models only with a constant term empty <- matrix(,nrow=nrow(ld.drivers),ncol=0) a4 <- altf4(y=ld.wti,x=empty,d=TRUE,windows=win,alpha=0.9,lambda=0.95)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] a1 <- altf4(y=ld.wti,x=ld.drivers,d=TRUE,windows=c(36,100,150)) win <- c(36,100,150) a2 <- altf4(y=ld.wti,x=ld.drivers,d=TRUE,windows=win,alpha=0.9,lambda=0.95) # models without a constant term a3 <- altf4(y=ld.wti,x=ld.drivers,d=TRUE,windows=win,alpha=0.9,lambda=0.95,c=FALSE) # models only with a constant term empty <- matrix(,nrow=nrow(ld.drivers),ncol=0) a4 <- altf4(y=ld.wti,x=empty,d=TRUE,windows=win,alpha=0.9,lambda=0.95)
This function computes Engle's ARCH test. The null hypothesis of this Lagrange Multiplier test is that a series of residuals exhibits no ARCH effects. The alternative hypothesis is that ARCH(lag) effects are present. The lag
is specified by the User.
archtest(ts,lag=NULL)
archtest(ts,lag=NULL)
ts |
|
lag |
|
class htest
object, list
of
statistic |
test statistic |
parameter |
|
alternative |
alternative hypothesis of the test |
p.value |
p-value |
method |
name of the test |
data.name |
name of the tested time-series |
Engle, R. F., 1982. Autoregressive conditional heteroscedasticity with estimates of the variance of United Kingdom inflation. Econometrica 50, 987–1007.
wti <- crudeoil[-1,1] ld.wti <- (diff(log(wti)))[-1,] arch <- archtest(ts=as.vector(ld.wti),lag=10)
wti <- crudeoil[-1,1] ld.wti <- (diff(log(wti)))[-1,] arch <- archtest(ts=as.vector(ld.wti),lag=10)
dma
Model.The function extracts the expected values of regression coefficients from the fDMA
model.
## S3 method for class 'dma' coef(object, ...)
## S3 method for class 'dma' coef(object, ...)
object |
an object of |
... |
not used |
matrix
of expected values of regression coefficients
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") c <- coef(object=m1)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") c <- coef(object=m1)
Selected data from oil market.
data(crudeoil)
data(crudeoil)
crudeoil
is xts
object such that
crudeoil$WTI
– WTI spot price in USD per barrel
crudeoil$MSCI
– MSCI World Index
crudeoil$TB3MS
– U.S. 3-month treasury bill secondary market rate in %
crudeoil$CSP
– Crude steel production in thousand tonnes
crudeoil$TWEXM
– Trade weighted U.S. dollar index (Mar, 1973 = 100)
crudeoil$PROD
– U.S. product supplied for crude oil and petroleum products in thousands of barrels
crudeoil$CONS
– Total consumption of petroleum products in OECD in quad BTU
crudeoil$VXO
– Implied volatility of S&P 100
The data are in monthly frequency. They cover the period between Jan, 1990 and Dec, 2016.
The data are provided by CBOE, Federal Reserve Bank of St. Louis, MSCI, U.S. Energy Information Administration and World Steel Association.
data(crudeoil) wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma")
data(crudeoil) wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma")
This function computes descriptive statistics which are most useful for Dynamic Model Averaging.
It is a wrapper of describe
.
If the argument is not a matrix
, the function tries to convert the object into a matrix
. For example, it works smoothly for xts
objects.
descstat(data)
descstat(data)
data |
|
See describe
.
descstat(crudeoil)
descstat(crudeoil)
This is a wrapper for dm.test
from forecast
package. This function computes the original Diebold-Mariano test.
dmtest(y,f)
dmtest(y,f)
y |
|
f |
|
The null hypothesis is that the two methods have the same forecast accuracy. This function assumes that one-step ahead forecasts are compared and the second power is used in the loss function (see dm.test
). "The Diebold-Mariano (DM) test was intended for comparing forecasts; it has been, and remains, useful in that regard. The DM test was not intended for comparing models." (Diebold, 2015)
matrix
,
first column contains tests statistics, next p-values are given for the alternative hypothesis that alternative forecasts have different accuracy than the compared forecast, alternative forecasts are less accurate and alternative forecasts have greater accuracy, tests outcomes for different forecasts are ordered by rows
Diebold, F. X., 2015. Comparing predictive accuracy, Twenty years later: A peersonal perspective on the use and abuse of Diebold-Mariano tests. Journal of Business & Economic Statistics 33, doi:10.1080/07350015.2014.983236.
Diebold, F. X., Mariano, R. S., 1995. Comparing predictive accuracy. Journal of Business & Economic Statistics 13, 253–263.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) dm <- dmtest(y=as.vector(ld.wti),f=fc)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) dm <- dmtest(y=as.vector(ld.wti),f=fc)
The function estimates Dynamic Model Averaging (and some of its variations). The method is described in Raftery et al. (2010).
fDMA(y,x,alpha,lambda,initvar,W=NULL,initial.period=NULL,V.meth=NULL,kappa=NULL, gprob=NULL,omega=NULL,model=NULL,parallel=NULL,m.prior=NULL,mods.incl=NULL, DOW=NULL,DOW.nmods=NULL,DOW.type=NULL,DOW.limit.nmods=NULL,progress.info=NULL, forced.models=NULL,forbidden.models=NULL,forced.variables=NULL,bm=NULL, small.c=NULL,fcores=NULL,mods.check=NULL,red.size=NULL,av=NULL)
fDMA(y,x,alpha,lambda,initvar,W=NULL,initial.period=NULL,V.meth=NULL,kappa=NULL, gprob=NULL,omega=NULL,model=NULL,parallel=NULL,m.prior=NULL,mods.incl=NULL, DOW=NULL,DOW.nmods=NULL,DOW.type=NULL,DOW.limit.nmods=NULL,progress.info=NULL, forced.models=NULL,forbidden.models=NULL,forced.variables=NULL,bm=NULL, small.c=NULL,fcores=NULL,mods.check=NULL,red.size=NULL,av=NULL)
y |
|
x |
|
alpha |
|
lambda |
|
initvar |
|
W |
optional, a method for setting the initial values of variance for the models equations, |
initial.period |
optional, |
V.meth |
optional, a method for the state space equation variance updating, |
kappa |
optional, |
gprob |
optional, |
omega |
optional, |
model |
optional, |
parallel |
optional, |
m.prior |
optional, |
mods.incl |
optional, |
DOW |
optional, |
DOW.nmods |
optional, |
DOW.type |
optional, |
DOW.limit.nmods |
optional, |
progress.info |
optional, |
forced.models |
optional, |
forbidden.models |
optional, |
forced.variables |
optional, |
bm |
optional, |
small.c |
optional, |
fcores |
optional, |
mods.check |
optional, |
red.size |
optional, |
av |
optional, |
It is possible to use numeric
vector
for lambda
. Its values are automatically ordered in descending order and if numbers are not unique they are reduced to become unique. If more than one value is given for lambda
, then model state space, i.e., mods.incl
, is expanded by considering all these models with given values of lambda
. The outcomes are then ordered by columns in a way that first outcomes from models with first value of lambda
are presented, then from models with second value of lambda
, etc. (Raftery et al., 2010).
If nrow(gprob)<length(y)
, then the method by Koop and Onorante (2014) is used for the last nrow(gprob)
observations. For the preceding ones the original method by Raftery et al. (2010) is used. In such case a warning
is generated.
class dma
object, list
of
$y.hat |
forecasted values |
$post.incl |
posterior inclusion probabilities for independent variables |
$MSE |
Mean Squared Error of forecast |
$MAE |
Mean Absolute Error of forecast |
$models |
models included in estimations, or models used in the last step of Dynamic Occam's Window method (if this method has been selected) |
$post.mod |
posterior probabilities of all used models, or NA if Dynamic Occam's Window method has been selected |
$exp.var |
expected number of variables (incl. constant) |
$exp.coef. |
expected values of regression coefficients |
$parameters |
parameters of the estimated model |
$yhat.all.mods |
predictions from every sub-model used in estimations |
$y |
|
$benchmarks |
Root Mean Squared Error and Mean Absolute Error of naive and auto ARIMA forecast |
$DOW.init.mods |
models initially selected to Dynamic Occam's Window, if this method has been selected |
$DOW.n.mods.t |
number of models used in Dynamic Model Averaging at time |
$p.dens. |
predicitive densities from the last period of all sub-models used in estimations |
$exp.lambda |
expected values of |
Raftery, A. E., Karny, M., Ettler, P., 2010. Online prediction under model uncertainty via Dynamic Model Averaging: Application to a cold rolling mill. Technometrics 52, 52–66.
Barbieri, M. M., Berger, J. O., 2004. Optimal predictive model selection. The Annals of Statistics 32, 870–897.
Eicher, T. S., Papageorgiou, C., Raftery, A. E., 2011. Default priors and predictive performance in Bayesian Model Averaging, with application to growth determinants. Journal of Applied Econometrics 26, 30–55.
Koop, G., Korobilis, D., 2012. Forecasting inflation using Dynamic Model Averaging. International Economic Review 53, 867–886.
Koop, G., Korobilis, D., 2018. Variational Bayes inference in high-dimensional time-varying parameter models. https://arxiv.org/pdf/1809.03031
Koop, G., Onorante, L., 2014. Macroeconomic nowcasting using Google probabilities. https://goo.gl/ATsBN9
Mitchell, T. J., Beauchamp, J. J., 1988. Bayesian variable selection in linear regression (with discussion). Journal of the American Statistical Association 83, 1023–1036.
Onorante, L., Raftery, A. E., 2016. Dynamic model averaging in large model spaces using dynamic Occam's window. European Economic Review 81, 2–14.
Yin, X., Peng, J., Tang, T., 2018. Improving the forecasting accuracy of crude oil prices. Sustainability 10, 454. doi:10.3390/su10020454
grid.DMA
, print.dma
, summary.dma
, plot.dma
, hit.ratio
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,model="dms") m3 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,V.meth="ewma",kappa=0.9) m4 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,DOW=0.7) # Google trends are available since 2004 gp <- trends/100 s <- ld.drivers['2004-01-01/'] m5 <- fDMA(y=ld.wti['2004-01-01/'],x=s,alpha=0.99,lambda=0.90,initvar=10,gprob=gp,omega=0.5) # models just with one independent variable and a constant will be averaged mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) m6 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds) # models just with one independent variable (without a constant) will be averaged mds.nc <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds.nc <- cbind(rep(0,ncol(ld.drivers)),mds.nc) m7 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds.nc) # model with multiple lambda m8 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=c(0.99,0.95,0.90),initvar=10)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,model="dms") m3 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,V.meth="ewma",kappa=0.9) m4 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,DOW=0.7) # Google trends are available since 2004 gp <- trends/100 s <- ld.drivers['2004-01-01/'] m5 <- fDMA(y=ld.wti['2004-01-01/'],x=s,alpha=0.99,lambda=0.90,initvar=10,gprob=gp,omega=0.5) # models just with one independent variable and a constant will be averaged mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) m6 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds) # models just with one independent variable (without a constant) will be averaged mds.nc <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds.nc <- cbind(rep(0,ncol(ld.drivers)),mds.nc) m7 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds.nc) # model with multiple lambda m8 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=c(0.99,0.95,0.90),initvar=10)
dma
Model.The function extracts predictions made by the fDMA
model.
## S3 method for class 'dma' fitted(object, ...)
## S3 method for class 'dma' fitted(object, ...)
object |
an object of |
... |
not used |
vector
of forecasted values
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") f <- fitted(object=m1)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") f <- fitted(object=m1)
For example, Google Trends data are given as numbers between 0 and 100. If the Users divide them by 100, they can be interpreted in a certain sense as probabilities.
However, if there are such probabilities for several variables, sometimes it might be desirable to have the sum of these probabilities for all variables to sum up to 1. This function does not divide the values of an argument by 100, but rescales every row to sum up to 1. In other words, values in each row of an argument are divided by the sum of all values in this row.
gNormalize(data)
gNormalize(data)
data |
|
Koop, G., Onorante, L., 2014. Macroeconomic nowcasting using Google probabilities. https://goo.gl/ATsBN9
gt <- gNormalize(trends) gNormalize(rbind(c(0,1,2),c(1,2,3)))
gt <- gNormalize(trends) gNormalize(rbind(c(0,1,2),c(1,2,3)))
fDMA
Function for Multiple Values of alpha
and lambda
.Sometimes it is necessary to consider various values of parameters alpha
and lambda
in Dynamic Model Averaging (or Dynamic Model Selection, etc.). This function computes fDMA
function for all combinations of alpha
and lambda
for given grids.
This function is a wrapper of fDMA
.
grid.DMA(y,x,grid.alpha,grid.lambda,initvar,W=NULL,initial.period=NULL,V.meth=NULL, kappa=NULL,gprob=NULL,omega=NULL,model=NULL,parallel.grid=NULL,m.prior=NULL, mods.incl=NULL,DOW=NULL,DOW.nmods=NULL,DOW.type=NULL,DOW.limit.nmods=NULL, forced.models=NULL,forbidden.models=NULL,forced.variables=NULL,bm=NULL, small.c=NULL,av=NULL)
grid.DMA(y,x,grid.alpha,grid.lambda,initvar,W=NULL,initial.period=NULL,V.meth=NULL, kappa=NULL,gprob=NULL,omega=NULL,model=NULL,parallel.grid=NULL,m.prior=NULL, mods.incl=NULL,DOW=NULL,DOW.nmods=NULL,DOW.type=NULL,DOW.limit.nmods=NULL, forced.models=NULL,forbidden.models=NULL,forced.variables=NULL,bm=NULL, small.c=NULL,av=NULL)
y |
see |
x |
see |
grid.alpha |
|
grid.lambda |
a |
initvar |
see |
W |
see |
initial.period |
see |
V.meth |
see |
kappa |
see |
gprob |
see |
omega |
see |
model |
see |
parallel.grid |
optional, |
m.prior |
see |
mods.incl |
see |
DOW |
see |
DOW.nmods |
see |
DOW.type |
see |
DOW.limit.nmods |
see |
forced.models |
see |
forbidden.models |
see |
forced.variables |
see |
bm |
see |
small.c |
see |
av |
see |
an object of class grid.dma
, list
of
$models |
|
$RMSE |
|
$MAE |
|
print.grid.dma
, summary.grid.dma
, plot.grid.dma
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=10) # extract model with alpha=0.97 and lambda=0.95 model <- g$models[[3]][[2]] # models with various multiple lambdas gra <- c(0.99,0.98,0.97) grl <- list(c(0.99,0.95,0.90),c(0.99,0.98,0.97,0.96,0.95)) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=10)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=10) # extract model with alpha=0.97 and lambda=0.95 model <- g$models[[3]][[2]] # models with various multiple lambdas gra <- c(0.99,0.98,0.97) grl <- list(c(0.99,0.95,0.90),c(0.99,0.98,0.97,0.96,0.95)) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=10)
roll.reg
Function for Multiple Values of window
.Sometimes it is necessary to consider various values of parameter window
in Rolling Regression. This function computes roll.reg
function for all values of window
for a given grid.
This function is a wrapper of roll.reg
.
grid.roll.reg(y,x=NULL,grid.window,parallel.grid=NULL,c=NULL)
grid.roll.reg(y,x=NULL,grid.window,parallel.grid=NULL,c=NULL)
y |
see |
x |
see |
grid.window |
a numeric |
parallel.grid |
optional, |
c |
optional, see |
an object of class grid.roll.reg
, list
of
$models |
|
$fq |
|
print.grid.roll.reg
, summary.grid.roll.reg
, plot.grid.roll.reg
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) # extract model with window=100 model <- g$models[[2]]
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) # extract model with window=100 model <- g$models[[2]]
tvp
Function for Multiple Values of lambda
.Sometimes it is necessary to consider various values of parameter lambda
in Time-Varying Parameters Regression. This function computes tvp
function for all values of lambda
for a given grid.
This function is a wrapper of tvp
.
grid.tvp(y,x,V,grid.lambda,W=NULL,kappa=NULL,parallel.grid=NULL,c=NULL)
grid.tvp(y,x,V,grid.lambda,W=NULL,kappa=NULL,parallel.grid=NULL,c=NULL)
y |
see |
x |
see |
V |
see |
grid.lambda |
|
W |
optional, see |
kappa |
optional, see |
parallel.grid |
optional, |
c |
optional, see |
an object of class grid.tvp
, list
of
$models |
|
$fq |
|
print.grid.tvp
, summary.grid.tvp
, plot.grid.tvp
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) # extract model with lambda=0.95 model <- g$models[[5]]
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) # extract model with lambda=0.95 model <- g$models[[5]]
Sometimes it is interesting to analyze just whether the forecast can predict the direction of a change in a modelled time-series. This function computes the proportion of correctly predicted signs (i.e., in which cases the direction of a change given by forecast agrees with the change in real data).
hit.ratio(y,y.hat,d=NULL)
hit.ratio(y,y.hat,d=NULL)
y |
|
y.hat |
|
d |
optional, |
Baur, D. G., Beckmann, J., Czudaj, R., 2016. A melting pot – Gold price forecasts under model and parameter uncertainty. International Review of Financial Analysis 48, 282–291.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=wti,x=drivers,alpha=0.99,lambda=0.99,initvar=10) hit.ratio(y=wti,y.hat=m1$y.hat) m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=10) hit.ratio(y=ld.wti,y.hat=m2$y.hat,d=TRUE)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=wti,x=drivers,alpha=0.99,lambda=0.99,initvar=10) hit.ratio(y=wti,y.hat=m1$y.hat) m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=10) hit.ratio(y=ld.wti,y.hat=m2$y.hat,d=TRUE)
This is a wrapper for dm.test
from forecast
package. This function computes the modified Diebold-Mariano test. The modification is useful if the presence of ARCH effects is suspected in forecast errors. It is also useful for small samples. This is a modification of mdmtest
for the presence of ARCH effects in forecast errors.
hmdmtest(y,f)
hmdmtest(y,f)
y |
|
f |
|
The null hypothesis is that the two methods have the same forecast accuracy. This function assumes that one-step ahead forecasts are compared and the second power is used in the loss function (see dm.test
).
matrix
,
first column contains tests statistics, next p-values are given for the alternative hypothesis that alternative forecasts have different accuracy than the compared forecast, alternative forecasts are less accurate and alternative forecasts have greater accuracy, tests outcomes for different forecasts are ordered by rows
Newbold, P., Harvey, D. J., 2002. Forecast combinations. In: Clements, M. P., Hendry, D. F. (eds.), A Companion to Economic Forecasting, Blackwell Publishing Ltd.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) hmdm <- hmdmtest(y=as.vector(ld.wti),f=fc)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) hmdm <- hmdmtest(y=as.vector(ld.wti),f=fc)
This is a wrapper for dm.test
from forecast
package. This function computes the modified Diebold-Mariano test. The modification is useful for small samples.
mdmtest(y,f)
mdmtest(y,f)
y |
|
f |
|
The null hypothesis is that the two methods have the same forecast accuracy. This function assumes that one-step ahead forecasts are compared and the second power is used in the loss function (see dm.test
).
matrix
,
first column contains tests statistics, next p-values are given for the alternative hypothesis that alternative forecasts have different accuracy than the compared forecast, alternative forecasts are less accurate and alternative forecasts have greater accuracy, tests outcomes for different forecasts are ordered by rows
Harvey, D., Leybourne, S., Newbold, P., 1997. Testing the equality of prediction mean squared errors. International Journal of Forecasting 13, 281–291.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) mdm <- mdmtest(y=as.vector(ld.wti),f=fc)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) mdm <- mdmtest(y=as.vector(ld.wti),f=fc)
For a variable considered to be used in Dynamic Model Averaging (or Dynamic Model Selection, etc.), sometimes it is desirable to have all its values between 0 and 1. This function rescales the values to fit between 0 and 1.
If the argument is not a matrix
, the function tries to convert the object into a matrix
. For example, it works smoothly for xts
objects.
normalize(data)
normalize(data)
data |
|
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] nwti <- normalize(wti) nd <- normalize(drivers) normalize(cbind(c(0,1,2),c(1,2,3),c(0,1,3)))
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] nwti <- normalize(wti) nd <- normalize(drivers) normalize(cbind(c(0,1,2),c(1,2,3),c(0,1,3)))
matrix
of one-variable models.This function simplifies working with one-variable models in, for example, fDMA
. It produces a matrix
corresponding to the set of models consisting of models with a constant and just one extra variable, and a model with a constant only.
onevar(x)
onevar(x)
x |
matrix
,
inclusion of a variable is indicated by 1, omitting by 0
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) mds <- rbind(rep(0,ncol(mds)),mds) mds[1,1] <- 1 m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds) # Equivalently: m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=onevar(ld.drivers))
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers)) mds <- cbind(rep(1,ncol(ld.drivers)),mds) mds <- rbind(rep(0,ncol(mds)),mds) mds[1,1] <- 1 m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds) # Equivalently: m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=onevar(ld.drivers))
altf
Object.The function plots selected outcomes from altf
object.
## S3 method for class 'altf' plot(x,non.interactive=NULL, ...)
## S3 method for class 'altf' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting regression coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
2 - for plotting p-values for t-test of statistical significance for regression coefficients from applied models, in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory).
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
Coefficients are plotted only for rec. OLS, roll. OLS, TVP, TVP-AR(1) and TVP-AR(2) models. P-values – for rec. OLS and roll. OLS.
It is suggested to execute graphics.off
before exectuing plot
command for altf
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting altf
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf(y=wti,x=drivers) plot(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf(y=wti,x=drivers) plot(a)
altf2
Object.The function plots selected outcomes from altf2
object.
## S3 method for class 'altf2' plot(x,non.interactive=NULL, ...)
## S3 method for class 'altf2' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting expected coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
2 - for plotting p-values (averaged over selected models) for t-test of statistical significance for regression coefficients from applied models, in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
3 - for plotting weights of all models used in averaging,
4 - for plotting relative variable importance in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
5 - for plotting expected number of variables (incl. constant) from all models used in averaging.
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for altf2
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting altf2
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf2(y=wti,x=drivers,av="aic") plot(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf2(y=wti,x=drivers,av="aic") plot(a)
altf3
Object.The function plots selected outcomes from altf3
object.
## S3 method for class 'altf3' plot(x,non.interactive=NULL, ...)
## S3 method for class 'altf3' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting expected coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
2 - for plotting p-values (averaged over selected window sizes) for t-test of statistical significance for coefficients from a rolling regression, in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
3 - for plotting weights of all models used in averaging,
4 - for plotting expected window size.
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for altf3
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting altf3
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf3(y=wti,x=drivers,windows=c(36,100,150)) plot(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf3(y=wti,x=drivers,windows=c(36,100,150)) plot(a)
altf4
Object.The function plots selected outcomes from altf4
object.
## S3 method for class 'altf4' plot(x,non.interactive=NULL, ...)
## S3 method for class 'altf4' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting expected coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
2 - for plotting weights of all models used in averaging,
3 - for plotting expected window size.
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for altf4
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting altf4
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf4(y=wti,x=drivers,windows=c(36,100,150)) plot(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf4(y=wti,x=drivers,windows=c(36,100,150)) plot(a)
fDMA
Function.The function plots selected outcomes from fDMA
.
## S3 method for class 'dma' plot(x,non.interactive=NULL, ...)
## S3 method for class 'dma' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
If x
comes from estimation of Dynamic Model Averaging (DMA), after executing the command, the User is asked to choose
1 - for plotting actual and predicted values,
2 - for plotting residuals,
3 - for plotting the expected number of variables (including constant),
4 - for plotting posterior inclusion probabilities (including constant) on one plot,
5 - for plotting posterior inclusion probabilities (including constant) in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
6 - for plotting expected coefficients (including constant) on one plot,
7 - for plotting expected coefficients (including constant) in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
8 - for plotting the expected value of lambda
,
9 - for plotting posterior model probabilities, if Dynamic Occam's Window method has not been selected, or plotting the number of models used in Dynamic Model Averaging, if Dynamic Occam's Window method has been selected.
Chosing 0 exits the plot
command.
—————————————
If x comes from estimation of Dynamic Model Selection (DMS) or Median Probability Model (MED), after executing plot
the User is asked to choose
1 - for plotting actual and predicted values,
2 - for plotting residuals,
3 - for plotting the expected number of variables (including constant),
4 - for producing a plot showing which variables (including constant) are included in the DMS or MED model in each time,
5 - for plotting expected coefficients (including constant) on one plot,
6 - for plotting expected coefficients (including constant) in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
7 - for plotting the expected value of lambda
(only for DMS).
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for dma
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting dma
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dms") # graphics.off() plot(m1) # graphics.off() plot(m2)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dms") # graphics.off() plot(m1) # graphics.off() plot(m2)
grid.DMA
Function.The function plots selected outcomes from grid.DMA
.
## S3 method for class 'grid.dma' plot(x,non.interactive=NULL, ...)
## S3 method for class 'grid.dma' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
If x
comes from estimation of Dynamic Model Averaging (DMA), after executing the command, the User is asked to choose
1 - for plotting Root Mean Squared Error (RMSE) for all estimated models,
2 - for plotting Mean Absolute Error (MAE) for all estimated models,
3 - for plotting posterior inclusion probabilities (including constant) for all estimated models, the outcomes are saved in separate png files in the temporary directory, and additionally, plots for different variables are collected into one big plot (also saved as a png file in the temporary directory),
4 - for plotting expected coefficients (including constant) for all estimated models, the outcomes are saved in separate png files in the temporary directory, and additionally, plots for different variables are collected into one big plot (also saved as a png file in the temporary directory).
Chosing 0 exits the plot
command.
—————————————
If x
comes from estimation of Dynamic Model Selection (DMS) or Median Probability Model (MED), after executing the command, the User is asked to choose
1 - for plotting Root Mean Squared Error (RMSE) for all estimated models,
2 - for plotting Mean Absolute Error (MAE) for all estimated models,
3 - for plotting expected coefficients (including constant) for all estimated models, the outcomes are saved in separate png files in the temporary directory, and additionally, plots for different variables are collected into one big plot (also saved as a png file in the temporary directory).
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for grid.dma
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting grid.dma
object, sometimes a legend might cover the important parts of the plot.
If any of the models comes from using multiple lambda (see fDMA
), then RMSE and MAE are not plotted.
Also, if length(grid.alpha)
or length(grid.lambda)
is less than 2, then RMSE and MAE are not plotted.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1,model="dms") # graphics.off() plot(g1) # graphics.off() plot(g2)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1,model="dms") # graphics.off() plot(g1) # graphics.off() plot(g2)
grid.roll.reg
Function.The function plots selected outcomes from grid.roll.reg
.
## S3 method for class 'grid.roll.reg' plot(x,non.interactive=NULL, ...)
## S3 method for class 'grid.roll.reg' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting Root Mean Squared Error (RMSE) for all estimated models,
2 - for plotting Mean Absolute Error (MAE) for all estimated models,
3 - for plotting coefficients (including constant) for all estimated models, the outcomes are saved in separate png files in the temporary directory, and additionally, plots for different variables are collected into one big plot (also saved as a png file in the temporary directory),
4 - for plotting p-values for t-test of statistical significance for regression coefficients for all estimated models, the outcomes are saved in separate png files in the temporary directory, and additionally, plots for different variables are collected into one big plot (also saved as a png file in the temporary directory),
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for grid.roll.reg
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting grid.roll.reg
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) plot(g)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) plot(g)
grid.tvp
Function.The function plots selected outcomes from grid.tvp
.
## S3 method for class 'grid.tvp' plot(x,non.interactive=NULL, ...)
## S3 method for class 'grid.tvp' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting Root Mean Squared Error (RMSE) for all estimated models,
2 - for plotting Mean Absolute Error (MAE) for all estimated models,
3 - for plotting coefficients (including constant) for all estimated models, the outcomes are saved in separate png files in the temporary directory, and additionally, plots for different variables are collected into one big plot (also saved as a png file in the temporary directory).
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for grid.tvp
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting grid.tvp
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) plot(g)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) plot(g)
reg
Object.The function plots selected outcomes from reg
object.
## S3 method for class 'reg' plot(x,non.interactive=NULL, ...)
## S3 method for class 'reg' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting actual and predicted values,
2 - for plotting residuals,
3 - for plotting regression coefficients on one plot,
4 - for plotting regression coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory),
5 - for plotting p-values for t-test of statistical significance for regression coefficients on one plot,
6 - for plotting p-values for t-test of statistical significance for regression coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory).
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for reg
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting reg
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll <- roll.reg(y=ld.wti,x=ld.drivers,window=100) rec <- rec.reg(y=ld.wti,x=ld.drivers) # graphics.off() plot(roll) # graphics.off() plot(rec)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll <- roll.reg(y=ld.wti,x=ld.drivers,window=100) rec <- rec.reg(y=ld.wti,x=ld.drivers) # graphics.off() plot(roll) # graphics.off() plot(rec)
tvp
Object.The function plots selected outcomes from tvp
object.
## S3 method for class 'tvp' plot(x,non.interactive=NULL, ...)
## S3 method for class 'tvp' plot(x,non.interactive=NULL, ...)
x |
an object of |
non.interactive |
optional, |
... |
not used |
After executing the command, the User is asked to choose
1 - for plotting actual and predicted values,
2 - for plotting residuals,
3 - for plotting regression coefficients on one plot,
4 - for plotting regression coefficients in separate png files, saved in the temporary directory, and moreover, to paste them into one big plot (also saved as a png file in the temporary directory).
Chosing 0 exits the plot
command.
If non.interactive=TRUE
all the above plots are made.
Called for making a plot.
It is suggested to execute graphics.off
before exectuing plot
command for tvp
object. However, the User should take care to save all other plots before executing this command, as they can be lost.
If graphics.off
is not executed before plotting tvp
object, sometimes a legend might cover the important parts of the plot.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] tvp <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) # graphics.off() plot(tvp)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] tvp <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) # graphics.off() plot(tvp)
dma
Model.The function computes predictions based on the model obtained from fDMA
.
## S3 method for class 'dma' predict(object, newdata, type, ...)
## S3 method for class 'dma' predict(object, newdata, type, ...)
object |
an object of |
newdata |
a |
type |
|
... |
not used |
vector
of forecasted values
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") p1 <- predict(object=m1,newdata=ld.drivers,type="backward") p2 <- predict(object=m1,newdata=ld.drivers[1,],type="forward") p3 <- predict(object=m1,newdata=ld.drivers[1:3,],type="forward")
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") p1 <- predict(object=m1,newdata=ld.drivers,type="backward") p2 <- predict(object=m1,newdata=ld.drivers[1,],type="forward") p3 <- predict(object=m1,newdata=ld.drivers[1:3,],type="forward")
altf
Object.The function prints selected outcomes obtained from altf
.
## S3 method for class 'altf' print(x, ...)
## S3 method for class 'altf' print(x, ...)
x |
an object of |
... |
not used |
The function prints forecast quality measures from x
. For details see accuracy
.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf(y=wti,x=drivers) print(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf(y=wti,x=drivers) print(a)
altf2
Object.The function prints selected outcomes obtained from altf2
.
## S3 method for class 'altf2' print(x, ...)
## S3 method for class 'altf2' print(x, ...)
x |
an object of |
... |
not used |
The function prints forecast quality measures from x
. For details see accuracy
.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf2(y=wti,x=drivers) print(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf2(y=wti,x=drivers) print(a)
altf3
Object.The function prints selected outcomes obtained from altf3
.
## S3 method for class 'altf3' print(x, ...)
## S3 method for class 'altf3' print(x, ...)
x |
an object of |
... |
not used |
The function prints forecast quality measures from x
. For details see accuracy
.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf3(y=wti,x=drivers,windows=c(36,100,150)) print(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf3(y=wti,x=drivers,windows=c(36,100,150)) print(a)
altf4
Object.The function prints selected outcomes obtained from altf4
.
## S3 method for class 'altf4' print(x, ...)
## S3 method for class 'altf4' print(x, ...)
x |
an object of |
... |
not used |
The function prints forecast quality measures from x
. For details see accuracy
.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf4(y=wti,x=drivers,windows=c(36,100,150)) print(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf4(y=wti,x=drivers,windows=c(36,100,150)) print(a)
dma
Object.The function prints selected outcomes obtained from fDMA
.
## S3 method for class 'dma' print(x, ...)
## S3 method for class 'dma' print(x, ...)
x |
an object of |
... |
not used |
The function prints parameters of an argument x
, Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) from the estimated model. It also shows the number of observations, the number of models in averaging (selecting) procedure and the number of variables (including constant) used in the model. The number of models does not include the increase, if multiple lambda
is used. The function also shows forecast quality measures for alternative forecasting methods, i.e., naive forecast (see also altf
) and, if computed, for Auto ARIMA auto.arima
.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dms") print(m1) print(m2)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dms") print(m1) print(m2)
grid.dma
Object.The function prints selected outcomes obtained from grid.DMA
.
## S3 method for class 'grid.dma' print(x, ...)
## S3 method for class 'grid.dma' print(x, ...)
x |
an object of |
... |
not used |
The function prints Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) for all estimated models.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1,model="dms") print(g1) print(g2)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1,model="dms") print(g1) print(g2)
grid.roll.reg
Object.The function prints selected outcomes obtained from grid.roll.reg
.
## S3 method for class 'grid.roll.reg' print(x, ...)
## S3 method for class 'grid.roll.reg' print(x, ...)
x |
an object of |
... |
not used |
The function prints Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) for all estimated models.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) print(g)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) print(g)
grid.tvp
Object.The function prints selected outcomes obtained from grid.tvp
.
## S3 method for class 'grid.tvp' print(x, ...)
## S3 method for class 'grid.tvp' print(x, ...)
x |
an object of |
... |
not used |
The function prints Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) for all estimated models.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) print(g)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) print(g)
reg
Object.The function prints selected outcomes obtained from roll.reg
and rec.reg
.
## S3 method for class 'reg' print(x, ...)
## S3 method for class 'reg' print(x, ...)
x |
an object of |
... |
not used |
The function prints mean regression coefficients from the analyzed period, Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) from the estimated model. For roll.reg
it also shows the size of a rolling window.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll <- roll.reg(y=ld.wti,x=ld.drivers,window=100) rec <- rec.reg(y=ld.wti,x=ld.drivers) print(roll) print(rec)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll <- roll.reg(y=ld.wti,x=ld.drivers,window=100) rec <- rec.reg(y=ld.wti,x=ld.drivers) print(roll) print(rec)
tvp
Object.The function prints selected outcomes obtained from tvp
.
## S3 method for class 'tvp' print(x, ...)
## S3 method for class 'tvp' print(x, ...)
x |
an object of |
... |
not used |
The function prints mean regression coefficients from the analyzed period, Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) from the estimated model.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] tvp <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) print(tvp)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] tvp <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) print(tvp)
This function computes Recursive Regression.
rec.reg(y,x=NULL,c=NULL)
rec.reg(y,x=NULL,c=NULL)
y |
|
x |
|
c |
optional, |
It might happen during computations that lm
(which is used inside rec.reg
) will produce NA
or NaN
. In such a case regression coefficients for a given period are taken as and p-values for t-test for statistical significance of regression coefficients are taken as
.
It is not possible to set c=FALSE
if x=NULL
. In such a case the function will automatically reset c=TRUE
inside the code.
class reg
object, list
of
$y.hat |
fitted (forecasted) values |
$AIC |
Akaike Information Criterion (from the current set of observations) |
$AICc |
Akaike Information Criterion with a correction for finite sample sizes (from the current set of observations) |
$BIC |
Bayesian Information Criterion (from the current set of observations) |
$MSE |
Mean Squared Error (from the current set of observations) |
$coeff. |
regression coefficients |
$p.val |
p-values for t-test for statistical significance of regression coefficients |
$y |
|
print.reg
, summary.reg
, plot.reg
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] rec1 <- rec.reg(y=ld.wti,x=ld.drivers) rec2 <- rec.reg(y=ld.wti)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] rec1 <- rec.reg(y=ld.wti,x=ld.drivers) rec2 <- rec.reg(y=ld.wti)
fDMA
or grid.DMA
Outcomes.This functions reduces the size of dma
or grid.dma
object.
reduce.size(dma.object)
reduce.size(dma.object)
dma.object |
|
The information corresponding to each sub-model is erased. In particular, for the object produced by fDMA
$models
is reduced to one-row matrix to keep only colnames
, and $postmod
, $yhat.all.mods
and $p.dens.
are replaced by NA
. It can be useful if large number of models is considered.
dma
or grid.dma
object,
with the information corresponding to each sub-model erased
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m2 <- reduce.size(m1)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) m2 <- reduce.size(m1)
dma
Model.The function extracts residuals from the fDMA
model.
## S3 method for class 'dma' residuals(object, ...)
## S3 method for class 'dma' residuals(object, ...)
object |
an object of |
... |
not used |
vector
of residuals
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") r <- residuals(object=m1)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") r <- residuals(object=m1)
This function computes Rolling Regression. For the first window
-1 observations Recursive Regression is computed. Since window
-th observation the rolling is performed.
roll.reg(y,x=NULL,window,c=NULL)
roll.reg(y,x=NULL,window,c=NULL)
y |
|
x |
|
window |
|
c |
optional, |
It might happen during computations that lm
(which is used inside roll.reg
) will produce NA
or NaN
. In such a case regression coefficients for a given period are taken as and p-values for t-test for statistical significance of regression coefficients are taken as
.
It is not possible to set c=FALSE
if x=NULL
. In such a case the function will automatically reset c=TRUE
inside the code.
class reg
object, list
of
$y.hat |
fitted (forecasted) values |
$AIC |
Akaike Information Criterion (from the current window size) |
$AICc |
Akaike Information Criterion with a correction for finite sample sizes (from the current window size) |
$BIC |
Bayesian Information Criterion (from the current window size) |
$MSE |
Mean Squared Error (from the current window size) |
$coeff. |
regression coefficients |
$p.val |
p-values for t-test for statistical significance of regression coefficients |
$window |
window size |
$y |
|
grid.roll.reg
, print.reg
, summary.reg
, plot.reg
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll1 <- roll.reg(y=ld.wti,x=ld.drivers,window=100) roll2 <- roll.reg(y=ld.wti,window=100)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll1 <- roll.reg(y=ld.wti,x=ld.drivers,window=100) roll2 <- roll.reg(y=ld.wti,window=100)
fDMA
Model.This functions extracts posterior inclusion probabilities for independent variables from dma
object.
rvi(dma.object)
rvi(dma.object)
dma.object |
|
matrix
of posterior inclusion probabilities for independent variables
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) r <- rvi(m1)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10) r <- rvi(m1)
Sometimes it is desirable to have all variables to have mean 0 and standard deviation 1. This function rescales the values in such a way.
If the argument is not a matrix
, the function tries to convert the object into a matrix
. For example, it works smoothly for xts
objects.
standardize(data)
standardize(data)
data |
|
standardize(crudeoil)
standardize(crudeoil)
This is a wrapper for three functions from tseries
package. Augmented Dickey-Fuller (ADF, adf.test
), Phillips-Perron (PP, pp.test
) and Kwiatkowski-Phillips-Schmidt-Shin (KPSS, kpss.test
) tests for stationarity are performed.
stest(data)
stest(data)
data |
|
matrix
,
tests statistics and p-values are given by columns,
tests outcomes for different variables are ordered by rows
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] x <- cbind(ld.wti,ld.drivers) stest(x)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] x <- cbind(ld.wti,ld.drivers) stest(x)
altf
Object.The function summarizes selected outcomes obtained from altf
.
## S3 method for class 'altf' summary(object, ...)
## S3 method for class 'altf' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.altf
.
Additionally, it provides mean values of coefficients and how often p-values for t-test of statistical significance for each independent variable in the model are below 1%, 5% and 10%, respectively.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf(y=wti,x=drivers) summary(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf(y=wti,x=drivers) summary(a)
altf2
Object.The function summarizes selected outcomes obtained from altf2
.
## S3 method for class 'altf2' summary(object, ...)
## S3 method for class 'altf2' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.altf2
.
Additionally, it provides mean values of coefficients, min, max and mean relative variable importance for each independent variable in the model, frequency when relative variable importance is over 0.5 for each independent variable in the model, and how often p-values (averaged over selected models) for t-test of statistical significance for each independent variable in the model are below 1%, 5% and 10%, respectively.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf2(y=wti,x=drivers) summary(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf2(y=wti,x=drivers) summary(a)
altf3
Object.The function summarizes selected outcomes obtained from altf3
.
## S3 method for class 'altf3' summary(object, ...)
## S3 method for class 'altf3' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.altf3
.
Additionally, it provides mean values of coefficients and how often p-values (averaged over selected window sizes) for t-test of statistical significance for each independent variable in the model are below 1%, 5% and 10%, respectively.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf3(y=wti,x=drivers,windows=c(36,100,150)) summary(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf3(y=wti,x=drivers,windows=c(36,100,150)) summary(a)
altf4
Object.The function summarizes selected outcomes obtained from altf4
.
## S3 method for class 'altf4' summary(object, ...)
## S3 method for class 'altf4' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.altf4
.
Additionally, it provides mean values of coefficients.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf4(y=wti,x=drivers,windows=c(36,100,150)) summary(a)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] a <- altf4(y=wti,x=drivers,windows=c(36,100,150)) summary(a)
dma
Object.The function summarizes outcomes obtained from fDMA
.
## S3 method for class 'dma' summary(object, ...)
## S3 method for class 'dma' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.dma
.
Additionally:
If object
comes from Dynamic Model Averaging (DMA), it shows how often (in comparision to the whole analyzed period) a posterior inclusion probability for a given variable exceeds 1/2. It also shows minimum, maximum and mean posterior inclusion probability for every variable throughout the analyzed period.
If object
comes from Dynamic Model Selection (DMS) or Median Probability Model (MED), it shows how often (in comparision to the whole analyzed period) a given variable is present in the selected model.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dms") summary(m1) summary(m2)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dma") m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=1,model="dms") summary(m1) summary(m2)
grid.dma
Objects.The function summarizes outcomes obtained from grid.DMA
.
## S3 method for class 'grid.dma' summary(object, ...)
## S3 method for class 'grid.dma' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.grid.dma
.
Additionally, it finds the indices for a model minimizing Root Mean Squared Error (RMSE) and for a model minimizing Mean Absolute Error (MAE).
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1,model="dms") summary(g1) summary(g2)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] gra <- c(0.99,0.98,0.97) grl <- c(0.99,0.95) g1 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1) g2 <- grid.DMA(y=ld.wti,x=ld.drivers,grid.alpha=gra,grid.lambda=grl,initvar=1,model="dms") summary(g1) summary(g2)
grid.roll.reg
Objects.The function summarizes outcomes obtained from grid.roll.reg
.
## S3 method for class 'grid.roll.reg' summary(object, ...)
## S3 method for class 'grid.roll.reg' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.grid.roll.reg
.
Additionally, it finds the model minimizing Root Mean Squared Error (RMSE) and minimizing Mean Absolute Error (MAE).
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) summary(g)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grw <- c(50,100,150) g <- grid.roll.reg(y=ld.wti,x=ld.drivers,grid.window=grw) summary(g)
grid.tvp
Objects.The function summarizes outcomes obtained from grid.tvp
.
## S3 method for class 'grid.tvp' summary(object, ...)
## S3 method for class 'grid.tvp' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.grid.tvp
.
Additionally, it finds the model minimizing Root Mean Squared Error (RMSE) and minimizing Mean Absolute Error (MAE).
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) summary(g)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] grl <- c(0.99,0.98,0.97,0.96,0.95) g <- grid.tvp(y=ld.wti,x=ld.drivers,V=1,grid.lambda=grl) summary(g)
reg
Object.The function summarizes selected outcomes obtained from roll.reg
and rec.reg
.
## S3 method for class 'reg' summary(object, ...)
## S3 method for class 'reg' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as print.reg
.
Additionally, it provides how often p-values for t-test of statistical significance for each independent variable in the model is below 1%, 5% and 10%, respectively.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll <- roll.reg(y=ld.wti,x=ld.drivers,window=100) rec <- rec.reg(y=ld.wti,x=ld.drivers) summary(roll) summary(rec)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] roll <- roll.reg(y=ld.wti,x=ld.drivers,window=100) rec <- rec.reg(y=ld.wti,x=ld.drivers) summary(roll) summary(rec)
tvp
Object.The function summarizes selected outcomes obtained from tvp
.
## S3 method for class 'tvp' summary(object, ...)
## S3 method for class 'tvp' summary(object, ...)
object |
an object of |
... |
not used |
The function produces the outcomes as tvp
.
Called for printing.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] tvp <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) summary(tvp)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] tvp <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) summary(tvp)
Google Trends for Crude Oil Data.
data(trends)
data(trends)
trends
is xts
object such that
trends$stock_markets
– Google Trends for "stock markets"
trends$interest_rate
– Google Trends for "interest rate"
trends$economic_activity
– Google Trends for "economic activity"
trends$exchange_rate
– Google Trends for "exchange rate"
trends$oil_production
– Google Trends for "oil production"
trends$oil_consumption
– Google Trends for "oil consumption"
trends$market_stress
– Google Trends for "market stress"
The data are in monthly frequency. They cover the period between Jan, 2004 and Dec, 2016.
The data are provided by Google.
https://trends.google.com/trends
data(trends) gtrends <- trends/100 data(crudeoil) wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] ld.wti <- ld.wti['2004-01-01-/'] ld.drivers <- ld.drivers['2004-01-01-/'] xx <- ld.drivers m <- fDMA(y=ld.wti,x=xx,alpha=0.99,lambda=0.99,initvar=1,model="dma",gprob=gtrends,omega=0.5)
data(trends) gtrends <- trends/100 data(crudeoil) wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] ld.wti <- ld.wti['2004-01-01-/'] ld.drivers <- ld.drivers['2004-01-01-/'] xx <- ld.drivers m <- fDMA(y=ld.wti,x=xx,alpha=0.99,lambda=0.99,initvar=1,model="dma",gprob=gtrends,omega=0.5)
This function computes Time-Varying Parameters Regression (TVP) with the updating procedure as in Raftery et. al (2010).
tvp(y,x,V,lambda,W=NULL,kappa=NULL,c=NULL)
tvp(y,x,V,lambda,W=NULL,kappa=NULL,c=NULL)
y |
|
x |
|
V |
|
lambda |
|
W |
optional, |
kappa |
optional, |
c |
optional, |
It is not possible to set c=FALSE
if ncol(x)=0
. In such a case the function will automatically reset c=TRUE
inside the code.
class tvp
object, list
of
$y.hat |
fitted (forecasted) values |
$thetas |
estimated regression coefficients |
$pred.dens. |
predicitive densities from each period |
$y |
|
Raftery, A. E., Karny, M., Ettler, P., 2010. Online prediction under model uncertainty via Dynamic Model Averaging: Application to a cold rolling mill. Technometrics 52, 52–66.
Sanderson, C., Curtin, R., 2016. Armadillo: A template-based C++ library for linear algebra. Journal of Open Source Software 1, https://arma.sourceforge.net/armadillo_joss_2016.pdf.
grid.tvp
, print.tvp
, summary.tvp
, plot.tvp
.
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] t1 <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) t2 <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99,W=1) t3 <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99,W=1,kappa=0.75) # Model with constant only empty <- matrix(,nrow=nrow(ld.drivers),ncol=0) t4 <- tvp(y=ld.wti,x=empty,lambda=0.99,V=1)
wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- (diff(log(drivers)))[-1,] t1 <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99) t2 <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99,W=1) t3 <- tvp(y=ld.wti,x=ld.drivers,V=1,lambda=0.99,W=1,kappa=0.75) # Model with constant only empty <- matrix(,nrow=nrow(ld.drivers),ncol=0) t4 <- tvp(y=ld.wti,x=empty,lambda=0.99,V=1)