# Determining sample size with biased data

I'm new to this forum but I've read a lot of interesting topics to help me in my research, so I'm hopefull someone can help me with this question!

My goal: provide management with a sample size. could be based on product category or variant level. This sample size has to provide statistical power to be 'certain' that the faulty bikes are found. so for example: how many bikes do I have to inspect in the 'blue' category when I know that 6,2% is defect?

I'm doing a research (internship) for a company to determine a sample size for a daily inspection. To illustrate my question I've constructed a fictitional table with some data, see attached picture. For clarity, my research is not about bikes but I can not publicly share the real product names. therefor some things might seem unlogical.

As you can see, produced bikes is left blank. I'm currently working on getting this data but is taking pretty long so I'm thinking of ways to work without it.

There are several product categories (example blue bikes) and within this category several variants exists. In fact you can think of the same product, but supplied by another supplier (for physical reasons, variants can not and are not mixed) This variant get produced/delivered on different dates (mostly daily) and this can be seen as a production batch.

This controlled bikes number is biased. This is because of 2 reasons: 1) The data is simply faulty (people only register a bike as controlled because it was faulty, but don't register controlled bikes that happened to be ok). This is a problem I can not really control (except deleting the really obvious errors) 2) Some bikes are clearly faulty and therefor get a inspection, while others clearly are good to go and thus won't get an inspection. For capacity/money reasons this is obviously good, but I'm struggling with it in my research.

What I've done so far is the following:

• Aggregate all production dates per variant because if I wouldn't do this, n is often very small (>15 controlled bikes is rare, so the fictitous data is not representative)
• Analysed the aggegrated data and concluded that the variants are exponentially distributed (using a K-S test) with E(X)=average of the percentage faulty bikes within this variant.
• Now I'm kinda stuck.

What I've found is the following: Using the program GPower I've determined that with an average rate of 6,2% faulty bikes within a category, a preferred power of 99% and significance of 95%, I'll need a sample of 4089. This number is what I'm not sure about. In reality, in my dataset there were 26374 inspections within this category (with unknown total bikes, but estimated at least half a million) and thus 1636 faulty bikes.

So, is this company already inspecting way more than necessary or am I doing some things wrong? I think the latter..

I hope it is clear what my question is about. I want to give management a number of bikes they need to inspect so they can confidentally say the faulty bikes are found, considering the now known E(X) are probably biased.

• What is actually your question? – hplieninger Jul 28 '17 at 13:38
• Hmm something went wrong here. My question was longer.... I'll edit it – JtenBulte Jul 28 '17 at 14:04
• I've added the "My goal" part andthe part from the bullet list till the end. I hope it is clear! I'm sorry for the inconvenience – JtenBulte Jul 28 '17 at 14:21
• If 6% of the bikes are flawed and you sample some percent of the bikes produced, that leaves the rest of the bikes uninspected. Absent other information, I would think the uninspected bikes would have flaws at the 6% rate. So you must be asking a different question. Perhaps you want to know if the production methodology has improved so that fewer than 6% are flawed. Is that what you mean? – Joel W. Jul 28 '17 at 16:51
• @JoelW., unfortunately that's not what I'm looking for. The flaw can not be influenced by the company in any way. The only thing this company does is inspecting the bikes (which are not bikes in real life..) to find flaws. We can not inspect every product, since this would cause major delays in the supply chain. I am looking for a statistical method to calculate the minimum number of items need that to be inspected, but still ensuring a certain statistical power (1-beta). – JtenBulte Jul 31 '17 at 7:23

This is what I've done in the end. I'm wondering about your thoughts on it.

At first, I've managed to get the numbers from the 'Produced bikes' column. I've calculated the faulty bikes percentages without any aggregation. These percentages happened to follow a Exponential Distribution (used K-S tests and 95% Confidence interval)

My final calculation was:

$$C=F^{-1}*\frac{E(x) }{\frac{faulty_{percentage}}{controlled_{percentage}}*BatchesControlled_{percentage}}$$

In this formula, C is the percentage of a batch that needs to be controlled. $F^{-1}$ is the inverse cumulative exponential function with $λ=\frac{1}{E(x)}$. This is only dependent on $α$ and is 2,99 for$α=0,95$.

The faulty/controlled percentages are based on the total number of bikes. $\frac{faulty_{percentage}}{controlled_{percentage}}$ is a way to account for the bias or performance of the inspector. The better the inspections (so inspection is only done at faulty bikes), the less bikes need inspections.

The BatchesControlled is to justify for the fact that not all batches get an inspection. The logic behind it is: if you save on inspections in 1 batch, you will have to pay for it in another batch.

$C$ can be applied to a batch with size $Q$ to determine the inspection size.

I'm really curious what you all think of this idea. It might not be very theoretically interesting, but for the company I work for it is practical and easy to understand.

• What is alpha? What is your goal with this formula (e.g. have probability xx% that the expected proportion of defective items that get shipped is below y% of the items)? – Björn Aug 9 '17 at 11:45
• @Björn The way I've interpreted Alpha is: for alpha=0,95, 95% of the batches contain at most $E(x)*F^{-1}$ faulty bikes. Now by compensating this for the control efficiency (faulty/controlled) and the fraction of batches controlled, it gives the fraction of controls of a batch. – JtenBulte Aug 10 '17 at 15:31
• Still unclear what you try to achieve and at what level of faulty items you would do what (e.g. decide all is well, do more testing on the batch, test every single item in the batch, throw everthing in the batch away). – Björn Aug 10 '17 at 16:46