Hello all,
I am trying to calculate test statistics for the TOST procedure and am trying to calculate the upper and lower bounds of the acceptance region by calling the beta coefficient and standard errors from two models that I previously did store in my code using the est function.
Here is my code:
// Step 3: Fit logistic regression models
logit burn_post2 ib0.Active1_Sham0 if Session==1 & PreviousStimulationYes1_No0==0
// Step 4: Estimate the difference in means
est store model1
// Step 5: Fit the reference model
logit burn_post2 if Session==1 & PreviousStimulationYes1_No0==0
// Step 6: Estimate the reference model
est store model2
// Step 7: Calculate the test statistics for the TOST procedure
estimates table model1 model2, b se
// Step 8: Calculate the lower and upper bounds of the acceptance region
local alpha = 0.05 // Set the significance level
scalar critical_value = invnormal(1 - `alpha'/2)
scalar lower_bound = $ML_b[model1] - critical_value * sqrt($ML_se[model1]^2 + $ML_se[model2]^2)
scalar upper_bound = $ML_b[model1] + critical_value * sqrt($ML_se[model1]^2 + $ML_se[model2]^2)
^the code works perfectly until I get to the scalar lower_bound line. I get an error that says "model1" not found. When I format my line of code to say $ML_b[model1], $ML_se[model1], etc. in the bolded scalar code, I am trying to draw from the beta coefficients and standard error in models 1 and 2. I did run the command "estimate dir" and got this output below that confirms that the Stata session did store my model1, so I am assuming there is an error in my syntax in the last two statements of my code.
This is the output of "estimate dir" to confirm that I do indeed have models 1 and 2 stored:
------------------------------------------------------------------
| Dependent Number of
Name | Command variable param. Title
-------------+----------------------------------------------------
model1 | logit burn_post2 3 Logistic regression
model2 | logit burn_post2 1 Logistic regression
------------------------------------------------------------------
Any thoughts would be greatly appreciated, thank you.
I am trying to calculate test statistics for the TOST procedure and am trying to calculate the upper and lower bounds of the acceptance region by calling the beta coefficient and standard errors from two models that I previously did store in my code using the est function.
Here is my code:
// Step 3: Fit logistic regression models
logit burn_post2 ib0.Active1_Sham0 if Session==1 & PreviousStimulationYes1_No0==0
// Step 4: Estimate the difference in means
est store model1
// Step 5: Fit the reference model
logit burn_post2 if Session==1 & PreviousStimulationYes1_No0==0
// Step 6: Estimate the reference model
est store model2
// Step 7: Calculate the test statistics for the TOST procedure
estimates table model1 model2, b se
// Step 8: Calculate the lower and upper bounds of the acceptance region
local alpha = 0.05 // Set the significance level
scalar critical_value = invnormal(1 - `alpha'/2)
scalar lower_bound = $ML_b[model1] - critical_value * sqrt($ML_se[model1]^2 + $ML_se[model2]^2)
scalar upper_bound = $ML_b[model1] + critical_value * sqrt($ML_se[model1]^2 + $ML_se[model2]^2)
^the code works perfectly until I get to the scalar lower_bound line. I get an error that says "model1" not found. When I format my line of code to say $ML_b[model1], $ML_se[model1], etc. in the bolded scalar code, I am trying to draw from the beta coefficients and standard error in models 1 and 2. I did run the command "estimate dir" and got this output below that confirms that the Stata session did store my model1, so I am assuming there is an error in my syntax in the last two statements of my code.
This is the output of "estimate dir" to confirm that I do indeed have models 1 and 2 stored:
------------------------------------------------------------------
| Dependent Number of
Name | Command variable param. Title
-------------+----------------------------------------------------
model1 | logit burn_post2 3 Logistic regression
model2 | logit burn_post2 1 Logistic regression
------------------------------------------------------------------
Any thoughts would be greatly appreciated, thank you.
Comment