multinomial logistic multilevel models in R

后端 未结 6 1280
甜味超标
甜味超标 2021-01-29 21:57

Problem: I need to estimate a set of multinomial logistic multilevel models and can’t find an appropriate R package. What is the best R package to estimate such

6条回答
  •  离开以前
    2021-01-29 22:05

    An older question, but I think a viable option has recently emerged is brms, which uses the Bayesian Stan program to actually run the model For example, if you want to run a multinomial logistic regression on the iris data:

    b1 <- brm (Species ~ Petal.Length + Petal.Width + Sepal.Length + Sepal.Width,
               data=iris, family="categorical",
               prior=c(set_prior ("normal (0, 8)")))
    

    And to get an ordinal regression -- not appropriate for iris, of course -- you'd switch the family="categorical" to family="acat" (or cratio or sratio, depending on the type of ordinal regression you want) and make sure that the dependent variable is ordered.

    Clarification per Raphael's comment: This brm call compiles your formula and arguments into Stan code. Stan compiles it into C++ and uses your system's C++ compiler -- which is required. On a Mac, for example, you may need to install the free Developer Tools to get C++. Not sure about Windows. Linux should have C++ installed by default.)

    Clarification per Qaswed's comment: brms easily handles multilevel models as well using the R formula (1 | groupvar) to add a group (random) intercept for a group, (1 + foo | groupvar) to add a random intercept and slope, etc.

提交回复
热议问题