Announcement

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

  • menl predicting outcome at different time points using margins

    Hello good people of statalist,

    A fairly basic question here on menl. I am new to the world of menl and related syntax. My problem is as follows: I have three variables id (assays 1-13), time (months 1-24), and outcome (the concentration of a chemical in the assay). The data at each time point is unbalanced across ids (i.e., there is not an outcome for all months across all assays).

    I would like to be able to fit a nonlinear curve to my data , and then pull the nutrient content at different time points from the curve, preferably using the margins, although perhaps predict after the model would be sufficient here. My code and output is as below:

    Code:
      
    menl outcome = ({b1}+{U[id]})/(1+exp(-(time-{b2})/{b3}))
    The above is my basic model. However, when I use predict:

    Code:
    predict fitoutcome, yhat
    This gives me predicted values for each id, not each time point. When, after fitting the model, I use:

    Code:
    margins, at( time = (1(1)24)) asbalanced
    I get an error "variable 'time' not found in list of covariates".

    What am I doing wrong here in my equation that I cannot get predicted outcome values for different time points here.
    Any help is very much appreciated.

    Best,


    John.
    Last edited by John Fitz; 31 Mar 2022, 03:34.
Working...
X