extractLT: Obtain complete set of LT or LD estimates

View source: R/extractLT.R

extractLTR Documentation

Obtain complete set of LT or LD estimates

Description

When supplied with a model object that has fitted dose-response lines for each of several levels of a factor, extractLT calls the function fieller to calculate lethal time

Usage

extractLT(
  obj,
  a = 1:3,
  b = 4:6,
  link = NULL,
  logscale = FALSE,
  p = 0.99,
  eps = 0,
  offset = 0,
  df.t = NULL
)

extractLTpwr(
  obj,
  a = 1:3,
  b = 1:3,
  link = "fpower",
  logscale = FALSE,
  p = 0.99,
  lambda = 0,
  eps = 0.015,
  offset = 0,
  df.t = NULL
)

Arguments

obj

merMod object, created using lmer() or glmerMod object, created using glmer().

a

Subscripts for intercepts.

b

Subscripts for corresponding slopes.

link

Link function, for use with objects where no link was specified in the function call, but it is required to back-transform a transformation that was performed prior to the function call. Otherwise leave as link=NULL, and the link function will be extracted as family(obj)[['link']]. For a folded power function, with extractLTpwr(), the only available link is fpower, and the exponent lambda must be specified.

logscale

Logical. Specify TRUE, if LT values are to be back-transformed from a logarithmic scale.

p

Target response proportion.

eps

Replace prob by prob+eps before transformation.

offset

Use to undo scaling of time or dose variable. This is passed to the fieller function that extractLT calls.

df.t

Degrees of freedom for a t-distribution approximation for 't' or 'z' statistics. If NULL, a conservative (low) value will be used. For linear (but not generalized linear) models and mixed models, approximations are implemented in the afex package. See vignette('introduction-mixed-models', package="afex"), page 19.

lambda

(extractLTpwr only) Power for power function.

Details

Fixed coefficients from obj must be for intercepts and for slopes. Starting the model formula with 0+ will commonly do what is required. The coefficients fixef(obj)[a] are assumed to specify line intercepts, while fixef(obj)[b] specify the corresponding slopes. These replace the arguments nEsts (subscripts for intercepts were 1:nEsts) and slopeAdd (subscripts for slopes were (nEsts+1):(nEsts+slopeAdd)).

Value

Matrix holding LD or LD estimates.

Examples

pcheck <- suppressWarnings(requireNamespace("glmmTMB", quietly = TRUE))
if(pcheck) pcheck & packageVersion("glmmTMB") >= "1.1.2"
if(pcheck){
form <- cbind(Dead,Live)~0+trtGp/TrtTime+(1|trtGpRep)
HawMed <- droplevels(subset(HawCon, CN=="MedFly"&LifestageTrt!="Egg"))
HawMed <- within(HawMed,
                 {trtGp <- factor(paste0(CN,LifestageTrt, sep=":"))
                 trtGpRep <- paste0(CN,LifestageTrt,":",RepNumber)
                 scTime <- scale(TrtTime) })
HawMedbb.cll <- glmmTMB::glmmTMB(form, dispformula=~trtGp+splines::ns(scTime,2),
                                 family=glmmTMB::betabinomial(link="cloglog"),
                                 data=HawMed)
round(qra::extractLT(p=0.99, obj=HawMedbb.cll, link="cloglog",
               a=1:3, b=4:6, eps=0, df.t=NULL)[,-2], 2)} else
message("Example requires `glmmTMB` version >= 1.1.2: not available")


jhmaindonald/qra-R-package documentation built on Nov. 16, 2023, 2:39 p.m.