Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Estimating effect size from linear mixed effects model with spline time terms

    Dear Statalisters,

    I was assessing the effect of an intervention on linear growth of children over a 12 months of follow-up by fitting linear mixed effects model. I used restricted spline terms of time in addition to the monthly linear time variable to improve model fit. Finally, I assessed the effect of intervention using p value from likelihood ratio test comparing two models; a model containing interactions between study group and the different time terms vs. a model without these interaction terms. But I don't know how to estimate the effect size of the intervention and its corresponding CI from such models. Anyone who knows how to do it in Stata would be of much help. Thanks in advance.

  • #2
    I think that you need to show your output in order to get specific advice here. See FAQ #12 for advice on how to post Stata results in a way that will be easy for others to read.

    Comment


    • #3
      Dear Statalisters,

      We did an RCT assessing the effect of fish oil supplementation (compared to control supplements) on linear growth of infants. We have monthly length measurements for a total of 12 months. We fitted linear mixed effects model (random intercept child & random slope time) to compare study groups. Covariates included study group, time variables & interaction terms between study group and different time variables. In addition to the linear time variable of the monthly follow-ups, we added restricted cubic spline terms of time with knots placed at 2, 4, 6, 8, 10 and 12 months so that to allow for smoothing of nonlinear changes in the growth curves. Therefore, we have several time variables and corresponding interactions between study group & the time variables. To assess the effect of intervention from the several coefficients for study group by time interactions, we used p-values from likelihood ratio test comparing a model containing the interaction terms against a model without the interaction terms. However, we are not clear about how to estimate the effect size of the intervention from the several coefficients for the interaction between study group & the different time variables. Below are the models we used to get p-values for the intervention effect. time_* represents the different restricted cubic spline terms of the time variable (time_1, time_2, ... time_6)


      mixed length time time_* group group#time group#time_* || id: time, covariance(unstructured) mle
      estimate store interaction

      mixed length time time_* group || id: time, covariance(unstructured) mle
      estimate store no_interaction

      lrtest interaction no_interaction






      Comment


      • #4
        Splines, especially cubic ones, are usually applied to continuous variables and create new continuous variables. But by specifying group#time_ and group#time you are telling Stata to treat time and time_ as discrete variables. If you want time to be discrete, that's fine, but then the cubic spline is completely pointless, and the assignment of a random slope to time is a mis-specification. If you want time and the splines to be treated as continuous variables, then you need to tell Stata that by using the c. prefix in the interaction term: group#c.time. (Stata assumes that the variables in an interaction term formed with # or ## are discrete unless they have c. prefixed to them. This is the opposite of what is assumed in non-interaction terms, where variables are continuous unless prefixed with i. Yes, I think it's confusing, too, though it's not hard to see why, to maintain consistency for people not using factor variable notation, they did it that way.) Also if you are treating time as continuous and using a cubic spline, there is no reason to also include time and group#c.time in the model: it just makes the interpretation all that much more difficult, as the spline now comes to model not the time trends themselves but the difference between the time trends and what would be seen if time trends were linear!

        I'm going to assume that you really want time to be continuous and that you will re-do your model accordingly, using group##c.time_* (and omitting reference to the original time variable altogether). Then to look at effects of treatment in the different time periods, following the regression I would run:

        Code:
        margins group, dydx(time_*)
        And if you want to do specific contrasts between the groups in each time period
        Code:
        margins group, dydx(time_*) pwcompare

        Comment


        • #5
          Thanks a lot for your help. but i have one more question. Now I run the model below as per your comments & got the effect size estimates in each time period. But I am not sure how to get overall effect size of the intervention. Is there any way to get a polled value for overall effect size of treatment over the 12 months intervention

          mixed length group##c.time_* || id: time, covariance(unstructured) mle

          margins group, dydx(time_*) pwcompare

          Comment


          • #6
            Well, you can fool yourself and Stata into estimating something that you might call an overall effect size of treatment by running

            Code:
            margins group
            But looking for such a statistic in the context of a model with interaction terms doesn't actually make any sense. By adopting a model with interaction terms, you are explicitly claiming that the effect of group differs from one time to the next. A pooled effect can be nothing other than some sort of weighted average of those, and it is more an artifact of the weights you choose for that averaging process than anything else. (The -margins- command shown above implicitly weights each time period in proportion to the number of observations it contributes to the data.) It's really not meaningful to do this unless there is some canonical weighting scheme to apply. As the saying goes, you can't have your cake and eat it to. If you believe there is such a thing as "the intervention effect" then you have no business using an interaction model. If you believe that the effect varies over time, then you need an interaction model and it is a contradiction in terms to talk about a pooled effect.

            Comment


            • #7
              Thanks a lot for your help.

              Comment


              • #8
                Thank you for sharing these posts. I am starting to learn to estimate the mixed models with restricted spline terms. I have a question about the model specification. Here Alemayehu specifies the random slope for time as:

                Code:
                mixed length group##c.time_* || id: time, covariance(unstructured) mle


                Should the random effect use the original "time" variable after "id:" or the created spline time variables "time_*" ?

                Thanks!


                Comment


                • #9
                  As a follow up, I found in a different post where Clyde help answer a user's question: Visualizing results after running linear piece-wise spline modelling (https://www.statalist.org/forums/for...line-modelling)

                  Based on Clyde's responses, here the model with random effects for time variables should be specified as follows:

                  Code:
                   mixed length group##c.time_* || id: time_1 time_2 time_3 _time_4 time_5 time_6, covariance(independent) mle

                  Is it correctly specified?

                  Thanks!

                  Alice
                  Last edited by Alice Nee; 27 Jan 2023, 10:06.

                  Comment


                  • #10
                    Assuming that your spline transformation yields those 6 variables, yes, it's correctly specified.

                    Comment

                    Working...
                    X