Skip to contents

Assigns each sample (observation) to a population/stock based on the highest Linear Discriminant Function (LDF) score. It also computes posterior probabilities (or values proportional to them if priors are not explicitly used).

Usage

classify_samples(samples, coefs, freq = NULL, type = "S")

Arguments

samples

A numeric matrix of samples to be classified. Rows are observations, columns are variables.

coefs

A numeric matrix of LDF coefficients, as returned by compute_ldf_coefficients. Rows are populations, columns are coefficients for variables followed by the constant term.

freq

Optional numeric vector of frequency weights for the samples. Defaults to 1 for each sample if NULL. (Used mainly for HISEA compatibility).

type

Character, indicates the type of run (e.g., "S" for simulation). This parameter is from HISEA Fortran and affects a condition for processing, though its impact here is minor if freq are positive. Default "S".

Value

A list containing:

class

An integer vector of predicted class labels (1 to NP) for each sample.

likelihood

A numeric matrix where rows are samples and columns are populations. Contains posterior probabilities of class membership (assuming equal priors, rows sum to 1).