Clinically, the dependent variable and the clinical outcome are sometimes not linearly related, and the regression model has an important assumption that the independent variable and the dependent variable are linearly related, so the nonlinear relationship model is limited by regression analysis. Therefore, a better solution is to fit the nonlinear relationship between the independent variable and the dependent variable. Restricted cubic spline (RCS) is one of the most common methods to analyze the nonlinear relationship.
In recent years, high-scoring SCI, such as The Lancet and BMJ, often use RCS to express non-linear relationships. Today we will teach you how to use R language to draw restricted cubic spline (RCS) bar graphs.
We are using a cancer data set that comes with the R language. First, import the data into RStudio to
import the survival and rms you need to download.
Delete the missing values, integrate the data,
establish the COX regression equation,
import the drawing package to
draw the graph, where rcs is Use the method of limiting the cube bar graph. Here you can also change other methods as needed. Geom_point here is the definition of scatter points.
You can also further beautify the picture. I won’t say more here. If you want to get the data in this article, you can follow the official account . contact me.
Teach you how to use R language to make restricted cube bar graphs
Guess you like
Origin blog.csdn.net/dege857/article/details/108864144
Recommended
Ranking