# Computational cost of unused parameters?

**URL:** <https://discourse.mc-stan.org/t/computational-cost-of-unused-parameters/18715>\
**Category:** Modeling\
**Created:** [October 16, 2020, 1:31am UTC](https://discourse.mc-stan.org/t/computational-cost-of-unused-parameters/18715 "2020-10-16T01:31:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![walkerharrison](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@walkerharrison](https://discourse.mc-stan.org/u/walkerharrison)\
**Post date:** [October 16, 2020, 1:31am UTC](https://discourse.mc-stan.org/t/computational-cost-of-unused-parameters/18715/1 "2020-10-16T01:31:28Z")

</div>

When modeling, for example, random intercepts in a regression, I follow the standard of indexing a vector the length of the number of groups in the variable:

```
data {

  int<lower = 0> N;
  int<lower = 0> N_grps;

  int<lower = 1, upper = N_grps> grp [N];
}
parameters {
  vector [N_grps] mu_grp; 
}

```

Sometimes I test my code on subsets of the data without rows from every member of the group. I like to avoid re-indexing the group for simplicity, so instead of declaring a smaller `N_grps`, I keep it the same and end up having elements of the vector `mu_grp` that are never referred to in the likelihood and therefore (I think) never actually “fit,” beyond their prior.

This doesn’t seem to cause much of a computational difference for modest `N` and `N_grp`, but I’m wondering if I should expect worse performance for bigger datasets or, more broadly speaking, if I should avoid including unused parameters for other reasons.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 16, 2020, 1:34am UTC](https://discourse.mc-stan.org/t/computational-cost-of-unused-parameters/18715/2 "2020-10-16T01:34:24Z")

</div>

> [@walkerharrison](#):
>
> if I should avoid including unused parameters for other reasons.

It’s OK if you have a proper prior (ideally with two finite moments) on the otherwised unused parameters.

---

<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:** [October 16, 2020, 12:23pm UTC](https://discourse.mc-stan.org/t/computational-cost-of-unused-parameters/18715/3 "2020-10-16T12:23:01Z")

</div>

Note that a related thread is [here](https://discourse.mc-stan.org/t/possibly-bad-idea-for-debatably-easier-ragged-arrays/18516/9), though you’ve asked the question more succinctly!
