[R] survreg help in R

David Winsemius dwinsemius at comcast.net
Sun Mar 8 19:25:09 CET 2009


I think R and survival took a look at what you provided for a formula  
to survreg and rejected it because it had no lh-rh separator, "~", and  
thus no rh terms. Turns out that it also expects a dataframe even if  
both terms for the Surv function are already given and there is  
nothing further to be evaluated. Try adding:
 > dft <- data.frame(times=times, censor=censor)
 > survreg(Surv(times,censor) ~ , dist='weibull', data=dft)
Error: syntax error
 > survreg(Surv(times,censor) ~ ., dist='weibull', data=dft)
Call:
survreg(formula = Surv(times, censor) ~ ., data = dft, dist = "weibull")

Coefficients:
(Intercept)
    4.591518

Scale= 0.5965153

Loglik(model)= -50.4   Loglik(intercept only)= -50.4
n= 18

-- 


On Mar 8, 2009, at 1:34 PM, murphy82nd wrote:

>
> Hey all,
> I am trying to use the survreg function in R to estimate the mean and
> standard deviation to come up with the MLE of alpha and lambda for the
> weibull distribution.  I am doing the following:
> times<-c(10,13,18,19,23,30,36,38,54,56,59,75,93,97,104,107,107,107)
> censor<-c(1,0,0,1,0,1,1,0,0,0,1,1,1,1,0,1,0,0)
> survreg(Surv(times,censor),dist='weibull')
> and I get the following error:
>> survreg(Surv(times,censor),dist='weibull')
> Error in x$terms : $ operator is invalid for atomic vectors
>
> I am fairly new to R and don't understand what I am doing wrong.   
> Any help
> would be great.
> -- 
> View this message in context: http://www.nabble.com/survreg-help-in-R-tp22400405p22400405.html
> Sent from the R help mailing list archive at Nabble.com.
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list