Learn R Programming

rstpm2 (version 1.6.6.1)

numDeltaMethod: Calculate numerical delta method for non-linear predictions.

Description

Given a regression object and an independent prediction function (as a function of the coefficients), calculate the point estimate and standard errors

Usage

numDeltaMethod(object, fun, gd=NULL, conf.int=FALSE, level=0.95, ...)

Value

fit

Point estimates

se.fit

Standard errors

Estimate

Point estimates

SE

Standard errors

conf.low

Lower confidence interval (if conf.int=TRUE)

conf.high

Upper confidence interval (if conf.int=TRUE)

Arguments

object

A regression object with methods coef and vcov.

fun

An independent prediction function with signature function(coef, ...).

gd

Specified gradients

conf.int

Logical for whether to also calculate the confidence interval

level

Numeric for the level of the confidence interval

...

Other arguments passed to fun.

Details

A more user-friendly interface is provided by predictnl.

See Also

See Also predictnl.

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (object, fun, ...) 
{
    coef <- coef(object)
    est <- fun(coef, ...)
    Sigma <- vcov(object)
    gd <- grad(fun, coef, ...)
    se.est <- as.vector(sqrt(colSums(gd * (Sigma %*% gd))))
    data.frame(Estimate = est, SE = se.est)
  }

Run the code above in your browser using DataLab