Announcement

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

  • menl -- predictions based only on the fixed effects

    I am fitting a logistic growth model using menl with the following code.

    menl DSS = {k:}/(1+exp(-{r:}*(Day-{d:}))), define(k: i.Group Uk[MID]) define(d: i.Group Ud[MID]) define(r: i.Group) rescorr(ctar1 , t(Day) group(MID)) covariance(Uk Ud, unstructured)

    All is good in the model fitting but I would like to get predictions with the random effect terms = 0, i.e. using only the fitted fixed effects. Some SAS mixed effect procedures offer a NoBLUP option, I am looking for something similar here.

    I would accept the margins, but
    margins i.Group, at(Day= (0 5(2)15 19(2)2 28(2)42)) does not return a result, at least in the 30 minutes I have waited for it.

    Any suggestions?
    Last edited by Greg Petroski; 22 May 2024, 14:08.

  • #2
    Originally posted by Greg Petroski View Post
    All is good in the model fitting but I would like to get predictions with the random effect terms = 0, i.e. using only the fitted fixed effects. Some SAS mixed effect procedures offer a NoBLUP option, I am looking for something similar here.
    . . . Any suggestions?
    Yes: use the fixedonly option of predict . . ., yhat as shown in the help file.

    I works for me in an example modeled after yours (see below—begin at the "Begin here" comment; the stuff above is to create an artificial dataset for illustration). Do-file and log file attached in case you're interested in perusing either further.
    Code:
    version 18.0
    
    clear *
    
    // seedem
    set seed 1241338700
    
    quietly drawnorm b1 b3, double ///
        sd(`=sqrt(10)' `=sqrt(0.5)') means(100 5) corr(1 -0.25 \ -0.25 1) n(200)
    generate int pid = _n
    generate byte grp = mod(_n, 2)
    
    quietly expand 11
    bysort pid: generate byte x = _n - 1
    
    /* log3     y =      b1/(1 + exp(-b2*(x-b3))) */
    generate double y = rnormal(b1 / (1 + exp(-1 * (x - b3))), sqrt(10))
    
    *
    * Begin here
    *
    menl y = ///
        {bee1:} / (1 + exp(-{bee2} * (x - {bee3:}))), ///
        define({bee1: i.grp U0[pid]}) define({bee3: i.grp U1[pid]}) ///
        covariance(U0 U1, unstructured) nolog
    
    // With random effects
    predict double yhat, yhat
    
    // "using only the fitted fixed effects"
    predict double xb, yhat fixedonly
    
    timer clear 1
    timer on 1
    margins grp, at(x = (0(1)2 4(1)6 8(1)10))
    timer off 1
    timer list 1
    
    list grp x yhat xb ///
        if inlist(pid, 1, 2) & inlist(x, 0, 1, 2, 4, 5, 6, 8, 9, 10), ///
        noobs sepby(grp)
    
    exit
    . . . margins . . .does not return a result, at least in the 30 minutes I have waited for it.
    Yeah, I think that margins needs to spend time computing the standard errors. Mine took only about a minute to complete (I used its output in order to verify that predict . . ., yhat fixedonly gives me what I expected). I assume that yours took longer because your continuous predictor has more values and you have a structured residual variance-covariance matrix.
    Attached Files

    Comment

    Working...
    X