estimateCoefficientsIndividual: Estimate Model Coefficients for a Subset of Features

View source: R/terga1.lib.R

estimateCoefficientsIndividualR Documentation

Estimate Model Coefficients for a Subset of Features

Description

This function estimates coefficients for a logistic regression model ('logit') on a subset of features specified by 'ind'. It evaluates the individual model’s performance by calculating the Akaike Information Criterion (AIC) and returns the coefficients.

Usage

estimateCoefficientsIndividual(X, y, ind, type = "logit")

Arguments

X

A matrix or data frame representing the features of the dataset.

y

A vector representing the binary target variable for the dataset.

ind

A vector of feature indices specifying the subset of features to include in the model.

type

A character string specifying the type of model to fit. Currently, only '"logit"' (logistic regression) is supported.

Details

The function fits a logistic regression model using the features specified in 'ind'. If 'ind' contains a single feature, the function formats 'X' accordingly. It then calculates the coefficients for each feature and the AIC of the model, providing insights into model performance.

**Note**: Currently, only '"logit"' models are supported. Other types will result in an error message.

Value

A list containing: - 'coefs': A named vector of estimated coefficients for each feature in 'ind'. - 'aic': The AIC value for the fitted logistic model, indicating model fit. - 'glm': The fitted 'glm' object.

Examples

## Not run: 
X <- matrix(rnorm(100), nrow = 10)
y <- sample(0:1, 10, replace = TRUE)
ind <- c(1, 2, 3)  # Example subset of feature indices
result <- estimateCoefficientsIndividual(X, y, ind, type = "logit")
print(result$coefs)  # Estimated coefficients
print(result$aic)    # AIC of the model

## End(Not run)


predomics/predomicspkg documentation built on Dec. 11, 2024, 11:06 a.m.