Description Usage Arguments Details Value References See Also Examples
Estimates the Inuoe and Kilian (2008) bagging for a given pre-testing procedure.
1 2 3 |
x |
Matrix of independent variables. Each row is an observation and each column is a variable. |
y |
Response variable equivalent to the function. |
fn |
If pre-testing="personal" the user must define the pre-testing function through this argument. This function must return a vector of coefficients where the first coefficient is the intercept. The first argument must be a matrix where the first column is the y and the remaining columns are x. |
R |
Number of bootstrap replucations. |
l |
lenght of the blocks for the block-boostrap. |
sim |
tsboot argument. |
pre.testing |
The type of pre-testing (see details). |
fixed.controls |
numeric or character vector indicating variables that must be used as fixed controls in the pre-testing. These variables are always selected. |
... |
Other arguments passed to tsboot and to personal pre-testing |
This function returns the pre-testing coefficients for all bootstrap samples. This coefficients may then be used to calculate forecasts.
There are three types of pre-testing:
jointTests all variables in one shot. This is the pre-testing used by Inuoe and Kilian (2008). It is not indicated when the number of variables is too close to the number of observations and it is unfeasible if the number of variables is bigger than the number of observations.
group-jointThe pre-testing is performed on random groups of variables. It is feasible even when the number of variables is bigger than the number of observations. The number of groups may be chosen by the user (default=10).
individualTests each variable individually. It is feasible when the number of observations is bigger than the number of variables but it consumes more time than group-joint.
An object with S3 class bagging.
coefficients |
Boostrap coefficients on each sample. |
orig.coef |
Coefficients on the original sample. |
fitted.values |
In-sample fitted values. |
residuals |
Model residuals. |
pre.testing |
The pre-testing used. |
call |
The matched call. |
Inoue, Atsushi, and Lutz Kilian. "How useful is bagging in forecasting economic time series? A case study of US consumer price inflation." Journal of the American Statistical Association 103.482 (2008): 511-522.
Garcia, Medeiros and Vasconcelos (2017).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## == This example uses the Brazilian inflation data from
#Garcia, Medeiros and Vasconcelos (2017) == ##
data("BRinf")
## == Data preparation == ##
## == The model is yt = a + Xt-1'b + ut == ##
## == The autorregressive is a fixed control == ##
aux = embed(BRinf,2)
y=aux[,1]
x=aux[,-c(1:ncol(BRinf))]
model=bagging(x,y,pre.testing = "group-joint")
model$orig.coef
## == check selection frequency == ##
coef=coef(model)
coef[coef!=0]=1
frequency=(colSums(coef))[-1] # remove intercept
barplot(frequency)
## == see fitted values == ##
plot(y,type="l")
lines(fitted(model),col=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.