# Model for sensitivity of a diagnostic test, expected value should be \> 50%

**URL:** <https://discourse.mc-stan.org/t/model-for-sensitivity-of-a-diagnostic-test-expected-value-should-be-50/26382>\
**Category:** Modeling\
**Tags:** posterior-predictive, priors, specification, interpret-results, brms\
**Created:** [February 16, 2022, 7:17pm UTC](https://discourse.mc-stan.org/t/model-for-sensitivity-of-a-diagnostic-test-expected-value-should-be-50/26382 "2022-02-16T19:17:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angelo\_D\_Ambrosio](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/angelo_d_ambrosio/32/5298_2.png) [@Angelo\_D\_Ambrosio](https://discourse.mc-stan.org/u/Angelo_D_Ambrosio)\
**Post date:** [February 16, 2022, 7:17pm UTC](https://discourse.mc-stan.org/t/model-for-sensitivity-of-a-diagnostic-test-expected-value-should-be-50/26382/1 "2022-02-16T19:17:47Z")

</div>

Hello,

I have a study design in which I’m comparing the sensitivity of two COVID19 serology tests at different time points from infection. I am using a logistic model in `brms` with the following formula:

`mvbind(TestOne, TestTwo) ~ TimeFromPos + (1 | g | ID) + (0 + TimeFromPos | p | ID)`

with TestOne and TestTwo being to booleans variables indicating a positive test result, and TimeFromPos being the time points (from 0 to 3, in terms of follow-ups from infection). It is assumed that once a person gets infected she should have a positive serology, but the antibody count can decrease causing a drop in sensitivity. I used random effects to add individual variability to the baseline sensitivity and to its decrease in time.

My problem is that in theory, the sensitivity should be always \> 50% since these tests should not fail systematically. But I don’t know how to force the logit of the expected value to stay positive.

I tried the following priors:

```nohighlight
c(
	prior(lkj(2), class = 'cor'),
	prior(exponential(1/1.6), class = "Intercept", resp = 'TestOne'),
	prior(normal(0, 1), class = "sd", group = 'ID',, resp = 'TestOne'),
	prior(student_t(3, 0, 1), class = "b", resp = 'TestOne'),
	prior(exponential(1/1.6), class = "Intercept", resp = 'TestTwo'),
	prior(normal(0, 1), class = "sd", group = 'ID',, resp = 'TestTwo'),
	prior(student_t(3, 0, 1), class = "b", resp = 'TestTwo'),
)

```

The exponential prior on the Intercept helps (at the cost of many out-of-boundary proposal values), but the random and fixed effects are still enough to produce a posterior all over the place:

```nohighlight
    [,1] [,2] [,3] [,4]   
5% "62.2%" "27.2%" "3.92%" "0.34%"
25% "89.1%" "80.7%" "60.3%" "34.3%"
50% "95.5%" "95.1%" "93.6%" "91.1%"
75% "98.7%" "98.9%" "99.3%" "99.6%"
95% "99.9%" "99.9%" "100%" "100%"

```

these are the expected (inv-logit transformed) values produced by `brms::posterior_epred`, with the 4 follow-ups in the columns, and the posterior quantiles on the rows.

These wide intervals are to be expected due to the small number of samples (58 evaluated at follow-up zero to only 2 with three follow-ups), but I really believe that it makes sense to force the final sensitivity to stay above 50%.  
Any indication on how to achieve this in `brms` or, if necessary, directly in `stan`?
