Estimating Proportion with Survey Data in R

#1

Hi, I am a new R user. I used Stata more before switching to R. When we want to obtain 95% confodence interval for proportion of the categories with survey data (for instance, body weight could have four categories, underweight, normal, overweight and obese), in Stata it is just like 'svy: proportion bmi_cat', even though I tried to use several commands like 'svyciprop', I could not get it with R. Can anyone please tell me if there is any such easy package in R?

Thanks in advance!

Gulam

0 Likes

#2

This answer is a summary from this webpage: http://rcompanion.org/handbook/H_02.html

There is a package called PropCIs that has two methods, the Clopper-Pearson Exact Method and the Blaker Exact Method. Here is an example of each:

The exactci function uses the Clopper–Pearson exact method.

7/21

[1] 0.3333333

library(PropCIs)

exactci(7, 21,
conf.level=0.95)

95 percent confidence interval:
0.1458769 0.5696755

The blakerci function uses the Blaker exact method.

7/21

[1] 0.3333333

library(PropCIs)

blakerci(7, 21,
conf.level=0.95)

95 percent confidence interval:
0.1523669 0.5510455

1 Like

#3

If you're going to be working with survey data in R, two of the best packages to get to know are survey and srvyr. It looks like you found survey as that is where the svyciprop() function comes from.

For more specific help here, you should post a reproducible example (reprex) including a sample of the data you are working with (or toy data if you can't share your data) as well as the code you have tried so far and the error message you've received. See below for more info on creating a reprex:

1 Like

closed #4

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes