Hi R helpers,

I am trying to use the if statement to generate a truncated random variable
as follows:

if (y[i]==0)  { v[i] ~ rnorm(1,0,1) | (-inf ,0) }
if (y[i]==1) { v[i] ~ rnorm(1,0,1) | (0, inf) }

I guess I cannot use " | (  , ) " to restrict the range of a variable in R.
Could you let me know how to write the code correctly in R?

Many thanks for your help.

Maomao

	[[alternative HTML version deleted]]

