# May I ask how to fix a parameter value in Stan without modifying stan file?

**URL:** <https://discourse.mc-stan.org/t/may-i-ask-how-to-fix-a-parameter-value-in-stan-without-modifying-stan-file/22980>\
**Category:** General\
**Created:** [June 11, 2021, 1:22pm UTC](https://discourse.mc-stan.org/t/may-i-ask-how-to-fix-a-parameter-value-in-stan-without-modifying-stan-file/22980 "2021-06-11T13:22:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [June 12, 2021, 10:08am UTC](https://discourse.mc-stan.org/t/may-i-ask-how-to-fix-a-parameter-value-in-stan-without-modifying-stan-file/22980/2 "2021-06-12T10:08:59Z")

</div>

This should work:

```stan
data{
  int which_fixed ;
  real fixed_value ;
  … // other data
}
parameters{
  vector[4] abcd ;
  … // other parameters 
}
model {
  abcd[1] ~ … // prior for a
  abcd[2] ~ … // prior for b
  … // c & d priors too
  vector[4] abcd_with_fixed = abcd ;
  abcd_with_fixed[which_fixed] = fixed_value ;
  … // other model structure 
}
…

```

You’ll still get samples for the fixed parameter that represent samples from the prior, but everything else will reflect a posterior conditional on that parameter being fixed at the supplied value.

---

_[View the full topic](https://discourse.mc-stan.org/t/may-i-ask-how-to-fix-a-parameter-value-in-stan-without-modifying-stan-file/22980)._
