model_impute: Model an imputed dataset

Description Usage Arguments Examples

Description

Model an imputed dataset

Usage

1
2
3
4
5
6
7
8
9
model_impute(object, model.fun, rhs, model.args, extractor, extractor.args)

## S4 method for signature 'ANY'
model_impute(object, model.fun, rhs, model.args, extractor,
  extractor.args)

## S4 method for signature 'aggregatedImputed'
model_impute(object, model.fun, rhs, model.args,
  extractor, extractor.args)

Arguments

object

the imputed dataset

model.fun

the function to apply on each imputation set

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 matrix or data.frame. The first column should contain the estimate, the second the standard error of the estimate

extractor.args

an optional list of arguments to pass to the extractor function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
dataset <- generateData(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
)

ThierryO/multimput documentation built on May 9, 2019, 4:42 p.m.