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

offset causes model gof error #14

Closed netterie closed 6 years ago

netterie commented 6 years ago

Is there something about this particular model that is causing the offset to malfunction?

data(faux.mesa.high)
fmh.ego <- as.egodata(faux.mesa.high)
model = ergm.ego(fmh.ego ~ edges + offset(nodematch("Sex", diff=FALSE)), 
                offset.coef=c(-Inf),
                popsize=network.size(faux.mesa.high))

gof(model, GOF='model') # gives same error as 
summary(fmh.ego ~ edges + offset(nodematch("Sex", diff=FALSE)))

Error is: Error in eval(expr, envir, enclos) : could not find function "EgoStat.offset"

dth2 commented 6 years ago

I just ran through your example and the offset is not malfunctioning. If you just run a summary on the model it works. The issue is that ergm.ego doesn’t recognize offset as a model term so the summary and gof functions specific to ergm.ego are throwing an error. EgoStat is the function in ergm.ego that goes through the ergm equation and decided what to do with each term in the model. The only terms that ergm.ego will recognize are listed below. I think this is an issue for Pavel. Hopefully it is a quick fix.

EgoStat.edges

' EgoStat.nodecov EgoStat.nodefactor EgoStat.nodematch EgoStat.nodemix

' EgoStat.absdiff EgoStat.degree EgoStat.degrange EgoStat.concurrent

' EgoStat.concurrentties EgoStat.degreepopularity EgoStat.mean.age

https://github.com/statnet/ergm.ego-private/blob/master/R/EgoStat.R

summary(model)

==========================

Summary of model fit

==========================

Formula: fmh.ego ~ edges + offset(nodematch("Sex", diff = FALSE))

Iterations: 5 out of 20

Monte Carlo MLE Results:

          Estimate Std. Error MCMC % p-value    

netsize.adj 0.00000 0.00000 0 NA

edges -3.92546 0.07474 0 <1e-04 ***

nodematch.Sex -Inf 0.00000 0 <1e-04 ***


Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

The following terms are fixed by offset and are not estimated:

netsize.adj nodematch.Sex

From: JKB [mailto:notifications@github.com] Sent: Monday, October 23, 2017 12:32 PM To: statnet/ergm.ego ergm.ego@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [statnet/ergm.ego] offset causes model gof error (#14)

Is there something about this particular model that is causing the offset to malfunction?

data(faux.mesa.high) fmh.ego <- as.egodata(faux.mesa.high) model = ergm.ego(fmh.ego ~ edges + offset(nodematch("Sex", diff=FALSE)), offset.coef=c(-Inf), popsize=network.size(faux.mesa.high))

gof(model, GOF='model') # gives same error as summary(fmh.ego ~ edges + offset(nodematch("Sex", diff=FALSE)))

Error is: Error in eval(expr, envir, enclos) : could not find function "EgoStat.offset"

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/statnet/ergm.ego/issues/14 , or mute the thread https://github.com/notifications/unsubscribe-auth/AJ-_MeMwRqd2JRq_HQ-lY6GyB2acJF2bks5svOmwgaJpZM4QDX1Q .

dth2 commented 6 years ago

Pavel,

It looks like you have addressed this in both the Public and Private versions which is awesome. Is there an easy way to pull this change in to the version that SHAMP currently uses?

https://github.com/statnet/ergm.ego-private/tree/3.7-compat

From: Pavel N. Krivitsky [mailto:notifications@github.com] Sent: Monday, October 23, 2017 2:42 PM To: statnet/ergm.ego ergm.ego@noreply.github.com Cc: dth2 dth2@u.washington.edu; Comment comment@noreply.github.com Subject: Re: [statnet/ergm.ego] offset causes model gof error (#14)

Closed #14 https://github.com/statnet/ergm.ego/issues/14 via https://github.com/statnet/ergm.ego/commit/c6e18f9bde69bf2feaf1a694d595ea82e3a6e856 c6e18f9.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/statnet/ergm.ego/issues/14#event-1306578211 , or mute the thread https://github.com/notifications/unsubscribe-auth/AJ-_Mdy9w2qE8ZNjWpIJNTeec_lzm401ks5svQgegaJpZM4QDX1Q .

krivit commented 6 years ago

I merged into 3.7-compat as well.

netterie commented 6 years ago

Thank you Pavel!

martinamorris commented 6 years ago

I merged into 3.7-compat as well.

thx for the quick response ;)