marginalPrediction {mmpf} | R Documentation |
marginalizes prediction functions
Description
monte-carlo integration of prediction functions
Usage
marginalPrediction(data, vars, n, model, uniform = TRUE, points,
int.points, aggregate.fun = function(x) sum(x)/length(x),
predict.fun = function(object, newdata) predict(object, newdata =
newdata), weight.fun = NULL)
Arguments
data |
a |
vars |
a character vector corresponding to a strict subset of the columns in |
n |
an integer vector of length two giving the resolution of the uniform or random grid on |
model |
an object which can be passed to |
uniform |
logical indicating whether to create the grid on |
points |
a named list which gives specific points for |
int.points |
a integer vector giving indices of the points in |
aggregate.fun |
what function to aggregate the predictions with. this function takes a single argument |
predict.fun |
what function to generate predictions using |
weight.fun |
a function to construct weights for |
Value
a data.table
with columns for predictions and vars
.
Examples
X = replicate(3, rnorm(100))
y = X %*% runif(3)
data = data.frame(X, y)
fit = lm(y ~ ., data)
marginalPrediction(data.frame(X), "X2", c(10, 25), fit,
aggregate.fun = function(x) c("mean" = mean(x), "variance" = var(x)))