% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compute_M_optimized.R
\name{compute_M_optimized}
\alias{compute_M_optimized}
\title{Compute the Weight Matrix M (Optimized)}
\usage{
compute_M_optimized(times, status, f, u_bis, clusters)
}
\arguments{
\item{times}{A numeric vector of observed times (events or censoring).}

\item{status}{A numeric vector of status indicators (0 = censored, 1 or 2 = cause of failure).}

\item{f}{A string, either \code{"KaplanMeier_Censoring_vectorized"} or \code{"Nelson_Censoring_vectorized"},
specifying the method to estimate the censoring distribution.}

\item{u_bis}{A numeric vector of cluster-level random effects (used only if \code{f == "Nelson_Censoring_vectorized"}).}

\item{clusters}{A vector indicating cluster membership for each subject (same length as \code{times}).}
}
\value{
A square matrix \code{M} of size N x N, where \code{M[i, j]} is the IPCW weight between subject i and subject j.
}
\description{
This function computes the matrix of inverse probability of censoring weights (IPCW),
used in multicenter competing risks models with frailty. It supports both Kaplan-Meier and Nelson-Aalen estimators
for the censoring distribution.
}
\details{
\itemize{
\item If \code{f == "KaplanMeier_Censoring_vectorized"}, then \code{u_bis} is ignored.
\item The weight matrix accounts for pairwise contributions, depending on event times and causes.
}
}
\seealso{
\code{\link[=KaplanMeier_Censoring_vectorized]{KaplanMeier_Censoring_vectorized()}}, \code{\link[=Nelson_Censoring_vectorized]{Nelson_Censoring_vectorized()}}, \code{\link[=create_G_function]{create_G_function()}}
}
