Skip to content

Commit

Permalink
fix check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkliming committed Oct 15, 2024
1 parent 57d40c7 commit 0bfe7ea
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Depends:
Imports:
checkmate,
numDeriv,
MASS,
prediction,
sandwich,
stats
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export(predict_counterfactual)
export(robin_glm)
export(treatment_effect)
import(checkmate)
importFrom(MASS,negative.binomial)
importFrom(numDeriv,jacobian)
importFrom(prediction,find_data)
importFrom(sandwich,vcovHC)
importFrom(stats,as.formula)
importFrom(stats,coefficients)
importFrom(stats,family)
importFrom(stats,fitted)
Expand Down
3 changes: 2 additions & 1 deletion R/RobinCar2-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#' @import checkmate
#' @importFrom numDeriv jacobian
#' @importFrom stats predict residuals fitted model.response model.matrix coefficients family
#' gaussian terms glm var family pnorm var
#' gaussian terms glm var family pnorm var as.formula
#' @importFrom sandwich vcovHC
#' @importFrom MASS negative.binomial
#' @importFrom prediction find_data
NULL
5 changes: 2 additions & 3 deletions R/robin_glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ robin_glm <- function(
}
pc <- predict_counterfactual(fit, treatment, data)
has_interaction <- h_interaction(formula, treatment)
if (
has_interaction && (identical(vcov, "vcovHC") || identical(vcov, vcovHC)) &&
!identical(contrast, "difference")) {
use_vcovhc <- identical(vcov, "vcovHC") || identical(vcov, vcovHC)
if (has_interaction && use_vcovhc && !identical(contrast, "difference")) {
stop(
"Huber-White variance estimator is ONLY supported when the expected outcome difference is estimated",
"using a linear model without treatment-covariate interactions; see the 2023 FDA guidance."
Expand Down
4 changes: 2 additions & 2 deletions R/treatment_effect.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ treatment_effect.prediction_cf <- function(
#' @inheritParams predict_counterfactual
treatment_effect.lm <- function(
object, pair, variance = gvcov, eff_measure, eff_jacobian,
treatment, vcov_args = list(), data = find_data(object), ...) {
vcov_args = list(), treatment, data = find_data(object), ...) {
pc <- predict_counterfactual(object, data = data, treatment)
treatment_effect(pc, pair = pair, variance = variance, eff_measure = eff_measure, eff_jacobian = eff_jacobian, ...)
}

#' @export
treatment_effect.glm <- function(
object, pair, variance = gvcov, eff_measure, eff_jacobian,
treatment, vcov_args = list(), data = find_data(object), ...) {
vcov_args = list(), treatment, data = find_data(object), ...) {
pc <- predict_counterfactual(object, treatment, data)
treatment_effect(pc, pair = pair, variance = variance, eff_measure = eff_measure, eff_jacobian = eff_jacobian, ...)
}
Expand Down

0 comments on commit 0bfe7ea

Please sign in to comment.