Hi R-users! I have a problem with the survey package and i would be very grateful if you can help me.
A short example: stratum id weight nh Nh y sex 1 1 3 5 15 23 1 1 2 3 5 15 25 1 1 3 3 5 15 27 2 1 4 3 5 15 21 2 1 5 3 5 15 22 1 2 6 4 3 12 33 1 2 7 4 3 12 27 1 2 8 4 3 12 29 2 where nh is size of sample stratum and Nh the corresponding population value, and y is metric variable. Now if i let design <- svydesign( id=~1, data=age, strata=~stratum, fpc=~Nh) then weights(design) gives me 3,3,3,3,3,4,4,4. If i then let x<- postStratify( design, strata=~sex, data.frame(sex=c("1","2"), freq=c(10,15))) the weights become 1 2 3 4 5 6 7 8 2.17 2.17 5.35 5.35 2.17 1.73 1.73 4.28 If i define design <- svydesign( id=~1, data=age ) x<- postStratify( design, strata=~sex, data.frame(sex=c("1","2"), freq=c(10,15))) weights become 2 2 5 5 2 2 2 5 The question: does poststratify recognize that i have already stratified in the first design by stratum and then it post stratifies by sex? and why is that? (because i don't have the full joint distribution, the sex*stratum crossing, in order to apply correctly the post stratify function) I see that Mr Lumley uses the postStratify function when the design does not include strata (eg from ?poststratify: dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) rclus1<-as.svrepdesign(dclus1) rclus1p<-postStratify(rclus1, ~stype, pop.types) and i use design <- svydesign( id=~1, data=age, strata=~stratum, fpc=~Nh) x<- postStratify( design, strata=~sex, data.frame(sex=c("1","2"), freq=c(10,15))) which has a first strata (stratum from svydesign) and a second strata(sex, from poststratify) Is it correct to use the functions as use them or am i doing something wrong? Thank you ! --------------------------------- Park yourself in front of a world of choices in alternative vehicles. [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.