<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/measuring-impact-from-giving-talks-on-my-r-package-downloads/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://jasdumas.github.io/2017-05-14-my-r-pkg-downloads-impact/"> Jasmine Dumas' R Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>	ggplot2, CausalImpact, &amp; prophet oh my! – </p>
<p>It has been a longstanding goal of mine to gain confidence in public speaking, give a technical talk at a conference and <a target="_blank" rel="nofollow" href="http://jasdumas.github.io/2017-05-14-my-r-pkg-downloads-impact/#note">develop R packages</a>. I’ve noticed a trend (and a quality I’d like to inherit) amongst other <em>productive</em> R programmers which was a greater ability to communicate results through sharing methodologies and best practices, so I’ve been signing up to speak on projects, packages and development paradigms in the R and data science community.</p>
<p>After accomplishing one of my goals, the first two seemed to be achievable in tandem as I sought out opportunities to share my work with others while learning how to communicate technical topics in a receptive way. I have not always been a confident public speaker and had little exposure in presenting from poster sessions, so in 2017 I signed up (and was <a target="_blank" rel="nofollow" href="https://ci.uri.edu/2017/04/19/jasmine-dumas-kicked-off-careers-r-speaker-series-adventures-crafting-data-science-career/">asked</a>!) to give <a target="_blank" rel="nofollow" href="https://jasdumas.github.io/speaking/">talks</a> at three different venues:</p>
<ol>
<li>
<p>RhodyRstats user group and Coastal Institute at the University of Rhode Island invited me to kickoff their <a target="_blank" rel="nofollow" href="https://ci.uri.edu/2017/02/15/adventures-in-crafting-a-data-science-career/"><em>Careers in R</em></a> seminar about my transition from Biomedical Engineering to <a target="_blank" rel="nofollow" href="https://jasdumas.github.io/talks/rhodyrstats-R-user-group/rhodyrstats-r-user-group-slides.html">Data Science with R</a>.</p>
</li>
<li>
<p>Portland user group on <a target="_blank" rel="nofollow" href="http://jasdumas.github.io/2017-05-14-my-r-pkg-downloads-impact/Extending%20Shiny%20by%20Enhancing%20User%20Experience%20with%20shinyLP"><em>‘Extending Shiny by Enhancing User Experience with shinyLP’</em></a> in Oregon</p>
</li>
<li>
<p>Open Data Science Conference, East on <a target="_blank" rel="nofollow" href="https://jasdumas.github.io/talks/odsc-boston/odsc-open-gov-beer.html"><em>‘Open Government Data &amp; Beer Analytics’</em></a> in Boston, MA</p>
</li>
</ol>
<hr>
<p>In turning my weekend data science adventures into blog posts, I hypothesized if my talks at meetup group, events and conferences would have an impact on my CRAN package downloads and sought out to explore those metrics using the <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=cranlogs"><code>cranlogs</code> package</a>.</p>
<p>There were already some interesting shiny applications that utilized <code>cranlogs</code> to get CRAN metrics: <a target="_blank" rel="nofollow" href="https://hadley.shinyapps.io/cran-downloads/">cran-downloads</a>, and <a target="_blank" rel="nofollow" href="https://jjallaire.shinyapps.io/shiny-crandash/">shiny-crandash</a> using flexdashboard, but I wanted to overlay CRAN download metrics for my packages (<code>ttbbeer</code> and <code>shinyLP</code>) with the dates of my speaking engagements to see if there was any trends leading up and/or after the talks. Here is the story through visualization of the impact of speaking engagements on my CRAN package downloads:</p>
<div>
<pre><code><span># Query download counts directly from R with the cranlogs R package.
</span><span>library</span><span>(</span><span>devtools</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggplot2</span><span>)</span><span>
</span><span>library</span><span>(</span><span>magrittr</span><span>)</span><span>
</span><span>#install_git(&quot;git://github.com/metacran/cranlogs.git&quot;)
</span><span>library</span><span>(</span><span>cranlogs</span><span>)</span><span>
</span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>plotly</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggrepel</span><span>)</span><span>
</span><span>library</span><span>(</span><span>emo</span><span>)</span><span>
</span><span>## Calculate a starting download date
</span><span>today_ish</span><span> </span><span>=</span><span> </span><span>Sys.Date</span><span>()</span><span> </span><span>-</span><span> </span><span>1</span><span>
</span><span>today</span><span> </span><span>=</span><span> </span><span>Sys.Date</span><span>()</span><span>
</span><span># Download CRAN metrics
</span><span>c</span><span> </span><span>&lt;-</span><span> </span><span>cran_downloads</span><span>(</span><span>from</span><span> </span><span>=</span><span> </span><span>&quot;2016-07-03&quot;</span><span>,</span><span> </span><span>to</span><span> </span><span>=</span><span> </span><span>today</span><span>,</span><span> </span><span>packages</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;shinyLP&quot;</span><span>,</span><span> </span><span>&quot;ttbbeer&quot;</span><span>))</span><span>
</span><span>## Important days for events and speaking
</span><span>cardiff_talk</span><span> </span><span>=</span><span> </span><span>as.Date</span><span>(</span><span>&quot;2016-08-02&quot;</span><span>)</span><span> </span><span># i gave a remote talk
</span><span>uri_talk</span><span> </span><span>=</span><span> </span><span>as.Date</span><span>(</span><span>&quot;2017-03-30&quot;</span><span>)</span><span>
</span><span>pdx_talk</span><span> </span><span>=</span><span> </span><span>as.Date</span><span>(</span><span>&quot;2017-04-06&quot;</span><span>)</span><span>
</span><span>odsc_talk</span><span> </span><span>=</span><span> </span><span>as.Date</span><span>(</span><span>&quot;2017-05-05&quot;</span><span>)</span><span>
</span><span>c</span><span>$</span><span>important_days</span><span> </span><span>&lt;-</span><span> </span><span>NA</span><span>
</span><span>c</span><span>$</span><span>important_days</span><span>[</span><span>which</span><span>(</span><span>c</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>cardiff_talk</span><span> </span><span>&amp;</span><span> </span><span>c</span><span>$</span><span>package</span><span> </span><span>==</span><span> </span><span>'ttbbeer'</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;Cardiff, UK (Remote)&quot;</span><span>
</span><span>c</span><span>$</span><span>important_days</span><span>[</span><span>which</span><span>(</span><span>c</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>uri_talk</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;URI&quot;</span><span>
</span><span>c</span><span>$</span><span>important_days</span><span>[</span><span>which</span><span>(</span><span>c</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>pdx_talk</span><span> </span><span>&amp;</span><span> </span><span>c</span><span>$</span><span>package</span><span> </span><span>==</span><span> </span><span>'shinyLP'</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;PDX&quot;</span><span>
</span><span>c</span><span>$</span><span>important_days</span><span>[</span><span>which</span><span>(</span><span>c</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>odsc_talk</span><span> </span><span>&amp;</span><span> </span><span>c</span><span>$</span><span>package</span><span> </span><span>==</span><span> </span><span>'ttbbeer'</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;ODSC&quot;</span><span>
</span><span>c</span><span>$</span><span>important_days</span><span>[</span><span>which</span><span>(</span><span>c</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>as.Date</span><span>(</span><span>&quot;2016-11-27&quot;</span><span>)</span><span> </span><span>&amp;</span><span> </span><span>c</span><span>$</span><span>package</span><span> </span><span>==</span><span> </span><span>'shinyLP'</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;Second release to CRAN&quot;</span><span> </span><span># abnormal spike in downloads
</span></code></pre>
</div>
<div>
<pre><code><span># Transform and visualize data
</span><span>c</span><span> </span><span>%>%</span><span> </span><span>slice</span><span>(</span><span>73</span><span>:</span><span>nrow</span><span>(</span><span>c</span><span>))</span><span> </span><span>%>%</span><span> </span><span># shinyLP was not available until 9/13/17
</span><span> </span><span>filter</span><span>(</span><span>package</span><span> </span><span>==</span><span> </span><span>'ttbbeer'</span><span>)</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>.</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>date</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>count</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>important_days</span><span>))</span><span> </span><span>+</span><span>
</span><span>#geom_point() +
</span><span> </span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_smooth</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_y_log10</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_label_repel</span><span>(</span><span>na.rm</span><span> </span><span>=</span><span> </span><span>T</span><span>,</span><span> </span><span>nudge_y</span><span> </span><span>=</span><span> </span><span>10</span><span>,</span><span> </span><span>nudge_x</span><span> </span><span>=</span><span> </span><span>-6</span><span>,</span><span> </span><span>segment.color</span><span> </span><span>=</span><span> </span><span>&quot;darkred&quot;</span><span>,</span><span> </span><span>arrow</span><span> </span><span>=</span><span> </span><span>arrow</span><span>(</span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;closed&quot;</span><span>,</span><span>length</span><span> </span><span>=</span><span> </span><span>unit</span><span>(</span><span>0.1</span><span>,</span><span> </span><span>&quot;inches&quot;</span><span>)))</span><span> </span><span>+</span><span>
</span><span>theme_minimal</span><span>()</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span>=</span><span>&quot;none&quot;</span><span>,</span><span> </span><span>axis.text.x</span><span>=</span><span>element_text</span><span>(</span><span>angle</span><span>=</span><span>60</span><span>,</span><span> </span><span>hjust</span><span>=</span><span>1</span><span>)</span><span> </span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;Daily ttbbeer R package downloads from CRAN&quot;</span><span>,</span><span> </span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Measuring impact from speaking engagements&quot;</span><span>,</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Date&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Download Count&quot;</span><span>,</span><span> </span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: @jasdumas&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_x_date</span><span>(</span><span>date_breaks</span><span> </span><span>=</span><span> </span><span>&quot;2 month&quot;</span><span>,</span><span> </span><span>date_labels</span><span> </span><span>=</span><span> </span><span>&quot;%b %Y&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk tb1" src="https://i2.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/tb1-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>c</span><span> </span><span>%>%</span><span> </span><span>slice</span><span>(</span><span>73</span><span>:</span><span>nrow</span><span>(</span><span>c</span><span>))</span><span> </span><span>%>%</span><span> </span><span># shinyLP was not available until 9/13/17
</span><span> </span><span>filter</span><span>(</span><span>package</span><span> </span><span>==</span><span> </span><span>'shinyLP'</span><span>)</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>.</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>date</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>count</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>important_days</span><span>))</span><span> </span><span>+</span><span>
</span><span>#geom_point() +
</span><span> </span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_smooth</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_y_log10</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_label_repel</span><span>(</span><span>na.rm</span><span> </span><span>=</span><span> </span><span>T</span><span>,</span><span> </span><span>nudge_x</span><span> </span><span>=</span><span> </span><span>-20</span><span>,</span><span> </span><span>segment.color</span><span> </span><span>=</span><span> </span><span>&quot;darkred&quot;</span><span>,</span><span> </span><span>arrow</span><span> </span><span>=</span><span> </span><span>arrow</span><span>(</span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;closed&quot;</span><span>,</span><span>length</span><span> </span><span>=</span><span> </span><span>unit</span><span>(</span><span>0.1</span><span>,</span><span> </span><span>&quot;inches&quot;</span><span>)))</span><span> </span><span>+</span><span>
</span><span>theme_minimal</span><span>()</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span>=</span><span>&quot;none&quot;</span><span>,</span><span> </span><span>axis.text.x</span><span>=</span><span>element_text</span><span>(</span><span>angle</span><span>=</span><span>60</span><span>,</span><span> </span><span>hjust</span><span>=</span><span>1</span><span>))</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;Daily shinyLP R package downloads from CRAN&quot;</span><span>,</span><span> </span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Measuring impact from speaking engagements&quot;</span><span>,</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Date&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Download Count&quot;</span><span>,</span><span> </span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;Source: @jasdumas&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_x_date</span><span>(</span><span>date_breaks</span><span> </span><span>=</span><span> </span><span>&quot;2 month&quot;</span><span>,</span><span> </span><span>date_labels</span><span> </span><span>=</span><span> </span><span>&quot;%b %Y&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk sl1" src="https://i0.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/sl1-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>There are some interesting trends in downloads following my invited talk at Coastal Institute (URI), which kicked of 2 additional talks within a nearly 5 week span and a spike in <code>shinyLP</code> downloads the day after the second release to CRAN <img alt="🎉" class="wp-smiley" src="https://s.w.org/images/core/emoji/2/72x72/1f389.png">.</p>
<hr>
<h3>Causal Impact of my first, in-person talk at the Coastal Institute (URI)</h3>
<p>For further analysis I will use the <a target="_blank" rel="nofollow" href="https://google.github.io/CausalImpact/CausalImpact.html"><code>CausalImpact</code></a> from Google to answer the question of estimating the causal effect of giving talks on my CRAN package downloads, by time period before and after my first talk at URI. This approach in determining impact is to try and predict the counter factual, i.e., how would package downloads would have evolved after the intervention (after giving the talk) if the intervention had never occurred. <em>Some gotchas to this approach is that the post period could have been amplified by additional speaking engagements and therefore the singe event determination could not be the true event for measuring causal impact and the pre period contains some lead-up times for events that were annouced on Twitter prior to the initial events</em></p>
<div>
<pre><code><span>library</span><span>(</span><span>CausalImpact</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span># run this one just for ttbbeer
</span><span>df_ttbbeer</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>package</span><span> </span><span>==</span><span> </span><span>'ttbbeer'</span><span>)</span><span>
</span><span>df_ttbbeer</span><span> </span><span>&lt;-</span><span> </span><span>df_ttbbeer</span><span>[,</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>2</span><span>)]</span><span>
</span><span>pre_period</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>df_ttbbeer</span><span>$</span><span>date</span><span>[</span><span>1</span><span>],</span><span> </span><span>df_ttbbeer</span><span>$</span><span>date</span><span>[</span><span>which</span><span>(</span><span>df_ttbbeer</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>uri_talk</span><span>)])</span><span>
</span><span>post_period</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>df_ttbbeer</span><span>$</span><span>date</span><span>[</span><span>which</span><span>(</span><span>df_ttbbeer</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>uri_talk</span><span>)]</span><span>+1</span><span>,</span><span> </span><span>tail</span><span>(</span><span>df_ttbbeer</span><span>$</span><span>date</span><span>)[</span><span>6</span><span>])</span><span>
</span><span>impact</span><span> </span><span>&lt;-</span><span> </span><span>CausalImpact</span><span>(</span><span>df_ttbbeer</span><span>,</span><span> </span><span>pre_period</span><span>,</span><span> </span><span>post_period</span><span>)</span><span>
</span><span>plot</span><span>(</span><span>impact</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk tb2" src="https://i1.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/tb2-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>summary</span><span>(</span><span>impact</span><span>,</span><span> </span><span>&quot;report&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## Analysis report {CausalImpact}
## 
## 
## During the post-intervention period, the response variable had an average value of approx. 6.64. By contrast, in the absence of an intervention, we would have expected an average response of 3.88. The 95% interval of this counterfactual prediction is [2.69, 5.13]. Subtracting this prediction from the observed response yields an estimate of the causal effect the intervention had on the response variable. This effect is 2.77 with a 95% interval of [1.51, 3.96]. For a discussion of the significance of this effect, see below.
## 
## Summing up the individual data points during the post-intervention period (which can only sometimes be meaningfully interpreted), the response variable had an overall value of 299.00. By contrast, had the intervention not taken place, we would have expected a sum of 174.50. The 95% interval of this prediction is [120.87, 231.05].
## 
## The above results are given in terms of absolute numbers. In relative terms, the response variable showed an increase of +71%. The 95% interval of this percentage is [+39%, +102%].
## 
## This means that the positive effect observed during the intervention period is statistically significant and unlikely to be due to random fluctuations. It should be noted, however, that the question of whether this increase also bears substantive significance can only be answered by comparing the absolute effect (2.77) to the original goal of the underlying intervention.
## 
## The probability of obtaining this effect by chance is very small (Bayesian one-sided tail-area probability p = 0.001). This means the causal effect can be considered statistically significant.
</code></pre>
</div>
<div>
<pre><code><span># run this one just for shinyLP
</span><span>df_shinylp</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>package</span><span> </span><span>==</span><span> </span><span>'shinyLP'</span><span>)</span><span>
</span><span>df_shinylp</span><span> </span><span>&lt;-</span><span> </span><span>df_shinylp</span><span>[,</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>2</span><span>)]</span><span>
</span><span>pre_period2</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>df_shinylp</span><span>$</span><span>date</span><span>[</span><span>1</span><span>],</span><span> </span><span>df_shinylp</span><span>$</span><span>date</span><span>[</span><span>which</span><span>(</span><span>df_shinylp</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>uri_talk</span><span>)])</span><span>
</span><span>post_period2</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>df_shinylp</span><span>$</span><span>date</span><span>[</span><span>which</span><span>(</span><span>df_shinylp</span><span>$</span><span>date</span><span> </span><span>==</span><span> </span><span>uri_talk</span><span>)]</span><span>+1</span><span>,</span><span> </span><span>tail</span><span>(</span><span>df_shinylp</span><span>$</span><span>date</span><span>)[</span><span>6</span><span>])</span><span>
</span><span>impact2</span><span> </span><span>&lt;-</span><span> </span><span>CausalImpact</span><span>(</span><span>df_shinylp</span><span>,</span><span> </span><span>pre_period2</span><span>,</span><span> </span><span>post_period2</span><span>)</span><span>
</span><span>plot</span><span>(</span><span>impact2</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk sl2" src="https://i2.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/sl2-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>summary</span><span>(</span><span>impact2</span><span>,</span><span> </span><span>&quot;report&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## Analysis report {CausalImpact}
## 
## 
## During the post-intervention period, the response variable had an average value of approx. 9.51. In the absence of an intervention, we would have expected an average response of 6.18. The 95% interval of this counterfactual prediction is [0.26, 11.72]. Subtracting this prediction from the observed response yields an estimate of the causal effect the intervention had on the response variable. This effect is 3.33 with a 95% interval of [-2.20, 9.25]. For a discussion of the significance of this effect, see below.
## 
## Summing up the individual data points during the post-intervention period (which can only sometimes be meaningfully interpreted), the response variable had an overall value of 428.00. Had the intervention not taken place, we would have expected a sum of 278.15. The 95% interval of this prediction is [11.86, 527.19].
## 
## The above results are given in terms of absolute numbers. In relative terms, the response variable showed an increase of +54%. The 95% interval of this percentage is [-36%, +150%].
## 
## This means that, although the intervention appears to have caused a positive effect, this effect is not statistically significant when considering the entire post-intervention period as a whole. Individual days or shorter stretches within the intervention period may of course still have had a significant effect, as indicated whenever the lower limit of the impact time series (lower plot) was above zero. The apparent effect could be the result of random fluctuations that are unrelated to the intervention. This is often the case when the intervention period is very long and includes much of the time when the effect has already worn off. It can also be the case when the intervention period is too short to distinguish the signal from the noise. Finally, failing to find a significant effect can happen when there are not enough control variables or when these variables do not correlate well with the response variable during the learning period.
## 
## The probability of obtaining this effect by chance is p = 0.132. This means the effect may be spurious and would generally not be considered statistically significant.
</code></pre>
</div>
<p>The reports from these analysis are quite interesting and aid in supporting my thoughts around package downloads being impacted (<code>ttbbeer</code> to a significant level) by beginning to give talks. <em>I also spoke about <code>ttbbeer</code> exclusively at a larger conference which could lead to inflated downloads during the post period</em></p>
<hr>
<h3>Forecasting Future CRAN downloads:</h3>
<p>I have been wanting to explore the <a target="_blank" rel="nofollow" href="http://facebookincubator.github.io/prophet/">Prophet</a> package from Facebook since it launched, and I added this additional section which follows along the documentation for R to get some predictions about future downloads for my CRAN packages. <em>Some gotchas with this appraoch is the need to round the predictions up, as the count is discrete</em></p>
<div>
<pre><code><span>library</span><span>(</span><span>prophet</span><span>)</span><span>
</span><span>c</span><span>$</span><span>y</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>$</span><span>count</span><span>
</span><span>c</span><span>$</span><span>ds</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>$</span><span>date</span><span>
</span><span>m_ttbbeer</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>package</span><span> </span><span>==</span><span> </span><span>'ttbbeer'</span><span>)</span><span> </span><span>m_ttbbeer</span><span> </span><span>&lt;-</span><span> </span><span>m_ttbbeer</span><span>[,</span><span> </span><span>c</span><span>(</span><span>5</span><span>,</span><span> </span><span>6</span><span>)]</span><span>
</span><span>m_shinylp</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>package</span><span> </span><span>==</span><span> </span><span>'shinyLP'</span><span>)</span><span>
</span><span>m_shinylp</span><span> </span><span>&lt;-</span><span> </span><span>m_shinylp</span><span>[,</span><span> </span><span>c</span><span>(</span><span>5</span><span>,</span><span> </span><span>6</span><span>)]</span><span>
</span></code></pre>
</div>
<p><strong>Fit the models for both packages seperately:</strong></p>
<div>
<pre><code><span>m_ttbbeer_fit</span><span> </span><span>&lt;-</span><span> </span><span>prophet</span><span>(</span><span>m_ttbbeer</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## Initial log joint probability = -4.02776
## Optimization terminated normally: 
##   Convergence detected: relative gradient magnitude is below tolerance
</code></pre>
</div>
<div>
<pre><code><span>m_shinylp_fit</span><span> </span><span>&lt;-</span><span> </span><span>prophet</span><span>(</span><span>m_shinylp</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## Initial log joint probability = -2.62488
## Optimization terminated normally: 
##   Convergence detected: relative gradient magnitude is below tolerance
</code></pre>
</div>
<p><strong>Create dataframes of future datestamps for predictions to be made:</strong></p>
<div>
<pre><code><span>future_ttbbeer</span><span> </span><span>&lt;-</span><span> </span><span>make_future_dataframe</span><span>(</span><span>m_ttbbeer_fit</span><span>,</span><span> </span><span>periods</span><span> </span><span>=</span><span> </span><span>90</span><span>)</span><span> </span><span># 90 days out
</span></code></pre>
</div>
<div>
<pre><code><span>future_shinylp</span><span> </span><span>&lt;-</span><span> </span><span>make_future_dataframe</span><span>(</span><span>m_shinylp_fit</span><span>,</span><span> </span><span>periods</span><span> </span><span>=</span><span> </span><span>90</span><span>)</span><span>
</span></code></pre>
</div>
<p><strong>Use the generic predict function:</strong></p>
<div>
<pre><code><span>forecast_ttbbeer</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>m_ttbbeer_fit</span><span>,</span><span> </span><span>future_ttbbeer</span><span>)</span><span>
</span><span>tail</span><span>(</span><span>forecast_ttbbeer</span><span>[</span><span>c</span><span>(</span><span>'ds'</span><span>,</span><span> </span><span>'yhat'</span><span>,</span><span> </span><span>'yhat_lower'</span><span>,</span><span> </span><span>'yhat_upper'</span><span>)])</span><span>
</span></code></pre>
</div>
<div>
<pre><code>##             ds     yhat yhat_lower yhat_upper
## 401 2017-08-07 5.685472  0.6864452  10.967567
## 402 2017-08-08 6.578210  1.5521184  11.791462
## 403 2017-08-09 6.248853  1.2338648  11.254427
## 404 2017-08-10 5.786098  0.8473032  10.862714
## 405 2017-08-11 5.567692  0.7022517  10.155702
## 406 2017-08-12 3.905032 -1.1035745   8.690154
</code></pre>
</div>
<div>
<pre><code><span>forecast_shinylp</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>m_shinylp_fit</span><span>,</span><span> </span><span>future_shinylp</span><span>)</span><span>
</span><span>tail</span><span>(</span><span>forecast_shinylp</span><span>[</span><span>c</span><span>(</span><span>'ds'</span><span>,</span><span> </span><span>'yhat'</span><span>,</span><span> </span><span>'yhat_lower'</span><span>,</span><span> </span><span>'yhat_upper'</span><span>)])</span><span>
</span></code></pre>
</div>
<div>
<pre><code>##             ds     yhat yhat_lower yhat_upper
## 401 2017-08-07 7.164134  -12.14148   26.22302
## 402 2017-08-08 8.376941  -10.00281   28.13020
## 403 2017-08-09 8.301135  -11.10511   28.03236
## 404 2017-08-10 7.581017  -11.68299   26.20226
## 405 2017-08-11 7.172581  -11.95713   25.27349
## 406 2017-08-12 5.431217  -14.40536   24.19389
</code></pre>
</div>
<p><strong>Plot the forecast and seperate componets:</strong></p>
<div>
<pre><code><span>plot</span><span>(</span><span>m_ttbbeer_fit</span><span>,</span><span> </span><span>forecast_ttbbeer</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk tb3" src="https://i1.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/tb3-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>plot</span><span>(</span><span>m_shinylp_fit</span><span>,</span><span> </span><span>forecast_shinylp</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk sl3" src="https://i1.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/sl3-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>prophet_plot_components</span><span>(</span><span>m_ttbbeer_fit</span><span>,</span><span> </span><span>forecast_ttbbeer</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk tb4" src="https://i0.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/tb4-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>prophet_plot_components</span><span>(</span><span>m_shinylp_fit</span><span>,</span><span> </span><span>forecast_shinylp</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk sl4" src="https://i0.wp.com/raw.githubusercontent.com/jasdumas/jasdumas.github.io/master/post_data/sl4-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<hr>
<p><a name="note"></a>Last year, after attending the annual R conference in Stanford, CA I began to aggregating all of my loose functions and code into R packages to submit to <a target="_blank" rel="nofollow" href="https://cran.r-project.org/">CRAN</a>. I’ve spent the last year developing two packages: one for beer statistics, called <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=ttbbeer">ttbbeer</a> and another for creating landing pages for shiny applications, called <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=shinyLP">shinyLP</a> thereby transitioning from an R user to an R package developer. <a target="_blank" rel="nofollow" href="http://jasdumas.github.io/shinyGEO/"><em>shinyGEO</em></a> is an entirely separate adventure that has been ongoing since Summer 2014, and which will hopefully conclude soon as a package submitted to <a target="_blank" rel="nofollow" href="https://ropensci.org/">rOpenSci</a> for review.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://jasdumas.github.io/2017-05-14-my-r-pkg-downloads-impact/"> Jasmine Dumas' R Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/LSp0W5Q9bCk"></a></div>