Title: | Tidy Methods for Bayesian Treatment Effect Models |
---|---|
Description: | Functions for extracting tidy data from Bayesian treatment effect models, in particular BART, but extensions are possible. Functionality includes extracting tidy posterior summaries as in 'tidybayes' <https://github.com/mjskay/tidybayes>, estimating (average) treatment effects, common support calculations, and plotting useful summaries of these. |
Authors: | Joshua J Bon [aut, cre] |
Maintainer: | Joshua J Bon <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0.1 |
Built: | 2024-11-21 04:22:32 UTC |
Source: | https://github.com/bonstats/tidytreatment |
(C)ATE = (Conditional) Average Treatment Effects
newdata
specifies the conditions, if unspecified it defaults to the original data.
Assumes treated column is either a integer column of 1's (treated) and 0's (nontreated) or logical indicating treatment if TRUE.
avg_treatment_effects( model, treatment, newdata, subset = "all", common_support_method, cutoff, ... )
avg_treatment_effects( model, treatment, newdata, subset = "all", common_support_method, cutoff, ... )
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
A character string specifying the name of the treatment variable. |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
subset |
Either "treated", "nontreated", or "all". Default is "all". |
common_support_method |
Either "sd", or "chisq". Default is unspecified, and no common support calculation is done. |
cutoff |
Cutoff for common support (if in use). |
... |
Arguments to be passed to |
A tidy data frame (tibble) with treatment effect values.
Model fit with simulated data from simulated dataset suhillsim1
.
bartmodel1
bartmodel1
Object of type BART::wbart
Propensity score estimated and included suhillsim1
for fitting the model.
https://github.com/bonStats/tidytreatment/tree/master/data-raw
bartmodel1
Useful for testing tidytreatment package functions.
bartmodel1_modelmatrix
bartmodel1_modelmatrix
Object of type BART::wbart
https://github.com/bonStats/tidytreatment/tree/master/data-raw
Inclusion metric for bartMachine and BART are scaled differently. bartMachine averaged over number of trees, in addition to number of MCMC draws.
covariate_importance(model, ...)
covariate_importance(model, ...)
model |
Model |
... |
Arguments to pass to particular methods. |
Tidy data with counts of variable inclusion, when interacting with treatment variable.
Counts of variable inclusion when interacting with treatment
covariate_with_treatment_importance(model, treatment, ...)
covariate_with_treatment_importance(model, treatment, ...)
model |
Model |
treatment |
A character string specifying the name of the treatment variable. |
... |
Arguments to pass to particular methods. |
Tidy data with counts of variable inclusion, when interacting with treatment variable.
bartCause
-package objectsTypically referred to as fitted value draws on response scale, where appropriate.
## S3 method for class 'bartcFit' epred_draws( object, ..., value = ".epred", re_formula = NULL, fitstage = c("response", "assignment") )
## S3 method for class 'bartcFit' epred_draws( object, ..., value = ".epred", re_formula = NULL, fitstage = c("response", "assignment") )
object |
A |
... |
Additional arguments (e.g. |
value |
The name of the output column. |
re_formula |
If NULL (default), include all group-level effects; if NA, include no group-level effects. |
fitstage |
If |
stan4bart
-package modelsTypically referred to as fitted value draws on response scale, where appropriate.
## S3 method for class 'stan4bartFit' epred_draws(object, newdata, ..., value = ".epred", re_formula = NULL)
## S3 method for class 'stan4bartFit' epred_draws(object, newdata, ..., value = ".epred", re_formula = NULL)
object |
A |
newdata |
Data frame to generate predictions from [optional]. |
... |
Additional arguments passed to the underlying prediction method for the type of model given. |
value |
The name of the output column. |
re_formula |
If NULL (default), include all group-level effects; if NA, include no group-level effects. |
BART
-package modelsGet fitted draws from posterior of BART
-package models
fitted_draws_BART( model, newdata = NULL, value = ".value", ..., include_newdata = TRUE, include_sigsqs = FALSE, scale = "real" )
fitted_draws_BART( model, newdata = NULL, value = ".value", ..., include_newdata = TRUE, include_sigsqs = FALSE, scale = "real" )
model |
A model from |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Arguments to pass to |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
scale |
Should the fitted values be on the real, probit or logit scale? |
A tidy data frame (tibble) with fitted values.
bartMachine
modelGet fitted draws from posterior of bartMachine
model
## S3 method for class 'bartMachine' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'bartMachine' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
model |
A |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
n |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with fitted values.
lbart
modelGet fitted draws from posterior of lbart
model
## S3 method for class 'lbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'lbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
model |
A model from |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
n |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with fitted values.
mbart
modelGet fitted draws from posterior of mbart
model
## S3 method for class 'mbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'mbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
model |
A model from |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
n |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with fitted values.
mbart2
modelGet fitted draws from posterior of mbart2
model
## S3 method for class 'mbart2' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'mbart2' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
model |
A model from |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
n |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with fitted values.
pbart
modelGet fitted draws from posterior of pbart
model
## S3 method for class 'pbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'pbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
model |
A model from |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
n |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with fitted values.
wbart
modelGet fitted draws from posterior of wbart
model
## S3 method for class 'wbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'wbart' fitted_draws( model, newdata, value = ".value", ..., n = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
model |
A model from |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
n |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with fitted values.
The common support identification methods are based on Hill and Su (2013). Loosely speaker, an individuals treatment effect estimate has common support if the counter factual estimate is not too uncertain. The estimates are uncertain when the prediction is 'far away' from other observations. Removing estimates without common support can be beneficial for treat effect estimates.
has_common_support(model, treatment, method, cutoff, modeldata = NULL)
has_common_support(model, treatment, method, cutoff, modeldata = NULL)
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
A character string specifying the name of the treatment variable. |
method |
Method to use in determining common support. 'chisq', or 'sd'. |
cutoff |
Cutoff point to use for method. |
modeldata |
Manually provide model data for some models (e.g. from BART package) |
Hill, Jennifer; Su, Yu-Sung. Ann. Appl. Stat. 7 (2013), no. 3, 1386–1420. doi:10.1214/13-AOAS630. https://projecteuclid.org/euclid.aoas/1380804800
Tibble with a row for each observation and a column indicating whether common support exists.
Check if a model class has required generic methods for tidytreatment functions.
has_tidytreatment_methods(model)
has_tidytreatment_methods(model)
model |
Model to be checked. |
Boolean
Dataset from the "Data Challenge" for the Atlantic Causal Inference Conference 2019.
highDim_testdataset3
highDim_testdataset3
A data frame with 2000 observations, and 187 variables.
Outcome variable
Treatment variable
Other covariates
...
bartCause
-package objectsTypically referred to as fitted value draws on linear scale, where appropriate.
## S3 method for class 'bartcFit' linpred_draws( object, ..., value = ".linpred", re_formula = NULL, fitstage = c("response", "assignment") )
## S3 method for class 'bartcFit' linpred_draws( object, ..., value = ".linpred", re_formula = NULL, fitstage = c("response", "assignment") )
object |
A |
... |
Additional arguments (e.g. |
value |
The name of the output column. |
re_formula |
If NULL (default), include all group-level effects; if NA, include no group-level effects. |
fitstage |
If |
stan4bart
-package modelsTypically referred to as fitted value draws on linear scale, where appropriate.
## S3 method for class 'stan4bartFit' linpred_draws(object, newdata, ..., value = ".linpred", re_formula = NULL)
## S3 method for class 'stan4bartFit' linpred_draws(object, newdata, ..., value = ".linpred", re_formula = NULL)
object |
A |
newdata |
Data frame to generate predictions from [optional]. |
... |
Additional arguments passed to the underlying prediction method for the type of model given. |
value |
The name of the output column. |
re_formula |
If NULL (default), include all group-level effects; if NA, include no group-level effects. |
Tibble grouped by iteration ('iter') and tree id ('tree_id'). All information calculated by method is included in output.
posterior_trees_BART(model, label_digits = 2)
posterior_trees_BART(model, label_digits = 2)
model |
BART model. |
label_digits |
Rounding for labels. |
A tibble with columns to
Integer describing unique MCMC iteration.
Integer. Unique tree id with each 'iter'.
Integer describing node in tree. Unique to each 'tree'-'iter'.
Integer describing parent node in tree.
Label for the node.
Position in tree hierarchy.
Variable for split.
Numeric. Value of decision rule for 'var'.
Logical. 'TRUE' if leaf, 'FALSE' if stem.
Integer. Left child of node.
Integer. Right child of node.
BART
-package modelsGet predict draws from posterior of BART
-package models
predicted_draws_BART( object, newdata = NULL, value = ".prediction", ..., rng = stats::rnorm, include_newdata = TRUE, include_fitted = FALSE, include_sigsqs = FALSE )
predicted_draws_BART( object, newdata = NULL, value = ".prediction", ..., rng = stats::rnorm, include_newdata = TRUE, include_fitted = FALSE, include_sigsqs = FALSE )
object |
A |
newdata |
Data frame to generate predictions from. If omitted, most model types will generate predictions from the data used to fit the model. |
value |
The name of the output column for |
... |
Arguments to pass to |
rng |
Random number generator function. Default is |
include_newdata |
Should the newdata be included in the tibble? |
include_fitted |
Should the posterior fitted values be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with predicted values.
bartCause
-package objectsGet prediction draws from posterior of bartCause
-package objects
## S3 method for class 'bartcFit' predicted_draws( object, ..., value = ".prediction", re_formula = NULL, fitstage = c("response", "assignment") )
## S3 method for class 'bartcFit' predicted_draws( object, ..., value = ".prediction", re_formula = NULL, fitstage = c("response", "assignment") )
object |
A |
... |
Additional arguments (e.g. |
value |
The name of the output column. |
re_formula |
If NULL (default), include all group-level effects; if NA, include no group-level effects. |
fitstage |
If |
bartMachine
modelGet predict draws from posterior of bartMachine
model
## S3 method for class 'bartMachine' predicted_draws( object, newdata, value = ".prediction", ..., ndraws = NULL, include_newdata = TRUE, include_fitted = FALSE, include_sigsqs = FALSE )
## S3 method for class 'bartMachine' predicted_draws( object, newdata, value = ".prediction", ..., ndraws = NULL, include_newdata = TRUE, include_fitted = FALSE, include_sigsqs = FALSE )
object |
A |
newdata |
Data frame to generate predictions from. If omitted, most model types will generate predictions from the data used to fit the model. |
value |
The name of the output column for |
... |
Not currently in use. |
ndraws |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_fitted |
Should the posterior fitted values be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with predicted values.
stan4bart
-package modelsGet prediction draws from posterior of stan4bart
-package models
## S3 method for class 'stan4bartFit' predicted_draws(object, newdata, ..., value = ".prediction", re_formula = NULL)
## S3 method for class 'stan4bartFit' predicted_draws(object, newdata, ..., value = ".prediction", re_formula = NULL)
object |
A |
newdata |
Data frame to generate predictions from [optional]. |
... |
Additional arguments passed to the underlying prediction method for the type of model given. |
value |
The name of the output column. |
re_formula |
If NULL (default), include all group-level effects; if NA, include no group-level effects. |
wbart
modelGet predict draws from posterior of wbart
model
## S3 method for class 'wbart' predicted_draws( object, newdata, value = ".prediction", ..., ndraws = NULL, include_newdata = TRUE, include_fitted = FALSE, include_sigsqs = FALSE )
## S3 method for class 'wbart' predicted_draws( object, newdata, value = ".prediction", ..., ndraws = NULL, include_newdata = TRUE, include_fitted = FALSE, include_sigsqs = FALSE )
object |
A |
newdata |
Data frame to generate predictions from. If omitted, most model types will generate predictions from the data used to fit the model. |
value |
The name of the output column for |
... |
Use to specify random number generator, default is |
ndraws |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_fitted |
Should the posterior fitted values be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
A tidy data frame (tibble) with predicted values.
Classes from BART
-package models
residual_draws_BART( object, response, newdata = NULL, value = ".residual", include_newdata = TRUE, include_sigsqs = FALSE )
residual_draws_BART( object, response, newdata = NULL, value = ".residual", include_newdata = TRUE, include_sigsqs = FALSE )
object |
model from |
response |
Original response vector. |
newdata |
Data frame to generate predictions from. If omitted, original data used to fit the model. |
value |
Name of the output column for residual_draws; default is |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
Tibble with residuals.
bartMachine
modelGet residual draw for bartMachine
model
## S3 method for class 'bartMachine' residual_draws( object, newdata, value = ".residual", ..., ndraws = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'bartMachine' residual_draws( object, newdata, value = ".residual", ..., ndraws = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
object |
|
newdata |
Data frame to generate predictions from. If omitted, original data used to fit the model. |
value |
Name of the output column for residual_draws; default is |
... |
Additional arguments passed to the underlying prediction method for the type of model given. |
ndraws |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
Tibble with residuals.
pbart
modelThe original response variable must be passed as an argument to this function. e.g. 'response = y'
## S3 method for class 'pbart' residual_draws( object, newdata, value = ".residual", ..., ndraws = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'pbart' residual_draws( object, newdata, value = ".residual", ..., ndraws = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
object |
|
newdata |
Data frame to generate predictions from. If omitted, original data used to fit the model. |
value |
Name of the output column for residual_draws; default is |
... |
Additional arguments passed to the underlying prediction method for the type of model given. |
ndraws |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
Tibble with residuals.
wbart
modelThe original response variable must be passed as an argument to this function. e.g. 'response = y'
## S3 method for class 'wbart' residual_draws( object, newdata, value = ".residual", ..., ndraws = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
## S3 method for class 'wbart' residual_draws( object, newdata, value = ".residual", ..., ndraws = NULL, include_newdata = TRUE, include_sigsqs = FALSE )
object |
|
newdata |
Data frame to generate predictions from. If omitted, original data used to fit the model. |
value |
Name of the output column for residual_draws; default is |
... |
Additional arguments passed to the underlying prediction method for the type of model given. |
ndraws |
Not currently implemented. |
include_newdata |
Should the newdata be included in the tibble? |
include_sigsqs |
Should the posterior sigma-squared draw be included? |
Tibble with residuals.
Sample observations with the following scheme:
Covariates: .
Assignment: with
where
.
Mean response: and
.
Observation: .
Superscript denotes the linear components, whilst
denotes the non-linear
components.
simulate_su_hill_data( n, treatment_linear = TRUE, response_parallel = TRUE, response_aligned = TRUE, y_sd = 1, tau = 4, omega = 0, add_categorical = FALSE, n_subjects = 0, sd_subjects = 1, coef_categorical_treatment = NULL, coef_categorical_nontreatment = NULL )
simulate_su_hill_data( n, treatment_linear = TRUE, response_parallel = TRUE, response_aligned = TRUE, y_sd = 1, tau = 4, omega = 0, add_categorical = FALSE, n_subjects = 0, sd_subjects = 1, coef_categorical_treatment = NULL, coef_categorical_nontreatment = NULL )
n |
Size of simulated sample. |
treatment_linear |
Treatment assignment mechanism is linear? |
response_parallel |
Response surface is parallel? |
response_aligned |
Response surface is aligned? |
y_sd |
Observation noise. |
tau |
Treatment effect for parallel response surfaces. Not applicable if surface is nonparallel. |
omega |
Offset to control treatment assignment ratios. |
add_categorical |
Should a categorical variable be added? (Not in Hill and Su) |
n_subjects |
How many subjects are there? For repeated observations. (Hill and Su = 0, default) |
sd_subjects |
Random effect intercept standard deviation for subjects. (Not in Hill and Su. Used if n_subjects > 0) |
coef_categorical_treatment |
What are the coefficients of the categorical variable under treatment? (Not in Hill and Su) |
coef_categorical_nontreatment |
What are the coefficients of the categorical variable under nontreatment? (Not in Hill and Su) |
Coefficients used are returned in the list this function creates. See Table 1 in Su and Hill (2013) for the table of coefficients.
The are in a data.frame named
data
in the returned list.
The formula for the model matrix is named
su_hill_formula
in the returned list.
The coefficients used for the model matrix are contained in coefs
.
The Su and Hill (2013) simulations did not include categorical variables, but you can add them here using arguments: add_categorical
, coef_categorical_treatment
, coef_categorical_nontreatment
.
Hill, Jennifer; Su, Yu-Sung. Ann. Appl. Stat. 7 (2013), no. 3, 1386–1420. doi:10.1214/13-AOAS630. https://projecteuclid.org/euclid.aoas/1380804800
An object of class suhillsim
that is a list with elements
data |
Simulated data in data.frame |
mean_y |
The mean y values for each individual (row) |
args |
List of arguments passed to function |
formulas |
Response formulas used to generate data |
coefs |
Coefficients for the formulas |
Simulated with simulate_su_hill_data(...)
, see details.
Includes propensity score estimated using BART (prop_score
), see source.
suhillsim1
suhillsim1
See ?simulate_su_hill_data
for output format.
set.seed(101) suhillsim1 <- simulate_su_hill_data(n = 100, treatment_linear = FALSE, omega = 0, add_categorical = TRUE, coef_categorical_treatment = c(0,0,1), coef_categorical_nontreatment = c(-1,0,-1))
https://github.com/bonStats/tidytreatment/tree/master/data-raw
Simulated with simulate_su_hill_data(...)
, see details.
suhillsim2_ranef
suhillsim2_ranef
See ?simulate_su_hill_data
for output format.
set.seed(101) suhillsim1 <- simulate_su_hill_data(n = 100, treatment_linear = FALSE, omega = 0, add_categorical = TRUE, coef_categorical_treatment = c(0,0,1), coef_categorical_nontreatment = c(-1,0,-1), sd_subjects = 2, n_subjects = 10)
https://github.com/bonStats/tidytreatment/tree/master/data-raw
ATE = Average Treatment Effects Assumes treated column is either a integer column of 1's (treated) and 0's (nontreated) or logical indicating treatment if TRUE.
tidy_ate(model, treatment, common_support_method, cutoff, ...)
tidy_ate(model, treatment, common_support_method, cutoff, ...)
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
A character string specifying the name of the treatment variable. |
common_support_method |
Either "sd", or "chisq". Default is unspecified, and no common support calculation is done. |
cutoff |
Cutoff for common support (if in use). |
... |
Arguments to be passed to |
A tidy data frame (tibble) with treatment effect values.
ATT = average Treatment Effects on Treated Assumes treated column is either a integer column of 1's (treated) and 0's (nontreated) or logical indicating treatment if TRUE.
tidy_att(model, treatment, common_support_method, cutoff, ...)
tidy_att(model, treatment, common_support_method, cutoff, ...)
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
A character string specifying the name of the treatment variable. |
common_support_method |
Either "sd", or "chisq". Default is unspecified, and no common support calculation is done. |
cutoff |
Cutoff for common support (if in use). |
... |
Arguments to be passed to |
A tidy data frame (tibble) with treatment effect values.
bartCause
-package objectsTidy access to posterior of bartCause
-package objects
## S3 method for class 'bartcFit' tidy_draws(object, type = NULL, fitstage = c("response", "assignment"), ...)
## S3 method for class 'bartcFit' tidy_draws(object, type = NULL, fitstage = c("response", "assignment"), ...)
object |
A |
type |
Posterior quantity to return. See |
fitstage |
If |
... |
Additional parameters passed up the generic method chain. |
tidytreatment provides functions for extracting tidy data from Bayesian treatment effect models, estimating treatment effects, and plotting useful summaries of these.
CTE = Conditional Treatment Effects (usually used to generate (C)ATE or ATT)
newdata
specifies the conditions, if unspecified it defaults to the original data.
Assumes treated column is either a integer column of 1's (treated) and 0's (nontreated) or logical indicating treatment if TRUE.
treatment_effects( model, treatment, newdata, subset = "all", common_support_method, cutoff, ... )
treatment_effects( model, treatment, newdata, subset = "all", common_support_method, cutoff, ... )
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
A character string specifying the name of the treatment variable. |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
subset |
Either "treated", "nontreated", or "all". Default is "all". |
common_support_method |
Either "sd", or "chisq". Default is unspecified, and no common support calculation is done. |
cutoff |
Cutoff for common support (if in use). |
... |
Arguments to be passed to |
A tidy data frame (tibble) with treatment effect values.
CTE = Conditional Treatment Effects (usually used to generate (C)ATE or ATT)
newdata
specifies the conditions, if unspecified it defaults to the original data.
Assumes treated column is either a integer column of 1's (treated) and 0's (nontreated) or logical indicating treatment if TRUE.
## S3 method for class 'bartcFit' treatment_effects( model, treatment = NULL, newdata = NULL, subset = "all", common_support_method, cutoff, ... )
## S3 method for class 'bartcFit' treatment_effects( model, treatment = NULL, newdata = NULL, subset = "all", common_support_method, cutoff, ... )
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
Not used. Treatment variable specified by |
newdata |
Not used. extracts treatment effects already calculated by |
subset |
Either "treated", "nontreated", or "all". Default is "all". |
common_support_method |
Either "sd", or "chisq". Default is unspecified, and no common support calculation is done. |
cutoff |
Cutoff for common support (if in use). |
... |
Arguments to be passed to |
A tidy data frame (tibble) with treatment effect values.
CTE = Conditional Treatment Effects (or CATE, the average effects)
newdata
specifies the conditions, if unspecified it defaults to the original data.
Assumes treated column is either a integer column of 1's (treated) and 0's (nontreated) or logical indicating treatment if TRUE.
## Default S3 method: treatment_effects( model, treatment, newdata, subset = "all", common_support_method, cutoff, ... )
## Default S3 method: treatment_effects( model, treatment, newdata, subset = "all", common_support_method, cutoff, ... )
model |
A supported Bayesian model fit that can provide fits and predictions. |
treatment |
A character string specifying the name of the treatment variable. |
newdata |
Data frame to generate fitted values from. If omitted, defaults to the data used to fit the model. |
subset |
Either "treated", "nontreated", or "all". Default is "all". |
common_support_method |
Either "sd", or "chisq". Default is unspecified, and no common support calculation is done. |
cutoff |
Cutoff for common support (if in use). |
... |
Arguments to be passed to |
A tidy data frame (tibble) with treatment effect values.
Models from BART
-package include warm-up and skipped MCMC draws.
variance_draws(model, value = ".sigma_sq", ...)
variance_draws(model, value = ".sigma_sq", ...)
model |
A model from a supported package. |
value |
The name of the output column for variance parameter; default |
... |
Additional arguments. |
A tidy data frame (tibble) with draws of variance parameter