# Finding the distribution when the observations are dependent

How do we find information about the distribution of a variable in presence of dependency among our observations? This dependency is coming from measuring the variable on the same group of subjects multiple times.

These are two examples of what I have in mind:

1. Suppose we have a website for customers to purchase goods. We are interested in the distribution of the amount of time the customers spend on this site per visit. A customer might come back to the site many times. These visits are considered distinct observations. A customer's second visit might be because of an earlier promotion that they saw on the site. Therefore, our observations are not i.i.d. (or a simple random sample).

2. In a clinical trial, where, say, blood glucose levels are measured for subjects in 3 minute intervals and we're interested in their "typical value" in the 20 minute interval after exercise. Again, the values are dependent for each subject.

My naive answer is to reduce all observations from the same subject to one value, and to look at the distribution of these values, but I'm certain there's a better way to do this.

Update: After reading the responses from @PeterFlom and @NickCox, I realized that my question was somewhat vague and I needed to add some more detail.

Let's assume that I'd like to find the mean of this distribution. The weak law of large numbers requires i.i.d. variables (probably there is a more general version, say for exchangeable variables, but that's still not a valid condition in the situations I mentioned above.) How does one go about finding "average time a user spends on the website per visit"?

I welcome any suggestions, but I'm most interested in answers that have some theoretical justification.

Update 2:

This is the mathematical formulation of my question. Hopefully, it'll clarify the ambiguities in the wording:

Suppose for $N$ subjects, we've made observations:

• For subject 1, $X_{1,1},\ldots,X_{1,i_1}$.
• For subject 2, $X_{2,1},\ldots,X_{2,i_2}$.
• ...
• For subject N, $X_{N,1},\ldots,X{N,i_N}$.

(So, the number of observations for different subjects is not the same.) All the $X_{i,j}$ have the same distribution, but they are not necessarily independent.

My question is, if my goal is to estimate $E(X_{i,j})$, what would be the best estimator? I don't believe the answer $$\frac{\sum_{i,j}X_{i,j}}{i_1+\cdots+i_N}$$ is correct, because the law of large numbers doesn't apply here.

My answer is $$\frac{\sum_i\frac{\sum_j X_{i,j}}{i_j}}{N}$$ but as I mentioned earlier, I feel there must be something better.

• Average time a user spends on the website per unit: I am lost on what you seek here. My answer is: use the data; evidently you want something else. May 20 '13 at 16:10

It depends on what you want to do and why you are looking at the distribution. If it is purely to describe the sample, there are several possibilities:

Just look at first visits. You could then find mean, etc., or (more usefully, I think) draw a density plot and either a strip plot or box plot (depending on N) and possibly other plots as well.

Look at all visits on one density plot, with different lines for first, second, third visits, or use parallel box plots.

Look only at people who made at least N visits, and then examine their first, second... nth visit, using similar graphs to last case.

Look at pairs of visits, perhaps using a matrix of quantile-quantile plots, or perhaps a scatter plot matrix.

Look at trend over time, with a line for each person (if the N is relatively small).

and probably a bunch of other things I am not thinking of at the moment.

If you want to use these data for modelling, then let us know more about it.

You are mixing together issues that usually are separate. The distribution of anything for a given customer is a distribution, regardless of whether there is any kind of dependence e.g. in time. Same is true for a patient in a clinical trial. If you reduce either distribution to a single value, you're throwing away information. The information gained by pooling summary values of different customers or patients won't be the same information, except by accident.

Note that your proposal would mean that you would never work with time series unless you were sure they were pure noise, but we usually can learn much more from a time series than from its average.

You are presumably thinking that dependence is a nuisance because you have often read of independence assumptions, particularly for inference. But the answer to any such nuisance is not usually to throw away information. It is more commonly to use methods that make more accurate assumptions e.g. time series methods when serial dependence is genuine -- or not to use methods that assume independence; or just to be much more cautious when dependence is an issue. Most inference procedures are approximate at best any way.