Grab estimating functions from a model object

grab_psiFUN(object, ...)

# S3 method for glm
grab_psiFUN(object, data, ...)

# S3 method for geeglm
grab_psiFUN(object, data, ...)

# S3 method for merMod
grab_psiFUN(object, data, numderiv_opts = NULL, ...)

Arguments

object

the object from which to extrace psiFUN

...

additonal arguments passed to other methods

data

the data to use for the estimating function

numderiv_opts

a list of arguments passed to numDeriv::grad

Value

a function corresponding to the estimating equations of a model

Methods (by class)

  • grab_psiFUN(glm): Create estimating equation function from a glm object

  • grab_psiFUN(geeglm): Create estimating equation function from a geeglm object

  • grab_psiFUN(merMod): Create estimating equation function from a merMod object

Examples


if (FALSE) {
library(geepack)
library(lme4)
data('ohio')

glmfit  <- glm(resp ~ age, data = ohio,
               family = binomial(link = "logit"))
geefit  <- geeglm(resp ~ age, data = ohio, id = id,
                  family = binomial(link = "logit"))
glmmfit <- glmer(resp ~ age + (1|id), data = ohio,
                 family = binomial(link = "logit"))
example_ee <- function(data, model){
 f <- grab_psiFUN(model, data)
 function(theta){
  f(theta)
 }
}

m_estimate(
  estFUN = example_ee,
  data = ohio,
  compute_roots = FALSE,
  units = 'id',
  roots = coef(glmfit),
  outer_args = list(model = glmfit))
m_estimate(
  estFUN = example_ee,
  data = ohio,
  compute_roots = FALSE,
  units = 'id',
  roots = coef(geefit),
  outer_args = list(model = geefit))
m_estimate(
  estFUN = example_ee,
  data = ohio,
  compute_roots = FALSE,
  units = 'id',
  roots = unlist(getME(glmmfit, c('beta', 'theta'))),
  outer_args = list(model = glmmfit))
 }