model_impute | R Documentation |
Model an imputed dataset
model_impute(
object,
model_fun,
rhs,
model_args = list(),
extractor,
extractor_args = list(),
filter = list(),
mutate = list(),
...
)
## S4 method for signature 'ANY'
model_impute(
object,
model_fun,
rhs,
model_args = list(),
extractor,
extractor_args = list(),
filter = list(),
mutate = list(),
...
)
## S4 method for signature 'aggregatedImputed'
model_impute(
object,
model_fun,
rhs,
model_args = list(),
extractor,
extractor_args = list(),
filter = list(),
mutate = list(),
...
)
object |
The imputed dataset. |
model_fun |
The function to apply on each imputation set.
Or a string with the name of the function.
Include the package name when the function is not in one of the base R
packages.
For example: |
rhs |
The right hand side of the model. |
model_args |
An optional list of arguments to pass to the model function. |
extractor |
A function which return a |
extractor_args |
An optional list of arguments to pass to the |
filter |
An optional argument to filter the raw dataset before aggregation.
Will be passed to |
mutate |
An optional argument to alter the aggregated dataset.
Will be passed to the |
... |
currently ignored. |
dataset <- generate_data(n_year = 10, n_site = 50, n_run = 1)
dataset$Count[sample(nrow(dataset), 50)] <- NA
model <- lm(Count ~ Year + factor(Period) + factor(Site), data = dataset)
imputed <- impute(data = dataset, model = model)
aggr <- aggregate_impute(imputed, grouping = c("Year", "Period"), fun = sum)
extractor <- function(model) {
summary(model)$coefficients[, c("Estimate", "Std. Error")]
}
model_impute(
object = aggr,
model_fun = lm,
rhs = "0 + factor(Year)",
extractor = extractor
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.