osofr / simcausal

Simulating Longitudinal and Network Data with Causal Inference Applications
64 stars 11 forks source link

Error in rcategor and rcategor.int for large numbers of groups #1

Closed bsaul closed 9 years ago

bsaul commented 9 years ago

I'd like to use rcategor (or rcategor.int) to assign individuals to a large number of categories, but the following example illustrates an error:

D <- DAG.empty()
D1 <- D + node('group',
              distr = 'rcategor.int',
              probs = rep(1/50, 50)) 
D2 <- D + node('group',
               distr = 'rcategor.int',
               probs = rep(1/55, 55)) 
D1 <- set.DAG(D1)
D2 <- set.DAG(D2)

D1 is fine. D2, however, presents the following error: image

I'm just starting to play with the package. It's great so far!

osofr commented 9 years ago

Thanks for catching this. Before I get to the bottom of this, as a quick fix, you can replace probs = rep(1/55, 55)) with probs = .(rep(1/55, 55))) This will force immediate evaluation of the expression inside .() and seems to work. It won't work though if the expression in probs includes other node names.

bsaul commented 9 years ago

Great. Thanks!

On Jul 8, 2015, at 3:13 PM, Oleg Sofrygin notifications@github.com wrote:

Thanks for catching this. Before I get to the bottom of this, as a quick fix, you can replace probs = rep(1/55, 55)) with probs = .(rep(1/55, 55))) This will force immediate evaluation of the expression inside .() and seems to work. It won't work though if the expression in probs includes other node names.

— Reply to this email directly or view it on GitHub https://github.com/osofr/simcausal/issues/1#issuecomment-119699974.

osofr commented 9 years ago

Fixed now, should work as intended. Thanks for reporting.