# How to calculate a weighted mean with missing observations

**URL:** https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281
**Category:** Statistics
**Created:** [January 4, 2019, 8:01pm UTC](https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281 "2019-01-04T20:01:56Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)
#### Post date: [January 5, 2019, 9:47am UTC](https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281/9 "2019-01-05T09:47:23Z")

</div>

We definitely need something to handle this. Passing both vectors to `skipmissing` is appealing (and could be useful in other situations), but unfortunately it wouldn’t work if we made weights a keyword argument of `mean`, which was our plan I think.

Another solution would be to have a custom `mean` method for a `SkipMissing` first argument which would automatically skip weights corresponding to missing entries (this would only apply if the length of the weights vector is equal to the total number of values, including missing values).

---

_[View the full topic](https://discourse.julialang.org/t/how-to-calculate-a-weighted-mean-with-missing-observations/19281)._
