survHE
                                
                                
                                
                                    survHE copied to clipboard
                            
                            
                            
                        Issue with make.transition.probs function
Hi Gianluca, many thanks for having developed this useful package.
I have some issue using the function make.transition.probs The function only works when I input a model (created with make.surv) where the nsim value equals the t intervals. In all other cases the error is:
Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent
Also, the output of the function is not fully clear to me.
I hope my question is not too naïve, I'm new to R
Thanks in advance for your kind answer
Lorenzo
@LorenzC91 thanks for this. Can I ask for more info (and possibly a replicable example) in order to debug your problem? In any case, make.transition.probs (which is being updated in the devel version of survHE) does take as input a survHE object, i.e. the output of a call to fit.models and uses the underlying survival curves to approximate the transition probabilities (indicating the chance of moving from "Non event" to "Event" between two consecutive times --- here "Non event" and "Event" depend of course on what you're modelling, for instance pre- and post-progression or pre-progression and death).
I'm not sure I follow your point about nsim above --- perhaps if you have a coded example I can help debug.
Hi Gianluca, thanks for your prompt and kind reply.
Here is the code I used:
`library(survHE)
dataset<-data
dataset$event<-NA
dataset[dataset$censored==0, 9]<-1
dataset[dataset$censored==1, 9]<-0
fitted_curves<-fit.models(formula = Surv(time, event)~1, data = dataset, distr = c("exponential", "weibull", "gompertz", "gamma", "loglogistic", "lognormal"))
survival_curves<-make.surv(fitted_curves, mod = 1, t=c(0:10))
make.transition.probs(survival_curves)`
Using this code gives the error I mentioned above as output.
If instead I use this:
`survival_curves<-make.surv(fitted_model, mod = 1, t=c(0:10), nsim=10)
make.transition.probs(survival_curves)`
then I have an output, even if it is a bit confusing, since I have 10 rows (which I suppose are the transition probabilities in each of the 10 time points) and 10 columns (I can immagine one column for each simulation).
You said that "make.transition.probs does take as input a survHE object, i.e. the output of a call to fit.models", but I see in the Reference manual that make.transition.probs takes as input "an object obtained as output of the call to make.surv" (pag 9). Am I missing something?
Thanks a lot for your help and patience, I really appreciate
Have a nice evening!
@LorenzC91 thanks. You're right that make.transition.probs does take a make.surv output not a fit.models one. Apologies --- it's just I'm fiddling with the function in the new version, like I said, and I got confused...
In terms of the worked example, it's not really reproducible though --- what is the data object? Is it one of the datasets included in survHE? Or your own? And why do you set event to NA? I am not even sure fit.models would actually run if you passed the event indicator as an empty variable...
Hi Gianluca,
thanks for the clarification regarding the input object.
Regarding the data object: yes, is the dataset included in survHE.
Regarding the event variable: it's not set to NA, but I set it to be 0 if the censored variable is 1 and to be 1 if the censored variable is 0 (3rd and 4th line of the code)(The same can be done using dplyr::mutate together with dplyr::case_when, if you prefer).
Regarding the reproducibility of my code:
actually if you copy and paste it in you R studio it should work. It generates the fitted model and the curves.
The only issue I have is with make.transition.probs, which gives me the error reported above.
Thanks and have a nice day!
@LorenzC91: my apologies for the confusion, you caught me in a moment when I was trying to juggle too many things and I got confused myself...
So: in the current version of survHE (the one on CRAN: version 1.1.2) you need to use as input for make.transition.probs the object obtained as the output to the call to make.surv. But I have been making changes and improvements to some of the functions (including make.transition.probs!) and the devel version (which you can find here) has changed this behaviour and you need to pass the output to fit.models as input.
If you install that version (which doesn't change the core of the package, but it's updated with respect to make.transition.probs), you get the following
library(survHE)
dataset<-data
dataset$event<-NA
dataset[dataset$censored==0, 9]<-1
dataset[dataset$censored==1, 9]<-0
fitted_curves<-fit.models(formula = Surv(time, event)~1, data = dataset,
distr = c("exponential", "weibull", "gompertz", "gamma", "loglogistic", "lognormal"))
make.transition.probs(fitted_curves,nsim=2)
# A tibble: 215 x 4
   profile     t lambda_1 lambda_2
   <chr>   <dbl>    <dbl>    <dbl>
 1 =        0.03  0.00232  0.00239
 2 =        0.52  0.0373   0.0383 
 3 =        0.79  0.0207   0.0213 
 4 =        0.92  0.0100   0.0103 
 5 =        1.02  0.00772  0.00793
 6 =        1.25  0.0177   0.0182 
 7 =        1.44  0.0146   0.0150 
 8 =        1.48  0.00310  0.00318
 9 =        1.61  0.0100   0.0103 
10 =        1.64  0.00232  0.00239
# … with 205 more rows
# Or setting up the times
> make.transition.probs(fitted_curves,nsim=2,t=seq(0,10))
# A tibble: 11 x 4
   profile     t lambda_1 lambda_2
   <chr>   <dbl>    <dbl>    <dbl>
 1 =           0   0        0     
 2 =           1   0.0674   0.0681
 3 =           2   0.0674   0.0681
 4 =           3   0.0674   0.0681
 5 =           4   0.0674   0.0681
 6 =           5   0.0674   0.0681
 7 =           6   0.0674   0.0681
 8 =           7   0.0674   0.0681
 9 =           8   0.0674   0.0681
10 =           9   0.0674   0.0681
11 =          10   0.0674   0.0681
which I think is what you want (there are as many columns as simulations, in the resulting object with the various transition probabilities at each time).
Hi Gianluca! Thanks a lot for your answer. Sorry for the delay, I'm having a super busy week and couldn't find the time to check the updated version yet. I come back to you with a feedback as soon as I can
Have a nice weekend!
No probs!
On Sat, 24 Apr 2021 at 10:51, LorenzC91 @.***> wrote:
Hi Gianluca! Thanks a lot for your answer. Sorry for the delay, I'm having a super busy week and couldn't find the time to check the updated version yet. I come back to you as soon as I can
Have a nice weekend!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/giabaio/survHE/issues/37#issuecomment-826066825, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCRVSLNV5BBILGCTUA7GJLTKKIAHANCNFSM426G74RQ .
--
Gianluca Baio
Professor of Statistics & Health Economics Department of Statistical Science University College London 1-19 Torrington Place, London WC1E 6BT, UK Telephone +44(0)20 7679 1248 (internal: 41248) Twitter: @stats_UCL https://twitter.com/stats_UCL Website: http://www.homepages.ucl.ac.uk/~ucakgba http://www.homepages.ucl.ac.uk/~ucakgba/ Blog: http://www.statistica.it/gianluca/blog/
[image: https://twitter.com/gianlubaio] https://twitter.com/gianlubaio https://www.linkedin.com/in/gianluca-baio-b893879/ https://github.com/giabaio https://scholar.google.com/citations?user=ro0QvGsAAAAJ&hl=en https://www.researchgate.net/profile/Gianluca_Baio[image: https://www.linkedin.com/in/gianluca-baio-b893879/] https://www.linkedin.com/in/gianluca-baio-b893879/ This email may reach you outside of your working hours. If that's the case, please do not feel pressure to reply immediately.
Hi Gianluca, I downloaded the devel version and now the function is working properly :-) Thanks a lot for your help and congratulations again for your work with this package
Have a nice evening!
Lorenzo
Cool! Thank you. G
On Wed, 28 Apr 2021 at 23:56, LorenzC91 @.***> wrote:
Hi Gianluca, I downloaded the devel version and now the function is working properly :-) Thanks a lot for your help and congratulations again for your work with this package
Have a nice evening!
Lorenzo
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/giabaio/survHE/issues/37#issuecomment-828833363, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCRVSJZJX7GYT6IQBRTTKTTLCHBXANCNFSM426G74RQ .
--
Gianluca Baio
Professor of Statistics & Health Economics Department of Statistical Science University College London 1-19 Torrington Place, London WC1E 6BT, UK Telephone +44(0)20 7679 1248 (internal: 41248) Twitter: @stats_UCL https://twitter.com/stats_UCL Website: http://www.homepages.ucl.ac.uk/~ucakgba http://www.homepages.ucl.ac.uk/~ucakgba/ Blog: http://www.statistica.it/gianluca/blog/
[image: https://twitter.com/gianlubaio] https://twitter.com/gianlubaio https://www.linkedin.com/in/gianluca-baio-b893879/ https://github.com/giabaio https://scholar.google.com/citations?user=ro0QvGsAAAAJ&hl=en https://www.researchgate.net/profile/Gianluca_Baio[image: https://www.linkedin.com/in/gianluca-baio-b893879/] https://www.linkedin.com/in/gianluca-baio-b893879/ This email may reach you outside of your working hours. If that's the case, please do not feel pressure to reply immediately.