# Fitting distributions in R

I hope you are very well. I have a big dataset (~9 million registries) and I have 2 variables $X$=purchase amount and $Y$=frequency of purchase. I would like to know what distribution should I use for each variable and fitting its distribution with R. For example, for $X$ I'm testing with package 'mixtools' but the results are not really good. I want to create a simulation model, that simulates that variables. First of all, I'm selecting appropriate probability distributions (and associated parameters) to describe the behavior of each uncertain input variable. Thanks.

UPDATE: I have replaced the pdf with a histogram for each variable.

• Y looks geometric. Is there a relationship between the two? Commented Jul 12, 2013 at 22:18
• Yes. The top image is the purchase amount (X), the bottom image is the frequency of purchase (Y).
– MSS
Commented Jul 12, 2013 at 22:22
• Could you indicate why you are fitting distributions to these data and what you hope to accomplish with the result?
– whuber
Commented Jul 13, 2013 at 2:32
• I'm going to bet that $Y$ is discrete (times per day) and your automatically-chosen bandwidth is too narrow to be useful. A simple histogram or table would be better in this case. Commented Jul 13, 2013 at 14:34
• I hope you are doing well too. Commented Jul 13, 2013 at 15:38

## 1 Answer

I'd say you don't need a density estimate at all. With millions of data points, you have a sample that's large enough that it can serve as your simulation model. Simply select data points at random (with replacement) to carry out your simulations.

• Great answer! No need to bother with a guess at a named distribution just because it has a name. @MSV since your variables are related, sample from them together. Don't pick a random X and a random Y, pick a random (X, Y) pair. Commented Jul 14, 2013 at 17:50
• +1 However, MSV, while for very large data sets this is probably the approach I'd suggest (taking into account @shujaa's clarification), one must understand that this approach nevertheless contains assumptions (such as independence of (x,y) pairs from other pairs, that the future will be like a random sample of the past). By the way, your histograms in your question should really have more bins. Commented Jul 15, 2013 at 0:33