How remove transformed parameters draws in cmdstanr

I am using cmdstanr, and I have a code that creates some transformed parameters, the problem is that these transformed parameters are very big vector >3k samples and I have multiple like this, so a total of more than 12k different transformed parameters. Once the model finishes I when I want to get the summary or draws it is very slow and inconvenient, either by using posterior or shinystan, also these are parameters that I don’t need so they are also a waste of space, is there a way to remove them from the fitted output. I don’t care about them, they are just an intermediate output, so maybe the .stan needs to be written differently? As an example this is how the model is written

    // the initial data is only used to transform it, not in the final model
    vector[N] values;

    real k;
    real beta;

transformed parameters{
    // create the transformed values by using a function and a parameter to tune
    vector[N] values_tf = fn(values, k)


    target ~ normal(values_tf * beta)


Move vector[N] values_tf = fn(values, k) to the model block. Intermediate quantities created there aren’t saved/writen out (see 8.7 Program block: model | Stan Reference Manual).


Wow!! didn’t know I could do that! I’ll try it thanks :)

1 Like