grab_psiFUN: Grab estimating functions from a model object

View source: R/grab_psiFUN_funs.R

grab_psiFUNR Documentation

Grab estimating functions from a model object

Description

Grab estimating functions from a model object

Usage

grab_psiFUN(object, ...)

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

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

## S3 method for class '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


## Not run: 
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))
 
## End(Not run)

geex documentation built on Aug. 8, 2022, 5:05 p.m.