Hi, I want to do logistic regression based on a complex sample design. I used package survey, but when I ran svyglm, an error message came out: Error in onestrat(x[index, , drop = FALSE], clusters[index], nPSU[index][1], : Stratum (16) has only one PSU at stage 1 My code is below: a.design<-svydesign(id = ~CASENUM ,strata = ~STRATUM ,data = a ,weights ~SIZAGYWT ) summary(logistic1 <- svyglm(ANYCONTR ~ CHAIN+OWN+HPPAT, family binomial(link = "logit"), design=a.design)) How to solve this issue? Thank you. [[alternative HTML version deleted]]
Milan Bouchet-Valat
2014-Apr-14 19:07 UTC
[R] problem on package "survey" , function svyglm,
Le lundi 14 avril 2014 ? 13:59 -0400, Hanze Zhang a ?crit :> Hi, > > I want to do logistic regression based on a complex sample design. I used > package survey, but when I ran svyglm, an error message came out: > Error in onestrat(x[index, , drop = FALSE], clusters[index], > nPSU[index][1], : > Stratum (16) has only one PSU at stage 1 > > > My code is below: > > a.design<-svydesign(id = ~CASENUM ,strata = ~STRATUM ,data = a ,weights > ~SIZAGYWT ) > summary(logistic1 <- svyglm(ANYCONTR ~ CHAIN+OWN+HPPAT, family > binomial(link = "logit"), design=a.design)) > > > How to solve this issue? Thank you.You need to merge manually the stratum with only one PSU with another stratum. See 3.2.1 in http://books.google.fr/books?id=L96ludyhFBsC (look for "single" in the whole book to find it). Regards