Should weights be applied in generated quantities block in stan?

fitting-issues
techniques

#1

Dear stan community. I want to do predictions via generated quantities block. Should the weights be applied again in the generated quantities block in addition to the likelihood in the model block?

   model{
        ...
    	target +=  weights[i] * binomial_lpmf(...);
        ...
        }

    generated quantities{
        ...
        y_pred[i] = weights[i] * inv_logit(...);
        ...
        }

or not?

    model{
        ...
    	target +=  weights[i] * binomial_lpmf(...);
        ...
        }

    generated quantities{
        ...
        y_pred[i] = inv_logit(...);
        ...
        }

Thanks in advance for any help.


#2

I’m not sure you want to use weights that way, but one thing I know for sure is that you don’t want to multiply on the log scale – 1/2 of log 5 is 0.8, but if you do log(.5) + log(5) and then exponentiate, you get the much more reasonable 2.5. You probably want to add the weights on the log scale, e.g.

target += log(weights[i]) + binomial_lpmf(...);

Survey weighted regression
#3

Thanks @saudiwin. With this question (also see here), what I seek is any clarification wrt this:

Thanks in advance for any help.