Announcement

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

  • syntax problems(?) with gformula

    Hi,

    I am using the -gformula- command in Stata 18. My data is in wide format. I am trying to run the most basic version of my model before I begin to build it but I cannot get the gformula command to run without issue. I have been successful running this same model using -mediate- and -sem-. I can't find much online on troubleshooting -gformula- but assume from the error codes given that it's a syntax problem. Please note that I am aware 15 bootstrap samples are not recommended... I just wanted to get the basic code running before I go further with my model. My code is:

    Code:
    #delimit;
    gformula multi9 lone hscrp4, 
    mediation outcome(multi9) 
    equations(multi9: lone hscrp4, hscrp4: lone) 
    commands(multi9:poisson, hscrp4:regress) 
    exposure(lone) linexp mediator(hscrp4)
    logOR samples(15) seed(179)
    moreMC sim(50000);
    #delimit cr
    I have also tried a simpler piece of code:
    Code:
    #delimit;
    gformula multi9 lone hscrp4, 
    mediation outcome(multi9) 
    equations(multi9: lone hscrp4, hscrp4: lone) 
    commands(multi9:poisson, hscrp4:regress) 
    exposure(lone) linexp mediator(hscrp4);
    #delimit cr
    Both returned the following Stata output:

    Code:
    G-computation procedure using Monte Carlo simulation: mediation
    
    [Please note that neither the abbreviation of variable names nor the use of
    variable lists (such as x1-x3 to denote x1 x2 x3) is supported by this command.
    If you have used abbreviations or lists, the command may fail to run or the
    results below may not be correct.]
    
    
       Outcome variable: multi9
       Exposure variable(s): lone
       Mediator variable(s): hscrp4
       Size of MC sample: 50000
       No. of bootstrap samples: 15
    
    
       A summary of the specified parametric models:
    
       (for simulation under different interventions)
    
          Variable | Command | Prediction equation
       ------------+---------+-------------------------------------------------------
            hscrp4 | regress | lone
            multi9 | poisson | lone hscrp4
       ------------------------------------------------------------------------------
    
    
       No. of subjects = 4947
    
                                                  |-PROGRESS-|
       Preparing dataset for MC simulations:      |----------|
    
                                                  |-PROGRESS-|
       Fitting parametric models and simulating:  |---- invalid name
    r(198);
    
    end of do-file
    
    r(198);
    Any advice would be much appreciated!

    Thanks,
    Robyn

  • #2
    gformula is community-contributed, as you are asked to explain (FAQ Advice #12). In this case I see a paper in the Stata Journal and a more recent version on SSC. So the first step is to confirm that you are using the SSC version and (if not) to ensure that you are.

    Beyond that, there's no reproducible example here. We don't necessarily expect you to post your data but the absence of such an example is a problem.

    Two things you can do:

    Contact the authors directly for support: none of them appears to be active on Statalist.


    Code:
    set trace on
    and show the trace output just before the command fails. That may help. You may need to fool around with the trace depth.

    Code:
    help trace
    gives guidance.

    Comment

    Working...
    X