8
$\begingroup$

I am trying to fit generalized linear model for weibull family, but when I try it in R, it gives an error. I know that weibull does not fit in exponential family, but I have read some research articles about fitting GLM for weibull family. If anyone can help me with this, I really appreciate. It gives the following error.

> data(lung)
> glm(time ~ age+sex+ph.ecog+ wt.loss, family = weibull(link='log'), data = lung)
Error in glm(time ~ age + sex + ph.ecog + wt.loss, family = weibull(link = "log"),  : 
  could not find function "weibull"
$\endgroup$
4
$\begingroup$

Sorry i'm quite late with this.... but might help someone i believe :

gamlss package is what you should be looking for. It supports almost all the distributions( not just exponential family ones). It gives amazing flexibility on almost all the parameters of a distribution.

$\endgroup$
  • 3
    $\begingroup$ +1. gamlss supports the Weibull distribution via WEI, WEI2 and WEI3, all 2-parameter though obviously different. Not sure if it supports censoring, though, which would be a key element of an AFT survival model. $\endgroup$ – Wayne Apr 26 '17 at 21:09
  • $\begingroup$ @Wayne gamlss definitely supports right censoring and left truncation also ....both also if wanted $\endgroup$ – user3801801 Apr 27 '17 at 11:31
3
$\begingroup$

The glm() function does not support the Weibull distribution in R unfortunately. You can try ?family to see which distributions are available. I would try using survreg() from the survival package instead.

$\endgroup$
  • $\begingroup$ yeah glm() do not support weibull. I am trying to use glm approach and AFT model using survreg, then compare the results of two methods. That is why I tried to figure it out to fit glm for weibull. Thank you for your comments. I appreciate it. $\endgroup$ – NiroshaR Jul 26 '16 at 4:26
1
$\begingroup$

I have used the brms package, which is Bayesian. It supports the Weibull, exponential, lognormal, Frechet, and other families and (left/right/interval) censoring so implements AFT models. It also includes random effects which are known in survival models as "frailty", and a host of other regression options like gam-style smoothers.

Since Bayesian approaches use MCMC sampling, it's slower than glm, gamlss, or survreg, but it's also a comprehensive regression solution, and being Bayesian has other advantages. (I love it's stanplot, which provides a host of illuminating diagnostic plots.)

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.