# Measurement error corrected hierarchical model in brms

**URL:** <https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427>\
**Category:** brms\
**Created:** [April 11, 2019, 2:56pm UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427 "2019-04-11T14:56:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilan\_Strauss](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ilan_strauss/32/4928_2.png) [@Ilan\_Strauss](https://discourse.mc-stan.org/u/Ilan_Strauss)\
**Post date:** [April 11, 2019, 2:56pm UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/1 "2019-04-11T14:56:05Z")

</div>

1. Have you released a vignette yet on measurement error using the brms package? I am trying to do a multilevel measurement error model but within a hierarchical structure.

The hierarchy is over time (year\_cat5) and the measurement error is on the variable “Q” which we are using to explain the investment rate of firms (inv\_rf).

1. In, principle, in this formulation, for a hierarchical measurement error model in brms correct?

## Family: student

## Links: mu = identity; sigma = identity; nu = identity

## Formula: inv\_rf ~ me(Q\_manual, Q\_sd) + cashflow\_rf + (1 + me(Q\_manual, Q\_sd) + cashflow\_rf | year\_cat5) + capital\_output + fic\_advanced\_nousa

## Data: data\_STAN\_lender\_sam (Number of observations: 584)

## Samples: 3 chains, each with iter = 4000; warmup = 2000; thin = 1;

## total post-warmup samples = 6000

I ask because when adding the hierarchical structure the impact of the measurement error vanishes basically, Ie when running a ‘fixed effects’ measurement error it makes a big difference; but the hierarchical measurement error makes little difference.

1. One issue is that I have a large dataset (360,000 data points. But it doesn’t seem to work with more 10,000 points or so. Understandable given that every datapoint will now be treated as an unknown parameter. What do you recommend to try work around this?

Best wishes,

our question:

- Operating System:
- brms Version:

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [April 15, 2019, 10:29am UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/2 "2019-04-15T10:29:51Z")

</div>

1. Not yet. I am still waiting for measurement models to be implemented in brms (version 3.0 as it currently stands) and then perhaps combine it into one vignette.

2. The specification looks reasonable to me.

3. You could try overimputation to incorporate the measurement error for instance via the **micemd** package and then pass the results to `brm_mutiple`. This will require fitting the model multiple times  
but at least each model will run considerably faster.

---

<div class="post-metadata">

**Author:** ![bnicenboim](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bnicenboim/32/21197_2.png) [@bnicenboim](https://discourse.mc-stan.org/u/bnicenboim)\
**Post date:** [August 24, 2020, 2:59pm UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/3 "2020-08-24T14:59:29Z")

</div>

sorry to bother with the same, but is there a draft?

I was trying to understand what exactly sdme and meanme are, but I couldn’t find anything in the help pages.

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [August 25, 2020, 7:58am UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/4 "2020-08-25T07:58:11Z")

</div>

I understand. It is badly documented. Perhaps looking at the Stan code itself can help. I don’t like the me() feature anymore to be honest. It implictely adds a measurement model without a separate formula, as does mi(). For this reason, I will soon deprecate me() in favor of using mi(), which can be used for the same purpose, as soon as I have figure out how to add grouping (argument `gr`) to mi().

---

<div class="post-metadata">

**Author:** ![bnicenboim](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bnicenboim/32/21197_2.png) [@bnicenboim](https://discourse.mc-stan.org/u/bnicenboim)\
**Post date:** [August 26, 2020, 11:07am UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/5 "2020-08-26T11:07:36Z")

</div>

ok, thanks!  
I’ll check mi() then, I wasn’t aware of it.

---

<div class="post-metadata">

**Author:** ![bnicenboim](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bnicenboim/32/21197_2.png) [@bnicenboim](https://discourse.mc-stan.org/u/bnicenboim)\
**Post date:** [May 28, 2021, 7:59pm UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/6 "2021-05-28T19:59:26Z")

</div>

hey, yearly question, what’s happening with measurement error models in brms :)  
Is `me()` getting deprecated? Should I teach (and write in our book) using mi()?

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [May 28, 2021, 10:29pm UTC](https://discourse.mc-stan.org/t/measurement-error-corrected-hierarchical-model-in-brms/8427/7 "2021-05-28T22:29:13Z")

</div>

That’s still a good question. Before deciding to deprecate, I still need to implement the gr argument to mi() and confirm that mi() indeed can be (easily) made to do the same as me(). I am pretty sure on the latter, but I would appreciate people trying it out. With regard to the former, perhaps I can get this implemented soon.
