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

  • How to make a point estimate in a mixed model with continuous variables

    Dear Stata users,

    I have a mixed model (see the syntax below) with main effects of group (two dichotomous groups, Groepfreq and Groepbeh), and three effects for time are centered and estimated: a linear, quadratic and cubic line and interactions between them all. Two levels are estimated: measurements in participants.

    What I want to know is the effect of group (Groepfreq) at day 90 (linear) or 8100 (quadratic) or 729000 (cubic). I played around with the syntax that is used to make contrasts (contrasts or margins codes) for categorial variables but it doesn't work out and I am stuck. Is it even possible to make a point estimate in a model like this? (in SPSS it is possible, but I like Stata more, so would be very happy if there is a function that can do this)

    I am very curious if anybody knows.

    Thank you for thinking along,
    Best regards,


    mixed BDI BDIbaseline i.Groepbeh i.Groepfreq c.timedayscentrkwad c.timedayscentered c.timedayscentrkub c.timedayscentrkub#i.Groepfreq c.timedayscentrkub#i.Groepbeh c.timedayscentrkwad#i.Groepfreq c.timedayscentrkwad#i.Groepbeh c.timedayscentered#i.Groepfreq c.timedayscentered#i.Groepbeh,|| ppnr:c.timedayscentered, covariance(unstructured) residuals(ma1, t(Time))

    BDI baseline is a covariate
    BDI is the dependent variable (8 measurements; Time in the residual covariance structure = time at point 1-8)
    Other timevariables are defined as time in days (timedays)
    ppnr= subject

  • #2
    Originally posted by Sanne Bruijniks View Post
    What I want to know is the effect of group (Groepfreq) at day 90
    Try something along these lines.
    summarize Time, meanonly
    local mean `r(mean)'
    mixed BDI BDIbaseline ///
        i.Groepbeh##c.timedayscentered##c.timedayscentered##c.timedayscentered ///
        i.Groepfreq##c.timedayscentered##c.timedayscentered##c.timedayscentered ///
        || ppnr: timedayscentered, covariance(unstructured) residuals(ma1, t(Time))
    margins , dydx(Groepfreq) at(timedayscentered = 90 - `mean') noestimcheck


    • #3
      Its working! Thank you very much!!


      • #4
        Hi all,

        Sorry another follow-up question. Does someone know if it is possible to estimate the following contrast:

        ('Groepfreq = 0 at day -90' - 'Groepfreq = 0 at day 90') - ('Groepfreq =1 at day -90' - 'Groepfreq =1 at day 90')

        Best wishes, Sanne


        • #5
          You may wish to fiddle with - margins - plus - contrast operations.

          Please read the Manual about using - margins r.groupvar - followed by the - at() option for the day threshold.
          Best regards,



          • #6
            Marcos, thanks for thinking along!

            (1) I tried margins r.Groepfreq, at (timedayscentered=90 timedayscentrkwad=8100 timedayscentrkub=729000) but it says factor Groepfreq not found, so it seems it does not accept c.Groepfreq variable used earlier in the mixed formula. Also this syntax only contrasts the two conditions at 1 time point and not at 2.

            (2) In the meantime I encountered the next problem, I seem not be able to get estimated means at each condition and at each timepoint, I tried the following syntax but but that does not give a plausible estimated mean.

            margins, at (c.Groepfreq=1 c.Groepbeh=1 c.timedayscentered=-76 c.timedayscentrkwad=-5776 c.timedayscentrkub=-438976)

            I tried to play with the adjust or for example . margins c.Groepbeh##c.timedayscentrkwad, atmeans post; but only factor variables and no interactions are allowed.

            Are estimated means after a mixed model with random levels and interactions (including variables that contain negative values) even possible in Stata?


            • #7
              The notation of - margins - for continuous variables is a little bit different. You may wish to check the examples of - margins - in the Stata Manual.
              Best regards,