Does Stan allowed complex sampling?

Hi Everyone,

When we work with survey data, we may need to incorporate the complex sampling to sample the data. Will stan allow to do complex sampling? I couldn’t find any useful information regarding complex sampling in the stan user manual.

Any help will be highly appreciated.

Thank you.

Hi, what do you mean with complex sampling? Complex numbers?

Edit. Or do you mean, can you create complex models (with custom interactions)?

@ahartikainen When data are independent, we assume that the each observation has the same weight. But the observations are not always independent. For an example when we analyze the survey data, the observations are coming from different clusters(strata). Then the observations are not independent and weights can be computed for each observation and we may need to incorporate these weights when fitting the models. I have the sampling weights and I need to know whether stan allow to use those weights (may be in the likelihood) when fitting models.(For an example If we fit a classical GLM model using glm function in r, there is a option called weight that we can use to specify the sampling weights).

Here is another source that you can read about complex sampling :


Ok, yes there are ways to add weights for observations if needed. Usually this is done by adding weights for individual likelihoods.

If you use bmrs / stanarm, there might be a straight forward way to do this.

cc @paul.buerkner @avehtari

See Survey weighted regression and related discussions

@ahartikainen Thank you. I will go through with this source. For my work I need to work directly with stan rather than using some package.