Incorporate Weights/Offsets with Nonparametric Models I am modeling pure premium in R. I have read that pure premiums are usually modeled using a Tweedie distribution (glm). There is generally an offset or weight added to the model, such as an exposure. I am investigating three nonparametric models for pure premiums: glmnet, regression trees, and random forest. My question: how can I incorporate a weight/offset with a nonparametric model? The two package I normally use for modeling in R are caret and tidymodels.
 A: From my understanding, such an exposure term is intended to model rates rather than count data. For example, from the Poisson regression (one possible model in the Tweedie family) wikipedia page: Poisson regression may also be appropriate for rate data, where the rate is a count of events divided by some measure of that unit's exposure (a particular unit of observation).
$\log(\operatorname{E}(Y\mid x)) = \log(\text{exposure}) + \theta' x$
The added exposure term in this case is a way to model continuous rate data using a Poisson model which is based on discrete count data and accordingly would not be suited to directly model rate data. Note that you don't estimate a coefficient for the log exposure term and if you subtract that term from both sides you simply recover a regression onto $\log\left(\frac{\operatorname{E}(Y\mid x)}{\text{exposure}}\right)$.
For a regression tree or forest, if you have access to the count data and corresponding exposure data and are looking to model the rate (defined by the count $Y$ divided by exposure), you should be able to directly regress onto the rate values. So define a new target variable by $\frac{Y}{exposure}$ and don't include exposure as a covariate in the tree/forest. If you want to recover the raw count values, you can then predict the rate and multiply by the exposure.
