Setting binomial prior

61 views
Skip to first unread message

Belinda Davey

unread,
Oct 2, 2023, 6:32:38 PM10/2/23
to blavaan
Hi all,

Is it possible to set a binomial prior on nu? I couldn't find anything on this.

Thank you,
Belinda

Ed Merkle

unread,
Oct 2, 2023, 9:18:28 PM10/2/23
to Belinda Davey, blavaan
Belinda, could you say more about what you are wanting to do? I don't think that a binomial prior would make sense here because binomial is a discrete distribution, and the intercepts (nu) are continuous.

In general, the default target="stan" allows only normal priors here, but target="jags" allows more flexibility for prior specification.

Ed

Ed

--
You received this message because you are subscribed to the Google Groups "blavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blavaan+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blavaan/a2932f34-fb97-425c-a249-ba318837ecafn%40googlegroups.com.

Belinda Davey

unread,
Oct 3, 2023, 4:58:30 PM10/3/23
to Ed Merkle, blavaan
Hi Ed,

Thanks for your assistance. One of my observed measures is based on the sum of 12 trials, which are each scored 0 or 1. In addition, the distribution of this variable is negatively skewed, and looks like the following, so we thought it is perhaps better represented by a binomial distribution rather than a normal distribution:
image.png

I have also been trying to check the ESS-tails. Is there an easy way to do that in blavaan? I have tried to use some options found in various papers etc but I can't get any to work.

Thank you, Ed.

Best wishes,
Belinda

Ed Merkle

unread,
Oct 4, 2023, 7:40:51 PM10/4/23
to Belinda Davey, blavaan
Thanks, that makes some more sense. For that observed variable, I think you would want the likelihood (not the prior) to be binomial(n=12, p), where p is the probability of a 1 on each trial. This sort of likelihood is not currently available in blavaan.

One possible workaround would be to create 12 0/1 variables, one for each trial. Then blavaan could handle them as 12 binary/ordered variables, using the "ordered" argument.


About the tail ESS: if fit is your fitted blavaan model, you could do

out <- blavInspect(fit, "mcobj")

Then out is the underlying Stan object. So you can do things like

rstan::ess_tail(as.matrix(out))

which returns the minimum tail ESS.

Ed


On Wed, 2023-10-04 at 07:58 +1100, Belinda Davey wrote:
Hi Ed,

Thanks for your assistance. One of my observed measures is based on the sum of 12 trials, which are each scored 0 or 1. In addition, the distribution of this variable is negatively skewed, and looks like the following, so we thought it is perhaps better represented by a binomial distribution rather than a normal distribution:

Belinda Davey

unread,
Oct 10, 2023, 4:46:44 AM10/10/23
to Ed Merkle, blavaan
Thank you, Ed. So the minimum tail ESS will tell me the minimum number of effective samples in the tail end? Do you know how many or what % of MCMC trials the tail ESS includes? 

Also, does the number that this code outputs (ie 378.68) tell me the minimum effective samples that my model produced across all of the estimated parameters in the tail end of the MCMC trials? So the worst estimated parameter in terms of ESS in the tail end produced 376.68 ESS? Is there a way to determine which parameter this was for?

Thank you so much for your help!

Best wishes,
Belinda

Ed Merkle

unread,
Oct 10, 2023, 1:28:47 PM10/10/23
to Belinda Davey, blavaan
No problem, and here are some more responses:

About % of MCMC trials is included: it should be all the trials after warmup/burnin. So this would be the blavaan "sample" argument times the "n.chains" argument.

About 378.68: yes, this should be the smallest (worst) value across all parameters.

About which parameter that is for: I think

monitor(as.array(out))

shows tail ESS for individual parameters. The parameter names will not match the blavaan parameter names... to see the correspondence, do

with(parTable(fit), cbind(paste0(lhs, op, rhs), pxnames))


Ed
Reply all
Reply to author
Forward
0 new messages