Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/make.margeffect.R

This function is called by `sim.survdata`

and is not intended to be used by itself.

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

`baseline` |
The baseline hazard functions, output by |

`xb` |
The simulated data, output by |

`covariate` |
Specification of the column number of the covariate in the |

`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 |

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.

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 |

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

`baseline.build`

, `generate.lm`

, `sim.survdata`

1 2 3 4 5 6 7 8 | ```
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
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.