Hi UseRs -

I am new to R, and could use some help making out-of-sample predictions
using a boosting model (the mboost command). The issue is complicated by the
fact that I have panel data (time by country), and am estimating the model
separately for each country. FYI, this is monthly data and I have 1986m1 -
2009m12 for 9 countries.

To give you a flavor of what I am doing, here is a simple example to show
how I make in-sample predictions:

# data has following columns: country year month y x1 x2 x3
dat = read.csv(data.csv)

# Create function that estimates model, produces in-sample predictions
bbox = function(df)
{
blackbox = mboost(y ~ x1 + x2 + x3)
predict(blackbox)
}

# Use lapply to estimate by country
bycountry = lapply(split(dat, dat$country), bbox)


So that in the end I have an object bycountry that contains the in-sample
predictions of the model, estimated for each country separately. What I
would like to do is take this model and estimate it for each country using
some initial data. I.e., estimate Australia with 1986m1-2003m12, make
prediction about 2004m1, roll data forward. Estimate AUS with 1986m2-2004m1,
predict 2004m2, etc for all data points. Now do the same for Canada,
Denmark, etc.

So I guess my problem is twofold. 1) How to make these out-of-sample
predictions, by country, when my data has not been declared as time-series?
(I do not think that mboost can handle time-series data...x1 x2 and x3 have
been lagged appropriately). 2) How to save the one-step ahead predictions
into a vector?

Any thoughts would be greatly appreciated. Many thanks!

-Travis

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to