Dear Statalist members,
I am trying to conduct causal mediation analysis and sensitivity analysis, using "mediation" packages. For some reasons, STATA gives me an error message ("invalid 'shim'" "r(198);") at the end of the commands below. The commands run well up until the very last line. But, STATA keeps giving me the error message for "medsens" commands. I have tried a smaller number of simulations but it does not fix the problem.
I would appreciate if anyone could provide me with a possible solution.
----------------------------------------------------
set seed 12345
local n 2000
set obs 9950
# population values #
local alpha_2 -138.97
local alpha_3 512.63
local beta_2 0.55
local beta_3 -5.97
local gamma -1.71
local x_beta1 -25.59
local x_beta2 12.99
local x_beta3 22.74
local y_beta1 0.7
local y_beta2 820.44
# Draw realizations of error terms and pretreatment covariate x assuming no correlations##
matrix m = (0,0,0,0,0,0)
matrix sd = (1,1,1,1,1,1)
drawnorm e1 e2 x1 x2 x3 x4, n(9950) means(m) sds(sd)
##Generate realizations of treatment (T), mediator (M), and outcome (Y) variables##
generate T = round(runiform(), 1)
generate M = -138.97 + 0.55*T -25.59*x1+ 12.99*x2 + 22.74*x3 + e1
generate Y = 512.63 - 5.97*T - 1.71*M + 0.7*x4 + 820.44*x1 + e2
## Conduct mediation analysis ##
medeff (regress M T x1 x2 x3) (regress Y T M x4 x1), treat (T) mediate (M) sims (1000)
## Run Sensitivity Analysis ##
medsens (regress M T x1 x2 x3) (regress Y T M x4 x1), treat (T) mediate(M) sims (1000)
---------------------------------------------------------------------------------------------------------
Thanks much!
Related Posts with Sensitivity Analysis after mediation analysis
Country fixed effects and dummy in IV regressionHello everyone, I want to use instrumental Variable regression and include country fixed effects in…
fsum commandHi all, I am using the fsum command to produce a table with my variables using label. it works well …
Error = { required r(100)Greetings Please attached is my do file that I am trying to use to test associations between my expl…
Updating generates error message - Stata 9 and file not Stata formatI have installed Stata 9 (intercooled) on a new laptop computer. It worked perfectly on my previous …
Heckpoisson Error MessageI am currently attempting to use the heckpoisson command in Stata 15.1. My dependent variable is an …
Subscribe to:
Post Comments (Atom)
0 Response to Sensitivity Analysis after mediation analysis
Post a Comment