Closed IlhemB closed 1 month ago
Hi Ilhem,
Thanks for the message. The parameters are coefficients associated with the transition probabilities, not the transition probabilities themselves (we denote these $\alpha_0, \alpha_1, \dots, \alpha_p$). The coefficients are transformed by an (inverse) multinomial logit link function to get the transition probabilities, as described in Equations 9-10 of Klappstein et al. (2023). Do you have covariates on the transition probabilities?
If you DO NOT have covariates on your transition probabilities, then mod$par$tpm
will just be in the intercepts (i.e., $\alpha_0$). If you're interested in the transition probability matrix, you can print this with print(mod)
(see pages 7-8 of the vignette on GitHub).
If you DO have covariates on the transition probabilities, then mod$par$tpm
will return the intercepts and coefficients for each covariate. In this case, print(mod)
also outputs these coefficients, rather than printing the matrix (as it varies with covariates). You can predict the transition probabilities (with uncertainty) for any covariate values, using the predict_tpm()
function (see page 13 of the vignette for an example).
I think there is some inconsistency in our naming and presentation, which might be confusing. I will think about how to improve this (and update here when there are relevant changes), but hopefully this helps for now.
Best, Natasha
Hi Natasha,
Thank you very much for the explanation. I now have a better understanding of the coefficients.
I would like to save the values of the transition matrix, print(mod)
only displays them. Is there a way to save these values directly?
Thank you for your assistance.
Best, Ilhem
Glad that helped.
Yes, ultimately print(mod)
is using predict_tpm()
under the hood. So, assuming you have no covariates, you can calculate the TPM for any row of data (here, we're using the first row, but this is arbitrary):
tpm <- predict_tpm(mod = mod, new_data = mod$args$data[1,], return_CI = TRUE)
.
This will give the TPM that is printed in the model summary. You can use return_CI = FALSE
if you don't want/need the 95% CIs. Let me know if you run into any issues.
Natasha
Hi Natasha,
The function predict_tpm
works perfectly. Thank you very much.
Best, Ilhem
Hello,
I am currently trying to extract the parameters of the transition matrix. However, I am encountering an issue where the values obtained from
mod$par$tpm
do not appear to be probabilities.Could you please guide me on the correct method to extract this information?
Thank you for your assistance.
Best regards, Ilhem