Re: [R] half-logistic distribution

2014-12-29 Thread Ben Bolker
Therneau, Terry M., Ph.D.  mayo.edu> writes:

> 
> 
> On 12/26/2014 05:00 AM, r-help-request  r-project.org wrote:
> > i want to analyse survival data using typeI HALF LOGISTIC
> > DISTRIBUTION.how can i go about it?it installed one on R in the
> > survival package didn't include the distribution...or i need a code to
> > use maximum likelihood to estimate the parameter in survival
> > analysis.a typical example of distribution other than that installed
> > in R will help.thanks
> >
 
> I am the author of the survival package, and had never heard of the
> "type I half-logistic" before.  New distributions can be added to
> survreg() if they can be represented as location-scale families; I
> don't think that your distribution can be written in that way.  Look
> at "survival" under the "Task Views" tab (upper left corner) of the
> cran.org web page

  I don't know about 'type I' but based on

http://en.wikipedia.org/wiki/Half-logistic_distribution

   you could try

dhalflogist <- function(x,s,log=FALSE) {
r <- log(2)-log(s)-x/s-2*log(1+exp(-x/s))
if (log) r else exp(r)
}
phalflogist <- function(q,s) { (1-exp(-q/s))/(1+exp(-(q/s))) }
rhalflogist <- function(n,s) { abs(rlogis(n,scale=s)) }
set.seed(101)
rr <- rhalflogist(1,2)
hist(rr,freq=FALSE,breaks=80,col="gray")
curve(dhalflogist(x,2),add=TRUE,col=2,lwd=2)

d <- data.frame(rr)
library("bbmle")
m1 <- mle2(rr~dhalflogist(s=exp(logs)),start=list(logs=0),data=d)

  If you want to fit multiple groups etc., see the 'parameters'
argument of ?mle2

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] half-logistic distribution

2014-12-29 Thread Therneau, Terry M., Ph.D.



On 12/26/2014 05:00 AM, r-help-requ...@r-project.org wrote:

i want to analyse survival data using typeI HALF LOGISTIC
DISTRIBUTION.how can i go about it?it installed one on R in the
survival package didn't include the distribution...or i need a code to
use maximum likelihood to estimate the parameter in survival
analysis.a typical example of distribution other than that installed
in R will help.thanks



I am the author of the survival package, and had never heard of the "type I half-logistic" 
before.
New distributions can be added to survreg() if they can be represented as location-scale 
families; I don't think that your distribution can be written in that way.


Look at "survival" under the "Task Views" tab (upper left corner) of the cran.org web page 
-- someone else may have already done it.


Terry T.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.