Learn R Programming

causaldrf (version 0.4.2)

scalar_wts: This function calculates scalar weights for use in other models

Description

This function calculates the scalar weights

Usage

scalar_wts(treat,
           treat_formula,
           numerator_formula,
           data,
           treat_mod,
           link_function,
           ...)

Value

scalar_wts returns an object of class "causaldrf_wts", a list that contains the following components:

param

summary of estimated weights.

t_mod

the result of the treatment model fit.

num_mod

the result of the numerator model fit.

weights

estimated weights for each unit.

call

the matched call.

Arguments

treat

is the name of the treatment variable contained in data.

treat_formula

an object of class "formula" (or one that can be coerced to that class) that regresses treat on a linear combination of X: a symbolic description of the model to be fitted.

numerator_formula

an object of class "formula" (or one that can be coerced to that class) that regresses treat on a linear combination of X: a symbolic description of the model to be fitted. i.e. treat ~ 1.

data

is a dataframe containing treat, and X.

treat_mod

a description of the error distribution to be used in the model for treatment. Options include: "Normal" for normal model, "LogNormal" for lognormal model, "Poisson" for Poisson model, "Sqrt" for square-root transformation to a normal treatment, "NegBinom" for negative binomial model, "Gamma" for gamma model.

link_function

is either "log", "inverse", or "identity" for the "Gamma" treat_mod.

...

additional arguments to be passed to the treatment regression fitting function.

References

Schafer, J.L., Galagate, D.L. (2015). Causal inference with a continuous treatment and outcome: alternative estimators for parametric dose-response models. Manuscript in preparation.

See Also

iptw_est, ismw_est, reg_est, aipwee_est, wtrg_est, etc. for other estimates.

t_mod, overlap_fun to prepare the data for use in the different estimates.

Examples

Run this code
## Example from Schafer (2015).

example_data <- sim_data

scalar_wts_list <- scalar_wts(treat = T,
                     treat_formula = T ~ B.1 + B.2 + B.3 + B.4 + B.5 + B.6 + B.7 + B.8,
                     numerator_formula = T ~ 1,
                     data = example_data,
                     treat_mod = "Normal")

sample_index <- sample(1:1000, 100)

plot(example_data$T[sample_index],
     scalar_wts_list$weights[sample_index],
     xlab = "T",
     ylab = "weights",
     main = "scalar_wts")


rm(example_data, scalar_wts_list, sample_index)

Run the code above in your browser using DataLab