PSIAIMS / CAMIS

https://psiaims.github.io/CAMIS/
Apache License 2.0
60 stars 60 forks source link

2 independent sample proportions. Checking R code vs hand & SAS #323

Open DrLynTaylor opened 1 month ago

DrLynTaylor commented 1 month ago

https://github.com/PSIAIMS/CAMIS/blob/cd5cb5016435bf7ea384b17ebdd9221b680083a1/R/ci_for_prop.qmd#L189-L193

Need someone to double check cardx::ard_stats_prop_test vs the by hand calculation using Wald and Wilson and compare to SAS & R. Currently it appears that R says it's uses Newcombe method (Wilson), but the results match the Wald method in SAS and by hand? Does cardx::ard_stats_prop_test use Wald or Wilson equations, and can the other method be done as well using a different function?

DrLynTaylor commented 1 month ago

@ddsjoberg, I've written quite a bit more into the CAMIS SAS pages, for 2 sample matched and independent 95% CI for differences in proportions: https://psiaims.github.io/CAMIS/SAS/ci_for_prop.html In my independent 2 sample example, WALD CI = -0.0271 to 0.1830 and Newcombe CI = -0.0361 to 0.1751. I then tried to replicate using: cardx::ard_stats_prop_test and the results seem to match the Wald CI not the Wilson/Newcome (which is odd as https://rdrr.io/r/stats/prop.test.html implies wilson/newcombe method is being used not Wald)? Just wondered if you had any thoughts on this? Do you know of any other package able to apply the newcombe method? Would be great to have both demonstrated in R.

ddsjoberg commented 1 month ago

Hey @DrLynTaylor ! I am not sure. Have you looked on cross validated? I did a quick search and there are a few conversations about the methods implemented in prop.test().

DrLynTaylor commented 1 month ago

Thanks for the tip, I'll have a look there and try to figure it out.

statasaurus commented 1 month ago

Is this still something for the hackathon? Will one of you take it on? Or is this resolved now and should be closed?

DrLynTaylor commented 1 month ago

Not yet had chance to explore, so yes someone could look into it at the hackathon if they want something challenging!