-
Notifications
You must be signed in to change notification settings - Fork 4
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
Modify all summary functions to take into account design information (i.e., weights). #3
Comments
@tilltnet , @raffaelevacca , this one might have to be you: I only understand the data structure and survey design parts of |
…lating average netzsize and average density.
I included this in summary.egor. All other analysis functions calculate per ego values from alters/ alter_ties, so I think there is no need to include weights there, but I should include examples using the weights for summarising, i.e. compositional results with weighted.mean() EDIT: or the svymean() thing, of course! |
I've changed the code so that Edit: The changes are in the |
As far as I can gather, we have two kinds of summary functions:
I am not actually sure which, except for the Based on this, I think that in order to properly incorporate sampling weights, we should probably have functions of the first type return a |
|
With #53 being resolved, we can now modify the first type of functions to return data of the appropriate type. I am increasingly of the opinion that we should not output different formats depending on whether the underlying In light of this, we need some way to control the output format for the first type, such as
Any thoughts? |
Both options are good I think. I have a slight preference for the first. I would use Stepping back a bit though I am not sure if this is offers the right workflow to people that have an The way I teach it in the workshop is that ego level results should be joined to the Long story short, I think if we go in this direction we should also consider implementing a |
Either works.
By that argument, should the default be
Do you mean that they should return an x %>% activate("ego") %>% left_join(res, ".egoID") should get the desired result. If we just want a survey with two variables, the ego ID and the result, it becomes out <- egor$ego
out$variables <- left_join(out$variables[".egoID"], res, ".egoID")
out
I opened a ticket on |
Ok, I looked into it and joining results to the egor object works fine, as demonstrated by your example above. Given this I think we should add the |
Apologies for the slow reply... I like the neutral ( |
Actually, could we make it an |
For the maintenance of the package using a global option with |
Just a quick note: options( foobleh = NULL )
o <- options()
"foobleh" %in% names(o)
## FALSE
getOption("foobleh")
## NULL |
Good point. That's a part of why I prefer |
If the option is needed in a (hopefully) single place in the code then simply |
I think that is an advantage in this case. If we want 'inherit` to be the standard we don't need to set the option anywhere and only the user will have to set it if they want something else than the default. The implementation I pushed in Currently I am not setting the global option and the default is 'inherit'. But as I said above, I am not completely sure, what the default should be. To summarize pros and cons from the previous discussion: Default =
|
The option is only accessed in one place currently. I was thinking to use |
Using the hooks for setting options is a bad idea. |
The options set in It's possible to set the options without clobbering existing ones using some code along the following lines (currently used in OPTIONS <- list(ergm.eval.loglik=TRUE,
ergm.loglik.warn_dyads=TRUE,
ergm.cluster.retries=5)
current <- names(options())
for(opt in names(OPTIONS)){
if(! opt%in%current){
do.call(options, OPTIONS[opt])
}
} |
If the user sets the option in say Rprofile (as is common to set options per user or per project), Edit: ok your code will not overwrite it. Still, i think having the defaults in the package namespace as I shown earlier is much cleaner. |
The defaults can go anywhere By the way, here's an even simpler implementation, assuming do.call(options, PKGOPTIONS[setdiff(names(PKGOPTIONS), names(options()))]) |
I've just implemented a function |
|
Thanks, I used that as inspiration. The defaults are now set with The default for |
Thanks! The name seems a bit verbose. Also, I would suggest replacing the dots after the first with underscores. |
would that be better? since those are not typed out regularly but at a maximum typed at the beginning of a session it should be as verbose as necessary to get across what it does. |
The simplest way to do that is to simply use
weights(egor)
to get the list of ego weights according to the design. Note that the weights are not normalized: they do not necessarily sum to 1.A more advanced use is
svymean(x, ego.design(egor))
, which takes a vector or a matrixx
and evaluates its sample mean in accordance with the survey design.The text was updated successfully, but these errors were encountered: