Function

コメント・参照等
  • GLMの結果によるfitted curveを散布図に重ねる関数

FUN = f_ggplot_smooth_glm.r
function (g, data0, x_col = 1, y_col = 2, color = "red", error_dist = "gamma", adoptedlink = "inverse") 
{
    datadf <- data0[, c(x_col, y_col)]
    colnames(datadf) <- c("X", "Y")
    method.args <- list(family = switch(tolower(error_dist), gamma = Gamma(link = adoptedlink)))
    g <- g + geom_smooth(data = datadf, mapping = aes(x = X, y = Y), col = color, method = "glm", method.args = method.args, fullrange = T, se = F, size = 1)
    return(g)
}