statnet / ergm.ego

Fit, Simulate and Diagnose Exponential-Family Random Graph Models to Egocentrically Sampled Network Data https://statnet.org
Other
14 stars 4 forks source link

Allow the user to disable network size adjustment. #65

Closed krivit closed 2 years ago

krivit commented 3 years ago

With edges, it's straightforward, and practically every model has some kind of a density effect anyway. With triadic effects, there is multiple ways to specify them (including the different GWESP decay values), which means that the default network size adjustment for network of size n may mess up the triadic model.

Since this is a "what model you're fitting" rather than a "how you're fitting it" type control, it should probably be a top-level parameter; and simulate.ergm.ego() probably needs it as well.

@martinamorris , @mbojan , what do you think?

mbojan commented 3 years ago

Sounds reasonable to me.

pt., 18 cze 2021, 16:29 użytkownik Pavel N. Krivitsky < @.***> napisał:

With edges, it's straightforward, and practically every model has some kind of a density effect anyway. With triadic effects, there is multiple ways to specify them (including the different GWESP decay values), which means that the default network size adjustment for network of size n may mess up the triadic model.

Since this is a "what model you're fitting" rather than a "how you're fitting it" type control, it should probably be a top-level parameter; and simulate.ergm.ego() probably needs it as well.

@martinamorris https://github.com/martinamorris , @mbojan https://github.com/mbojan , what do you think?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/statnet/ergm.ego/issues/65, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3NHXKGDBLBVMJLZV2WOLTTNJ43ANCNFSM465ZB3TQ .

martinamorris commented 3 years ago

yes it sounds reasonable. but it should probably be the default as long as there are only dyad.independent and degree terms in the model, and we may want to throw a warning for any other term.

this seems like a complicated issue, as i'm not sure what should be done if both mutual and gwesp are in a model.

krivit commented 3 years ago

Right now, that's not possible because we only support undirected networks.

martinamorris commented 3 years ago

So the only conflict now is with the gwesp term? And that's only relevant when the aatie component exists for modeling, right?

Assuming you knew how you wanted to scale gwesp, i'm assuming you'd still use the standard size adjustment for the DI terms, but a gwesp-specific adjustment for that term. Is that right?

I guess I'd be in favor now of throwing an error if someone tries to scale a model with a gwesp term. They can still fit to the observed sample, and models without gwesp would behave as they do now.

mbojan commented 3 years ago

Would a simple top-level argument, say sizeadj, expecting TRUE/FALSE suffice? TRUE boils down to adding an offset to the formula, doesn't it?

BTW. Has there been any progress that I might have missed wrt the issue with (gw)esp and network size adjustment we hit when doing the working paper on triadic terms? I'm not sure I follow the gwesp scaling @martinamorris refers to.

martinamorris commented 3 years ago

@mbojan i was referring to the scaling proposed in Kolaczyk & ‎Krivitsky 2015 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4584154/

krivit commented 3 years ago

@mbojan , I didn't have time to work on it. I think we had a way forward, but no time to implement it.

krivit commented 3 years ago

OK, you can now disable net size adjustment by entering popsize = 0 or popsize = I(N). Does this UI make sense?

I still need to write some unit tests, unless someone else volunteers?

mbojan commented 3 years ago

@mbojan i was referring to the scaling proposed in Kolaczyk & ‎Krivitsky 2015 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4584154/

Ah, OK.

OK, you can now disable net size adjustment by entering popsize = 0 or popsize = I(N). Does this UI make sense?

I still need to write some unit tests, unless someone else volunteers?

Why I(N)? How about popsize=NULL?

krivit commented 3 years ago

@mbojan , we can have NULL do the same as 0. The reason for I(N) is that in the ordinary course of things, if you specify a popsize that isn't 1, it'll also use that as the pseudo-population size. I want to retain that capability.

krivit commented 3 years ago

I'll call this done and release the package. Please reopen if unsatisfied.

chad-klumb commented 2 years ago

I am getting an error in the MPLE case:

require(ergm.ego)
nw <- network(10, dir = F)
e <- as.egor(nw)
ergm.ego(e ~ edges, popsize = 0)

produces

> ergm.ego(e ~ edges, popsize = 0)
Constructing pseudopopulation network.
Starting maximum pseudolikelihood estimation (MPLE):
Evaluating the predictor and response matrix.
Maximizing the pseudolikelihood.
Finished MPLE.
Stopping at the initial estimate.
Error in ergm.fit$sample[, 1] <- 0 : 
  incorrect number of subscripts on matrix

but, e.g., ergm.ego(e ~ edges + degree(1), popsize = 0) seems to work.