Learn R Programming

RMark (version 3.0.0)

deltamethod.special: Compute delta method variance for sum, cumsum, prod and cumprod functions

Description

This function computes the delta method std errors or v-c matrix for a sum, cumsum (vector of cummulative sums), prod (product), or cumprod(vector of cummulative products) of a set of estimates.

Usage

deltamethod.special(function.name, mean, cov, ses = TRUE)

Value

either a vector of standard errors (ses=TRUE) or a variance-covariance matrix (ses=FALSE)

Arguments

function.name

Quoted character string of either "sum", "cumsum", "prod" or "cumprod"

mean

vector of estimates used in the function

cov

variance-covariance matrix of the estimates

ses

if TRUE it returns a vector of estimated standard errors of the function of the estimates and if FALSE it returns the variance-covariance matrix

Author

Jeff Laake

Details

This function computes the delta method std errors or v-c matrix for a sum, cumsum (vector of cummulative sums), prod (product), or cumprod(vector of cummulative products). It uses the function deltamethod from the msm package and constructs the necessary formula for these special cases. It will load the msm pacakge but assumes that it has already been installed. See the msm documentation for a complete description on how the deltamethod function works. If ses=TRUE, it returns a vector of std errors for each of functions of the estimates contained in mean. If ses=F, then it returns a v-c matrix for the functions of the estimates contained in mean. cov is the input v-c matrix of the estimates.

Examples

Run this code
# \donttest{
# This example is excluded from testing to reduce package check time
#
# The following are examples only to demonstrate selecting different 
# model sets for adjusting chat and showing model selection table. 
# It is not a realistic analysis.
#
  data(dipper)
  mod=mark(dipper,model.parameters=list(Phi=list(formula=~time)),delete=TRUE)
  rr=get.real(mod,"Phi",se=TRUE,vcv=TRUE)
  deltamethod.special("prod",rr$estimates$estimate[1:6],rr$vcv.real)
  deltamethod.special("cumprod",rr$estimates$estimate[1:6],rr$vcv.real,ses=FALSE)
  deltamethod.special("sum",rr$estimates$estimate[1:6],rr$vcv.real)
  deltamethod.special("cumsum",rr$estimates$estimate[1:6],rr$vcv.real,ses=FALSE)
# }

Run the code above in your browser using DataLab