make.margeffect {coxed}R Documentation

Calculating a simulated marginal effect

Description

This function is called by sim.survdata and is not intended to be used by itself.

Usage

make.margeffect(baseline, xb, covariate = 1, low = 0, high = 1,
  compare = median)

Arguments

baseline

The baseline hazard functions, output by baseline.build

xb

The simulated data, output by generate.lm

covariate

Specification of the column number of the covariate in the X matrix for which to generate a simulated marginal effect (default is 1). The marginal effect is the difference in expected duration when the covariate is fixed at a high value and the expected duration when the covariate is fixed at a low value

low

The low value of the covariate for which to calculate a marginal effect

high

The high value of the covariate for which to calculate a marginal effect

compare

The statistic to employ when examining the two new vectors of expected durations (see details for sim.survdata). The default is median

Details

The idea is to simulate a marginal change in duration so that researchers can compare the performance of estimators of this statistic using simulated data.

The function calculates simulated durations for each observation conditional on a baseline hazard function and exogenous covariates and coefficients. The covariate argument specifies the variable in the X matrix to vary so as to measure the marginal effect. First the covariate is set to the value specified in low for all observations, then to the value specified in high for all observations. Given each value, new durations are drawn. The durations when the covariate equals the low value are subtracted from the durations when the covariate equals the high value. The marginal effect is calculated by employing the statistic given by compare, which is median by default.

Value

A list with three items:

marg.effect A scalar containing the simulated marginal effect
data.low The durations and covariates when the covariate of interest is set to the low value
data.high The durations and covariates when the covariate of interest is set to the high value

Author(s)

Jonathan Kropko <jkropko@virginia.edu> and Jeffrey J. Harden <jharden2@nd.edu>

See Also

baseline.build, generate.lm, sim.survdata

Examples

T <- 100
N <- 1000
X <- as.matrix(data.frame(X1=rnorm(N), X2=rnorm(N), X3=rnorm(N)))
beta <- as.matrix(rnorm(3))
baseline <- baseline.build(T=T, knots=8, spline=TRUE)
xb <- generate.lm(baseline, X=X, beta=beta, N=N, censor=.1, type="none")
me <- make.margeffect(baseline, xb, covariate=1, low=0, high=1)
me$marg.effect

[Package coxed version 0.3.3 Index]