0
votes

I'm trying to run the following code, but I got this error Error in unclass(x)[i, , drop = FALSE] : (subscript) logical subscript too long

library ( survival ) 
library(KMsurv)
data("tongue")
tongue
Weibull.1<-survreg(Surv(times,censor)~1, data=tongue, subset=(group==1),scale=1,dist="weibull")
Weibull.2<-survreg(Surv(times,censor)~1, data=tongue, subset=(group==2),scale=1,dist="weibull")

How can I avoid this error?

1
Error: object 'times' not found. (change to time) ..... Error: object 'censor' not found. (change to delta) .... Error: object 'group' not found. SighEdward
I got another error. Warning message: In survreg.fit(X, Y, weights, offset, init = init, controlvals = control, : Ran out of iterations and did not convergeDana

1 Answers

0
votes

I'm not really sure what were you doing. All the variables you were specifying were not present in the dataset. Tongue has only 3 variables, type, time and delta. If you correct those then you'll get your answer.

survreg(Surv(time, delta) ~ 1,
        data = tongue,
        subset = ( type == 1),
        scale = 1,
        dist = "weibull")

Call:
survreg(formula = Surv(time, delta) ~ 1, data = tongue, subset = (type == 
    1), dist = "weibull", scale = 1)

Coefficients:
(Intercept) 
   4.911231 

Scale fixed at 1 

Loglik(model)= -183.2   Loglik(intercept only)= -183.2
n= 52