Announcement

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

  • Categorical variables when using med4way for mediation analysis

    Hello.
    I've started using the command "med4way" recently for mediation analyses. The issue is that when I indicate the categorical covariables with the prefix i. , STATA doesn't run the syntaxis.

    Here's an example:
    med4way s_total ST_tot sue_00 i.aj_c ed_vs i.se_vs zIM_00 im_m im_p i.edu_m i.edu_p i.recom_lac ffq_ener act_fis i.edo_m i.edo_p, yreg(linear) mreg(linear) a0(2) a1(0) m(10.38453)

    The error that results from this is as follows:
    factor-variable and time-series operators not allowed
    r(101);
    .
    So, I wonder if is necessary to indicate the categorical confounder variables with this prefix when using the command "med4way" and how I can do this...
    Could you please help me with this?

  • #2
    Hi Tany, just wondering if you found a solution? I'm facing the same issue. Thanks in advance!

    Comment


    • #3
      The current version med4way is wrote in 2021, I don't know why it does not support factor-variable and time-series operators. But the workaround is simple, just add the xi prefix before command. By the way, as to the unofficial Stata command, you have obligation to declare its source. net install med4way, from("https://raw.githubusercontent.com/anddis/med4way/master/") replace
      Code:
      use "med4way_example_1.dta"
      
      // prefix i. is not supported by med4way
      med4way y_bin i.treat m_bin i.cvar1 cvar2 cvar3, yreg(logistic) mreg(logistic) a0(0) a1(1) m(0) c(0 0 .)
      
      // however, we can find an easy work-around
      xi: med4way y_bin i.treat m_bin i.cvar1 cvar2 cvar3, yreg(logistic) mreg(logistic) a0(0) a1(1) m(0) c(0 0 .)
      Last edited by Chen Samulsion; 28 Jan 2025, 19:59.

      Comment

      Working...
      X