How can I calculate the difference between the marginals.fitted.values of two INLA models?

  • Hi everyone,

    I am trying to determine the change in the posterior distributions of marginals.fitted.values between two Stochastic Partial Differential Equation (SPDE) models, akin to the methodologies employed in this guide: https://www.paulamoraga.com/bo…aldataexamplespatial.html


    The two models have been constructed utilizing the same spatial points, albeit with data from two distinct years. My aim is to discern whether there has been a shift in the disease's prevalence over these two different timeframes. As a result, I've chosen to compute the difference between the posterior distributions of the marginals.fitted.values from both models.


    I initially believed this could be achieved with a straightforward subtraction, however, the complexity of the marginals.fitted.values structure has proven this to be unfeasible.


    I tried this but it I did not have any success:

    Code
    model1$marginals.fitted.values[index] - model2$marginals.fitted.values[index]


    Thank you in advance.

    • Best Answer

    Hello,


    The marginals.fitted.values of an INLA model gives you a list of marginal posterior distributions, not point estimates, which is why simple subtraction isn't working.

    As you've correctly understood, taking the difference between two marginal distributions isn't as straightforward as subtracting means or modes. Instead, you can perform the operation on the whole distributions.

    One possible approach to your problem could be to sample from these distributions, subtract these samples, and then look at the distribution of these differences.

    Below is a basic sketch of how you might do this in R:

    This script draws samples from each marginal posterior of the fitted values, then subtracts these samples. This gives you a distribution of differences for each location. You could then summarize these distributions (e.g., by calculating the mean or median) or visualize them to understand how the disease prevalence has changed.


    Remember, each marginal distribution in the marginals.fitted.values list is a different location, so this will give you a separate distribution of differences for each location.


    This is a somewhat advanced topic and might seem difficult if you're new to Bayesian statistics or spatial modeling. I'd recommend discussing this approach with a mentor or statistician if you can, and cross-validating the results with other forms of analysis if possible.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!