Closed martinamorris closed 3 years ago
summary(c.egodata ~ meandeg, scaleto = fit_casl$ppopsize)
doesn't work?
I don't think it is related. This does not work because there is no summary
in ergm.ego
. The actual S3 dispatch is base::summary()
-> ergm:::summary.formula()
-> ergm::summary_formula()
-> ergm.ego:::summary_formula.egodata()
. I'm not sure if it is possible without attaching ergm.ego
.
data(faux.mesa.high, package="ergm")
fmh <- ergm.ego::as.egodata(faux.mesa.high)
summary(fmh ~ edges)
# Error in EgoStat.edges(egodata = list(egos = list(vertex.names = 1:205, :
# could not find function "EgoStat.edges"
The compiled code not loading @krivit ?
What @mbojan said.
But even after attaching, it doesn't work:
d> summary(c.egodata ~ meandeg, scaleto = fit_casl$ppopsize)
Error in EgoStat.meandeg(egodata = list(egos = list(if_PART5 = c(NA, 1, :
could not find function "EgoStat.meandeg"
ergm
3.11, ergm.ego 0.6
Per the error message, that's because there is no meandeg
EgoStat. Mean degree is not an egocentric statistic: its ego's contribution depends on the network size, which an ego cannot observe.
Still, the edges
does not work with package not attached.
I (untested and speculative) think that in:
the terms are evaluated in the environment of the formula. If the formula is created with the package not attached, R can't find these functions in none of the enclosing environments of the formula environment.
The meandeg
case is working as intended. The problem arises when the package is loaded but not attached.
Yep, exactly.
We need to use the term lookup mechanism from ergm
, which can handle this situation. (The relevant utilities are exported.)
Per the error message, that's because there is no
meandeg
EgoStat. Mean degree is not an egocentric statistic: its ego's contribution depends on the network size, which an ego cannot observe.
Right. But if our assumption is (as it has been) that meandeg is the size invariant parameterization, can you remind me why we can't estimate it from egocentric data?
I'm trying to track down the source of the 25% difference in the observed and simulated meandegs for the casl network (as we've been discussing, report online here), and they track back to the way the network is scaled up in ergm.ego -- it doesn't preserve the mean degree for either the fit$network, or the fit$newnetwork. Both of those have the same mean degree as sims from the model, so there's consistency after scaleup -- the problem emerges in the scaleup itself.
We can calculate it, but it doesn't scale like an egocentric statistic. We may be able to add the term (and tag it appropriately to keep it from confusing the inferential machinery). In the meantime, summary(egodata~edges, scaleto=2)
should do the trick (since m = 2 * e / n
).
Yep, but the post-scale up edges for all nets are consistent with the scaled up target stats from the summary function. So the divergence between the weighted egodata and the scaled up network is happening somewhere in that scaleup.
It's not consistent (the other nets don't show this large discrepancy), and I don't think it's a weighting problem (the other nets are also weighted, and the weights are generally moderate (with a handful of outliers).
d> summary(c.egodata$egoWt)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.6273 0.8056 0.9476 1.0000 1.1050 11.7128
So I'm at a dead end here.
OK, it looks like the term locator is not actually exported from ergm
. That complicates things.
OK, that fixes the problem of not being able to find the EgoStat.*
when package not attached. The downside is that we need to release another update to statnet.common
before pushing this.
I'll start a separate ticket to discuss how the meandeg
egostat should be evaluated, if at all.
Using the mean.age
statistic as a model, it turned out that EgoStat.meandeg
was easy enough that it's not worth opening another ticket.
not sure if this is related to the
ergm::ergm issue
. this is withergm.ego 0.6