Announcement

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

  • From SAS to Stata: sampling weight for nonlinear models (menl)?

    Hello all,

    I am trying to replicate code from SAS to Stata, and I am also struggling with specifying weights. Here is the SAS code, for example:

    Code:
    proc nlmixed data= mydata;
            odds= exp(b0)*(1+b1*A + b2*B + b3*A*B);
            model y ~ binary(odds/(1+odds));
            replicate ipw;
    run;
    1- any suggestion how this code can be written in Stata with the menl command? I guess it would be like this, but please correct me if wrong.

    Code:
    menl y= {odds:}/(1+{odds:}), define(odds:exp({b0})*(1+ {b1}*A + {b2}*B + {b3}* A*B))
    2- My concern is about the "replicate ipw" above, which weights the data to account for sampling (pweights).

    Many thanks for your time and help. I very much appreciate it.

    Best,
    Walid
    Last edited by Walid Al-Soneidar; 24 Jan 2022, 21:10.

  • #2
    Looks like a slightly different parameterization of a logistic regression, as an analogue of a log-linear model. -logit- with pweights seems to be what you want but you'll have to do the coefficient transformation yourself, or else use -margins- if you don't care about coefficients and instead want predictive margins.

    Edit to add: you may also consider -glm- with binomial family and log link, instead of the canonical logit link.
    Last edited by Leonardo Guizzetti; 24 Jan 2022, 22:12.

    Comment


    • #3
      Thanks, Leonardo. Actually this is called a linear odds model. While it has similarities to both the logisitc and the log-linear models, its not quite the same. Indeed, my first intuition was to use glm, but that did not work. It is best estimated with a non-linear mixed models framework. If not already clear from the code, here is the equation for it:

      Odds = exp(B0) (1 + B1A + B2B + B3AB), where A and B are two binary random variables, and AB is an interaction term.

      The method is explained in the paper by VanderWeele and Vansteelandt 2011. (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3246690/)



      Comment

      Working...
      X