This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Why the shape of RCS is contradictory to the p value for nonlinearity.

Hi! I plotted a RCS with ggplot2 package based on my data. The plot looks like a curve obviously, but the p value for nonlinearity = 0.69. enter image description here What went wrong?

I checked the p value with "anova" function, it tells the exactly same value:

>anova(f)
                Wald Statistics          Response: MAFLD 

 Factor          Chi-Square d.f. P     
 logALT           839.22     4   <.0001
  Nonlinear         1.45     3   0.6934
 HBsAg             18.87     1   <.0001
 age_categroty     16.65     3   0.0008
 V1         19.87     1   <.0001
 V2  205.39     1   <.0001
 V3           7.83     3   0.0497
 V4         19.16     3   0.0003
 T2M1             348.41     1   <.0001
 HBP              251.88     1   <.0001
 hyperlipidemia   435.14     1   <.0001
 High_WC         1468.87     1   <.0001
 UA               530.13     1   <.0001
 CREA              18.16     1   <.0001
 V5        22.67     1   <.0001
 AST              217.05     1   <.0001
 DBIL              22.03     1   <.0001
 V6          42.29     1   <.0001
 V7           301.21     1   <.0001
 V8           231.51     1   <.0001
 V9            93.28     1   <.0001
 GGT               55.88     1   <.0001
 TOTAL           5467.91    30   <.0001

The code that i used is listed below:

f <- lrm(MAFLD ~ rcs(logALT,5)+HBsAg+age_categroty+V1+V2+V3+V4+T2M1+HBP+hyperlipidemia+High_WC+UA+CREA+V5+AST+DBIL+V6+V7+V8+V9+GGT, dat)
p <- ggplot(Predict(f7, logALT, fun=exp,ref.zero=TRUE)) + 
  geom_hline(yintercept = 1, color="red",linetype=2)+ 
  theme_bw() +
  ylab("Adjusted OR(95%CI)") +
  annotate("text", x = Inf, y = Inf,
           label = paste("P for nonlinearity", get_pvalue(f7, " Nonlinear")),
           hjust = 1, vjust = 1, size = 4, color = "black") + 
  xlab("logALT(U/L)")+
  labs(caption=element_blank()) +
  theme_classic() 

I have no idea what this is all about. Really appreciate it if you could solve this problem. Thanks in advance!!

rcs ggplot2 ggplot r

0 answers

No answers yet.

Log in to answer this question.