I though I could work through this on a more complicated model, but I’m still struggling. Here’s my model as currently is:

```
data{
int n_pos;
int n_halves;
int n_offTeams;
int n_defTeams;
int n_matchups;
int n_offCoaches;
int n_defCoaches;
int n_posTypes;
int<lower=1, upper=n_halves> half[n_pos];
int<lower=1, upper=n_posTypes> posType[n_pos];
int<lower=1, upper=n_offCoaches> offCoach[n_pos];
int<lower=1, upper=n_defCoaches> defCoach[n_pos];
int<lower=1, upper=n_offTeams> offTeam[n_pos];
int<lower=1, upper=n_defTeams> defTeam[n_pos];
int<lower=1, upper=n_matchups> matchup[n_pos];
vector[n_pos] weight;
vector[n_pos] offFouls;
vector[n_pos] defFouls;
vector[n_pos] offRecord;
vector[n_pos] defRecord;
vector[n_pos] offWinStreak;
vector[n_pos] offLoseStreak;
vector[n_pos] defWinStreak;
vector[n_pos] defLoseStreak;
}
parameters{
vector[n_posTypes-1] a;
vector[n_offCoaches] a_offCoach;
vector[n_defCoaches] a_defCoach;
vector[n_offTeams] a_offTeam;
vector[n_defTeams] a_defTeam;
vector[n_matchups] a_matchup;
vector[n_halves] b_offFouls;
vector[n_halves] b_defFouls;
real b_offRecord;
real b_defRecord;
real b_offWinStreak;
real b_defWinStreak;
real b_offLoseStreak;
real b_defLoseStreak;
}
model{
vector[n_posTypes] p;
vector[n_posTypes] s = rep_vector(0, n_posTypes);
a ~ normal(0,1);
a_offCoach ~ normal(0,1);
a_defCoach ~ normal(0,1);
a_offTeam ~ normal(0,1);
a_defTeam ~ normal(0,1);
a_matchup ~ normal(0,1);
b_offFouls ~ normal(0,1);
b_defFouls ~ normal(0,1);
b_offRecord ~ normal(0,1);
b_defRecord ~ normal(0,1);
b_offWinStreak ~ normal(0,1);
b_defWinStreak ~ normal(0,1);
b_offLoseStreak ~ normal(0,1);
b_defLoseStreak ~ normal(0,1);
s[1:(n_posTypes - 1)] = weight .* (a +
a_offCoach[offCoach] + // line 63
a_defCoach[defCoach] +
a_offTeam[offTeam] +
a_defTeam[defTeam] +
a_matchup[matchup] +
b_offFouls[half] .* offFouls +
b_defFouls[half] .* defFouls +
b_offRecord * offRecord +
b_defRecord * defRecord +
b_offWinStreak * offWinStreak +
b_defWinStreak * defWinStreak +
b_offLoseStreak * offLoseStreak +
b_defLoseStreak * defLoseStreak);
p = softmax( s);
posType ~ categorical(p);
}
```

and here’s the `str()`

of the data:

```
$ n_pos : int 3919
$ n_halves : num 2
$ n_offTeams : int 132
$ n_defTeams : int 143
$ n_matchups : int 734
$ n_offCoaches : int 17
$ n_defCoaches : int 17
$ n_posTypes : int 25
$ half : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
$ posType : Factor w/ 25 levels "NoDefFoul_NoOffFoul_NoOffTechFlag_0DefPts_0OffPts",..: 1 1 1 3 1 3 1 1 2 5 ...
$ offCoach : Factor w/ 17 levels "AmirJohnson",..: 7 10 7 10 7 10 7 7 7 10 ...
$ defCoach : Factor w/ 17 levels "AmirJohnson",..: 10 7 10 7 10 7 10 10 10 7 ...
$ offTeam : Factor w/ 132 levels "AkilMitchellTJClineGlenRiceJr",..: 102 84 102 84 102 84 102 102 102 84 ...
$ defTeam : Factor w/ 143 levels "AkilMitchellTJClineGlenRiceJr",..: 91 109 91 109 91 109 91 91 91 112 ...
$ matchup : Factor w/ 734 levels "OFFAkilMitchellTJClineGlenRiceJr_VS_DEFChrisJohnsonJohathonSimmonsCharlesGarcia",..: 628 556 628 556 628 556 628 628 628 557 ...
$ weight : num [1:3919] 1 1 1 1 1 ...
$ offFouls : num [1:3919] -1.79 -1.79 -1.79 -1.79 -1.79 ...
$ defFouls : num [1:3919] -1.79 -1.79 -1.79 -1.79 -1.79 ...
$ offRecord : num [1:3919] 0 0 0 0 0 0 0 0 0 0 ...
$ defRecord : num [1:3919] 0 0 0 0 0 0 0 0 0 0 ...
$ offWinStreak : num [1:3919] 0 0 0 0 0 0 0 0 0 0 ...
$ offLoseStreak: num [1:3919] 0 0 0 0 0 0 0 0 0 0 ...
$ defWinStreak : num [1:3919] 0 0 0 0 0 0 0 0 0 0 ...
$ defLoseStreak: num [1:3919] 0 0 0 0 0 0 0 0 0 0 ...
```

Running as is, I get the following error:

```
Chain 1 Unrecoverable error evaluating the log probability at the initial value.
Chain 1 Exception: add: m1 ((24, 1)3919, 1) must match in size (in [...], line 63, column 2 to line 76, column 70)
```

I think there is something wrong with the dimenions of my parameters, but changing them to something like `matrix[n_posType, n_offCoach] offCoach`

hasn’t helped. Relatedly, if the problem is the dimensions of the parameters, I’m not sure using the `.*`

operator will be appropriate once corrected.

Any help greatly appreciated. Many thanks!