Sample from the product of the normal distribution and the cumulative normal distribution

Dear Stan developers,

Thanks for developing this fantastic program.
I am implementing MCMC for computing the posterior distribution of parameters of a cognitive model.

The data structure is like follows:

trial stimulus choice estimation
1     1        1      0.9
2     -2       0      -1.3
3     -3       0      -3.1
4     2        0      2.2

On each trial, a stimulus is shown and subjects were required to make a binary choice to decide whether the stimulus is smaller (choice=0) or larger than 0 (choice=1).
Subsequently, subjects should estimate the magnitude of the stimulus in the continuous dimension.

The likelihood of parameters given the data is the product of the normal pdf and the normal cdf:
Likelihood[trial] = normal(...)*normal_pdf(...).

An error occurred when I just coded the sampling process by the product of normal and normal_pdf.
Can Stan implement MCMC with that likelihood?

Thanks!

If the likelihood is the product of the normal pdf and cdf, then you can use the sum of the normal log pdf and log cdf:

 target += normal_lpdf(y | mu, sigma) + normal_lcdf(y | mu, sigma)

Thanks for the reply!
I am sorry that I might mislead the problem.

My target is a continuous estimation (e.g., -3, 0, or 1).
And the target is sampled from the product of the normal pdf and cdf.
So, I want to implement a code that samples the target from the product of the normal pdf and cdf:
target[t] ~ normal(mu1,sigma1)*normal_pdf(mu2,sigma2)

By the way, should I use += instead of ~?
I am unfamiliar with +=.
Does += indicate sampling?

Because you are specifying the likelihood as a function, rather than a distribution, then you need to use the target += notation.

The target += notation allows you specify the log-likelihood directly, rather than one of the built-in distributions. The Functions Reference for each distribution shows the log-probability function that is used. More information is in this section.

For example, when you call:

y ~ normal(mu, sigma);

This is the same as:

target += normal_lupdf(mu, sigma)

Because you want the likelihood to be:

y ~ normal(mu1,sigma1)*normal_cdf(mu2,sigma2)

This can be specified using the log-probability functions directly:

target += normal_lpdf(y|mu1, sigma1) + normal_lcdf(y|mu2, sigma2)
2 Likes

What a kind reply!
I understood the situation.
Very thanks!!!

2 Likes

This is proportional to a skew normal distribution with shape parameter α = 1 if the location and scale parameters are the same. Would it be preferable to use skew_normal_lpdf or one of the variants directly?

1 Like