Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从ictreg模型自动计算BIC_R - Fatal编程技术网

从ictreg模型自动计算BIC

从ictreg模型自动计算BIC,r,R,我从列表包提供的ictreg()估计的模型中寻找一种计算贝叶斯信息标准(BIC)的方法,但没有找到答案 例如: library(list) data(race) lm.results <- ictreg(y ~ south + age + male + college, data = race, treat = "treat", J=3, method = "ml") summary(lm.results) 这是我遇到的解决方案。它使用模型使用以

我从
列表
包提供的
ictreg()
估计的模型中寻找一种计算贝叶斯信息标准(BIC)的方法,但没有找到答案

例如:

library(list)

data(race)

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

summary(lm.results)

这是我遇到的解决方案。它使用模型使用以下公式计算BIC:
-2*对数似然+npar*对数(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)
结果与Blair&Imai报告的BIC一致(2012年,第70页)

参考文献

Blair,G.,和Imai,K.(2012)。列表实验的统计分析。政治分析,20(01),47-77

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