Survival Analysis Guide logo

Survival Analysis Guide

Community
wentorai
survival-analysis-guide

Conduct Kaplan-Meier, Cox regression, and time-to-event analyses

Overview

Publisherwentorai
Repositoryresearch-plugins
Skill namesurvival-analysis-guide
Stars
294
Forks
42
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by wentorai on GitHub. Read the source before you install it.

Installation

Install the Survival Analysis Guide AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wentorai/research-plugins.git /tmp/research-plugins
mkdir -p .claude/skills
cp -r /tmp/research-plugins/skills/analysis/statistics/survival-analysis-guide .claude/skills/survival-analysis-guide
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Survival Analysis Guide in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Survival Analysis Guide on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Survival Analysis Guide is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Survival Analysis Guide

A skill for conducting time-to-event analyses including Kaplan-Meier estimation, log-rank tests, and Cox proportional hazards regression. Covers censoring concepts, assumption checking, and reporting standards for clinical and social science research.

Core Concepts

What Is Survival Analysis?

Survival analysis studies the time until an event of interest occurs. Despite the name, the "event" need not be death -- it can be any well-defined transition:

Medical:      Time to disease recurrence, death, or recovery
Engineering:  Time to equipment failure
Social:       Time to job termination, divorce, or graduation
Business:     Time to customer churn or first purchase
Ecology:      Time to species extinction in a habitat

Censoring

Right censoring (most common):
  The event has not occurred by the end of the study period.
  Example: Patient is still alive at study end.
  The survival time is "at least T" -- we know T but not the true event time.

Left censoring:
  The event occurred before the observation period began.
  Example: HIV infection detected, but seroconversion happened before testing.

Interval censoring:
  The event occurred between two observation times.
  Example: A patient tests negative at visit 3 and positive at visit 4.

Kaplan-Meier Estimation

Computing the Survival Curve

python
import numpy as np


def kaplan_meier(times: list[float], events: list[int]) -> dict:
    """
    Compute Kaplan-Meier survival estimates.

    Args:
        times: Observed times (event or censoring time)
        events: Event indicator (1 = event occurred, 0 = censored)

    Returns:
        Dict with time points and survival probabilities
    """
    data = sorted(zip(times, events), key=lambda x: x[0])
    n = len(data)

    unique_event_times = sorted(set(t for t, e in data if e == 1))
    survival = 1.0
    results = {"time": [0], "survival": [1.0]}

    at_risk = n
    idx = 0

    for t_event in unique_event_times:
        # Count censored before this event time
        while idx < n and data[idx][0] < t_event:
            if data[idx][1] == 0:
                at_risk -= 1
            idx += 1

        # Count events at this time
        d = sum(1 for t, e in data if t == t_event and e == 1)
        c = sum(1 for t, e in data if t == t_event and e == 0)

        survival *= (at_risk - d) / at_risk
        results["time"].append(t_event)
        results["survival"].append(survival)

        at_risk -= (d + c)
        idx = max(idx, sum(1 for t, _ in data if t <= t_event))

    return results

Using lifelines in Python

python
from lifelines import KaplanMeierFitter

kmf = KaplanMeierFitter()
kmf.fit(durations=time_column, event_observed=event_column, label="Overall")

# Plot the survival curve
kmf.plot_survival_function()

# Median survival time
print(f"Median survival: {kmf.median_survival_time_}")

# Survival probability at specific time
print(f"5-year survival: {kmf.predict(5.0):.3f}")

Log-Rank Test

Comparing Survival Between Groups

python
from lifelines.statistics import logrank_test

results = logrank_test(
    durations_A=group_a_times,
    durations_B=group_b_times,
    event_observed_A=group_a_events,
    event_observed_B=group_b_events
)

print(f"Test statistic: {results.test_statistic:.3f}")
print(f"p-value: {results.p_value:.4f}")

The log-rank test is the standard method for comparing two or more survival curves. It tests the null hypothesis that the survival functions are identical. It is most powerful when hazards are proportional (consistent relative risk over time).

Cox Proportional Hazards Regression

Model Fitting

python
from lifelines import CoxPHFitter
import pandas as pd

cph = CoxPHFitter()
cph.fit(
    df,
    duration_col="time",
    event_col="event",
    formula="age + treatment + stage"
)

cph.print_summary()

# Hazard ratios
print(cph.summary[["exp(coef)", "exp(coef) lower 95%", "exp(coef) upper 95%", "p"]])

Interpreting Hazard Ratios

Hazard Ratio (HR) = exp(coefficient)

HR = 1.0   No effect
HR > 1.0   Increased hazard (worse survival)
HR < 1.0   Decreased hazard (better survival)

Example output:
  treatment:  HR = 0.65, 95% CI [0.48, 0.88], p = 0.005
  Interpretation: Treatment group has 35% lower hazard of the event
                  compared to the control group.

Checking the Proportional Hazards Assumption

python
# Schoenfeld residuals test
cph.check_assumptions(df, p_value_threshold=0.05, show_plots=True)

If the proportional hazards assumption is violated, consider: stratified Cox models, time-varying covariates, or accelerated failure time (AFT) models as alternatives.

Reporting Standards

STROBE-style Reporting for Survival Analyses

1. Report number of events and total person-time at risk
2. Present Kaplan-Meier curves with number-at-risk tables
3. Report median survival with 95% confidence intervals
4. Report hazard ratios with 95% CIs and p-values
5. State which covariates were included in adjusted models
6. Report proportional hazards assumption test results
7. Specify the handling of tied event times (Efron, Breslow)
8. Note any competing risks and how they were handled

Frequently asked questions

What does the Survival Analysis Guide AI skill do?

Conduct Kaplan-Meier, Cox regression, and time-to-event analyses

Why use Survival Analysis Guide on TypingMind?

Because you install it once and use it with any model. Survival Analysis Guide is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Survival Analysis Guide in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wentorai/research-plugins/tree/main/skills/analysis/statistics/survival-analysis-guide. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Survival Analysis Guide?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Survival Analysis Guide?

As many as you like. As long as a model supports skills, you can use Survival Analysis Guide with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Survival Analysis Guide AI skill free?

Yes. It is published on GitHub by wentorai under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇