% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_cv_sets_methods.R
\name{balanced_mc}
\alias{balanced_mc}
\title{Balanced Monte-Carlo resampling strategy}
\usage{
balanced_mc(k, split, type = c("DA", "R"), probs = NULL)
}
\arguments{
\item{k}{Integer. Number of repeated random splits.}

\item{split}{Numeric. Fraction of samples assigned to the training set
(e.g. \code{2/3}).}

\item{type}{Character. Either \code{"DA"} (classification) or \code{"R"} (regression).}

\item{probs}{Numeric vector of quantile probabilities used to stratify
continuous \code{Y} when \code{type = "R"}.}
}
\value{
A named \code{list} with elements:
\describe{
\item{train}{List of integer vectors containing training set indices
for each resampling iteration.}
\item{strategy}{Character string indicating the resampling strategy.}
\item{n}{Integer. Number of samples in the dataset.}
\item{seed}{Integer. Random seed used to generate the resampling splits,
ensuring reproducibility.}
}
}
\description{
Balanced Monte-Carlo resampling strategy
}
\details{
Generates \code{k} Monte-Carlo resampling splits by randomly partitioning
the data into training and test sets without replacement.

Balancing ensures equal representation of strata in the training data:
\describe{
\item{\code{type = "DA"}}{
Class labels define the strata, and sampling is balanced across classes.
}
\item{\code{type = "R"}}{
The response is discretised into bins using quantiles defined by
\code{probs}, and each bin contributes equally to the training set.
}
}

This strategy can improve robustness of model evaluation in settings with
limited samples size and imbalanced or unevenly distributed outcome variables.
}
\examples{
n <- 100
# bivariate outcome
thr <- 1.5
Y <- c(rnorm(80, thr-3, 0.3), rnorm(20, thr+3, 0.3))  # unbalanced low/high outcome
mean(Y>thr)

cv_k <- kfold(k = 10)
cv_mc <- balanced_mc(k = 10, split = 2/3, type = "R", probs = c(0, 0.8, 1))

k_inst <- metabom8:::.arg_check_cv(cv_pars=cv_k, model_type='R', n=n, Y_prepped=cbind(Y))
mc_inst <- metabom8:::.arg_check_cv(cv_pars=cv_mc, model_type='R', n=n, Y_prepped=cbind(Y))

# balanced splits: proportion above global median stays ~0.5
q80 <- quantile(Y, 0.8)
round(sapply(k_inst$train, function(i) mean(Y[i] > q80)), 2) # resembles original Y distr.
round(sapply(mc_inst$train, function(i) mean(Y[i] > q80)), 2) # balanced strata (low/high)
}
\seealso{
Other resampling strategies: 
\code{\link{balanced_boot}()},
\code{\link{kfold}()},
\code{\link{mc}()},
\code{\link{stratified_kfold}()}
}
\concept{resampling strategies}
