Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing multiple model objects to setNode (+ Issue #6) #7

Closed
jdutch27 opened this issue Feb 15, 2015 · 4 comments
Closed

Passing multiple model objects to setNode (+ Issue #6) #7

jdutch27 opened this issue Feb 15, 2015 · 4 comments

Comments

@jdutch27
Copy link
Collaborator

In Issue #6 (get node distn from model object) I assumed only a single model object.

Maybe the modelObjects parameter should be a list of model objects instead of a single model object.

Here's what I think the user should be able to do.

mod.pe <- glm(pe ~ wells, family="binomial", data=d1)
mod.d.dimer <- lm(d.dimer ~ pregnant_pe, data=d2)
mod.angio <- glm(angio ~ pe, family="binomial", data=d1)
mod.treat <- glm(treat~ d.dimer_angio, family="binomial", data=d3)
mod.death <- glm(death ~ pe*treat, family="binomial", data=d2)

my.models <- list(mod.pe, mod.d.dimer, mod.angio, mod.treat, mod.death)

net <- HydeNetwork(~ wells
+ pe | wells
+ d.dimer | pregnant_pe
+ angio | pe
+ treat | d.dimer_angio
+ death | pe*treat)

net <- setNode(net, modelObjects = my.models)
net <- setNode(net, wells, "dnorm", mu=5, tau=1/(1.5^2))
net <- setNode(net, pregnant, "dbern", p=0.10)

**Even better:

my.models <- c(my.models, lm(wells ~ 1, data=d2), glm(pregnant ~ 1, family="binomial", data=d1))
net <- HydeNetwork(modelObjects = my.models)

@nutterb
Copy link
Owner

nutterb commented Feb 19, 2015

I think I might be more comfortable with this as a separate function. setNode is very clearly structured for dealing with a single node, a decision I made because I assumed most users would work with one node at a time.

This proposal seems like the user is providing the information as several nodes at once. It's a great idea, and can be done, but I might suggest something more like

net <- setNodeModels(lm(wells ~ 1, data=d2),
    glm(pregnant ~ 1, family=binomial, data=d1))

This may require an additional element for each node, if we are going to accept the possibility of differing data objects for each model. But if net$nodeData$[node_name] = NULL, it could then look to net$data.

@nutterb
Copy link
Owner

nutterb commented Feb 20, 2015

Agreed to have separate functions.

@jdutch27
Copy link
Collaborator Author

jdutch27 commented Mar 2, 2015

See Issue #20 .

We may consider doing the above but for single nodes, using an adaptation of modelToNode().

@nutterb
Copy link
Owner

nutterb commented Mar 2, 2015

setNodeModels is now included.

@nutterb nutterb closed this as completed Mar 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants