【问题标题】:Automatically calculating BIC from ictreg model从 ictreg 模型自动计算 BIC
【发布时间】:2018-06-18 21:48:03
【问题描述】:

我寻找一种方法来计算贝叶斯信息准则 (BIC),该方法由 ictreg() 估计的模型(由 list 包提供,但没有找到答案。

例子:

library(list)

data(race)

lm.results <- ictreg(y ~ south + age + male + college, data = race, 
                 treat = "treat", J=3, method = "ml")

summary(lm.results)

结果:

Item Count Technique Regression 

Call: ictreg(formula = y ~ south + age + male + college, data = race, 
    treat = "treat", J = 3, method = "ml")

Sensitive item 
                Est.    S.E.
(Intercept) -5.50833 1.02112
south        1.67564 0.55855
age          0.63587 0.16334
male         0.84647 0.49375
college     -0.31527 0.47360

Control items 
                Est.    S.E.
(Intercept)  1.19141 0.14369
south       -0.29204 0.09692
age          0.03322 0.02768
male        -0.25060 0.08194
college     -0.51641 0.08368

Log-likelihood: -1444.394

Number of control items J set to 3. Treatment groups were indicated by '1' and the control group by '0'.

【问题讨论】:

    标签: r


    【解决方案1】:

    这是我遇到的解决方案。它使用该模型使用以下公式计算 BIC:-2*log-likelihood + npar*log(nobs),其中 npar 表示参数的数量,而 nobs 表示拟合模型中的观察数

    以下函数计算 BIC:

    bic_ictreg <- function(fit) {
      # Check if method is "ml". Stop if not.
      if(fit[["method"]] != "ml") {
        stop("Function needs a model that uses the Expectation-Maximization algorithm to estimate. Use method = 'ml' within ictreg")
      }
    
      # Calculate BIC
      -2*fit[["llik"]] + (length(fit[["par.treat"]]) + 
                            length(fit[["par.control"]])) * 
        log(length(fit[["pred.post"]]))
    }
    
    bic_ictreg(lm.results)
    

    上面的例子:

    library(list)
    
    data(race)
    
    lm.results <- ictreg(y ~ south + age + male + college, data = race, 
                     treat = "treat", J=3, method = "ml")
    
    bic_ictreg(lm.results)
    

    结果:

    [1] 2959.797
    

    结果与 Blair & Imai (2012, p. 70) 报告的 BIC 一致。

    参考

    Blair, G. 和 Imai, K.(2012 年)。列表实验的统计分析。 政治分析, 20(01), 47–77. https://doi.org/10.1093/pan/mpr048

    【讨论】:

      猜你喜欢
      • 2016-05-09
      • 1970-01-01
      • 2018-02-21
      • 2018-02-09
      • 2016-11-15
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2015-11-24
      相关资源
      最近更新 更多