Difficulty packing parameter matrix for map_rect

I’m trying to write a function of map_rect. I need to pack up parameters for the theta term and its proving a little troublesome.

The variables are:

matrix[NvarsY, N_ind] beta0_ind;
matrix[NvarsX, N_ind] beta_ind [NvarsY];

…and I will be slicing them by unique values of NvarsY. My current best attempt is:

    vector[(NvarsX +1) * N_ind] theta [NvarsY];
     ...other stuff...

    for (dv in 1:NvarsY){
        // pack up betas into thetas
        theta = append_row( to_vector(beta0_ind[dv, ]), to_vector( beta_ind[dv, 1:NvarsX, ] )) );
    }

This is giving me the error:

Dimension mismatch in assignment; variable name = theta, num dimensions given = 1; right-hand side dimensions = 0

I can’t see whats causing this - any suggestions ? Much appreciated!

Nevermind. I just spotted two syntax errors that have fixed the issue. 🙃

Corrected line of code:

        theta[dv] = append_row( to_vector(beta0_ind[dv, ]), to_vector( beta_ind[dv, 1:NvarsX, ] ));
1 Like