-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME.Rmd
More file actions
56 lines (42 loc) · 2.04 KB
/
README.Rmd
File metadata and controls
56 lines (42 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
title: Package eha
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# eha
**eha** is a package for *event history and survival analysis*, with some
enhancements of the *survival* package and many unique features, like *sampling
of risk sets* and the *weird bootstrap* in Cox regression, parametric proportional
hazards and accelerated failure time models allowing for right censoring and left
truncation. You can read more about that and other features in the `vignette("eha")`.
## Installation
The stable version of **eha** is found on *CRAN* and installed in the usual way.
You can install the development version of **eha** from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("goranbrostrom/eha")
```
If you are on Windows, you need to have
[Rtools](https://cran.r-project.org/bin/windows/Rtools/)
installed as well, needed for compiling C and Fortran code.
On Windows, it is a good idea (but not necessary) to install
[MikTeX](https://miktex.org)
so you can get documentation in PDF format.
## Example
This is a basic example which shows you how to solve a common problem: In focus is male mortality in the ages 40--60 and the dependence on social class (SES). Data come from the Skellefteå region in northern Sweden and consists of males born in the time period 1800--1820. It is assumed that mortality follow a Gompertz distribution in both SES classes. The result is adjusted for birth date centered around January 1, 1810.
```{r example}
library(eha)
fit <- phreg(Surv(enter + 40, exit + 40, event) ~ I(birthdate - 1810) + strata(ses),
data = mort, dist = "gompertz")
plot(fit, fn = "haz", col = c("red", "blue"),
main = "Male mortality by social class",
ylab = "Gompertz hazard", xlab = "Age")
```
A *proportional hazards model* seems to be appropriate, and a formal test of proportionality is easy to perform.