Skip to content
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

Add summary table of metrics at the end #10

Open
sgoodreau opened this issue Apr 13, 2020 · 9 comments
Open

Add summary table of metrics at the end #10

sgoodreau opened this issue Apr 13, 2020 · 9 comments

Comments

@sgoodreau
Copy link
Contributor

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
Copy link
Collaborator

@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
Copy link
Collaborator

@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
Copy link
Collaborator

EmilyPo commented Apr 14, 2020 via email

@EmilyPo
Copy link
Collaborator

EmilyPo commented Apr 14, 2020 via email

@sgoodreau
Copy link
Contributor Author

sgoodreau commented Apr 15, 2020 via email

@martinamorris
Copy link
Member

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

@netterie
Copy link
Collaborator

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
Copy link
Member

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
Copy link
Collaborator

Moving the discussion re: simulation uncertainty to #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants