Learn R Programming

GRAB (version 0.2.4)

fitNullModel.SPAmix: Fit a SPAmix null model from a survival response (Surv) with covariates or from precomputed residuals. Principal components (PCs) named in control$PC_columns are extracted; residual outliers are detected using an IQR rule with adjustable multiplier and stored for SPA testing.

Description

Fit a SPAmix null model from a survival response (Surv) with covariates or from precomputed residuals. Principal components (PCs) named in control$PC_columns are extracted; residual outliers are detected using an IQR rule with adjustable multiplier and stored for SPA testing.

Usage

fitNullModel.SPAmix(response, designMat, subjData, control, ...)

Value

A list of class "SPAmix_NULL_Model" containing:

resid

Residual matrix (n x k)

N

Number of subjects

yVec

Response vector (event indicator for survival models)

PCs

Selected principal component columns

nPheno

Number of phenotypes (columns of residuals)

outLierList

List of per-phenotype indices (0-based) and residual subsets for outlier/non-outlier strata

Arguments

response

Either a survival::Surv object (time-to-event data) or a numeric residual vector/matrix with class "Residual".

designMat

Numeric matrix (n x p) of covariates; must include the PC columns specified in control$PC_columns.

subjData

Vector of subject IDs aligned with rows of designMat and response.

control

List of options. Required element: PC_columns, a single comma-separated string of PC column names (e.g. "PC1,PC2,PC3,PC4"). OutlierRatio.

...

Extra arguments passed to survival::coxph when response is Surv.

Details

If response is Surv, a Cox model is fit and martingale residuals are used. If response is Residual, its values are used directly. Outliers per phenotype are defined by [Q1 - r*IQR, Q3 + r*IQR] with r = OutlierRatio; if none are found, r is iteratively reduced by 20% until at least one appears.