我希望运行一个logit回归,预测家庭大小和年龄的平均边际效应,以及二元指标(个人是否移民、是否有健康保险或抽烟)对发生高血压概率的影响。
这些数据来自于集群调查,并且我希望在输出中包含稳健的集群标准误差。
但是当我添加代码以包括稳健的集群SE时,我收到一个错误,指出我的回归变量不再被找到,我不确定原因。任何建议都将不胜感激!谢谢。
AGE IMMIGRANT FAMSIZE HLTH_INS HYPERTEN SMOKE PSU
<int> <dbl> <int> <dbl> <dbl> <dbl> <int>
40 0 2 1 0 0 2
23 0 2 1 0 0 1
24 0 2 1 0 0 2
18 0 3 1 1 0 2
30 0 2 1 0 0 2
33 1 6 0 0 0 1
#or if this is an easier output to reproduce:
structure(list(AGE = c(40L, 23L, 24L, 18L, 30L, 33L, 32L, 63L,
22L, 24L), IMMIGRANT = c(0, 0, 0, 0, 0, 1, 0, 0, 0, 1), FAMSIZE = c(2L,
2L, 2L, 3L, 2L, 6L, 2L, 1L, 2L, 1L), HLTH_INS = c(1, 1, 1, 1,
1, 0, 1, 1, 1, 0), HYPERTEN = c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0),
SMOKE = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1), PSU = c(2L, 1L,
2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L)), row.names = c(NA, -10L), class = "data.frame")
#The regression works without adjusting for clustered SE
logit<-logitmfx(HYPERTEN~scale(AGE)+IMMIGRANT+scale(FAMSIZE)+HLTH_INS+
SMOKE,data=sample,
atmean=TRUE,robust=T)
#However, when I add in the code to cluster SE I receive the error: "Error in scale(AGE) : object 'AGE' not found"
logit<-logitmfx(HYPERTEN~scale(AGE)+IMMIGRANT+scale(FAMSIZE)+HLTH_INS+
SMOKE,data=sample,
atmean=TRUE,robust=T,clustervar1="PSU", clustervar2=NULL,!is.null("PSU"))