4
$\begingroup$

I use a Bayesian latent variable model to construct a time series cross-sectional measure of corruption for all countries in the world from 1960 to 2010. For each country-year observation, I obtain a latent estimate $\theta$. To illustrate, here is the code for the model:

# run the Stan model 
mod.dyn <- stan(file="DynamicLVMminfinal.stan",
                data=stan.data, seed=570175513, thin = 5,
                iter=8000)

Next, I calculate the median values for each column in the out$thetas object and then adding those median values as a new column named dyn.estimates to the data frame df.

out <- extract(mod.dyn)
df <- df[order(df$count.year.id),]
df$dyn.estimates <- apply(out$thetas, 2, median)
df$dyn.up <- apply(out$thetas, 2, quantile, 0.975) 
df$dyn.lo <- apply(out$thetas, 2, quantile, 0.025) 

I want to plot the average level of corruption for each year over time. To do so, I group the observations by year, and then calculate the average of dyn.estimates for that year. Here is my question. Is this mathematically/analytically defensible? That is, is it fine to take the mean of what are median values? Thanks.

$\endgroup$
2
  • 1
    $\begingroup$ This question could be easier to answer if you explain what the latent estimate θ represents, and over what variable you are calculating median and mean. E.g. do you calculate a median of multiple observations of a single country in a single year? $\endgroup$
    – jpa
    Commented Aug 27, 2023 at 9:11
  • $\begingroup$ @jpa, good point. Maybe my answer is too generic, just addressing the last question, and the outcome is not the what is intended. W5698, could you outline your model in "DynamicLVMminfinal.stan"? $\endgroup$
    – Ute
    Commented Aug 27, 2023 at 11:15

1 Answer 1

4
$\begingroup$

Is it fine to take the mean of what are median values?

It is fine, from a mathematical view. The median of a sample or of a posterior distribution obtained from a sample is, like all statistics, just a random variable. There is nothing to say against taking its average.

Inference from the average of medians may be mathematically more tricky, since theoretical properties are not so easy to derive than for averages of averages.

$\endgroup$
2
  • 1
    $\begingroup$ On a finite collection of numbers I don't see a problem. Whether the expectation of the a random median is defined in the population depends on the distribution of that random median. Not all distributions have a finite expectation. Suppose that the random median followed a Cauchy distribution, then the expectation of the random median would not exist. But I cannot say that I have thought through the math fully. Is it possible to have a random median with unbounded expectation? I don't know. $\endgroup$
    – Galen
    Commented Aug 27, 2023 at 5:37
  • 1
    $\begingroup$ @Galen, also had that started to write about that Cauchy distribution. But as the posterior itselve, whence the median is consistent. A distribution with Cauchy distibuted sample median would be quite artificial if it existed at all. A situation where posterior median is Cauchy :??? Anyway, in less dramatic cases median should be better than mean. When posterior distributions are Cauchy, then median is better than mean $\endgroup$
    – Ute
    Commented Aug 27, 2023 at 5:45

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.