问题描述
我使用 sjplot 的 plot_model 函数来绘制回归模型。回归包含一个结果(C,具有 3 个级别)和 1 个连续预测变量 A 和 D 以及一个分类 B。
我想调整构面的名称(例如,更改名称而不是 C 以获得“This is C=0.11”)。有没有办法调整这个?
示例代码:
图书馆(sjplot) 图书馆(sjmisc) 图书馆(sjlabelled)
theme_set(theme_sjplot())
df <- read_csv("stacks.csv")
colnames(df)=c("A","B","C","D")
df$B<-factor(df$B,c(1,2),labels=c("FT","PT"))
model1 <- lm(D ~ A +
relevel(B,ref = "FT")+
A*relevel(B,ref = "FT")+
A*C,data = df)
set_theme( #To remove the background color and the grids
theme.font = 'serif',#To change the font type
axis.title.size = 1.5,#To change axis title size
axis.textsize.x = 1.2,#To change x axis text size
axis.textsize.y = 1.2,title.size=1.5,axis.textcolor = "black",#To change y axis text size
geom.outline.color = "black",axis.line.size = 3,base = theme_bw())
p1<-plot_model(model1,type = "pred",show.p = TRUE,terms = c("A","C"),axis.title = c("","" ),title = "")
(p1_f<-p1+geom_line(size = 1)+ xlim(0,10.00)+ theme(plot.title = element_text(hjust = 0.5))+theme(legend.position = "top"))
示例数据:
structure(list(A = c(2.5,9.5,9,13,9.25,10.25,5,8.25,7.5,7.25,4.5,8.5,8,11.5,5.5,6.5,10.5,1,5.25,3.5,7,9.75,2,6.75,7.75,13.25,6,1.5,4.25,4.75,4,11,15,7),B = structure(c(1L,1L,2L,1L),.Label = c("FT","PT"),class = "factor"),C = c(0.413194444,0.395224172,0.137362637,666,0.0625,0.382352941,0.074074074,0.277472527,0.413194444,0.411111111,0.071428571,0.090659341,0.272058824,0.029220779,0.142857143,0.446428571,0.416666667,0.287878788,0.3,0.208333333,0.076923077,0.273897059,0.252747253,0.577922078,0.2875,0.555860806,0.085416667,0.158333333,0.111111111,0.206043956,0.126482213,0.037878788,0.197802198,0.1375,0.262820513,0.663398693,0.276515152,0.5,0.636363636,0.030701754,0.476190476,0.435897436,0.316544118,0.152380952,0.1,0.454545455,0.188888889,0.273809524,0.538461538,0.022671569,666),D = c(80,180,100,260,140,160,120,130,90,150,190,240,10,110,60,200,20,50,30,40,220,320,80,310,350,340,230,380,1070,160)),row.names = c(NA,-80L),class = c("tbl_df","tbl","data.frame"))
示例输出:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)