statnet / COVID-JustOneFriend

GNU General Public License v3.0
1 stars 2 forks source link

Add summary table of metrics at the end #10

Open sgoodreau opened 4 years ago

sgoodreau commented 4 years ago

Needs to be in a tab though so only seen by the "What's Going On?" crowd, or else somehow very carefully worded to make sense to the others.

netterie commented 4 years ago

@sgoodreau @EmilyPo

I didn't have time to insert this into the document in a good place, but here's a start to the table - code below (and it's easy to change the rounding).

image

Two questions:

  1. Should the denominator be 200, or 199, for computing percentages for degrees of separation? Steve used 200 in the document (line 205). I kept it at 200, but it's easy to change using the code below.
  2. Where does the GeekWire stat of 71% come from? They write image

Code - I put it in the code chunk starting at 309

# Distances 
distances <- rbind( geo.sep(net.precov, 'Pre-Covid'),
    geo.sep(emptynet, 'Pure Isolation'),
    geo.sep(net.essl, 'Essential Only'),
    geo.sep(net.comb.1, 'Just One Friend'),
    geo.sep(net.comb.2, 'Just One Friend Per HH'))

# Labels
net.order <- c('Pre-Covid', 'Pure Isolation', 
               'Essential Only', 'Just One Friend', 
               'Just One Friend Per HH')
rownames(distances) <-net.order

# Function to add percentages
add_percent <- function(x, r1, r2, n=200) {
  xround <- round(x, r1)
  percround <- round(100*x/n, r2)
  return(paste0(xround, " (", percround, "%)"))
}

# Vector of largest components, in net.order order
largest.components <- c(largcomp.precov,
                        1,
                        largcomp.essl,
                        largcomp.comb.1,
                        largcomp.comb.2)

# Summary table
summary.table <- data.frame(Network=net.order,
                            `Largest Cluster`=
                              add_percent(largest.components,
                                          r1=0, r2=1, n=200),
                            `vs Essential Network`=
                              round(largest.components/largcomp.essl, 1),
                            `3 Degrees of Separation`=
                              add_percent(distances[,1],
                                          r1=1, r2=2, n=200),
                            `6 Degrees of Separation`=
                              add_percent(distances[,2], 
                                          r1=1, r2=2, n=200),
                            check.names=FALSE,
                            row.names=NULL)

Note: I used the kableExtra option "responsive" because "Tables with option responsive looks the same with others on a large screen. However, on a small screen like phone, they are horizontally scrollable. Please resize your window to see the result."

library(kableExtra)
knitr::kable(summary.table) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))

Note, if you run the code on the inverted table t(summary.table), it looks something like this: image

netterie commented 4 years ago

@sgoodreau @EmilyPo I see that the 71% statistic is in the published version and also in SocDistNets.html. The weird thing is, when I knit SocDistNets.Rmd, this is what I see:

image

Is this happening to anyone else? If not, I won't worry about it! It's just weird - it's a fresh knit from a fresh clone - no cache. Is something changing the seed? It's kind of a big difference for just that.

EmilyPo commented 4 years ago

That is odd…I’m getting that too when I re-knit. For it to be up online at 71% the change had to have happened when I was monkeying with the yaml (trying to get the google analytics tag in the html header without directly editing the html) - but I thought I only committed the html file that contains the google analytics tag in case we needed it again.

But I didn’t touch anything other part of the code??

On Apr 14, 2020, at 4:33 PM, JKB notifications@github.com wrote:

@sgoodreau https://github.com/sgoodreau @EmilyPo https://github.com/EmilyPo I see that the 71% statistic is in the published version and also in SocDistNets.html. The weird thing is, when I knit SocDistNets.Rmd, this is what I see:

https://user-images.githubusercontent.com/4825649/79283694-718fb580-7e6d-11ea-9c05-1900854e6340.png Is this happening to anyone else? If not, I won't worry about it! It's just weird - it's a fresh knit from a fresh clone - no cache. Is something changing the seed? It's kind of a big difference for just that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/statnet/COVID-JustOneFriend/issues/10#issuecomment-613731978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6YCJGESIWFWATLPIDXDZ3RMTXFTANCNFSM4MGU62LA.

EmilyPo commented 4 years ago

I actually think the change starts in the essential network.

What i’ve got locally: Screen Shot 2020-04-14 at 4 52 48 PM

What’s on the web: Screen Shot 2020-04-14 at 4 52 07 PM

Tried to go back and see the different commit versions, but couldn't find a difference in the rmd files other than the author list change Steve made earlier today...

On Apr 14, 2020, at 4:44 PM, Emily D Pollock emilypo@uw.edu wrote:

That is odd…I’m getting that too when I re-knit. For it to be up online at 71% the change had to have happened when I was monkeying with the yaml (trying to get the google analytics tag in the html header without directly editing the html) - but I thought I only committed the html file that contains the google analytics tag in case we needed it again.

But I didn’t touch anything other part of the code??

On Apr 14, 2020, at 4:33 PM, JKB <notifications@github.com mailto:notifications@github.com> wrote:

@sgoodreau https://github.com/sgoodreau @EmilyPo https://github.com/EmilyPo I see that the 71% statistic is in the published version and also in SocDistNets.html. The weird thing is, when I knit SocDistNets.Rmd, this is what I see:

https://user-images.githubusercontent.com/4825649/79283694-718fb580-7e6d-11ea-9c05-1900854e6340.png Is this happening to anyone else? If not, I won't worry about it! It's just weird - it's a fresh knit from a fresh clone - no cache. Is something changing the seed? It's kind of a big difference for just that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/statnet/COVID-JustOneFriend/issues/10#issuecomment-613731978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6YCJGESIWFWATLPIDXDZ3RMTXFTANCNFSM4MGU62LA.

sgoodreau commented 4 years ago

My guess is that the same seed produces different results on different systems. We do need to be careful about changing the numbers so much with each change, so perhaps it's best for me to be the only one who renders the final html from now on? Not super efficient, but if it leads to consistent numbers it seems worth it.

On 4/14/2020 4:56 PM, Emily Pollock wrote:

I actually think the change starts in the essential network.

What i’ve got locally:

What’s on the web:

On Apr 14, 2020, at 4:44 PM, Emily D Pollock emilypo@uw.edu wrote:

That is odd…I’m getting that too when I re-knit. For it to be up online at 71% the change had to have happened when I was monkeying with the yaml (trying to get the google analytics tag in the html header without directly editing the html) - but I thought I only committed the html file that contains the google analytics tag in case we needed it again.

But I didn’t touch anything other part of the code??

On Apr 14, 2020, at 4:33 PM, JKB <notifications@github.com mailto:notifications@github.com> wrote:

@sgoodreau https://github.com/sgoodreau @EmilyPo https://github.com/EmilyPo I see that the 71% statistic is in the published version and also in SocDistNets.html. The weird thing is, when I knit SocDistNets.Rmd, this is what I see:

https://user-images.githubusercontent.com/4825649/79283694-718fb580-7e6d-11ea-9c05-1900854e6340.png Is this happening to anyone else? If not, I won't worry about it! It's just weird - it's a fresh knit from a fresh clone - no cache. Is something changing the seed? It's kind of a big difference for just that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/statnet/COVID-JustOneFriend/issues/10#issuecomment-613731978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6YCJGESIWFWATLPIDXDZ3RMTXFTANCNFSM4MGU62LA.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/statnet/COVID-JustOneFriend/issues/10#issuecomment-613738360, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB66LAQPBBPWPW3RICUWQ5DRMTZ3DANCNFSM4MGU62LA.

--


Steven M. Goodreau / Professor / Dept. of Anthropology Physical address: Denny Hall M236 Mailing address: Campus Box 353100 / 4216 Memorial Way NE Univ. of Washington / Seattle WA 98195 1-206-685-3870 (phone) /1-206-543-3285 (fax) http://faculty.washington.edu/goodreau


martinamorris commented 4 years ago

And we will need to exploit the stochastic capacity we have to generate distributions :)

netterie commented 4 years ago

I’ll definitely leave the rendering to you, Steve, but I am surprised that setting the seed isn’t sufficient. I will poke around tomorrow, maybe explore seed sensitivity to get an interval for the stats.

martinamorris commented 4 years ago

seed setting is complicated in R. if you add any code in between, it changes the sequence, and subsequent calculations can change. i think the sol'n is to run the distributions, so we can justify our numbers...

netterie commented 4 years ago

Moving the discussion re: simulation uncertainty to #14