diff --git a/R/select_weight.R b/R/select_weight.R index f344250..17da336 100644 --- a/R/select_weight.R +++ b/R/select_weight.R @@ -9,11 +9,12 @@ #' @param grp string containing the name of the column where the group membership variable is stored in df #' @param X vector of strings containing the name of confounders to be included in the model #' @param instr vector of strings containing the name of instrumental variables to be included in the model +#' @param type.res string containing the type of glm residuals to be used. Default is "deviance" #' @return A vector of weights to be included in a PCBSM #' @export -select_weight <- function(df=NULL,grp=NULL,X=NULL,instr=NULL) { +select_weight <- function(df=NULL,grp=NULL,X=NULL,instr=NULL,type.res="deviance") { formu <- paste0(grp,"~") formu2 <- paste(X,sep="+",collapse="+") formu3 <- paste(instr,sep="+",collapse="+") @@ -25,6 +26,6 @@ select_weight <- function(df=NULL,grp=NULL,X=NULL,instr=NULL) { } formu <- paste(formu,formu2) logit_mod <- glm(formula = formu,data = df,family = binomial(link = "probit")) - res <- residuals(logit_mod) + res <- residuals(logit_mod,type=type.res) return(res) } diff --git a/man/select_weight.Rd b/man/select_weight.Rd index f553e12..93812b6 100644 --- a/man/select_weight.Rd +++ b/man/select_weight.Rd @@ -4,7 +4,13 @@ \alias{select_weight} \title{Compute confounding weights for the PCBSM.} \usage{ -select_weight(df = NULL, grp = NULL, X = NULL, instr = NULL) +select_weight( + df = NULL, + grp = NULL, + X = NULL, + instr = NULL, + type.res = "deviance" +) } \arguments{ \item{df}{data.frame containing the data} @@ -14,6 +20,8 @@ select_weight(df = NULL, grp = NULL, X = NULL, instr = NULL) \item{X}{vector of strings containing the name of confounders to be included in the model} \item{instr}{vector of strings containing the name of instrumental variables to be included in the model} + +\item{type.res}{string containing the type of glm residuals to be used. Default is "deviance"} } \value{ A vector of weights to be included in a PCBSM