Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

This question already has an answer here:

I am estimating a stochastic frontier with a mixed model. So far the half normal distribution worked good but I need a truncated normal distribution. It does not work, and I receive the error „Expected collection operator c“. I am using R2WinBUGS and as you can see in the model I have tried OpenBUGS and WinBUGS. Any suggestion? My model looks like:

for (i in 1:N)
 {

    mu[i] <- alpha + x[i,1]*beta[1] + x[i,2]*beta[2] + x[i,3]*beta[3] + 
         x[i,4]*beta[4] + x[i,5]*beta[5] + u0[county[i]] + u1[county[i]]*x[i,1] + 
         u2[county[i]]*x[i,2] + u3[county[i]]*x[i,3] + u4[county[i]]*x[i,4] + 
         u5[county[i]]*x[i,5] - z[ID[i]]

    y[i] ~ dnorm(mu[i], tau)

}


for (i in 1:220) {
    z[i] ~ djl.dnorm.trunc(rho,lambda,0,1000)

    z[i] ~ dnorm(rho,lambda)T(0,100)  #For openbugs

    eff[i] <- exp(-z[i])
}

prior for rho~dnorm(0,0.027)

I would appreciate your help! Regards, Daniel

share|improve this question

marked as duplicate by David, Peter Flom, whuber Jun 4 '13 at 12:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Is this question only about how to get something done in R / WinBUGS? If so, it would be off-topic for CV (see our FAQ), but on topic for Stack Overflow. If you have a substantive statistical question, please edit to clarify it, if not, you can flag your Q for migration (please don't cross-post, though). –  gung Feb 3 '13 at 19:38
    
The function djl.dnorm.trunc looks suspicious to me. Why don't you use the dnorm(..)I(..) here also? –  Curious Feb 3 '13 at 19:53
    
Thanks Thomas, I tried that one too and it doesn't work –  Daniel C Feb 4 '13 at 8:38

1 Answer 1

For truncating, I use the operator I i.e.:

x ~ dnorm(mean, tau)I(low, high)
share|improve this answer
    
I have tried it and I get the same error. Thanks! –  Daniel C Feb 3 '13 at 19:28
1  
@DanielC Your error will be probably caused by different line of code than this one... –  Curious Feb 3 '13 at 19:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.