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]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to