% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rem.R
\name{fit_rem_sep}
\alias{fit_rem_sep}
\title{Fit a Separable Relational Event Model}
\usage{
fit_rem_sep(
  edgelist,
  formula_init,
  formula_cont,
  n = NULL,
  n_nonevents = 200L,
  base_riskset = NULL,
  cl = NULL,
  method = c("cox", "clogit", "temporal"),
  covariates = NULL,
  min_events = 2L
)
}
\arguments{
\item{edgelist}{Data frame with columns \code{time}, \code{sender}, \code{receiver},
\code{eveid}. Use \code{\link[=prepare_edgelist]{prepare_edgelist()}} to create this from a raw matrix.}

\item{formula_init}{Survival formula for the initiation sub-model
(events where \code{SndInitiation == 0}).  Typical terms: \code{RRecInitiation},
\code{NOTPSnd}, \code{NITPSnd}.  Must include \code{survival::strata(time2)}.}

\item{formula_cont}{Survival formula for the continuation sub-model
(events where \code{SndInitiation == 1}).  Typical terms: \code{Repetition},
\code{RecRecencyLog}.  Must include \code{survival::strata(time2)}.}

\item{n}{Number of nodes. Inferred from \code{edgelist} if \code{NULL}.}

\item{n_nonevents}{Sampled non-event risk-set size per event. \code{NULL} uses
the full risk set. Passed to \code{\link[=fit_rem]{fit_rem()}} internally.}

\item{base_riskset}{Precomputed base risk-set data frame.}

\item{cl}{Optional PSOCK cluster for parallelised risk-set computation.}

\item{method}{Estimation method: \code{"cox"} (default), \code{"clogit"}, or
\code{"temporal"}. Applied independently to each sub-model.}

\item{covariates}{Optional exogenous covariate list from \code{\link[=rem_covariates]{rem_covariates()}}.}

\item{min_events}{Minimum number of focal events required in each partition
to attempt fitting. Partitions below this threshold return \code{NULL} for
that sub-model with a warning. Default 2.}
}
\value{
A \code{rem_sep} object (a named list) with elements:
\describe{
\item{\code{init}}{Fitted initiation sub-model (same class as \code{\link[=fit_rem]{fit_rem()}}
output for the chosen \code{method}), or \code{NULL} if too few events.}
\item{\code{cont}}{Fitted continuation sub-model, or \code{NULL}.}
\item{\code{loglik}}{Named numeric vector: \code{init}, \code{cont}, \code{sep}
(= init + cont), and \code{null} (= init_null + cont_null).}
\item{\code{n_init}}{Number of initiation events in the sequence.}
\item{\code{n_cont}}{Number of continuation events.}
\item{\code{init_fraction}}{Proportion of events that are initiations.}
\item{\code{method}}{The estimation method used.}
}
}
\description{
Partitions the risk set by prior contact status (\code{SndInitiation}) and fits
two independent sub-models: one for \strong{initiation} events (sender has never
previously contacted receiver; \code{SndInitiation == 0}) and one for
\strong{continuation} events (sender has contacted receiver before;
\code{SndInitiation == 1}).  The approach is analogous to separable TERGMs
(Krivitsky and Handcock, 2014): because the two subsets are disjoint, their
parameters are conditionally independent and can be estimated separately via
standard Cox partial likelihood on each partition.
}
\details{
The combined log-likelihood is \code{loglik_init + loglik_cont}, which is directly
comparable to a pooled five-parameter model with the same degrees of freedom
(see paper for details).
}
\examples{
data(edgelist)
el <- prepare_edgelist(edgelist)
fit <- fit_rem_sep(
  el[1:200, ],
  formula_init = survival::Surv(time1, occurred) ~
    RRecInitiation + survival::strata(time2),
  formula_cont = survival::Surv(time1, occurred) ~
    Repetition + RecRecencyLog + survival::strata(time2),
  n_nonevents = 20L, method = "clogit"
)
print(fit)
}
