Title: | Two Cut-Points with Maximum Odds Ratio |
---|---|
Description: | Enables the computation of the 'two cut-points with maximum odds ratio (OR) value method' for data analysis, particularly suited for binary classification tasks. Users can identify optimal cut-points in a continuous variable by maximizing the odds ratio while maintaining an equal risk level, useful for tasks such as medical diagnostics, risk assessment, or predictive modeling. |
Authors: | Xianying He [aut], Shuo Yang [aut, cre], Yi Fei [ctb], Jinxin Zhang [aut] |
Maintainer: | Shuo Yang <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0 |
Built: | 2025-02-21 03:29:01 UTC |
Source: | https://github.com/cran/TCPMOR |
Calculate data filtering results and two cutoffs for given sensitivity and specificity threshold
calculateCutoffs(dataC, seThreshold = 0.1, spThreshold = 0.1)
calculateCutoffs(dataC, seThreshold = 0.1, spThreshold = 0.1)
dataC |
Data frame containing columns: se, sp, age, y0, OR, y |
seThreshold |
Sensitivity threshold |
spThreshold |
Specificity threshold |
A list with two elements: filteredData(the filtered dataset) and cutoffs(the calculated two cutoffs)
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC) # Output the two cut-off points after limiting sensitivity se and specificity sp result <- calculateCutoffs(dataC) cutoffs <- result$cutoffs dataC2 <- result$filteredData print(cutoffs)
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC) # Output the two cut-off points after limiting sensitivity se and specificity sp result <- calculateCutoffs(dataC) cutoffs <- result$cutoffs dataC2 <- result$filteredData print(cutoffs)
Generate simulation data
createData(n, seed = 123589)
createData(n, seed = 123589)
n |
The total number of observations to generate |
seed |
Randomized seeds for ensuring reproducible results |
A data frame containing age and a binary outcome variable
dataC <- createData(200)
dataC <- createData(200)
Discretize the age variable according to the two cut-off points
discretizeAge(data, cutoffs)
discretizeAge(data, cutoffs)
data |
Data frame with column: age |
cutoffs |
The cut-off points of the age range |
A modified data frame with a new column: age_p
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC) # Calculate the two cut-off points after limiting sensitivity se and specificity sp result <- calculateCutoffs(dataC) cutoffs <- result$cutoffs dataC2 <- result$filteredData # Discretize age variable based on the two cutoffs dataC2 <- discretizeAge(dataC2, cutoffs)
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC) # Calculate the two cut-off points after limiting sensitivity se and specificity sp result <- calculateCutoffs(dataC) cutoffs <- result$cutoffs dataC2 <- result$filteredData # Discretize age variable based on the two cutoffs dataC2 <- discretizeAge(dataC2, cutoffs)
Finding the two cut-off points
findCutoffs(spm.fit, dataC)
findCutoffs(spm.fit, dataC)
spm.fit |
Fitted semi-parametric model object |
dataC |
Data frame containing age and binary outcome variables |
Data frame containing age, fitted lnOR, OR, se, sp, sse, and ssp
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC)
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC)
Fit a logistic regression model and return the OR and 95% confidence interval
fitLogisticRegression(data)
fitLogisticRegression(data)
data |
A data frame with columns: y, age_p |
A matrix of OR and 95% confidence intervals
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC) # Calculate the two cut-off points after limiting sensitivity se and specificity sp result <- calculateCutoffs(dataC) cutoffs <- result$cutoffs dataC2 <- result$filteredData # Discretize age variable based on the two cutoffs dataC2 <- discretizeAge(dataC2, cutoffs) # Fitting logistic regression models and obtaining OR values and 95% confidence intervals OR_Results <- fitLogisticRegression(dataC2) print(round(OR_Results, 3))
# Generate simulated data dataC dataC <- createData(200) # Fit the semi-parametric model spm.fit <- fitSemiParamModel(dataC) # Find two cut-off points dataC <- findCutoffs(spm.fit, dataC) # Calculate the two cut-off points after limiting sensitivity se and specificity sp result <- calculateCutoffs(dataC) cutoffs <- result$cutoffs dataC2 <- result$filteredData # Discretize age variable based on the two cutoffs dataC2 <- discretizeAge(dataC2, cutoffs) # Fitting logistic regression models and obtaining OR values and 95% confidence intervals OR_Results <- fitLogisticRegression(dataC2) print(round(OR_Results, 3))
Fit the data using a semi-parametric model to explore the nonlinear dose-response relationship between the independent variable and lnOR
fitSemiParamModel(dataC)
fitSemiParamModel(dataC)
dataC |
Data frame containing age and binary outcome variables |
Fitted semi-parametric model object
# Generate simulated data dataC dataC <- createData(200) # Plot the nonlinear dose-response relationship between the independent variable and lnOR spm.fit <- fitSemiParamModel(dataC) plot(spm.fit,ylab = "lnOR",xlab = "age",shade = FALSE) summary(spm.fit)
# Generate simulated data dataC dataC <- createData(200) # Plot the nonlinear dose-response relationship between the independent variable and lnOR spm.fit <- fitSemiParamModel(dataC) plot(spm.fit,ylab = "lnOR",xlab = "age",shade = FALSE) summary(spm.fit)