---
title: "tutorial"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{tutorial}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
## package preparation
```{r,warning=FALSE,message=FALSE}
library(rms)
library(base.rms)
library(survival)
```
## 1. transform between linear regressions
### base to rms
```{r,warning=FALSE}
fit <- lm(mpg~cyl+vs,data=mtcars)
lm2ols(fit)
```
### rms to base
```{r}
fit <- ols(mpg~cyl+vs,data=mtcars)
ols2lm(fit)
```
## 2. transform between logistic regressions
### base to rms
```{r}
fit <- glm(vs~mpg,data=mtcars,family = binomial(link='logit'))
logit2lrm(fit)
```
### rms to base
```{r}
fit <- lrm(vs~mpg,data=mtcars)
lrm2logit(fit)
```
## 3. transform between cox regressions
### base to rms
```{r}
fit <- coxph(Surv(mpg,vs)~am+gear,data=mtcars)
coxph2cph(fit)
```
### rms to base
```{r}
fit <- cph(Surv(mpg,vs)~am+gear,data=mtcars)
cph2coxph(fit)
```