Function

コメント・参照等
  • 指定した誤差構造における最尤リンク関数をAICにより求める関数

FUN = f_glm_mle_link.r
function (data0, x_col = 1, y_col = 2, round_digits = 2, error_dist = "gamma", LINKs = c("log", "inverse")) 
{
    datadf <- data0[, c(x_col, y_col)]
    colnames(datadf) <- c("X", "Y")
    AICs <- sapply(LINKs, function(x) AIC(glm(data = datadf, formula = Y ~ X, family = switch(tolower(error_dist), gamma = Gamma(link = x)))))
    mle_link <- LINKs[which.min(AICs)]
    result_aic <- paste0("AIC:", paste0(paste0(LINKs, " = ", round(AICs, round_digits)), collapse = ","))
    return(list(mle_link = mle_link, result_aic = result_aic, AICs = AICs))
}