【问题标题】:mlogit package in R: with alternative specific variables and without interceptR中的mlogit包:具有替代特定变量且无截距
【发布时间】:2020-04-15 15:07:06
【问题描述】:

我是 R 新手,我正在尝试运行一个带有替代特定变量且没有截距的 logit 模型。我检查了文档,但似乎当我使用替代特定变量运行模型时,总是包含截距。谁能告诉我如何在不拦截的情况下运行模型?谢谢。 以下是我尝试过的。我在R中使用mlogit包中的数据集Fishing。

m.fishing.1 <- mlogit(mode ~ price + catch | income, data = df.fishing, reflevel = "beach");

【问题讨论】:

    标签: r mlogit


    【解决方案1】:

    在模型公式规范中使用 +0 来排除截距。来自mlogit::mFormula()的帮助:

    data("Fishing", package = "mlogit")
    Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice =
                          "mode")    
    f3 <- mFormula(mode ~ price + catch | income + 0)
    mlogit(f3,Fish)
    

    ...和输出:

    > mlogit(f3,Fish)
    
    Call:
    mlogit(formula = mode ~ price + catch | income + 0, data = Fish,     method = "nr")
    
    Coefficients:
             price           catch     income:boat  income:charter     income:pier  
       -2.1597e-02      7.1208e-01      2.1014e-04      2.4498e-04      3.1272e-05  
    
    > 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多