Added option in select_weight

This commit is contained in:
2025-05-26 14:10:58 +02:00
parent 2eafd5c3a6
commit 9a9c7aab6f
2 changed files with 9 additions and 2 deletions

View File

@ -10,11 +10,12 @@
#' @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"
#' @param std boolean indicating whether residuals should be standardized. Default is TRUE
#' @return A vector of weights to be included in a PCBSM
#' @export
select_weight <- function(df=NULL,grp=NULL,X=NULL,instr=NULL,type.res="deviance") {
select_weight <- function(df=NULL,grp=NULL,X=NULL,instr=NULL,type.res="deviance",std=T) {
formu <- paste0(grp,"~")
formu2 <- paste(X,sep="+",collapse="+")
formu3 <- paste(instr,sep="+",collapse="+")
@ -27,5 +28,8 @@ select_weight <- function(df=NULL,grp=NULL,X=NULL,instr=NULL,type.res="deviance"
formu <- paste(formu,formu2)
logit_mod <- glm(formula = formu,data = df,family = binomial(link = "probit"))
res <- residuals(logit_mod,type=type.res)
if (std) {
res <- rstandard(logit_mod,type='deviance')
}
return(res)
}

View File

@ -9,7 +9,8 @@ select_weight(
grp = NULL,
X = NULL,
instr = NULL,
type.res = "deviance"
type.res = "deviance",
std = T
)
}
\arguments{
@ -22,6 +23,8 @@ select_weight(
\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"}
\item{std}{boolean indicating whether residuals should be standardized. Default is TRUE}
}
\value{
A vector of weights to be included in a PCBSM