Question

Would someone please let me know what the equals function in WinBUGS return if one of the elements in the equals brackets is NA?

Specifically, I want to do the transformation:

for(i in 1:N){
    newvar[i] <- 1*equals(oldvar[i],0) + 2*equals(oldvar[i],1.5) + 3*equals(oldvar[i],4) + 4*equals(oldvar[i],8)
}

and want to preserve NA's, so records with NA in oldvar[i] also has NA in newvar[i], but I am afraid that this tranformation turns NA's into 0's.

Any and all advice is much appreciated.

Trang

Était-ce utile?

La solution

This should give an error message (made use of undefined node) if you haven't put a prior distribution on oldvar[1]. WinBUGS expects all nodes to have values if they are used in calculations. If you have put a prior on it, then WinBUGS should generate values from the posterior distribution of oldvar[1], and then the equals() function should operate on those generated values. Have you used a prior which systematically generates zeroes for oldvar[1]? If you're not interested in modelling the missing data, I'd advise dropping the missing values from your data before using it in WinBUGS.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top