3
$\begingroup$

I want to calculate the mean and standard error of the mean for the amount spent per person visiting a store. Most people don't buy anything, so the distribution looks like this

${\rm P}({\rm purchased},{\rm spend}) = {\rm P}({\rm purchased}) {\space} {\rm P}({\rm spend} | {\rm purchased})$

where purchased and spend are two dependent variables -- dependent in that if purchased = False, then spend is necessarily 0.

One way to do this would be by taking the mean and standard error from the collection of amount spent by each person:
$ T = [\$13, \$6, \$0, \$0, \$0, \$0, \$0, \$0, \$0, \$5, \$0, \$0, \$0, ...]$

$ E(T) = \frac{1}{N} \sum_{i=1}^{N} T_{i}$

$ {\rm standard \space error} = \frac{\sqrt{\frac{1}{N-1} \sum_{i=1}^{N} (T_{i} - E(T))^2}}{\sqrt{N}} $

However, I'm worried about missing the inherent binomial distribution, given that some people bought something and others didn't.

Is there a more correct way to calculate the standard error of the mean?

$\endgroup$

2 Answers 2

1
$\begingroup$

I'll offer slightly different notation. Assuming each customer only visits the store once (thus visits can be taken to be IID), for customer $i$, let $X_i=1$ be the event that she makes a purchase and $X_i=0$ if she does not. Let $Y_i$ be the amount spent if anything is purchased. Thus the total purchase is $$P_i = X_i Y_i,$$ and in fact because we take the purchase amount to be the product of $X$ with $Y$, they can be defined to be independent without loss of generality. (Recall, you observe $P_i$, and based on $P_i>0$ you also know $X_i=1$. If you observe $P_i=0$, then it doesn't matter what value $Y_i$ took--you can use any model. So you might as well assume it's independent.).

Now $\bar P = \frac{1}{n} \sum_{i=1}^n P_i$ converges to $E\left[ P \right]$ by the law of large numbers and if $Var \left[ P \right] = \sigma^2 < \infty$, then $$\sqrt{n} \left( \bar P - E \left[ P \right] \right) \sim N(0, \sigma^2),$$ so you know the asymptotic distribution (or rate of convergence if you like) of your estimator. So you don't have do to any fancy to get an estimate of the mean purchase amount--just take the average. The exact same logic applies to getting an estimate of $\sigma^2$--you can just plug in the sample estimate $\hat \sigma^2 = \frac{1}{n} \sum_{i=1}^n \left( P_i - \bar P \right)^2$ and it doesn't matter if we scale by $1/n$ or $1/(n-1)$ asymptotically.

On the other hand, if you want to estimate the mean of $X$ or of $Y$, then you've got a more interesting problem. For the mean of $X$, can consider the purchases to be bernoulli coin flips, so you can use standard estimates for bernoulli/binomial counts. For $Y$, we must lean heavily on the assumption that $Y$ is independent of $X$--then we can just estimate properties of $Y$ from the cases in which $X=1$. (So $Y$ is missing completely at random when $X=0$.) There's no way to identify a more complicated model than this from the observations $P$ alone--because when $X=0$, you have no knowledge of $Y$.

$\endgroup$
0
0
$\begingroup$

I believe you are considering fitting two models. 1 is a binomial of whether or not someone bought a cake. The other is the total amount spent on cakes from a power law function.

We will call distribution 1 N and distribution 2 X and S be the combination of N and X.

If these are distributions are assumed to be independent then calculating the total variance and mean is fairly simple: E[S]=E[N]E[X], Var(S) = E[N]Var(X)+Var(N)E[X]^2

(edit - I had the second moment when I meant to type the mean squared)

Again, only if N and X are assumed to be independent. If they were not independent then I would model the total spent using a Tweedie distribution.

$\endgroup$
2
  • $\begingroup$ The formula that I know for total variance for two independent random variables is (I'm switching to X and Y because I use N for sample size): Var(XY) = [E(X)]^2 Var(Y) + [E(Y)]^2 Var(X) + Var(X) Var(Y) (I think that you're missing raising N to the power of 2 in the first term on the right hand side). However, how do you normalize this for standard error? One model comes from the full sample of visitors. The other comes from the subset who actually made a purchase. This is why I asked if it's okay to use the simple calculation, as described. $\endgroup$
    – rebka
    Aug 14, 2014 at 23:10
  • $\begingroup$ Also, I just added a note that the variables are actually not independent $\endgroup$
    – rebka
    Aug 14, 2014 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.