mclements / rstpm2

An R package for generalised survival models
28 stars 11 forks source link

Delayed entry model #2

Closed RobertReynolds1 closed 9 years ago

RobertReynolds1 commented 9 years ago

Hi there,

Firstly, many thanks for sharing this package, it's great to be able to build stpm2 models in R; however, I'm having issues generating a delayed entry model (I have the latest version of your package installed from github and am working in Windows 7)...

I found your example R code for the breast cancer dataset but it's causing an error:

library("rstpm2") data(brcancer2) brcancer2 <- transform(brcancer,startTime=ifelse(hormon==0,rectime*0.5,0))

summary(fit <- stpm2(Surv(startTime,rectime,censrec==1)~hormon,data=brcancer2, logH.formula=~nsx(log(rectime),df=3,stata=TRUE)))

Error in summary(fit <- stpm2(Surv(startTime, rectime, censrec == 1) ~ : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: !delayed is not TRUE

I tried to fix this as follows but then get a different error:

summary(fit <- stpm2(Surv(startTime,rectime,censrec==1, type="counting")~hormon,data=brcancer2, logH.formula=~nsx(log(rectime),df=3,stata=TRUE)))

Error in summary(fit <- stpm2(Surv(startTime, rectime, censrec == 1, type = "counting") ~ : error in evaluating the argument 'object' in selecting a method for function 'summary': Error in quantile.default(x[!outside], round(knots, 2), type = 2) : missing values and NaN's not allowed if 'na.rm' is FALSE

So I then tried the following but get a different error again:

summary(fit <- stpm2(Surv(startTime,rectime,censrec==1, type="counting")~hormon,data=brcancer2, logH.formula=~nsx(log(rectime),df=3,stata=TRUE,Boundary.knots = c(2.079442, 7.885705),knots= c(6.591742, 7.292133))))

Error in summary(fit <- stpm2(Surv(startTime, rectime, censrec == 1, type = "counting") ~ : error in evaluating the argument 'object' in selecting a method for function 'summary': Error in rep.int(1L:nx, rep.int(ord, nx)) : invalid 'times' value

Now I'm stumped as to how to fix it! Any support would be much appreciated.

Many thanks, RR

mclements commented 9 years ago

Robert,

This is a question that I may be able to answer: you need data(brcancer) rather than data(brcancer2). Does that help?

On a related topic: the "develop" branch has some bug fixes that have not yet been pushed to the main branch.

Kindly, Mark.

On 11/05/2014 05:19 PM, RobertReynolds1 wrote:

Hi there,

Firstly, many thanks for sharing this package, it's great to be able to build stpm2 models in R; however, I'm having issues generating a delayed entry model (I have the latest version of your package installed from github and am working in Windows 7)...

I found your example R code for the breast cancer dataset but it's causing an error:

library("rstpm2") data(brcancer2) brcancer2 <- transform(brcancer,startTime=ifelse(hormon==0,rectime*0.5,0))

summary(fit <- stpm2(Surv(startTime,rectime,censrec==1)~hormon,data=brcancer2, logH.formula=~nsx(log(rectime),df=3,stata=TRUE)))

Error in summary(fit <- stpm2(Surv(startTime, rectime, censrec == 1) ~ : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: !delayed is not TRUE

I tried to fix this as follows but then get a different error:

summary(fit <- stpm2(Surv(startTime,rectime,censrec==1, type="counting")~hormon,data=brcancer2, logH.formula=~nsx(log(rectime),df=3,stata=TRUE)))

Error in summary(fit <- stpm2(Surv(startTime, rectime, censrec == 1, type = "counting") ~ : error in evaluating the argument 'object' in selecting a method for function 'summary': Error in quantile.default(x[!outside], round(knots, 2), type = 2) : missing values and NaN's not allowed if 'na.rm' is FALSE

So I then tried the following but get a different error again:

summary(fit <- stpm2(Surv(startTime,rectime,censrec==1, type="counting")~hormon,data=brcancer2, logH.formula=~nsx(log(rectime),df=3,stata=TRUE,Boundary.knots = c(2.079442, 7.885705),knots= c(6.591742, 7.292133))))

Error in summary(fit <- stpm2(Surv(startTime, rectime, censrec == 1, type = "counting") ~ : error in evaluating the argument 'object' in selecting a method for function 'summary': Error in rep.int(1L:nx, rep.int(ord, nx)) : invalid 'times' value

Now I'm stumped as to how to fix it! Any support would be much appreciated.

Many thanks, RR

— Reply to this email directly or view it on GitHubhttps://github.com/mclements/rstpm2/issues/2.

RobertReynolds1 commented 9 years ago

Hi Mark,

Sorry, that was a typo, the R code I had was data(brcancer) rather than data(brcancer2).

However, using the "develop" branch has fixed things for me so thanks very much!

Best, RR