# If I have T total records, how big should my sample size be for a valid analysis?

I have a bunch of records, T in total. I want to know how many of these I can get away with analyzing in order to extrapolate the analysis to the entire population T.

I know this is a basic question and largely depends on how much error I can accept, but can anyone tell me the math?

• It also depends on what the records represent (ie are they independent observations, or a sequence of events on independent units in time, or a sequence of events for a single unit) and what kind of analysis (summarize the data, compare two groups, regression an outcome on some covariates) you plan to do. Can you provide more details? It would be also helpful to know the reason you want to subsample instead of analyzing the full population. – Jeremy Coyle Jan 30 '14 at 16:04
• Try googling for power analysis. It allows you to answer questions like "how many should I sample to get this-and-that margin of error, this-and-that confidence". – Marc Claesen Jan 30 '14 at 16:45
• I don't see why this question needs 3 downvotes. – gung - Reinstate Monica Jan 30 '14 at 18:35
• There is no single answer to that, @RemyF. It depends on the nature of the analysis you are going to do & what you want to know. If you tell us that, we can try to help you further. If you can't, this question cannot be answered. – gung - Reinstate Monica Jan 30 '14 at 18:44
• (Copied & pasted from above) "Eg, do you want to know the arithmetic mean of your population +/- some MoE, the proportion of your population w/ some attribute +/-, the SD of your population, etc?" There are potentially innumerable types of analyses. Moreover, there is no way to know how much data you'll need to do what you want to do if you don't know what you want to do. – gung - Reinstate Monica Jan 30 '14 at 18:48

Assuming you want to estimate the mean of a variable with a certain margin of error you can use $E=z_{\alpha/2}\frac{\sigma}{\sqrt{n}}$ where $E$ is the margin of error, $z_{\alpha/2}$ is the normal distribution quantile for the confidence level you want (1.96 for a 95% confidence interval), $\sigma$ is the standard deviation of the variable you're forming the confidence interval for, and $n$ is the sample size.

Obviously you don't know $\sigma$ but you can get a small sample (say n=100) and estimate it with the sample standard deviation to get a first approximation.

In general you can see from this formula that margin of error decreases proportional to $\sqrt(n)$, which should give you some intuition that there's diminishing returns for large n. This "root n" rate is common to anything that behaves like a mean (many parameters including regression coefficients are essentially means). This is all a result of the central limit theorem.

See http://stattrek.com/estimation/margin-of-error.aspx for more exposition.

• I'm not sure what you're asking, but confidence intervals/margin of errors relate to estimates for some parameter, most commonly estimates of population mean. This is why I asked you to clarify what kind of analysis you wanted to do. – Jeremy Coyle Jan 30 '14 at 17:52
• I think the key issue is that the OP has a finite sample, thus, the standard formulas don't apply, you need to use a finite sample correction. – gung - Reinstate Monica Jan 30 '14 at 18:35
• It's not that we're trying to make things complicated; they are potentially complicated because there's not enough to go on and we don't want to assume things that mightn't be true. This is a simple question and it does have a simple answer: 5000 of them, in fact, ranging from a sample size of 1 through the entire population. Nobody is happy with such a broad range of possibilities, though, because they don't narrow your options. If you want to make progress, you need to supply more information, as many commenters have been requesting. – whuber Jan 30 '14 at 21:22
• @Gung all samples are finite: I presume you mean finite population and you are referring to a finite population correction. – whuber Jan 30 '14 at 21:23
• @whuber, someone w/ enough grit & determination could keep sampling indefinitely. (Yes, I meant finite population ;-). – gung - Reinstate Monica Jan 30 '14 at 21:25