Wald测试比较Stata中的两个模型

时间:2017-06-29 19:27:34

标签: model compare stata hypothesis-test

我正在使用结果(ser)和一些预测变量进行逻辑回归, 标准错误聚集(通过provider_id)。其中一个预测因子(years_cat)是一个分类 我从连续变量(任期)创建的变量;换句话说,years_cat是类别 任期。 years_cat类别的优势比是单调增加的,我愿意 喜欢测试变量任期是否实际上是线性的(尽管我将报告分类 在我的论文中变量。)

通常,我会使用分类变量(cat1)运行模型,存储估计值,然后 使用线性变量(lin1)运行模型,并存储估计值,然后使用似然比检验进行比较 两个(lrtest cat1 lin1)。由于我有聚类标准错误,因此似然比检验不是 适当的,我想使用Wald测试。但是,当我运行wald测试时,我收到错误(请参阅下面的详细信息),Stata无法找到我存储的模型(尽管确认它们实际存储了)。如何运行wald测试来比较这两个存储模型的相等性?

*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

0 个答案:

没有答案