【问题标题】:Plotting beta coefficients from lmList?从lmList绘制β系数?
【发布时间】:2021-01-19 02:03:20
【问题描述】:

我使用以下代码计算逻辑回归的系数:

model<-lmList(VariableD ~ VariableE + VariableF + VariableG | Participant, database, family = binomial(link = "logit"))

输出样本为:

  (Intercept)     VariableE   VariableF   VariableG
19   3.2665591 -0.0132012216 -0.25732617  0.26778854
20  -3.4393826  0.0194122526  1.03047235  0.78898713
21   1.2678461 -0.0010176256  0.09012313 -0.01289391
22  -0.7699174  0.0023954388  0.54327987 -0.31296745
23   1.3254696 -0.0034261267 -0.51176849 -0.71606725
24  -4.7511126  0.0435291070  0.31071099  0.10152898
25   0.4081270  0.0007494644 -0.16591073 -0.23714568
26  -2.7565715  0.0085388717  0.18503239  0.24941414
27  -2.2610725  0.0138908941 -0.34104256 -0.87318270

现在我想绘制这些值。谢谢!!

【问题讨论】:

    标签: r regression lme4 nlme


    【解决方案1】:

    我们可以将数据转换为“长”格式,然后使用ggplot 进行绘图

    library(dplyr)
    library(tidyr)
    library(ggplot2)
    model %>%
       coef(.) %>%
       mutate(rn = row_number()) %>%
       pivot_longer(cols = -rn) %>%
       ggplot(aes(x = rn, y = value, color = name)) + 
            geom_line()
    

    【讨论】:

    • UseMethod("mutate_") 中的错误:没有适用于 'mutate_' 的方法应用于类“c('lmList4', 'list', 'vector')” 的对象另外:警告消息:mutate_() 自 dplyr 0.7.0 起已弃用。请改用mutate()。有关更多帮助,请参阅 vignette('programming')
    • @Christina 我从model中提取了coef
    猜你喜欢
    • 2015-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-04
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多