<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title></title>
    <atom:link href="http://modelingsocialdata.org/feed.xml" rel="self" type="application/rss+xml"/>
    <link>http://modelingsocialdata.org/</link>
    <description></description>
    <pubDate>Wed, 24 Jul 2019 14:14:52 +0000</pubDate>
    
      <item>
        <title>Final project reports</title>
        <link>http://modelingsocialdata.org/lectures/2019/05/17/final-project-reports-2019.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/05/17/final-project-reports-2019.html</guid>
        <description>&lt;p&gt;Below is a list of the &lt;a href=&quot;/final-projects&quot;&gt;final projects&lt;/a&gt; for the Spring 2019 semester, including a link to the original paper, the students’ final report, and all code and data necessary to reproduce the final report.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Group&lt;/th&gt;
      &lt;th&gt;Original paper&lt;/th&gt;
      &lt;th&gt;Replication report&lt;/th&gt;
      &lt;th&gt;Code&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0165176599002499&quot;&gt;Wage disparity and team productivity: evidence from Major League Baseball&lt;/a&gt;, Craig A. Depken II, &lt;em&gt;Economics Letters&lt;/em&gt; (2000)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-1/blob/master/03_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-1&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.cambridge.org/core/journals/american-political-science-review/article/ethnicity-insurgency-and-civil-war/B1D5D0E7C782483C5D7E102A61AD6605&quot;&gt;Ethnicity, Insurgency, and Civil War&lt;/a&gt;, Fearon &amp;amp; Laitin, &lt;em&gt;American Political Science Review&lt;/em&gt; (2003)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-2/blob/master/05_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-2&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.cambridge.org/core/journals/american-political-science-review/article/ethnicity-insurgency-and-civil-war/B1D5D0E7C782483C5D7E102A61AD6605&quot;&gt;Greed and Grievance in Civil War&lt;/a&gt;, Collier &amp;amp; Hoeffler, &lt;em&gt;Oxford Economic Papers&lt;/em&gt; (2004)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-3/blob/master/02_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-3&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://dl.acm.org/citation.cfm?id=1772756&quot;&gt;Predicting Positive and Negative Links in Online Social Networks&lt;/a&gt;, Leskovec et al., &lt;em&gt;World Wide Web Conference&lt;/em&gt; (2010)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-4/blob/master/05_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-4&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1475-4932.2012.00809.x&quot;&gt;Predicting the Present with Google Trends&lt;/a&gt;, Choi &amp;amp; Varian, &lt;em&gt;Economic Record&lt;/em&gt; (2012)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-5/blob/master/08_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-5&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;6&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.cambridge.org/core/journals/political-analysis/article/comparing-random-forest-with-logistic-regression-for-predicting-classimbalanced-civil-war-onset-data/109E1511378A38BB4B41F721E6017FB1&quot;&gt;Comparing random forest with logistic regression for predicting class-imbalanced civil war onset data&lt;/a&gt;, Muchlinski et al., &lt;em&gt;Political Analysis&lt;/em&gt; (2016)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-6/blob/master/06_Analysis_And_Comparison.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-6&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;7&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.aeaweb.org/articles?id=10.1257/pol.1.1.75&quot;&gt;Housing, Health, and Happiness&lt;/a&gt;, Cattaneo et al., &lt;em&gt;American Economic Journal: Economic Policy&lt;/em&gt; (2009)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-7/blob/master/05_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-7&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;8&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.aaai.org/ocs/index.php/ICWSM/ICWSM17/paper/viewPaper/15665&quot;&gt;Automated Hate Speech Detection and the Problem of Offensive Language&lt;/a&gt;, Davidson et al., &lt;em&gt;International Conference on Weblogs and Social Media&lt;/em&gt; (2017)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-8/blob/master/05_final_report.pdf&quot;&gt;Jupyter pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-8&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;9&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://advances.sciencemag.org/content/1/1/e1400005&quot;&gt;Systematic Inequality and Hierarchy in Faculty Hiring Networks&lt;/a&gt;, Clauset et al., &lt;em&gt;Science Advances&lt;/em&gt; (2015)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-9/blob/master/02_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-final-project-group-9&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;10&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2769645&quot;&gt;Chilling Effects: Online Surveillance and Wikipedia Use&lt;/a&gt;, Penney, &lt;em&gt;Berkeley Technology Law Journal&lt;/em&gt; (2016)&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-10/blob/master/02_final_report.pdf&quot;&gt;Rmarkdown pdf&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/msd2019/msd2019-final-project-group-10&quot;&gt;Github repository&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</description>
        <pubDate>Fri, 17 May 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 12: Causality &amp; Experiments</title>
        <link>http://modelingsocialdata.org/lectures/2019/04/26/lecture-12-causality-and-experiments.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/04/26/lecture-12-causality-and-experiments.html</guid>
        <description>&lt;p&gt;In this lecture we discussed causal inference, randomized experiments, and natural experiments.&lt;/p&gt;

&lt;center&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;f50c15e459d24ecbbe2380a40316a08f&quot; data-ratio=&quot;1.77777777777778&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;
&lt;/center&gt;

&lt;p&gt;Most of what we’ve discussed in this class has focused on observational data—data obtained without direct intervention from or manipulation by those studying it.
We can learn a lot from observational data and use it to find interesting relationships, build predictive models, or even to generate hypotheses, but it has it limits.
This is often summarized by catchy phrases such as &lt;a href=&quot;http://freakonomics.com/2009/06/30/so-long-and-thanks-for-all-the-f-tests/&quot;&gt;“correlation is not causation”&lt;/a&gt; or &lt;a href=&quot;http://freakonomics.com/2009/06/30/so-long-and-thanks-for-all-the-f-tests/&quot;&gt;“no causation without manipulation”&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We opened this discussion by comparing two scenarios: (a) making a forecast about a static world with (b) trying to predict what happens when you change something in the world.
For the former you might do well by simply recognizing correlations (e.g., seeing my neighbor with an umbrella might predict rain), but the latter requires a more robust model of the world (e.g., handing my neighbor an umbrella is unlikely to cause rain).
We discussed the idea of trying to estimate the “effects of causes”, touching on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Rubin_causal_model&quot;&gt;potential outcomes&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Causal_graph&quot;&gt;causal graphical model&lt;/a&gt; frameworks.&lt;/p&gt;

&lt;p&gt;Using the effect of hospitalization on health as an example, we talked about confounding factors that complicate causal inference.
For instance, my health today might affect both whether I go to the hospital as well as my health tomorrow, making it difficult to isolate the effect of hospitalization on health from other factors.
We saw this mathematized in what Varian calls the “basic identity of causal inference”: observational estimates conflate the average treatment effect with selection bias, where selection bias measures the baseline difference between those who opted into treatment and those who didn’t. 
We also discussed &lt;a href=&quot;http://en.wikipedia.org/wiki/Simpson's_paradox&quot;&gt;Simpson’s paradox&lt;/a&gt;, where selection bias is so large that it leads to a directionally incorrect estimate of a causal effect: what appears to be a positive correlation without adjusting for possible confounds can in fact become a negative one when all available information is accounted for.&lt;/p&gt;

&lt;p&gt;We then introduced counterfactuals and &lt;a href=&quot;http://en.wikipedia.org/wiki/Randomized_experiment&quot;&gt;randomized experiments&lt;/a&gt;.
The question you’d really like to answer is this: if you cloned each person and sent one copy of that person to the hospital, but not the other, what would the resulting difference in health be?
Short of being able to do this, we could ask a slightly different question: if we had two groups of people who were nearly identical in every way and we sent one group to the hospital, but not the other, how would the health of the two groups differ?
This is precisely the idea behind randomized experiments, such as &lt;a href=&quot;http://en.wikipedia.org/wiki/Clinical_trial&quot;&gt;clinical trials&lt;/a&gt; in medicine and &lt;a href=&quot;http://en.wikipedia.org/wiki/A/B_testing&quot;&gt;A/B testing&lt;/a&gt; for online platforms.
Randomization is key here, as it provides a way of creating two groups that are as similar as possible prior to the treatment (e.g., hospitalization) being administered: if people are randomly assigned to groups, then there shouldn’t be any systematic difference between the two groups, eliminating selection bias.
Since the only difference between the groups is that one gets treated and the other doesn’t, we can ascribe differences in the outcome to the treatment.&lt;/p&gt;

&lt;p&gt;While randomized experiments are the “gold standard” for causal inference, we discussed some caveats and limitations in traditional approaches to experimentation in the social sciences, covering issues of both “internal” and “external” validity.
The first asks whether the experiment was properly designed to isolate the intended effect, whereas the second asks if we should expect the results of the study to generalize to other scenarios.&lt;/p&gt;

&lt;p&gt;We discussed natural experiments as an alternative, where the idea is to exploit naturally occuring variation to tease out causal effects from observational data. We followed &lt;a href=&quot;http://www.thaddunning.com/wp-content/uploads/2009/12/Dunning_IEPS_InstrumentalVariables2.pdf&quot;&gt;Dunning’s treatment of instrumental variables&lt;/a&gt; (IV) by looking at randomized experiments with non-compliance, where there’s a difference between assignment to treatment (e.g., whether you’re told to take a drug) versus receipt of treatment (e.g., whether you actually take it).
The basic idea is that we can estimate two separate quantities: the effect of being assigned a treatment and the odds of actually complying with that assignment.
Dividing the former by the latter provides an estimate of the causal effect of actually receiving the treatment.
Furthermore, we can extend this analysis to situations in which nature provides the randomization instead of a researcher flipping a coin, in which case the source of randomness is referred to as an “instrument” that systematically shifts the probability of being treated.
Classic examples include lotteries or weather events.
&lt;!-- We briefly looked an example of the latter in a recent paper that uses random variations in weather to study [peer effects of exercise](https://www.nature.com/articles/ncomms14753) in social networks. --&gt;
We finished with a brief discussion of regression discontinuity and difference-in-difference designs as well.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://bayes.cs.ucla.edu/WHY/&quot;&gt;The Book of Why&lt;/a&gt; by Pearl and Mackenzie&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://ftp.cs.ucla.edu/pub/stat_ser/r414.pdf&quot;&gt;Understanding Simpson’s Paradox&lt;/a&gt; by Judea Pearl&lt;/li&gt;
  &lt;li&gt;Chapter 21 of &lt;a href=&quot;http://www.stat.cmu.edu/~cshalizi/ADAfaEPoV/&quot;&gt;Advanced Data Analysis from an Elementary Point of View&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapters 1 and 2 of &lt;a href=&quot;http://isps.yale.edu/FEDAI&quot;&gt;Field Experiments: Design, Analysis, and Interpretation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Matt Blackwell’s lecture notes on &lt;a href=&quot;http://www.mattblackwell.org/files/teaching/s03-potential.pdf&quot;&gt;causality and potential outcomes&lt;/a&gt; as well as &lt;a href=&quot;http://www.mattblackwell.org/files/teaching/s04-experiments.pdf&quot;&gt;randomized experiments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Some notes on &lt;a href=&quot;http://andrewgelman.com/2007/12/08/causal_inferenc_2/&quot;&gt;causal inference&lt;/a&gt; from Andrew Gelman&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nature.com/articles/ncomms13800&quot;&gt;Resilient cooperators stabilize long-run cooperation in the finitely repeated Prisoner’s Dilemma&lt;/a&gt; by Mao, Dworkin, Suri &amp;amp; Watts&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.pnas.org/content/113/27/7310.full.pdf&quot;&gt;Causal inference in economics and marketing&lt;/a&gt; by Hal Varian&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.thaddunning.com/wp-content/uploads/2009/12/Dunning_IEPS_InstrumentalVariables2.pdf&quot;&gt;Instrumental Variables&lt;/a&gt; by Thad Dunning (followup &lt;a href=&quot;http://www.thaddunning.com/wp-content/uploads/2009/12/Dunning-PA.pdf&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
  &lt;li&gt;See Chapter 5 of &lt;a href=&quot;http://www.cambridge.org/gb/academic/subjects/politics-international-relations/research-methods-politics/natural-experiments-social-sciences-design-based-approach&quot;&gt;Natural Experiments in the Social Sciences&lt;/a&gt; by Dunning for more detail&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nature.com/articles/ncomms14753&quot;&gt;Exercise contagion in a global social network&lt;/a&gt; by Aral &amp;amp; Nicolaides&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 26 Apr 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 11: Networks II</title>
        <link>http://modelingsocialdata.org/lectures/2019/04/12/lecture-11-networks-2.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/04/12/lecture-11-networks-2.html</guid>
        <description>&lt;p&gt;We spent this lecture discussing representations and characteristics of networks and algorithms for analyzing network data.&lt;/p&gt;

&lt;p&gt;After discussing many different types of networks that we might analyze as well as the various levels of abstraction available for representing them, we turned to algorithms for efficiently computing shortest path lengths, connected components, mutual friends, and clustering coefficients.&lt;/p&gt;

&lt;p&gt;We started with the problem of finding the shortest distance between a single source node and all other nodes in a (undirected, unweighted) network, as measured by the fewest number of edges you need to traverse to get from the source to every other node.
(Every researcher’s favorite version of this is computing their &lt;a href=&quot;http://en.wikipedia.org/wiki/Erdős_number&quot;&gt;Erdős number&lt;/a&gt;, the academic take on the more well-known &lt;a href=&quot;http://en.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon&quot;&gt;Kevin Bacon game&lt;/a&gt;. Compute yours &lt;a href=&quot;http://academic.research.microsoft.com&quot;&gt;here&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;Breadth first search (BFS) provides a nice solution.
The intuition behind BFS is simple: we start from the source node and mark it as distance zero from itself.
Then we visit each of its neighbors and mark those as distance one.
We repeat this iteratively, pushing forward a boundary of recently discovered nodes that are one additional hop from the source at each step.
BFS visits each node and edge in a network once, scaling linearly in the size of the network.
If, however, we would like to find the shortest distance between &lt;em&gt;all pairs&lt;/em&gt; of nodes then we must repeat this for each possible source node, and so this quickly becomes prohibitively expensive for even moderately sized networks.
(See &lt;a href=&quot;http://en.wikipedia.org/wiki/Shortest_path_problem#All-pairs_shortest_paths&quot;&gt;here&lt;/a&gt; for fancier, more efficient algorithms.)&lt;/p&gt;

&lt;p&gt;Next we looked at using BFS for a related problem: finding the number of &lt;a href=&quot;http://en.wikipedia.org/wiki/Connected_component_(graph_theory)&quot;&gt;connected components&lt;/a&gt;, or separate pieces, of a network.
We did this by simply looping over our shortest path code, seeding it on each iteration with a currently unreachable node as the source until we reach all nodes.
We gave the reachable nodes in each BFS a unique label corresponding to its component.&lt;/p&gt;

&lt;p&gt;Then we moved on to computing the number of friends that any two nodes have in common, motivated by the problem of friend recommendations on social networks.
The underlying idea can be traced back to &lt;a href=&quot;https://sociology.stanford.edu/sites/default/files/publications/the_strength_of_weak_ties_and_exch_w-gans.pdf&quot;&gt;Granovetter&lt;/a&gt;: two people are likely to know each other if they have many mutual friends.
To compute the number of mutual friends between all pairs of nodes, we exploit the fact that the neighbors of every node share that node as a common friend.
To count all mutual friends we simply loop over each node and increment a counter for every pair of its neighbors.
For each node this scales as the square of its degree, so the whole algorithm scales as the sum of the squared degrees of all nodes.
This can quickly become expensive if we have even a few high-degree nodes, which are quite common in practice.&lt;/p&gt;

&lt;p&gt;Finally, we looked at the closely related problem of counting the number of triangles around each node in a network.
This algorithm is nearly identical to computing mutual friends, as we generate the same set of two-hop paths through all pairs of a node’s neighbors, but simply increment different counters to generate different results.
Instead of accumulating mutual friends for each pair of a node’s neighbors, we ask whether every pair of neighbors are themselves directly connected.
If so, we count this as (half of) a triangle in which the node participates.
Dividing the number of closed triangles in a network by the number of possible triangles that could be present gives a useful for how &lt;a href=&quot;http://en.wikipedia.org/wiki/Clustering_coefficient&quot;&gt;clustered&lt;/a&gt; a network is.&lt;/p&gt;

&lt;p&gt;To better understand properties of networks and how to compute them, we looked at a few example networks in R using the &lt;code class=&quot;highlighter-rouge&quot;&gt;igraph&lt;/code&gt; package.
See the &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/lectures/lecture_11&quot;&gt;notebooks&lt;/a&gt; on the course GitHub page for related code and data used in the lectures.&lt;/p&gt;

&lt;p&gt;We finished lecture with a preview of issues related to causal inference.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Chapters 2, 18, and 20 of Easley and Kleinberg’s &lt;a href=&quot;http://www.cs.cornell.edu/home/kleinber/networks-book/&quot;&gt;Networks, Crowds, and Markets&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.math.cornell.edu/m/sites/default/files/imported/People/strogatz/nature_smallworld.pdf&quot;&gt;Collective dynamics of ‘small-world’ networks&lt;/a&gt; by Watts &amp;amp; Strogatz&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://web.stanford.edu/~jugander/papers/websci12-fourdegrees.pdf&quot;&gt;Four degrees of separation&lt;/a&gt;: scaling up calculations to the entire Facebook social graph&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.rebennack.net/SEA2011/files/talks/SEA2011_Pajor.pdf&quot;&gt;Customizable route planning&lt;/a&gt;: how shortest path calculations are done in modern mapping applications&lt;/li&gt;
  &lt;li&gt;These &lt;a href=&quot;https://berkeleydatascience.files.wordpress.com/2012/03/20120320berkeley.pdf&quot;&gt;slides&lt;/a&gt; on the early system for friend recommendation on Facebook (pages 28 to 37)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://theory.stanford.edu/~sergei/papers/www11-triangles.pdf&quot;&gt;The Curse of the Last Reducer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://theory.stanford.edu/~sergei/papers/soda10-mrc.pdf&quot;&gt;A Model of Computation for MapReduce&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;!--
  BFS computes shortest path: http://www.cs.toronto.edu/~krueger/cscB63h/lectures/BFS.pdf
  BFS runtime and correctness: http://www.cse.ust.hk/faculty/golin/COMP271Sp03/Notes/MyL06.ps
  [MapReduce for networks](http://jakehofman.com/icwsm2010/slides.html)
    https://github.com/jhofman/icwsm2010_tutorial
 
  [Facebook at scale](http://arxiv.org/abs/1111.4503)
--&gt;
</description>
        <pubDate>Fri, 12 Apr 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Homework 4</title>
        <link>http://modelingsocialdata.org/homework/2019/04/10/homework-4.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/homework/2019/04/10/homework-4.html</guid>
        <description>&lt;p&gt;The fourth homework assignment, &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/homework/homework_4&quot;&gt;posted on Github&lt;/a&gt;, is due on Thursday, April 25 by 11:59pm ET.&lt;/p&gt;

&lt;p&gt;The first problem explores the small-world phenomenon in “close” vs. “distant” friend networks, the second studies how the structure of an email network changes as we remove weak ties from it, and the third looks at gender assortativity in networks. Details are in the README.md file for each problem.&lt;/p&gt;

&lt;p&gt;Your code and results are to be submitted electronically in one zipped (or tarball-ed) file through the &lt;a href=&quot;https://courseworks2.columbia.edu/courses/77738&quot;&gt;CourseWorks&lt;/a&gt; site. All solutions should be contained in the corresponding files provided here. Code should be written in bash / R and should not have complex dependencies on non-standard libraries. Each problem contains an Rmarkdown file which should be rendered as a pdf to be submitted with your solution. All work should be your own and done individually.&lt;/p&gt;
</description>
        <pubDate>Wed, 10 Apr 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 10: Networks I</title>
        <link>http://modelingsocialdata.org/lectures/2019/04/05/lecture-10-networks-1.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/04/05/lecture-10-networks-1.html</guid>
        <description>&lt;p&gt;We used this lecture to first go through applications of logistic regression and then to discuss the history of network science.&lt;/p&gt;

&lt;!-- We spent this lecture discussing network data, including a whirlwhind tour of the history of network theory, representations and characteristics of networks, and algorithms for analyzing network data. --&gt;

&lt;center&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;7848c1385ff346709bae389edb62613d&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;
&lt;/center&gt;

&lt;p&gt;We started off this lecture by revisiting logistic regression, looking at the  problem of modeling which passengers &lt;a href=&quot;https://www.kaggle.com/c/titanic&quot;&gt;survived the Titanic disaster&lt;/a&gt;. We saw that interpreting logistic regression results can be challenging, as coefficients give information about changes in log-odds (as opposed to probabilities directly). We stressed the idea of converting back to probabilities and visually comparing predicted and actual values for a range of feature values to better understand the model fit. See &lt;a href=&quot;http://htmlpreview.github.io/?https://github.com/jhofman/msd2019/blob/master/lectures/lecture_10/interpreting_logistic_regression.html&quot;&gt;this notebook&lt;/a&gt; for details.&lt;/p&gt;

&lt;p&gt;Next we discussed &lt;a href=&quot;https://github.com/VowpalWabbit/vowpal_wabbit/wiki&quot;&gt;Vowpal Wabbit&lt;/a&gt; (VW), an open source tool for various machine learning tasks. VW has many attractive features, such as a flexible input format, speed, scalability, and sensible defaults. For binary classification, VW defaults to fitting a (clipped) linear model to minimize squared loss. We looked at an example of &lt;a href=&quot;https://github.com/VowpalWabbit/vowpal_wabbit/wiki/Rcv1-example&quot;&gt;classifying news&lt;/a&gt; with VW to get a sense of the interface and performance, which is quite competetive.&lt;/p&gt;

&lt;p&gt;Then we moved on to a history of nertwork science.&lt;/p&gt;

&lt;p&gt;We talked about some of the earliest studies of networks, such as Jacob Moreno’s &lt;a href=&quot;https://timesmachine.nytimes.com/timesmachine/1933/04/03/99218765.html?action=click&amp;amp;contentCollection=Archives&amp;amp;module=LedeAsset&amp;amp;region=ArchiveBody&amp;amp;pgtype=article&amp;amp;pageNumber=17&quot;&gt;sociograms&lt;/a&gt; and Mark Granovetter’s work on the &lt;a href=&quot;https://sociology.stanford.edu/sites/default/files/publications/the_strength_of_weak_ties_and_exch_w-gans.pdf&quot;&gt;strength of weak ties&lt;/a&gt;. We contrasted theoretical models of graphs (e.g., &lt;a href=&quot;http://en.wikipedia.org/wiki/Erdős–Rényi_model&quot;&gt;Erdős–Rényi&lt;/a&gt; random graphs) to real-world networks, which tend to have highly &lt;a href=&quot;http://en.wikipedia.org/wiki/Complex_network#Scale-free_networks&quot;&gt;skewed degree distributions&lt;/a&gt; as originally discussed in Derek de Solla Price’s studies of &lt;a href=&quot;http://garfield.library.upenn.edu/papers/pricenetworks1965.pdf&quot;&gt;citation networks&lt;/a&gt;. At the same time, social networks typically have &lt;a href=&quot;http://en.wikipedia.org/wiki/Small-world_network&quot;&gt;short path lengths&lt;/a&gt;, in the sense that one needs only to traverse a handful of links to connect a randomly selected set of people in the network.&lt;/p&gt;

&lt;p&gt;We finished by discussing different types of networks that we might analyze as well as the various levels of abstraction available for representing them.&lt;/p&gt;

&lt;p&gt;More on networks next time.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a href=&quot;https://github.com/VowpalWabbit/vowpal_wabbit/wiki&quot;&gt;Vowpal Wabbit Wiki&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapters 2, 18, and 20 of Easley and Kleinberg’s &lt;a href=&quot;http://www.cs.cornell.edu/home/kleinber/networks-book/&quot;&gt;Networks, Crowds, and Markets&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Granovetter’s &lt;a href=&quot;https://sociology.stanford.edu/sites/default/files/publications/the_strength_of_weak_ties_and_exch_w-gans.pdf&quot;&gt;Strength of Weak Ties&lt;/a&gt; paper&lt;/li&gt;
  &lt;li&gt;de Solla Price on &lt;a href=&quot;http://garfield.library.upenn.edu/papers/pricenetworks1965.pdf&quot;&gt;citation networks&lt;/a&gt; and &lt;a href=&quot;http://garfield.library.upenn.edu/price/pricetheory1976.pdf&quot;&gt;cumulative advantage&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Milgram’s original &lt;a href=&quot;https://en.wikipedia.org/wiki/Small-world_experiment&quot;&gt;small world experiment&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.math.cornell.edu/m/sites/default/files/imported/People/strogatz/nature_smallworld.pdf&quot;&gt;Collective dynamics of ‘small-world’ networks&lt;/a&gt; by Watts &amp;amp; Strogatz&lt;/li&gt;
&lt;/ul&gt;

&lt;!--
* [Four degrees of separation](http://web.stanford.edu/~jugander/papers/websci12-fourdegrees.pdf): scaling up calculations to the entire Facebook social graph
* [Customizable route planning](http://www.rebennack.net/SEA2011/files/talks/SEA2011_Pajor.pdf): how shortest path calculations are done in modern mapping applications
* These [slides](https://berkeleydatascience.files.wordpress.com/2012/03/20120320berkeley.pdf) on the early system for friend recommendation on Facebook (pages 28 to 37)
--&gt;

&lt;!--
  BFS computes shortest path: http://www.cs.toronto.edu/~krueger/cscB63h/lectures/BFS.pdf
  BFS runtime and correctness: http://www.cse.ust.hk/faculty/golin/COMP271Sp03/Notes/MyL06.ps
  [MapReduce for networks](http://jakehofman.com/icwsm2010/slides.html)
    https://github.com/jhofman/icwsm2010_tutorial
  [Curse of the last reducer](http://theory.stanford.edu/~sergei/papers/www11-triangles.pdf)
  [Model of MapReduce](http://theory.stanford.edu/~sergei/papers/soda10-mrc.pdf)
  [Facebook at scale](http://arxiv.org/abs/1111.4503)
--&gt;
</description>
        <pubDate>Fri, 05 Apr 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 9: Classification</title>
        <link>http://modelingsocialdata.org/lectures/2019/03/29/lecture-9-classification.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/03/29/lecture-9-classification.html</guid>
        <description>&lt;p&gt;In this lecture we covered classification with linear models, specifically naive Bayes and logistics regression.&lt;/p&gt;

&lt;center&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;46903fe715de4ab59c254c6a61ea866d&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;
&lt;/center&gt;

&lt;p&gt;We started this lecture by introducing the problem of classification and how it differs from regression: the outcome is categorical (e.g., whether an email is spam or &lt;a href=&quot;https://wiki.apache.org/spamassassin/Ham&quot;&gt;ham&lt;/a&gt;) rather than continuous.
We first reviewed &lt;a href=&quot;http://en.wikipedia.org/wiki/Bayes'_rule&quot;&gt;Bayes’ rule&lt;/a&gt; for inverting conditional probabilities via a simple, but &lt;a href=&quot;http://bit.ly/ggbbc&quot;&gt;somewhat counterintuitive&lt;/a&gt;, &lt;a href=&quot;http://www.scientificamerican.com/article/what-is-bayess-theorem-an/&quot;&gt;medical diagnosis example&lt;/a&gt; and then adapted this to an (extremely naive) &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_9/enron_naive_bayes.sh&quot;&gt;one-word spam classifier&lt;/a&gt;.
We improved upon this by considering all words present in a document and arrived at naive Bayes—a simple linear method for classification in which we model each word occurrence independently and use Bayes’ rule to calculate the probability the document belongs to each class given the words it contains.&lt;/p&gt;

&lt;p&gt;Although naive Bayes makes an obviously incorrect assumption that all features are independent, it turns out to be a reasonably useful method in practice. 
It’s simple and scalable to train, easy to update as new data arrive, easy to interpret, and often more competitive in performance than one might expect.
That said, there are some obvious issues with naive Bayes as presented, namely overfitting in the training process and overconfidence / miscalibration when making predictions.&lt;/p&gt;

&lt;p&gt;The first issue arises when thinking about how to estimate word probabilities.
Simple maximum likelihood estimates (MLE) for word probabilities lead to overfitting, implying, for instance, that it’s impossible to see a word in a given class in the future if we’ve never seen it occur in that class in the past.
We dealt with this by thinking about maximum a posteriori (MAP) estimation which led to the idea of &lt;a href=&quot;https://en.wikipedia.org/wiki/Additive_smoothing&quot;&gt;Laplace smoothing&lt;/a&gt;, or adding &lt;a href=&quot;http://en.wikipedia.org/wiki/Pseudocount&quot;&gt;pseudocounts&lt;/a&gt; to empirical word counts to prevent overfitting.
As usual, determining the amount of smoothing to use is an empirical question, often solved by methods such as cross-validation.&lt;/p&gt;

&lt;p&gt;As for the second problem of feature independence, we addressed this by abandoning naive Bayes in favor of logistic regression.
Logistic regression makes predictions using the same functional form as naive Bayes—the log-odds are modeled as a weighted combination of feature values—but fits these weights in a manner that accounts for correlations between features.
We (once again) applied the maximum likelihood principle to arrive at criteria for estimating these weights, and discussed gradient descent for a solution. The resulting algorithms are very close in spirit to those for linear regression, but slightly more complex due to the logistic function.
And, similar to linear regression, we discussed the idea of regularizing logistic regression by including a term in the loss function to penalize large weight vectors.&lt;/p&gt;

&lt;p&gt;We concluded with a discussion of several metrics for evaluating classifiers, including calibration, &lt;a href=&quot;https://en.wikipedia.org/wiki/Confusion_matrix&quot;&gt;confusion matrices&lt;/a&gt;, accuracy, precision and recall, and the &lt;a href=&quot;https://en.wikipedia.org/wiki/Receiver_operating_characteristic&quot;&gt;ROC curve&lt;/a&gt;. See the &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_9/classification.ipynb&quot;&gt;classification notebook&lt;/a&gt; up on Github for more details.&lt;/p&gt;

&lt;p&gt;A few references:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Chapter 12 of &lt;a href=&quot;http://www.stat.cmu.edu/~cshalizi/ADAfaEPoV/&quot;&gt;Advanced Data Analysis from an Elementary Point of View&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapter 4 of &lt;a href=&quot;http://www-bcf.usc.edu/~gareth/ISL/getbook.html&quot;&gt;An Introduction to Statistical Learning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cs.iastate.edu/~honavar/bayes-lewis.pdf&quot;&gt;Naive Bayes at 40&lt;/a&gt; by Lewis (1998)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.jstor.org/pss/1403452&quot;&gt;Idiots Bayes—Not So Stupid After All?&lt;/a&gt; by Hand and Yu (2001)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://robotics.stanford.edu/users/sahami/papers-dir/spam.pdf&quot;&gt;A Bayesian Approach to Filtering Junk E-mail&lt;/a&gt; from Sahami, Dumais, Heckerman, and Horvitz (1998)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.paulgraham.com/spam.html&quot;&gt;A Plan for Spam&lt;/a&gt; by Paul Graham (2002)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://ccrma.stanford.edu/workshops/mir2009/references/ROCintro.pdf&quot;&gt;An introduction to ROC analysis&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.navan.name/roc/&quot;&gt;Understanding ROC curves&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/VowpalWabbit/vowpal_wabbit/wiki&quot;&gt;Vowpal Wabbit&lt;/a&gt; for scalable classification&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Fri, 29 Mar 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Homework 3</title>
        <link>http://modelingsocialdata.org/homework/2019/03/29/homework-3.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/homework/2019/03/29/homework-3.html</guid>
        <description>&lt;p&gt;The third homework assignment, &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/homework/homework_3&quot;&gt;posted on Github&lt;/a&gt;, is due on Thursday, April 11 by 11:59pm ET.&lt;/p&gt;

&lt;p&gt;The first problem explores various modeling scenarios, the second looks at cross-validation for polynomial regression, and in the third you’ll use regularized logistic regression to classify New York Times articles. Details are in the README.md file for each problem.&lt;/p&gt;

&lt;p&gt;Your code and results are to be submitted electronically in one zipped (or tarball-ed) file through the &lt;a href=&quot;https://courseworks2.columbia.edu/courses/77738&quot;&gt;CourseWorks&lt;/a&gt; site. All solutions should be contained in the corresponding files provided here. Code should be written in bash / R and should not have complex dependencies on non-standard libraries. Each problem contains an Rmarkdown file which should be rendered as a pdf to be submitted with your solution. All work should be your own and done individually.&lt;/p&gt;
</description>
        <pubDate>Fri, 29 Mar 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 8: Regression, Part 2</title>
        <link>http://modelingsocialdata.org/lectures/2019/03/15/lecture-8-regression-2.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/03/15/lecture-8-regression-2.html</guid>
        <description>&lt;p&gt;This was the second lecture on the theory and practice of regression, focused on model complexity and generalization.&lt;/p&gt;

&lt;center&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;8b16d5652bae434e8d478f70bcce6724&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;
&lt;/center&gt;

&lt;p&gt;We started with an applied modeling problem: understanding how internet browsing activity varies by age and gender. We saw that there’s a lot more to modeling than just optimization, with many important steps along the way that range from collecting and specifying outcomes and predictors, to determining the form of a model, to assessing performance and interpreting results. We found that including quadratic terms for age and interacting gender with age gave a reasonable model, at least in terms of visually matching empirical aggregates. See the &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_7/linear_models.ipynb&quot;&gt;linear models&lt;/a&gt; notebook up on Github for more details.&lt;/p&gt;

&lt;p&gt;Then we talked about two high-level points.
First, quantifying model fit and second, knowing when to stop fitting.
In this case, that translates to asking “how good is a quadratic fit” and “why shouldn’t I use a cubic, or quartic, etc.?” or “should I add another interaction?”&lt;/p&gt;

&lt;p&gt;To the first point, we discussed &lt;a href=&quot;https://en.wikipedia.org/wiki/Root-mean-square_deviation&quot;&gt;root mean squared error (RMSE)&lt;/a&gt; and the &lt;a href=&quot;https://en.wikipedia.org/wiki/Coefficient_of_determination&quot;&gt;coefficient of determination (&lt;script type=&quot;math/tex&quot;&gt;R^2&lt;/script&gt;)&lt;/a&gt; as sensible metrics of model fit.
RMSE is just the squared loss function we discussed last time, with a square root to adjust units to match those of the outcome we’re trying to predict.
It’s useful when we already have a sense of absolute scale for “what’s good”.
The coefficient of determination, on the other hand,  captures the fraction of variance in outcomes explained by the model, and is useful when we don’t have such a scale or are comparing across different problems.
We showed that this is the same as comparing the mean squared error (MSE) of the model to the MSE of a simple baseline where we always predict the average outcome.
Finally, we discussed the connection between &lt;a href=&quot;https://en.wikipedia.org/wiki/Pearson_correlation_coefficient&quot;&gt;Pearson’s correlation coefficient&lt;/a&gt; and &lt;script type=&quot;math/tex&quot;&gt;R^2&lt;/script&gt;.
See &lt;a href=&quot;https://economictheoryblog.com/2014/11/05/proof/&quot;&gt;here&lt;/a&gt; for a proof that the latter is in fact the square of the former. See the &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_8/model_evaluation.ipynb&quot;&gt;model evaluation&lt;/a&gt; notebook on Github for details.&lt;/p&gt;

&lt;p&gt;Applying both of these metrics to the pageview dataset, we saw that while there were systematic trends in typical viewing behavior by age and gender, there was still a surprisingly large amount of variation in individual activity for people of the same age and gender.&lt;/p&gt;

&lt;p&gt;This led us to our second high-level topic, the question of complexity control: How complicated should we make our model?
We discussed the idea of generalization error, and how we’d like models that are both complex enough to account for the past and simple enough to predict the future.
Cross-validation is the most common approach to navigating this tradeoff, where we divide our data into a training set for fitting models, a validation set for comparing these different fits, and a test set that’s used once (and &lt;em&gt;only once&lt;/em&gt;) to quote the expected future performance of the model we end up selecting.
We talked about &lt;a href=&quot;https://www.youtube.com/watch?v=TIgfjmp-4BA&quot;&gt;k-fold cross-validation&lt;/a&gt; as a more statistically robust version of estimating generalization error. See the &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_8/complexity_Control.ipynb&quot;&gt;complexity control&lt;/a&gt; notebook on Github for details.&lt;/p&gt;

&lt;p&gt;We also phrased this issue in terms of the &lt;a href=&quot;http://scott.fortmann-roe.com/docs/BiasVariance.html&quot;&gt;bias-variance tradeoff&lt;/a&gt;.
Simple models are likely biased in that they systematically misrepresent the world, and would do so even with an infinite amount of data.
At the same time, estimating a simple model is a low variance procedure in that our results don’t change substantially when we fit it on different samples of data.
More flexible models, on the other hand, have little bias and can capture more complex patterns in the world.
The downside is that this flexibility also renders such models sensitive to noise, often leading to high variance, or drastically different results with different samples of the data.&lt;/p&gt;

&lt;p&gt;We concluded lecture with a brief discussion of &lt;a href=&quot;https://en.wikipedia.org/wiki/Regularization_%28mathematics%29&quot;&gt;regularization&lt;/a&gt; as a way of modifying loss functions to improve the generalization error of our models by explicitly balancing the fit to the training data with the “complexity” of the model.
The idea is that introducing some bias in our models is sometimes a good idea if the corresponding reduction in variance is enough to lower the mean squared error.&lt;/p&gt;

&lt;p&gt;See Github for an &lt;a href=&quot;http://localhost:8888/notebooks/lecture_8/intro_to_glmnet.ipynb&quot;&gt;introduction to glmnet&lt;/a&gt; as well as this interactive Shiny App to explore &lt;a href=&quot;https://jmhmsr.shinyapps.io/regularization/&quot;&gt;regularization&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Chapter 2 of &lt;a href=&quot;http://www-bcf.usc.edu/~gareth/ISL/&quot;&gt;An Introduction to Statistical Learning&lt;/a&gt; on the bias-variance tradeoff&lt;/li&gt;
  &lt;li&gt;Section 1.4 of &lt;a href=&quot;http://www.stat.cmu.edu/~cshalizi/ADAfaEPoV/&quot;&gt;Advanced Data Analysis from an Elementary Point of View&lt;/a&gt; on the same, with a more detailed derivation
&lt;!-- http://www.inf.ed.ac.uk/teaching/courses/mlsc/Notes/Lecture4/BiasVariance.pdf --&gt;&lt;/li&gt;
  &lt;li&gt;Chapter 5 of &lt;a href=&quot;http://www-bcf.usc.edu/~gareth/ISL/&quot;&gt;An Introduction to Statistical Learning&lt;/a&gt; and 3 of &lt;a href=&quot;http://www.stat.cmu.edu/~cshalizi/ADAfaEPoV/&quot;&gt;Advanced Data Analysis from an Elementary Point of View&lt;/a&gt; on resampling and cross-validation&lt;/li&gt;
  &lt;li&gt;Recent work on using differentially private mechanisms for &lt;a href=&quot;https://research.googleblog.com/2015/08/the-reusable-holdout-preserving.html&quot;&gt;reusing holdout sets&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapters &lt;a href=&quot;http://r4ds.had.co.nz/model-basics.html&quot;&gt;23&lt;/a&gt; and &lt;a href=&quot;http://r4ds.had.co.nz/model-building.html&quot;&gt;24&lt;/a&gt; of &lt;a href=&quot;http://r4ds.had.co.nz&quot;&gt;R for Data Science&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;https://modelr.tidyverse.org&quot;&gt;modelr&lt;/a&gt; and &lt;a href=&quot;https://github.com/tidymodels/tidymodels&quot;&gt;tidymodels&lt;/a&gt; packages in R&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;https://web.stanford.edu/~hastie/glmnet/glmnet_alpha.html&quot;&gt;glmnet vignette&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 15 Mar 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 7: Regression, Part 1</title>
        <link>http://modelingsocialdata.org/lectures/2019/03/08/lecture-7-regression-1.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/03/08/lecture-7-regression-1.html</guid>
        <description>&lt;p&gt;This was the first of two lectures on the theory and practice of regression.&lt;/p&gt;

&lt;center&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;199594cffb524787a7bced446593789a&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;
&lt;/center&gt;

&lt;p&gt;In the first part of class we shifted from talking about problems in how science is often done to best practices for doing good science. We went through the pipeline of designing a study, piloting and revising it, doing a power calculation, pre-registering the study, running it, creating a reproducible analysis and report, and thinking critically about the results.&lt;/p&gt;

&lt;p&gt;Next we moved on to regression.
We started with a high-level overview of regression, which can be broadly defined as any analysis of how one continuous variable (the “outcome”) changes with others (the “inputs”, “predictors”, or “features”).
The goals of a regression analysis can vary, from describing the data at hand, to predicting new outcomes, to explaining the associations between outcomes and predictors.
This includes everything from looking at histograms and scatter plots to building statistical models.&lt;/p&gt;

&lt;p&gt;We focused on the latter and discussed ordinary least squares regression.
First, we motivated this as an optimization problem and then connected squared loss minimization to the more general principle of maximum likelihood.
Then we discussed several ways to solve this optimization problem to estimate coefficients for a linear model, which are summarized in the table below.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Space&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Time&lt;/th&gt;
      &lt;th&gt;Comments&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Invert normal equations&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;script type=&quot;math/tex&quot;&gt;N K + K^2&lt;/script&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;script type=&quot;math/tex&quot;&gt;K^3&lt;/script&gt;&lt;/td&gt;
      &lt;td&gt;Good for medium-sized datasets with a relatively small number (e.g., hundreds or thousands) of features&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Gradient descent&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;script type=&quot;math/tex&quot;&gt;N K&lt;/script&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;script type=&quot;math/tex&quot;&gt;NK&lt;/script&gt; per step&lt;/td&gt;
      &lt;td&gt;Good for larger datasets that still fit in memory but have more (e.g., millions) features; requires tuning learning rate&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Stochastic gradient descent&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;script type=&quot;math/tex&quot;&gt;K&lt;/script&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;script type=&quot;math/tex&quot;&gt;K&lt;/script&gt; per step&lt;/td&gt;
      &lt;td&gt;Good for datasets that exceed available memory; more sensitive to learning rate schedule&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;See also this interactive Shiny App to explore &lt;a href=&quot;https://jmhmsr.shinyapps.io/modelfit/&quot;&gt;manually fitting a simple model&lt;/a&gt; and this notebook by Jongbin Jung with &lt;a href=&quot;http://jakehofman.com/gd/&quot;&gt;an animation of gradient descent&lt;/a&gt;.&lt;/p&gt;

&lt;!--
In the second half of class we looked at fitting linear models in R, with an application to understanding how internet browsing activity varies by age and gender.
See the [Jupyter notebook](https://github.com/jhofman/msd2017/blob/master/lectures/lecture_6/linear_models.ipynb) up on Github for more details.
The main lesson here is that there's more to modeling than just optimization, with many important steps along the way that range from collecting and specifying outcomes and predictors, to determining the form of a model, to assessing performance and interpreting results.
--&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Chapter 3 of &lt;a href=&quot;http://www-bcf.usc.edu/~gareth/ISL/&quot;&gt;An Introduction to Statistical Learning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapters 1 and 2 of &lt;a href=&quot;http://www.stat.cmu.edu/%7Ecshalizi/ADAfaEPoV/&quot;&gt;Advanced Data Analysis from an Elementary Point of View&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapter 5 of OpenIntro’s &lt;a href=&quot;https://www.openintro.org/stat/textbook.php&quot;&gt;Introductory Statistics with Randomization and Simulation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cambridge.org/us/academic/subjects/statistics-probability/statistical-theory-and-methods/statistical-models-theory-and-practice-2nd-edition?format=PB&quot;&gt;Statistical Models&lt;/a&gt; by David Freedman&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://us.sagepub.com/en-us/nam/regression-analysis/book226138&quot;&gt;Regression Analysis&lt;/a&gt; by Richard Berk&lt;/li&gt;
  &lt;li&gt;Chapters &lt;a href=&quot;http://r4ds.had.co.nz/model-basics.html&quot;&gt;23&lt;/a&gt; and &lt;a href=&quot;http://r4ds.had.co.nz/model-building.html&quot;&gt;24&lt;/a&gt; of &lt;a href=&quot;http://r4ds.had.co.nz&quot;&gt;R for Data Science&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 08 Mar 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 6: Reproducibility and replication, Part 2</title>
        <link>http://modelingsocialdata.org/lectures/2019/03/01/lecture-6-reproducibility-2.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/03/01/lecture-6-reproducibility-2.html</guid>
        <description>&lt;p&gt;This was our second lecture on reproducibility and replication in which we discussed false discoveries, effect sizes, and p-hacking / researcher degrees of freedom.&lt;/p&gt;

&lt;center&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;ce73cc7b18114447b75619411419bd76&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;
&lt;/center&gt;

&lt;p&gt;The &lt;a href=&quot;/lectures/2019/02/22/lecture-5-reproducibility-1.html&quot;&gt;previous lecture&lt;/a&gt; provided a high-level overview of the ongoing replication crisis in the sciences. In this lecture we continued the discussion, first by talking about false discoveries. Following Felix Schönbrodt’s excellent &lt;a href=&quot;http://www.nicebread.de/whats-the-probability-that-a-significant-p-value-indicates-a-true-effect/&quot;&gt;blog post&lt;/a&gt;, we talked about how underpowered studies lead to false discoveries. Then we went on to discuss &lt;a href=&quot;https://transparentstats.github.io/guidelines/effectsize.html&quot;&gt;effect sizes&lt;/a&gt;, specifically &lt;a href=&quot;https://en.wikipedia.org/wiki/Effect_size#Cohen's_d&quot;&gt;Cohen’s d&lt;/a&gt; and the &lt;a href=&quot;https://en.wikipedia.org/wiki/Effect_size#Common_language_effect_size&quot;&gt;AUC&lt;/a&gt;, through this excellent &lt;a href=&quot;https://rpsychologist.com/d3/cohend/&quot;&gt;visual tool&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next we spoke about &lt;a href=&quot;https://en.wikipedia.org/wiki/Post_hoc_analysis&quot;&gt;post-hoc data analysis&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Data_dredging&quot;&gt;p-hacking&lt;/a&gt;.  We looked at the &lt;a href=&quot;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1850704&quot;&gt;False-Positive Psychology&lt;/a&gt; paper by Simmons, Nelson &amp;amp; Simonsohn, which has an illustrative example of how one can arrive at non-sensical conclusions if there’s enough flexibility in data collection and analysis. Gelman and Loken’s &lt;a href=&quot;http://www.stat.columbia.edu/~gelman/research/unpublished/p_hacking.pdf&quot;&gt;The Garden of Forking Paths&lt;/a&gt; makes a similar point, noting that this can often occur without mal intent on the part of the researcher. While these issues are complex, there are few best practices (e.g., running pilot studies followed by &lt;a href=&quot;https://aspredicted.org&quot;&gt;pre-registration&lt;/a&gt; of high-powered, large-scale experiments) that can help mitigate these concerns.
&lt;a href=&quot;http://www.sciencemag.org/careers/2015/12/register-your-study-new-publication-option&quot;&gt;Registered reports&lt;/a&gt; are a particularly attractive solution, wherein researchers write up and submit an experimental study for peer review &lt;em&gt;before&lt;/em&gt; the study is conducted. Reviewers make an acceptance decision at this point based on the merit of the study, and, if accepted, it is published regardless of the results. We also discussed how these ideas that come largely from randomized experiments might be adapted for observational studies.&lt;/p&gt;

&lt;p&gt;We finished up class by talking about a few tools for computational reproducibility, specifically &lt;a href=&quot;https://rmarkdown.rstudio.com&quot;&gt;RMarkdown&lt;/a&gt; for reproducible documents and &lt;a href=&quot;https://bost.ocks.org/mike/make/&quot;&gt;Makefiles&lt;/a&gt; for efficient workflows. Example files are up
&lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/lectures/lecture_6&quot;&gt;on Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A guide on &lt;a href=&quot;https://transparentstats.github.io/guidelines/effectsize.html&quot;&gt;effect sizes&lt;/a&gt; and related &lt;a href=&quot;https://transparentstatistics.org/2018/07/05/meanings-effect-size/&quot;&gt;blog post&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://rpsychologist.com/d3/cohend/&quot;&gt;Interpreting Cohen’s d effect size&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://journals.sagepub.com/doi/pdf/10.1177/0956797613504966&quot;&gt;The New Statistics: Why and How&lt;/a&gt; by Cummings&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.jstor.org/stable/3802789?seq=1#metadata_info_tab_contents&quot;&gt;The Insignificance of Significance Testing&lt;/a&gt; by Johnson&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://journals.sagepub.com/doi/abs/10.1177/106591299905200309&quot;&gt;The Insignificance of Null Hypothesis Significance Testing&lt;/a&gt; by Gill&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://journals.plos.org/plosmedicine/article/file?id=10.1371/journal.pmed.0020124&amp;amp;type=printable&quot;&gt;Why Most Published Research Findings Are False&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Felix Schönbrodt’s &lt;a href=&quot;http://www.nicebread.de/whats-the-probability-that-a-significant-p-value-indicates-a-true-effect/&quot;&gt;blog post&lt;/a&gt; and 
&lt;a href=&quot;http://shinyapps.org/apps/PPV/&quot;&gt;shiny app&lt;/a&gt; on misconceptions about p-values and false discoveries&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cyclismo.org/tutorial/R/power.html&quot;&gt;Calculating the power of a test&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.nature.com/nrn/journal/v14/n5/pdf/nrn3475.pdf&quot;&gt;Power failure: why small sample size undermines the reliability of neuroscience&lt;/a&gt; by Button, et. al.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1850704&quot;&gt;False-Positive Psychology&lt;/a&gt; by Simmons, Nelson &amp;amp; Simonsohn&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.stat.columbia.edu/~gelman/research/unpublished/p_hacking.pdf&quot;&gt;The garden of forking paths&lt;/a&gt; by Gelman &amp;amp; Loken&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.cambridge.org/core/journals/psychological-medicine/article/cumulative-effect-of-reporting-and-citation-biases-on-the-apparent-efficacy-of-treatments-the-case-of-depression/71D73CADE32C0D3D996DABEA3FCDBF57/core-reader&quot;&gt;The cumulative effect of reporting and citation biases on the apparent efficacy of treatments&lt;/a&gt; by de Vries et al. (&lt;a href=&quot;https://www.nytimes.com/2018/09/24/upshot/publication-bias-threat-to-science.html?em_pos=small&amp;amp;emc=edit_up_20180924&amp;amp;nl=upshot&amp;amp;nl_art=0&amp;amp;nlid=57978065emc%3Dedit_up_20180924&amp;amp;ref=headline&amp;amp;te=1&quot;&gt;popular coverage&lt;/a&gt;)&lt;/li&gt;
  &lt;li&gt;Pre-registration portals from the &lt;a href=&quot;https://osf.io/registries/&quot;&gt;Open Science Framework&lt;/a&gt;, &lt;a href=&quot;https://cos.io/prereg/&quot;&gt;Center for Open Science&lt;/a&gt;, and &lt;a href=&quot;https://aspredicted.org/index.php&quot;&gt;AsPredicted.org&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Science magazine’s announcement of &lt;a href=&quot;http://www.sciencemag.org/careers/2015/12/register-your-study-new-publication-option&quot;&gt;registered reports&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://bost.ocks.org/mike/make/&quot;&gt;Why Use Make&lt;/a&gt; by Mike Bostock&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://zmjones.com/make/&quot;&gt;GNU Make for Reproducible Data Analysis&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf&quot;&gt;RMarkdown cheatsheet&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://rmarkdown.rstudio.com/&quot;&gt;RStudio’s RMarkdown site&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;https://bookdown.org/yihui/rmarkdown/&quot;&gt;RMarkdown: The Definitive Guide&lt;/a&gt; book&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- measures of effect size rosenthal https://books.google.com/books?hl=en&amp;lr=&amp;id=p-aFAwAAQBAJ&amp;oi=fnd&amp;pg=PA231&amp;dq=parametric+measure+of+effect+size+rosenthal&amp;ots=TVzKQfiJTJ&amp;sig=JwandSbd84lwhv0BeK0O9FX8k70#v=onepage&amp;q&amp;f=false --&gt;
</description>
        <pubDate>Fri, 01 Mar 2019 10:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Homework 2</title>
        <link>http://modelingsocialdata.org/homework/2019/02/28/homework-2.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/homework/2019/02/28/homework-2.html</guid>
        <description>&lt;p&gt;The second homework assignment, &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/homework/homework_2&quot;&gt;posted on Github&lt;/a&gt;, is due on Thursday, March 14 by 11:59pm ET.&lt;/p&gt;

&lt;p&gt;The first problem looks at the link between coffee and cancer, the second problem examines an experiment on whether yawning is contagious, and the third problem involves replicating the results of a paper about the Google ngram dataset. Details are in the README.md file for each problem.&lt;/p&gt;

&lt;p&gt;Your code and a brief report with your results are to be submitted electronically in one zipped (or tarball-ed) file through the &lt;a href=&quot;https://courseworks2.columbia.edu/courses/77738&quot;&gt;CourseWorks&lt;/a&gt; site. All solutions should be contained in the corresponding files provided here. Code should be written in bash / R and should not have complex dependencies on non-standard libraries. Each problem contains an Rmarkdown file which should be rendered as a pdf to be submitted with your solution. All work should be your own and done individually.&lt;/p&gt;
</description>
        <pubDate>Thu, 28 Feb 2019 17:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 5: Reproducibility and replication, Part 1</title>
        <link>http://modelingsocialdata.org/lectures/2019/02/22/lecture-5-reproducibility-1.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/02/22/lecture-5-reproducibility-1.html</guid>
        <description>&lt;p&gt;We discussed the ongoing &lt;a href=&quot;https://en.wikipedia.org/wiki/Replication_crisis&quot;&gt;replication crisis&lt;/a&gt; in the sciences, wherein it has proven difficult or impossible for researchers to independently verify results of previously published studies.&lt;/p&gt;

&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;8c1dd50c57e14f26b3a9c8fbc9837376&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;We started off the lecture by talking about how to evaluate research findings. Namely, how can you assess whether the results of a study are believable and/or important?&lt;/p&gt;

&lt;p&gt;We took the optimistic view that most researchers are honest, although there are &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_scientific_misconduct_incidents&quot;&gt;some exceptions&lt;/a&gt;. For instance, a recent study by &lt;a href=&quot;http://science.sciencemag.org/content/346/6215/1366.full&quot;&gt;LaCour and Green&lt;/a&gt; reported that a single conversation with canvassers had lasting impact on support for gay marriage. But soon after the study was published, Broockman, Kalla, and Aronow found &lt;a href=&quot;http://stanford.edu/~dbroock/broockman_kalla_aronow_lg_irregularities.pdf&quot;&gt;some irregularities&lt;/a&gt; in the data. The paper was later &lt;a href=&quot;http://www.sciencemag.org/news/2015/05/science-retracts-gay-marriage-paper-without-agreement-lead-author-lacour&quot;&gt;retracted&lt;/a&gt; on account of the data being fabricated using the results of a previous study. Broockman and Kalla then proceeded to carry out &lt;a href=&quot;http://science.sciencemag.org/content/352/6282/220&quot;&gt;their own version&lt;/a&gt; of such a study, and ironically found &lt;a href=&quot;https://www.wired.com/2016/04/political-sciences-whistleblowers-rebunk-gay-canvassing-study/&quot;&gt;support for the original hypothesis&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While such instantces of fraud are rare, there are other, more common concerns among published studies. The first is &lt;em&gt;reproducibility&lt;/em&gt;, or whether one can independently verify the results of a study with the same data and same code used in the original paper. Though a low bar, most research currently doesn’t pass this test simply because it’s often the case that papers are published without all of the supporting data or code. And when the data and code are available, the code can be surprisingly difficult to understand or run, especially when there are complex software dependencies. This is improving as researchers adopt better software engineering practices and develop &lt;a href=&quot;http://science.sciencemag.org/content/354/6317/1240.full&quot;&gt;guildelines&lt;/a&gt;, &lt;a href=&quot;http://www.rctatman.com/files/2018-7-14-MLReproducability.pdf&quot;&gt;best practices&lt;/a&gt;, and &lt;a href=&quot;https://medium.com/@michel.steuwer/artifact-review-and-badging-855dc11b64a0&quot;&gt;incentives&lt;/a&gt; for reproducibility.&lt;/p&gt;

&lt;p&gt;Next we discussed &lt;em&gt;replicability&lt;/em&gt;, or whether a result holds when a study is repeated with new data but the same analysis as the original paper. The main issue here is that it’s easy to be fooled by randomness because noise can dominate signal in small datasets and asking too many questions of the data can lead to overfitting, even with large datasets. We looked at a seminal paper from the &lt;a href=&quot;https://osf.io/vmrgu/&quot;&gt;Open Science Collaboration&lt;/a&gt;, &lt;a href=&quot;http://science.sciencemag.org/content/349/6251/aac4716.full&quot;&gt;Estimating the reproducibility of psychological science&lt;/a&gt;, which conducts replications of 100 published psychology studies and finds that roughly a third replicate, often with smaller effect sizes than reported in the original studies.&lt;/p&gt;

&lt;p&gt;This led us to a review of frequentist statistics, which although somewhat of a &lt;a href=&quot;https://www.mpib-berlin.mpg.de/pubdata/gigerenzer/Gigerenzer_2018_Statistical_rituals.pdf&quot;&gt;statistical ritual&lt;/a&gt;, is still an &lt;a href=&quot;https://amstat.tandfonline.com/doi/abs/10.1080/00031305.2016.1154108#.XE8wl89KjRY&quot;&gt;important one to understand&lt;/a&gt;, for better or worse. A short quiz on the topic highlighted that it’s easy for newcomers and trained professionals alike to &lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10654-016-0149-3&quot;&gt;misunderstand&lt;/a&gt; the meaning of p-values, hypothesis tests, and statistical significance. We reviewed null hypothesis testing through the lens of simulation, in contrast to the usual textbook approach of learning a battery of parametric tests.&lt;/p&gt;

&lt;p&gt;At a high-level, null hypothesis testing asks “how (un)likely are the data I observed under a certain (null) model of the world”? If the data are sufficiently unlikely, we can reject this null model, otherwise our test is inconclusive. The catch is that we have to quantify what consititutes “sufficiently unlikely” and we have to make sure our experiment is actually powerful enough to reject the null when it’s false. In the Neyman-Pearson framework, we make choices based on the long-run error rates we’re willing to tolerate if this procedure is repeated over and over again. While this is usually taught using a reasonable amount of fancy math, we instead discussed it using brute force simulation, which allowed us to focus on the concepts instead of formulas and recipes. The basic idea is simple: if we’d like to know what to expect if the null model is actually true, we can just simulate many such experiments assuming it’s true, look at the distribution of outcomes, and compare what we actually see in the world to the results of our simulations. More details are in this notebook on 
&lt;a href=&quot;http://htmlpreview.github.io/?https://github.com/jhofman/msd2019/blob/master/lectures/lecture_5/statistical_inference.html&quot;&gt;simulation-based statistical inference&lt;/a&gt; and the &lt;a href=&quot;https://github.com/jhofman/msd2019-notes/tree/master/lecture_5&quot;&gt;scribed notes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We’ll continue this discussion of statistics, reproducibility, replication, and evaluating research next week.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://science.sciencemag.org/content/354/6317/1240.full&quot;&gt;Enhancing reproducibility for computational methods&lt;/a&gt; by Stodden et al.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.rctatman.com/files/2018-7-14-MLReproducability.pdf&quot;&gt;A Practical Taxonomy of Reproducibility for Machine Learning Research&lt;/a&gt; by Tatman, VanderPlas &amp;amp; Dane&lt;/li&gt;
  &lt;li&gt;A post on &lt;a href=&quot;https://medium.com/@michel.steuwer/artifact-review-and-badging-855dc11b64a0&quot;&gt;ACM’s Artifact Review and Badging&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://science.sciencemag.org/content/349/6251/aac4716.full&quot;&gt;Estimating the reproducibility of psychological science&lt;/a&gt; from the Open Science Collaboration&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.mpib-berlin.mpg.de/pubdata/gigerenzer/Gigerenzer_2018_Statistical_rituals.pdf&quot;&gt;Statistical Rituals: The Replication Delusion and How We Got There&lt;/a&gt; by Gigerenzer&lt;/li&gt;
  &lt;li&gt;The American Statistical Association’s &lt;a href=&quot;https://amstat.tandfonline.com/doi/abs/10.1080/00031305.2016.1154108#.XE8wl89KjRY&quot;&gt;statement on p-values&lt;/a&gt; by Wasserstein &amp;amp; Lazar&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://link.springer.com/article/10.1007%2Fs10654-016-0149-3&quot;&gt;Statistical tests, P values, confidence intervals, and power: a guide to misinterpretations&lt;/a&gt; by Greenland et al.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://seeing-theory.brown.edu&quot;&gt;Seeing Theory&lt;/a&gt;, a visual, simulation-based tour of statistics&lt;/li&gt;
  &lt;li&gt;Chapters 12 and 13 of &lt;a href=&quot;http://pluto.huji.ac.il/%7Emsby/StatThink/index.html&quot;&gt;Introduction to Statistical Thinking (With R, Without Calculus)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.openintro.org/stat/textbook.php&quot;&gt;Introductory Statistics with Randomization and Simulation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Statistics for Hackers by VanderPlas (&lt;a href=&quot;https://speakerdeck.com/jakevdp/statistics-for-hackers&quot;&gt;slides&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/watch?v=Iq9DzN6mvYA&quot;&gt;video&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Fri, 22 Feb 2019 10:10:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 4: Data Visualization</title>
        <link>http://modelingsocialdata.org/lectures/2019/02/15/lecture-4-data-visualization.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/02/15/lecture-4-data-visualization.html</guid>
        <description>&lt;p&gt;We used this lecture to discuss &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_3/intro_to_r.ipynb&quot;&gt;data manipulation&lt;/a&gt; and &lt;a href=&quot;https://github.com/jhofman/msd2019/blob/master/lectures/lecture_4/visualization_with_ggplot2.ipynb&quot;&gt;data visualization &lt;/a&gt; in R, specifically focusing on &lt;a href=&quot;https://dplyr.tidyverse.org&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;dplyr&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://ggplot2.tidyverse.org&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt;&lt;/a&gt; from the &lt;a href=&quot;http://tidyverse.org&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;tidyverse&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;4540923077774710a34ba80dfc9c4dd5&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;tidyverse&lt;/code&gt; relies on data being in a “tidy” format of one observation per row, one variable per column, and one value per cell. It provides tools for getting untidy data (of which there’s lots) into a tidy format. Once data are in this format, it provides tools for chaining together a string of commands, similar to unix pipes, that makes it very easy to translate ideas and question in your mind into working and readable code. This allows you to spend more time exploring and understanding your data and less time debugging code.&lt;/p&gt;

&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;5bf041357fc24ff5b9cef83713baed0e&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;We discussed visualization as a way to better understand data and as a way of communicating readers. We briefly reviewed experiments by &lt;a href=&quot;http://www.jstor.org/stable/2288400?seq=1#page_scan_tab_contents&quot;&gt;Cleveland and McGill&lt;/a&gt; showing that not all visual encodings are created equal, &lt;a href=&quot;http://dl.acm.org/citation.cfm?id=22950&quot;&gt;Mackinlay’s&lt;/a&gt; expressiveness / effectiveness tradeoff, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Leland_Wilkinson&quot;&gt;Wilkinson’s&lt;/a&gt; grammar of graphics. We spent a good amount of time discussing how every visualization should convey a point, preferrably one that can be summarized by a short sentence. These data visualization slides are generously adapted from &lt;a href=&quot;http://hci.stanford.edu/~cagatay/&quot;&gt;Çağatay Demiralp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Source code for the examples we reviewed are available on the course Github page: &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/lectures/lecture_3&quot;&gt;data manipulation&lt;/a&gt;, &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/lectures/lecture_4&quot;&gt;data visualization&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are &lt;a href=&quot;https://pinboard.in/u:jhofman/t:r/t:tutorials/&quot;&gt;lots of R resources&lt;/a&gt; available on the web, but here are a few highlights:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://tryr.codeschool.com&quot;&gt;CodeSchool&lt;/a&gt; and &lt;a href=&quot;https://www.datacamp.com/courses/free-introduction-to-r&quot;&gt;DataCamp&lt;/a&gt; intro to R courses&lt;/li&gt;
  &lt;li&gt;More about &lt;a href=&quot;http://www.r-tutor.com/r-introduction/basic-data-types&quot;&gt;basic types&lt;/a&gt; (numeric, character, logical, factor) in R&lt;/li&gt;
  &lt;li&gt;Vectors, lists, dataframes: a &lt;a href=&quot;http://www.statmethods.net/input/datatypes.html&quot;&gt;one page reference&lt;/a&gt; and [more details]&lt;/li&gt;
  &lt;li&gt;Chapters &lt;a href=&quot;http://r4ds.had.co.nz/introduction.html&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;http://r4ds.had.co.nz/explore-intro.html&quot;&gt;2&lt;/a&gt;, and &lt;a href=&quot;http://r4ds.had.co.nz/transform.html&quot;&gt;5&lt;/a&gt; of &lt;a href=&quot;http://r4ds.had.co.nz&quot;&gt;R for Data Science&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;DataCamp’s &lt;a href=&quot;https://campus.datacamp.com/courses/dplyr-data-manipulation-r-tutorial&quot;&gt;Data Manipulation in R&lt;/a&gt; tutorial&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html&quot;&gt;dplyr vignette&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Sean Anderson’s &lt;a href=&quot;http://seananderson.ca/2014/09/13/dplyr-intro.html&quot;&gt;dplyr and pipes examples&lt;/a&gt; (&lt;a href=&quot;https://github.com/seananderson/dplyr-intro-2014&quot;&gt;code&lt;/a&gt; on github)&lt;/li&gt;
  &lt;li&gt;Rstudio’s &lt;a href=&quot;http://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf&quot;&gt;data wrangling cheatsheet&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Hadley Wickham’s &lt;a href=&quot;http://bit.ly/splitapplycombine&quot;&gt;split/apply/combine&lt;/a&gt; paper&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;https://style.tidyverse.org&quot;&gt;tidyverse style guide&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapters &lt;a href=&quot;http://r4ds.had.co.nz/data-visualisation.html&quot;&gt;3&lt;/a&gt;, &lt;a href=&quot;http://r4ds.had.co.nz/exploratory-data-analysis.html&quot;&gt;7&lt;/a&gt;, and &lt;a href=&quot;http://r4ds.had.co.nz/graphics-for-communication.html&quot;&gt;28&lt;/a&gt; in &lt;a href=&quot;http://r4ds.had.co.nz/&quot;&gt;R for Data Science&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;DataCamp’s &lt;a href=&quot;https://campus.datacamp.com/courses/data-visualization-with-ggplot2-1/&quot;&gt;Data Visualization with ggplot2&lt;/a&gt; tutorial&lt;/li&gt;
  &lt;li&gt;Videos on &lt;a href=&quot;http://varianceexplained.org/RData/lessons/lesson2/&quot;&gt;Visualizing Data with ggplot2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Sean Anderson’s &lt;a href=&quot;http://seananderson.ca/courses/12-ggplot2/ggplot2_slides_with_examples.pdf&quot;&gt;ggplot2 slides&lt;/a&gt; (&lt;a href=&quot;(http://github.com/seananderson/datawranglR)&quot;&gt;code&lt;/a&gt;) for more examples&lt;/li&gt;
  &lt;li&gt;RStudio’s &lt;a href=&quot;https://www.rstudio.com/resources/cheatsheets/&quot;&gt;cheatsheets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Fri, 15 Feb 2019 10:10:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Lecture 3: Computational complexity</title>
        <link>http://modelingsocialdata.org/lectures/2019/02/08/lecture-3-computational-complexity.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/lectures/2019/02/08/lecture-3-computational-complexity.html</guid>
        <description>&lt;p&gt;We had a guest lecture from &lt;a href=&quot;http://sidsen.org/&quot;&gt;Sid Sen&lt;/a&gt; on computational complexity and algorithm analysis.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://modelingsocialdata.org/img/runtime_table.png&quot; alt=&quot;Algorithm runtime in seconds, from Kleinberg &amp;amp; Tardos&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Sid discussed various ways of analyzing how long algorithms take to run, focusing on worst-case analysis.
We discussed &lt;a href=&quot;https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/asymptotic-notation&quot;&gt;asymptotic notation&lt;/a&gt; (&lt;a href=&quot;https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-o-notation&quot;&gt;big-O&lt;/a&gt; for upper bounds, &lt;a href=&quot;https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-big-omega-notation&quot;&gt;big-omega&lt;/a&gt; for lower bounds, and &lt;a href=&quot;https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-big-theta-notation&quot;&gt;big-theta&lt;/a&gt; for tight bounds).
The table above, from &lt;a href=&quot;https://www.pearsonhighered.com/program/Kleinberg-Algorithm-Design/PGM319216.html&quot;&gt;Algorithm Design&lt;/a&gt; by Kleinberg and Tardos, shows how long we should expect different algorithms to run on modern hardware.
The key takeaway is that knowing how to match the right algorithm to your dataset is important.
For instance, when you’re dealing with millions of observations, only linear (or maybe &lt;a href=&quot;https://en.wikipedia.org/wiki/Time_complexity#Linearithmic_time&quot;&gt;linearithmic&lt;/a&gt;) time algorithms are practical.&lt;/p&gt;

&lt;p&gt;A few other references:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A &lt;a href=&quot;https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/&quot;&gt;beginner’s guide&lt;/a&gt; to big-O notation&lt;/li&gt;
  &lt;li&gt;Another &lt;a href=&quot;https://www.interviewcake.com/article/python/big-o-notation-time-and-space-complexity&quot;&gt;introduction to big-O&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;http://bigocheatsheet.com/&quot;&gt;big-O cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We touched upon a few more advanced topics around the tradeoff between how long something takes to run and how much space it requires. Sid gave a brief overview of &lt;a href=&quot;https://brilliant.org/wiki/skip-lists/&quot;&gt;skip lists&lt;/a&gt; and mentioned some more recent work by his advisor, Robert Tarjan, on &lt;a href=&quot;https://arxiv.org/abs/1806.06726v2&quot;&gt;zip trees&lt;/a&gt; (video lecture &lt;a href=&quot;https://www.youtube.com/watch?v=NxRXhBur6Xs&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Sid finished his lecture by discussing how this applies to something as simple as taking the intersection of two lists, useful for &lt;a href=&quot;https://en.wikipedia.org/wiki/Join_(SQL)&quot;&gt;joining&lt;/a&gt; different tables.
A naive approach of comparing all pairs of elements takes quadratic time.
It’s relatively easy to do much better by &lt;a href=&quot;https://en.wikipedia.org/wiki/Sort-merge_join&quot;&gt;sorting and merging&lt;/a&gt; the two sets, reducing this to &lt;code class=&quot;highlighter-rouge&quot;&gt;n log(n)&lt;/code&gt; time.
And if we’re willing to trade space for time, we can use a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hash_table&quot;&gt;hash table&lt;/a&gt; to get the job done in linear time, known as a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hash_join&quot;&gt;hash join&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We used the end of lecture to revisit the command line and finish up a few leftover topics. See &lt;a href=&quot;/lectures/2019/02/01/lecture-2-counting.html&quot;&gt;last week’s post&lt;/a&gt; for links to code from class.&lt;/p&gt;

&lt;!-- 
&lt;center&gt;
&lt;iframe src=&quot;//www.slideshare.net/slideshow/embed_code/key/ejmirP42ECxx3f&quot; width=&quot;476&quot; height=&quot;400&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;&quot; allowfullscreen&gt; &lt;/iframe&gt;
&lt;/center&gt;
--&gt;

&lt;p&gt;Next week we’ll discuss data manipulation in R. In preparation, make sure to &lt;a href=&quot;/homework/2019/01/24/installing-tools.html&quot;&gt;set up&lt;/a&gt; R and the &lt;a href=&quot;https://www.tidyverse.org&quot;&gt;tidyverse&lt;/a&gt; packages. If you’re new to R, in addition to the readings in R4DS book, check out the &lt;a href=&quot;http://tryr.codeschool.com&quot;&gt;CodeSchool&lt;/a&gt; and &lt;a href=&quot;https://www.datacamp.com/courses/free-introduction-to-r&quot;&gt;DataCamp&lt;/a&gt; intro to R courses. Also have a look at the slides and code we’ll discuss in class next week, which are &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/lectures/lecture_3&quot;&gt;up on github&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Fri, 08 Feb 2019 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Homework 1</title>
        <link>http://modelingsocialdata.org/homework/2019/02/07/homework-1.html</link>
        <guid isPermaLink="true">http://modelingsocialdata.org/homework/2019/02/07/homework-1.html</guid>
        <description>&lt;p&gt;The first homework assignment, &lt;a href=&quot;https://github.com/jhofman/msd2019/tree/master/homework/homework_1&quot;&gt;posted on Github&lt;/a&gt;, is due on Thursday, February 21 by 11:59pm ET.&lt;/p&gt;

&lt;p&gt;The first problem explores various counting techniques, the second involves some command line and R counting exercises, and the third looks at the impact of inventory size on customer satisfaction for the MovieLens data.
Details are in the README.md file for each problem.&lt;/p&gt;

&lt;p&gt;Your code and a brief report with your results are to be submitted electronically in one zipped (or tarball-ed) file through the &lt;a href=&quot;https://courseworks2.columbia.edu/courses/77738&quot;&gt;CourseWorks&lt;/a&gt; site.
All code should be contained in plain text files and should produce the exact results you provide in your writeup.
Code should be written in bash / R and should not have complex dependencies on non-standard libraries.
The report should simply present your answers to the questions in an organized format as either a plain text or pdf file.
All work should be your own and done individually.&lt;/p&gt;
</description>
        <pubDate>Thu, 07 Feb 2019 17:00:00 +0000</pubDate>
      </item>
    
  </channel>
</rss>
