Search code examples
rstatistical-sampling

(R) Finding proportion of population defectives at probability 0.1 acceptance


I'm using the following R code:

library(AcceptanceSampling)

x <- OC2c(50, 2, type="hypergeom", N=4000)
plot(x, xlim=c(0,0.2))

which generates the plot:

enter image description here

I will like to find the proportion when P(accept) (Y-axis) is 0.1. Is there a way to do this in R? I have a feeling this package does not allow direct computation of that according to its documentation at https://cran.r-project.org/web/packages/AcceptanceSampling/AcceptanceSampling.pdf.


Solution

  • As far as I know, you can't get this exactly, but you can get close. x is an S4 object, and the slots you're interested in here are paccept and pd. We can get the pd value with the paccept value closest to 0.1 of all the paccept values:

    idx <- which.min(abs(x@paccept - 0.1))
    round(cbind(paccept = x@paccept[idx], pd = x@pd[idx]), 3)
    #      paccept  pd
    # [1,]    0.11 0.1