| Title: | Convert Regression Between Base Function and 'rms' Package |
|---|---|
| Description: | We perform linear, logistic, and cox regression using the base functions lm(), glm(), and coxph() in the R software and the 'survival' package. Likewise, we can use ols(), lrm() and cph() from the 'rms' package for the same functionality. Each of these two sets of commands has a different focus. In many cases, we need to use both sets of commands in the same situation, e.g. we need to filter the full subset model using AIC, and we need to build a visualization graph for the final model. 'base.rms' package can help you to switch between the two sets of commands easily. |
| Authors: | Jing Zhang [aut, cre], Zhi Jin [aut] |
| Maintainer: | Jing Zhang <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0 |
| Built: | 2026-05-14 07:04:39 UTC |
| Source: | https://github.com/cran/base.rms |
Convert results of cox regression from coxph() in 'survival' package to cph() in 'rms' package.
coxph2cph(fit)coxph2cph(fit)
fit |
cox regression results of coxph() |
results of coxph()
library(survival) fit <- coxph(Surv(mpg,vs)~am+gear+carb,data=mtcars) coxph2cph(fit)library(survival) fit <- coxph(Surv(mpg,vs)~am+gear+carb,data=mtcars) coxph2cph(fit)
Convert results of cox regression from cph() in 'rms' package to coxph() in 'stats' package.
cph2coxph(fit)cph2coxph(fit)
fit |
cox regression results of cph() |
results of coxph()
library(rms) fit <- cph(formula = Surv(mpg, vs) ~ am + gear + carb, data = mtcars) cph2coxph(fit)library(rms) fit <- cph(formula = Surv(mpg, vs) ~ am + gear + carb, data = mtcars) cph2coxph(fit)
Convert results of lm() from 'stats' package to ols() from 'rms' package.
lm2ols(fit)lm2ols(fit)
fit |
reults of lm() |
results of ols()
fit <- lm(mpg ~ disp,data=mtcars) lm2ols(fit)fit <- lm(mpg ~ disp,data=mtcars) lm2ols(fit)
Convert results of logistic regression from glm() in 'stats' package to lrm() in 'rms' package.
logit2lrm(fit)logit2lrm(fit)
fit |
logistic regression reults of glm() |
results of lrm()
fit <- glm(vs~mpg+cyl,data=mtcars, family = binomial(link = 'logit')) logit2lrm(fit)fit <- glm(vs~mpg+cyl,data=mtcars, family = binomial(link = 'logit')) logit2lrm(fit)
Convert results of logistic regression from lrm() in 'rms' package to glm() in 'stats' package.
lrm2logit(fit)lrm2logit(fit)
fit |
logistic regression reults of lrm() |
results of glm()
library(rms) fit <- lrm(vs ~ mpg + cyl, data = mtcars) lrm2logit(fit)library(rms) fit <- lrm(vs ~ mpg + cyl, data = mtcars) lrm2logit(fit)
Convert results of ols() from 'rms' package to lm() from 'stats' package.
ols2lm(fit)ols2lm(fit)
fit |
reults of ols() |
results of lm()
library(rms) fit <- ols(mpg ~ disp^2,data=mtcars) ols2lm(fit)library(rms) fit <- ols(mpg ~ disp^2,data=mtcars) ols2lm(fit)