Programming the statistical procedures from SAS

PROC NLMIXED: group contrasts

New Contributor AK
New Contributor
Posts: 2

PROC NLMIXED: group contrasts

I have repeated measures data that contains subjects' performance on a task over many trials. I also have a group variable as well (three groups, and this variable is categorical- there is no order to the groups).
In NLMIXED, I get the parameters for an exponential function that describes the learning curves. Specifically, I have a parameter that reflects the asymptote and another that reflects the learning rate (ie, a time constant). I also find that there is a significant effect of my group variable on the asymptote parameter, but not the learning rate. This all looks good and the fit is nice.
**How can I test for differences between pairs of groups?** Ie, the hypothesis that Group A does not differ from Group B, but does differ from Group C. Here are some avenues I've tried, with little luck:

1. Use the CONTRAST statement. This really seems like the what I'm supposed to do, but I just can't figure out the syntax, and how to code the data to use it! I read that it's *not* executed the same was as the contrast statement in PROC MIXED, but I can't seem to find the right way.

2. Get each individual subjects' parameter estimate, then determine (in a separate analysis) whether there is a signif effect of group on the estimate. The output gives me the mean and variance of the estimate, but can I get the estimate for each individual? Or, should I run NLMIXED on each subject (without the group variable, of course), and get the parameters from each output?

Would either of these work? Thanks for any insight!

Code so far:
PARMS m_g0 = 1 m_g2 = -0.5 b01 = 0 b21 = 0
s2e = 0.1 v_Ey0 = 0.1 v_Ey1 = 0.1 c_01 = 0.1;
g0 = m_g0 + b01*group + Ey0;
g2 = m_g2 + b21*group + Ey1;
eqn = g0 + (-exp(trial * g2)) ;
MODEL adapt ~ normal(eqn,s2e) ;
RANDOM Ey0 Ey1 ~ normal([0, 0], [v_Ey0, c_01, v_Ey1])
SUBJECT = subject;

Regular Contributor
Posts: 169

Re: PROC NLMIXED: group contrasts


First of all, I don't think you have coded your group effects appropriately. Since you have three unordered groups, you should have three models for the asymptote and also three models for the learning rate. The three asymptote models can all be written employing a single statement of the form:

    g0 = m_g0 + b01*(group=2) + b02*(group=3) + Ey0;

This statement resolves to

      g0 = m_g0 + Ey0;                (group=1)
      g0 = m_g0 + b01 + Ey0;       (group=2)
      g0 = m_g0 + b02 + Ey0;       (group=3)

Similarly, the expression for g2 would be:

      g2 = m_g2 + b21*(group=2) + b22*(group=3) + Ey1;

Now, if you want to see if there is variation across groups in their asymptotic values, you would want a 2 df test that examines whether the b01 and b11 values differ from 0:

    contrast "Difference in asymptotic values" b01, b02;

Similarly, you should have a 2 df test for the learning rates:

    contrast "Difference in learning rates" b21, b22;

At trial=, there is a 3 df test which compares

    m_g0 + (-exp(*m_g2))
    m_b0 + b01 + (-exp(*(m_g2 + b21)))
    m_b0 + b02 + (-exp(*(m_g2 + b22)))

At trial=1, this contrast would be

    contrast "Diff across 3 groups at trial=1)
        ( m_b0 + b01 + (-exp(1*(m_g2 + b21))) ) - ( m_g0 + (-exp(1*m_g2)) ),
        ( m_b0 + b02 + (-exp(1*(m_g2 + b22))) ) - ( m_g0 + (-exp(1*m_g2)) );

Similarly, at trial=2 you would have the 3 group contrast

    contrast "Diff across 3 groups at trial=2)
          ( m_b0 + b01 + (-exp(2*(m_g2 + b21))) ) - ( m_g0 + (-exp(2*m_g2)) ),
          ( m_b0 + b02 + (-exp(2*(m_g2 + b22))) ) - ( m_g0 + (-exp(2*m_g2)) );

A contrast comparing expected values for groups 1 and 2 at trial=j would have the form:

    contrast "E(G=2) - E(G=1) at trial=[j[)
          ( m_b0 + b01 + (-exp(*(m_g2 + b21))) ) - ( m_g0 + (-exp(*m_g2)) ),

Just be sure to substitute specific values for everywhere in the above equation. Similarly, you can construct contrasts between expected values for groups 1 and 3 and also between expected values for groups 2 and 3. I'll let you work out the code for these latter two contrasts. It should be readily apparent from everything that has been shown above.

New Contributor AK
New Contributor
Posts: 2

Re: PROC NLMIXED: group contrasts

Right, of course! I felt like my version was off but I didn't know what the solution was. This makes complete sense, thanks very much for the clear and thorough reply. And thanks also for pointing out the trial contrast.
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation