View source: R/df_counting_helpers.R
| check_results | R Documentation |
Calculates and compares three equivalent test statistics from weighted survival analysis: the squared standardized weighted log-rank statistic, the log-rank chi-squared statistic, and the squared Cox model z-score. These should be approximately equal under correct implementation.
check_results(dfcount, verbose = TRUE)
dfcount |
A list or data frame from
|
verbose |
Logical; if |
This function serves as a diagnostic tool to verify computational consistency. The three statistics should be numerically equivalent (within rounding error):
(lr / \sqrt{sig2\_lr})^2 \approx logrank\_chisq \approx z.score^2
Discrepancies between these values may indicate:
Numerical instability in variance estimation
Incorrect weighting scheme application
Data processing errors
A data frame with one row and three columns, returned invisibly:
Squared standardized weighted log-rank: (lr / \sqrt{sig2\_lr})^2
Chi-squared statistic from log-rank test
Squared z-score from Cox model: z.score^2
This function is primarily used for package development and validation. End users typically don't need to call it directly.
df_counting for generating the input object
# After running df_counting
library(survival)
data(veteran)
veteran$treat <- as.numeric(veteran$trt) - 1
result <- df_counting(
df = veteran,
tte.name = "time",
event.name = "status",
treat.name = "treat"
)
# Check consistency of test statistics
check_results(result)
# Store results without printing
stats_comparison <- check_results(result, verbose = FALSE)
print(stats_comparison)
# Simple example with constructed data
dfcount_example <- list(
lr = 2.5,
sig2_lr = 1.0,
z.score = 2.5,
logrank_results = list(chisq = 6.25)
)
check_results(dfcount_example)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.