[R] if statement and truncated distribution

2010-10-25 Thread Sally Luo
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

Re: [R] if statement and truncated distribution

2010-10-25 Thread Nick Sabbe
25 oktober 2010 2:01 To: r-help@r-project.org Subject: [R] if statement and truncated distribution 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