I am running a logistic regression with the outcome (ser) and a number of predictor variables,
with standard errors clustered (by provider_id). One of the predictors (years_cat) is a categorical
variable that I created from a continuous variable (tenure); in other words, years_cat is categories
of tenure. The odds ratios on the categories of years_cat are monotonically increasing and I would
like to test if the variable tenure is in fact linear (though I will be reporting the categorical
variable in my paper).
Usually, I would run the model with the categorical variable (cat1), store the estimates, and then
run the model with the linear variable (lin1), and store the estimates, and then use a likelihood ratio test to compare
the two (lrtest cat1 lin1). Since I have clustered standard errors, the likelihood ratio test is not
appropriate and I would like to use a Wald test. However, when I run the wald test, I am getting errors (see details below) that Stata cannot find the models that I've stored (despite confirming that they are in fact stored). How can I run the wald test to compare the equality of these two stored models?
with standard errors clustered (by provider_id). One of the predictors (years_cat) is a categorical
variable that I created from a continuous variable (tenure); in other words, years_cat is categories
of tenure. The odds ratios on the categories of years_cat are monotonically increasing and I would
like to test if the variable tenure is in fact linear (though I will be reporting the categorical
variable in my paper).
Usually, I would run the model with the categorical variable (cat1), store the estimates, and then
run the model with the linear variable (lin1), and store the estimates, and then use a likelihood ratio test to compare
the two (lrtest cat1 lin1). Since I have clustered standard errors, the likelihood ratio test is not
appropriate and I would like to use a Wald test. However, when I run the wald test, I am getting errors (see details below) that Stata cannot find the models that I've stored (despite confirming that they are in fact stored). How can I run the wald test to compare the equality of these two stored models?
Code:
*Run the model with categorical variable (years_cat), store. logistic ser i.age_ra i.sex ib5.indication ib2.gender_doc ib1.specialty1 i.vol ib4.years_cat, cluster(provider_id) estimates store cat1 *Run the model with continuous variable (tenure), store. logistic ser i.age_ra i.sex ib5.indication ib2.gender_doc ib1.specialty1 i.vol tenure, cluster(provider_id) estimates store lin1 *Confirm that stata has stored the estimates estimates table cat1 lin1 *Run wald test test lin1 cat1 *returns error "r(111) lin1 not found" *Run wald test with alternative syntax test [lin1 cat1] *returns error "r(303) equation lin1 not found" /*The same errors are reutrned if I put an = between lin1 and cat1. If I put cat1 before lin1, the error tells me instead taht cat1 is not found.*/ *I've also tried using the suest command, but I get the same errors logistic ser i.age_ra i.sex ib5.indication ib2.gender_doc ib1.specialty1 i.vol ib4.years_cat estimates store cat2 logistic ser i.age_ra i.sex ib5.indication ib2.gender_doc ib1.specialty1 tenure i.vol ib4.years_cat estimates store lin2 suest cat2 lin2, cluster(provider_id) test lin2 cat2 *Error: r(111) lin2 not found
Comment