Learn R Programming

emmeans (version 1.6.2-1)

qdrg: Quick and dirty reference grid

Description

This function may make it possible to compute a reference grid for a model object that is otherwise not supported.

Usage

qdrg(formula, data, coef, mcmc, vcov, object, df, subset, weights, contrasts,
  link, qr, ...)

Arguments

formula

Formula for the fixed effects

data

Dataset containing the variables in the model

coef

Fixed-effect regression coefficients (must conform to formula)

mcmc

Posterior sample of fixed-effect coefficients

vcov

Variance-covariance matrix of the fixed effects

object

Optional model object. If provided, it is used to set certain other arguments, if not specified. See Details.

df

Error degrees of freedom

subset

Subset of data used in fitting the model

weights

Weights used in fitting the model

contrasts

List of contrasts specified in fitting the model

link

Link function (character or list) used, if a generalized linear model. (Note: response transformations are auto-detected from formula)

qr

QR decomposition of the model matrix; needed only if there are NAs in coef.

...

Optional arguments passed to ref_grid

Value

An emmGrid object constructed from the arguments

Details

If object is specified, it is used to try to obtain certain other arguments, as detailed below. The user should ensure that these defaults will work. The default values for the arguments are as follows:

  • formula: Required unless obtainable via formula(object)

  • data: Required if variables are not in parent.frame() or obtainable via object$data

  • coef: coef(object)

  • mcmc: object$sample

  • vcov: vcov(object)

  • df: Set to Inf if not available in object$df.residual

  • subset: NULL (so that all observations in data are used)

  • contrasts: NULL (so that getOption("contrasts") is used)

The functions qdrg and emmobj are close cousins, in that they both produce emmGrid objects. When starting with summary statistics for an existing grid, emmobj is more useful, while qdrg is more useful when starting from a fitted model.

See Also

emmobj for an alternative way to construct an emmGrid.

Examples

Run this code
# NOT RUN {
if (require(biglm)) {
  # Post hoc analysis of a "biglm" object -- not supported by emmeans
  bigmod <- biglm(log(conc) ~ source + factor(percent), data = pigs)
   
  rg2 <- qdrg(object = bigmod, data = pigs)
  summary(emmeans(rg2, "source"), type = "response")
}
if(require(coda) && require(lme4)) {
  # Use a stored example having a posterior sample
  # Model is based on the data in lme4::cbpp
  
  post <- readRDS(system.file("extdata", "cbpplist", package = "emmeans"))$post.beta
  rg1 <- qdrg(~ size + period, data = lme4::cbpp, mcmc = post, link = "logit")
  summary(rg1, type = "response")
}

# }

Run the code above in your browser using DataLab