| Type: | Package | 
| Title: | Estimating the Cluster Specific Treatment Effects in Partially Nested Designs | 
| Version: | 0.1.0 | 
| Maintainer: | Xiao Liu <xiao.liu@austin.utexas.edu> | 
| Description: | Implements the methods for assessing heterogeneous cluster-specific treatment effects in partially nested designs as described in Liu (2024) <doi:10.1037/met0000723>. The estimation uses the multiply robust method, allowing for the use of machine learning methods in model estimation (e.g., random forest, neural network, and the super learner ensemble). Partially nested designs (also known as partially clustered designs) are designs where individuals in the treatment arm are assigned to clusters (e.g., teachers, tutoring groups, therapists), whereas individuals in the control arm have no such clustering. | 
| Depends: | R (≥ 4.0.0) | 
| Imports: | stats, mvtnorm, SuperLearner, ranger, xgboost, nnet, origami, boot, tidyverse, dplyr, purrr, magrittr, glue | 
| Suggests: | testthat, knitr, rmarkdown | 
| URL: | https://github.com/xliu12/PND.heter | 
| License: | GPL-2 | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| RoxygenNote: | 7.3.1 | 
| NeedsCompilation: | no | 
| Packaged: | 2025-06-03 13:39:44 UTC; xl9663 | 
| Author: | Xiao Liu [aut, cre] | 
| Repository: | CRAN | 
| Date/Publication: | 2025-06-05 10:00:08 UTC | 
Estimation of the cluster-specific treatment effects in the partially nested design.
Description
Estimation of the cluster-specific treatment effects in the partially nested design.
Usage
atekCl(
  data_in,
  ttname,
  Kname,
  Yname,
  Xnames,
  Yfamily = "gaussian",
  learners_tt = c("SL.glm"),
  learners_k = c("SL.multinom"),
  learners_y = c("SL.glm"),
  sensitivity = NULL,
  cv_folds = 4L,
  seed = NULL
)
Arguments
| data_in | A  | 
| ttname | [ | 
| Kname | [ | 
| Yname | [ | 
| Xnames | [ | 
| Yfamily | [ | 
| learners_tt | [ | 
| learners_k | [ | 
| learners_y | [ | 
| sensitivity | Specification for sensitivity parameter values on the standardized mean difference scale, which can be  | 
| cv_folds | [ | 
| seed | An integer that is used as argument by the  | 
Value
A list containing the following components:
| ate_K | A  The columns "ate_k", "std_error", "CI_lower", and "CI_upper" contain the estimate, standard error estimate, and lower and upper bounds of the 0.95 confidence interval of the cluster-specific treatment effect for the cluster (indicated by column "cluster") in the same row. | 
| cv_components | A  | 
| sens_results | 
 If the argument  | 
Examples
library(tidyverse)
library(SuperLearner)
library(glue)
library(nnet)
# data
data(data_in)
data_in <- data_in
# baseline covariates
Xnames <- c(grep("X_dat", colnames(data_in), value = TRUE))
estimates_ate_K <- PND.heter.cluster::atekCl(
data_in = data_in,
ttname = "tt",  # treatment variable
Kname = "K",    # cluster assignment variable, coded as 0 for
                # individuals in the (non-clustered) control arm
Yname = "Y",    # outcome variable
Xnames = Xnames,
seed = 12345
)
estimates_ate_K$ate_K
Checking covariate balance based on estimated cluster assignment probabilities (principal score) and treatment assignment probabilities (propensity score).
Description
Checking covariate balance based on estimated cluster assignment probabilities (principal score) and treatment assignment probabilities (propensity score).
Usage
balance(data_in, atekCl_results, covariate_names = "X_dat.1", ttname, Kname)
Arguments
| data_in | A  | 
| atekCl_results | [ | 
| covariate_names | [ | 
| ttname | [ | 
| Kname | [ | 
Value
A data.frame containing the covariate balance measures (smd, standardized mean difference) between each cluster in the treatment arm and the control arm, both before and after the weighting adjustment.
data_in
Description
A simulated dataset from the 2/1 partially nested design with treatment-incuded clustering
Usage
data_in
Format
A data frame with 400 rows and 8 variables:
- Y
- Outcome. 
- K
- Cluster assignment in the treatment arm. 
- tt
- Treatment assignment. 1 for individuals assigned to the treatment arm. 0 for individuals assigned to the control arm. The control arm is unclustered. 
- X_dat.1
- Baseline covariates. 
- X_dat.2
- Baseline covariates. 
- X_dat.3
- Baseline covariates. 
- X_dat.4
- Baseline covariates. 
- id
- Individual id. 
partially_nested_data_example
Description
An example dataset with the 2/1 partially nested design where the clustering is induced by treatment delivery. The example was based on the public-use data of the National Center for Research on Early Childhood Education Teacher Professional Development Study (2007-2011; for details about the study, see this [website](https://www.childandfamilydataarchive.org/cfda/archives/cfda/studies/34848/versions/V2)). The participants were assigned to either the treatment or control arms. The treatment arm was a one-on-one, web-mediated consultancy intervention in which the participants received online coaching from one of J = 12 coaches; that is, each coach represents a cluster in this example. The control arm participants had no such clustering.
Usage
partially_nested_data_example
Format
A data frame with 308 rows and 8 variables:
- Posttest_Instructional_Support
- The outcome variable, measuring the instructional support quality after the intervention program. 
- Coach_ID
- Coach (i.e., cluster) assignment for participants in the treatment arm. 
- Intervention_Assignment
- Treatment assignment. 1 for participants assigned to the treatment arm to receive the intervention program. 0 for participants assigned to the control arm. The control arm is unclustered. 
- X_gender
- Baseline covariates. 
- X_age
- Baseline covariates. 
- X_TRace_Black
- Baseline covariates. 
- X_TRace_Hispanic
- Baseline covariates. 
- X_TRace_White
- Baseline covariates. 
- X_Tses_aboveMiddle
- Baseline covariates. 
- X_TINTNEED
- Baseline covariates. 
- X_Tparedu_aboveHS
- Baseline covariates. 
- X_yrs_education
- Baseline covariates. 
- X_yrs_teaching_experience
- Baseline covariates. 
- X_CLASSPOV
- Baseline covariates. 
- X_Cheadstart
- Baseline covariates. 
- X_CpublicSCH
- Baseline covariates. 
- X_self_efficacy
- Baseline covariates. 
- X_pretest_emotional_support
- Baseline covariates. 
- X_pretest_organizational_support
- Baseline covariates. 
- X_pretest_instructional_support
- Baseline covariates. 
- X_extraversion
- Baseline covariates. 
- X_agreeableness
- Baseline covariates. 
- X_conscientiousness
- Baseline covariates. 
- id
- Participant id.