cstarme: Compute cstar for simulated marginal effects

Description Usage Arguments Details Value References Examples

View source: R/me_cstar_loss.r

Description

cstarme computes the minimum actionable effect size of a simulated marginal effect under a kinked linear loss function with user-specified degree of loss.

Usage

1
cstarme(sims, r)

Arguments

sims

A vector of simulated marginal effects. See Details.

r

The degree of loss aversion; must be a non-negative number. This parameter maps to gamma in Esarey and Danneman (2014).

Details

sims can be any vector of simulated marginal effects. For example, the change in predicted probability of an outcome as we change the level of a predictor in a logistic regression model.

Value

A vector of expected values for the utility of acting on the evidence encapsulated by the simulated marginal effects, given the researcher's stated level of loss aversion.

References

Esarey and Danneman (2014). A Quantitative Method for Substantive Robustness Assessment. Political Science Research and Methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# create some logit data
x <- rnorm(50)
xb <- .5 + 2*x
pry <- exp(xb) / (1 + exp(xb))
y <- rbinom(50, 1, pry)

plot(x, y)

# run logistic regression
mod <- glm(y~x, family=binomial(link="logit"))

# extract variance-covariance matrix
VCV <- vcov(mod)

# simulate intercept and B1 from multivariate normal
require(MASS)
simulated_betas <- mvrnorm(n=50, mu=coefficients(mod), Sigma=VCV)

# calculate pr(y=1) for each simulated pair of (intercept, B1);
# do so at x=0 and x=2
pry_x0 <- apply(simulated_betas, 1, function(x){
  exp(x[1] + 0*x[2]) / (1 + exp(x[1] + 0*x[2]))
  })
pry_x2 <- apply(simulated_betas, 1, function(x){
  exp(x[1] + 2*x[2]) / (1 + exp(x[1] + 2*x[2]))
})

# compute the simulated change in predicted probability
simulated_marginal_effects <- pry_x2 - pry_x0

# estimate the expected utility of accepting evidence
cstarme(simulated_marginal_effects, 2)

cstar documentation built on May 1, 2019, 8:44 p.m.