```{r setup, include=FALSE}

library(survival) install.packages(“survminer”) library(survminer)


## Nelson-Aalen Estimator
```{r}
data(rats)  # Load sample dataset
na_est <- survfit(Surv(time, status) ~ 1, data = rats, type = "fleming-harrington")

# Plot Nelson-Aalen Estimator
plot(na_est$cumhaz ~ na_est$time, type = "s", xlab = "Time", ylab = "Cumulative Hazard",
     main = "Nelson-Aalen Estimator", col = "blue")

Interpretation

The Nelson-Aalen plot shows the cumulative hazard over time. The increasing trend indicates an increasing hazard rate as time progresses.

logrank_test <- survdiff(Surv(time, status) ~ sex, data = rats) logrank_test

### Interpretation
The Log-Rank Test checks for survival differences between groups. If the p-value is small (e.g., < 0.05), we reject the null hypothesis and conclude significant survival differences between groups.

## Conclusion
This analysis demonstrates the application of the Nelson-Aalen Estimator and Log-Rank Test in survival analysis. The results indicate significant differences in survival times between groups.