简体   繁体   English

是否可以使用speedglm,biglm和glm包为logit模型自定义似然函数

[英]Is it possible to customize a likelihood function for logit models using speedglm, biglm, and glm packages

I am trying to fit a customized logistic regression/survival analysis function using the optim / maxBFGS functions in R and literally defining the functions by hand. 我正在尝试使用R中的optim / maxBFGS函数拟合自定义的逻辑回归/生存分析函数,并手动定义函数。

I was always under the impression that for the packages speedglm , biglm , and glm , the likelihood functions for logit models or whatever distribution were hardlocked. 我总是给人印象,对于包speedglmbiglmglm ,对logit模型或任何分布的似然函数进行了speedglm biglm However, I was wondering if I was mistaken or if it was possible to specify my own likelihood functions. 但是,我想知道我是否弄错了,或者是否有可能指定自己的似然函数。 The reason being that optim / maxBFGS is a LOT slower to run than speedglm . 原因是optim / maxBFGSspeedglm运行慢speedglm

The R glm function is set up only to work with likelihoods from the exponential family. 设置R glm函数仅适用于指数族的可能性。 The fitting algorithms won't work with any other kind of likelihood, and with any other you're not in fact fitting a glm but some other kind of model. 拟合算法不适用于任何其他类型的可能性,而对于其他任何一种,您实际上并不是在拟合glm,而是在拟合其他模型。

The glm functions fit using iterated reweighted least squares; glm函数适合使用迭代的加权最小二乘法; the special form of the likelihood function for the exponential families makes Newton's method for solving the max likelihood equations identical to fitting ordinary least squares regression repeatedly until convergence is achieved. 指数族似然函数的特殊形式使牛顿求解最大似然方程的方法等同于重复拟合普通最小二乘回归直到达到收敛。

This is a faster process than generic nonlinear optimization; 这比通用的非线性优化更快。 so if the likelihoods you want to use have been customized so that they are no longer from an exponential family, you are no longer fitting a generalized linear model. 因此,如果您要使用的可能性已经过定制,因此它们不再来自指数族,那么您将不再适合广义线性模型。 This means that the IRWLS algorithm isn't applicable, and the fit will be slower, as you are finding. 这意味着IRWLS算法不适用,并且适合您的需求,因此拟合速度会变慢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM