Bayesian model averaging with sign restictions
rbma_g = bma_g_signed(namey0,signs,ndraw,arg1,...,argn)
* namey0 = dependent variable vector
* signs = a vector of size (k x 1), collecting the sign restictions:
. 1 if the coefficient of the corresponding variable should be positive
. - 1 if the coefficient of the corresponding variable should be negative
. 0 if the coefficient of the corresponding variable should not be restricted
* ndraw = # of draws to carry out
* arg1,...,argn = a string which can be
. a time series
. a real (n x k) vector
. a string equal to the name of a time series or a (n x p) real vector between quotes
. 'burnin=xx' : # of burn-in MCMC simulation
. 'g =XX' : value of g-prior (default = 1/max(n,k^2))
. 'mcmc = ''mc3'' or ''jump''' : type of MCMC algorithm (MC3 or reversible jump) must be in quote
. 'nvmax = xx' : max # of variables allowed in each models
. the string 'noprint' if the user doesn't want to print the results of the regression
. the string 'dropna' if the user wants to remove the NA values from the data
* rbma = a tlist result with :
- rbma_g('meth') = 'bma g-prior'
- rbma_g('nmod') = # of models visited during sampling
- rbma_g('beta') = bhat averaged over all models
- rbma_g('mprob') = posterior prob of each model
- rbma_g('vprob') = posterior prob of each variable
- rbma_g('model') = indicator variables for each model (nmod x k)
- rbma_g('yhat') = yhat averaged over all models
- rbma_g('resid') = residuals based on yhat averaged over models
- rbma_g('sige') = averaged over all models
- rbma_g('nobs') = nobs
- rbma_g('nvar') = # of exogenous
- rbma_g('y') = y data vector
- rbma_g('x') = y data vector
- rbma_g('visit') = visits to each model during sampling (nmod x 1)
- rbma_g('time') = time taken for MCMC sampling
- rbma_g('ndraw') = # of MCMC sampling draws rbma_g('burnin') = # of burn-in MCMC simulation
- rbma_g('gprior') = value of g-prior
- rbma_g('bounds') = if there is a timeseries in the regression, the bounds of the regression
- rbma_g('mcmc') = type of MCMC algorithm
- rbma_g('prests') = boolean indicating the presence or absence of a time series in the regression
- rbma_g('namey') = name of the y variable
- rbma_g('namex') = name of the x variables
- rbma_g('bounds') = if there is a time series in the regression, the bounds of the regression
- rbma_g('dropna') = boolean indicating if NAs have been dropped
- rbma_g('nonna') = vector indicating position of non-NAs
global GROCERDIR ; load(GROCERDIR+'\data\fra_bs_sept25.dat') // define the balances on expected ourput (global order for the retail sector) and past output bal=["surv_bat_exp_out_c" ; "surv_bat_past_out_c" ;... "surv_ind_exp_out_c" ; "surv_ind_past_out_c" ; "surv_ret_glob_ord_c" ;... "surv_ret_past_out_c" ; "surv_serv_exp_out_c" ; "surv_serv_past_out_c" ] // retrieve the values of these balances for each second month of a quarter (February, April, August and November) execstr(bal+'_m2 =m2q('+bal+',2)') // retrieve the values of the difference between the balances for each second month of a quarter and the previous month execstr('del_'+bal+'_m2 =m2q('+bal+',2)-m2q('+bal+',1)') // retrieve the values of the difference between the balances for each second month of a quarter and of the same month of the previois quarter execstr('del3_'+bal+'_m2 =delts('+bal+'_m2)') // perform bma of the regression of the growth rate of GDP on the calculated transformations of the original balances, imposing that all coefficients are positive // with 30000draws, discarding the first 10000 ones and the mc3 algorithm bma_g_signed('100*growthr(PIB_7CH)',[ones(24,1)],30000,[bal+'_m2';'del_'+bal+'_m2';'del3_'+bal+'_m2'],'burnin=10000','mcmc=''mc3''') | ![]() | ![]() |