<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>R | Data Science Portfolio</title>
    <link>http://mreevesdsba.hopto.org/tag/r/</link>
      <atom:link href="http://mreevesdsba.hopto.org/tag/r/index.xml" rel="self" type="application/rss+xml" />
    <description>R</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Sun, 12 May 2019 00:00:00 +0000</lastBuildDate>
    <image>
      <url>http://mreevesdsba.hopto.org/images/icon_hua2ec155b4296a9c9791d015323e16eb5_11927_512x512_fill_lanczos_center_2.png</url>
      <title>R</title>
      <link>http://mreevesdsba.hopto.org/tag/r/</link>
    </image>
    
    <item>
      <title>Regression Assumptions</title>
      <link>http://mreevesdsba.hopto.org/post/regression-assumptions/</link>
      <pubDate>Sun, 12 May 2019 00:00:00 +0000</pubDate>
      <guid>http://mreevesdsba.hopto.org/post/regression-assumptions/</guid>
      <description>
&lt;script src=&#34;http://mreevesdsba.hopto.org/rmarkdown-libs/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;http://mreevesdsba.hopto.org/rmarkdown-libs/htmlwidgets/htmlwidgets.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;http://mreevesdsba.hopto.org/rmarkdown-libs/echarts4r/echarts-en.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;http://mreevesdsba.hopto.org/rmarkdown-libs/echarts4r/ecStat.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;http://mreevesdsba.hopto.org/rmarkdown-libs/echarts4r/dataTool.min.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;http://mreevesdsba.hopto.org/rmarkdown-libs/echarts4r-binding/echarts4r.js&#34;&gt;&lt;/script&gt;


&lt;div id=&#34;overview&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Overview:&lt;/h2&gt;
&lt;p&gt;In the real world, you would normally start with a data set and attempt to find a model that best fits that problem; however, there is a lot of value in starting with a data set that you know will exactly fit a model and add complexity to see the effects of the assumptions made by a model. This will be our approach as we look at linear regression models, the assumptions they make about data, and the effects of those assumptions. Helpful models can absolutely be built outside of these assumptions, and almost always are, but it is important to see the isolated effects of different scenarios.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;problem&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Problem:&lt;/h2&gt;
&lt;p&gt;Imagine that at the end of of the year, you are reviewing your bank statement and you look at how much you spent on lunch every day. Assume that you track your food intake and write down what you eat for each meal. From your bank statement you can see the total cost of your lunch and from your caloric tracking you can see what items you ate each day, but you don’t know how much each item cost. Our goal is to build a linear regression model that will calculate how much each item cost. We will then add in additional complexities to the model and see their effects. Linear models make these assumptions about the dataset:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;a href=&#34;#number_one&#34;&gt;The cost of each item doesn’t change day-to-day&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#number_tow&#34;&gt;Purchasing more of an item does not change the cost of the item&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Purchasing an item doesn’t affect the cost of the other items&lt;/li&gt;
&lt;li&gt;The total cost is dependent solely dependent on the items purchased&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We will show the affects of running a model on a data set that breaks each of these. This is is not an exhaustive list of scenarios, but this will be our scope.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dataset&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Dataset&lt;/h2&gt;
&lt;p&gt;Our dataset will represent what we ate for lunch each day. Let us assume that each day we purchased:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;1 or 2 sandwiches&lt;/li&gt;
&lt;li&gt;Up to 2 apples&lt;/li&gt;
&lt;li&gt;The possibility of a bag of chips&lt;/li&gt;
&lt;li&gt;Up to 3 cookies (because we can all dream).&lt;/li&gt;
&lt;li&gt;$1 tip (a constant)&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#Set our seed to make sure our code is repeatable with consistent randomness
set.seed(101)

#Create our dataset
dataset&amp;lt;-as.data.frame(cbind(
  sandwich_count = sample(1:2, 100, replace=TRUE)
  , apple_count = sample(0:2, 100, replace=TRUE)
  , chip_count = sample(0:1, 100, replace=TRUE)
  , cookie_count = sample(0:3, 100, replace=TRUE)
))

#Peek at our dataset to make sure everything looks good
kable(head(dataset))&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;right&#34;&gt;sandwich_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;apple_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;chip_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;cookie_count&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Now that we have our dataset, let us calculate the cost total cost for each day. Here are the menu prices:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Sandwhich: $4&lt;/li&gt;
&lt;li&gt;Apple: $1.50&lt;/li&gt;
&lt;li&gt;Chips: $2.50&lt;/li&gt;
&lt;li&gt;Cookie: $.50&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Before you start wondering how we know the costs of each item (which is what we are trying to find out), we are just calculating the total cost for each lunch which would have come from our bank statement. We will only show the model the count of each item and the total cost.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#create a total column and calculate total based on cost
dataset$total&amp;lt;-(
  dataset$sandwich_count*4 
 + dataset$apple_count * 1.5
 + dataset$chip_count * 2.5
 + dataset$cookie_count * .5
 + 1
)

#Peek at our dataset to make sure everything looks good
kable(head(dataset))&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;right&#34;&gt;sandwich_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;apple_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;chip_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;cookie_count&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;total&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;9.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;3&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;6.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;14.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;9.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;5.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;11.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;build-the-model&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Build the model&lt;/h2&gt;
&lt;p&gt;In our context, the linear model will look like:&lt;/p&gt;
&lt;blockquote&gt;
Total = (tip) + (cost of item A)x(number of item A) + (cost of item B)x(number of item B)…
&lt;/blockquote&gt;
&lt;p&gt;And the cost of each item will be the coefficients that the model is going to find.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#Build the model
lunch_model&amp;lt;-lm(total~ sandwich_count + apple_count + chip_count + cookie_count, data = dataset)

#Look at the coefficients (Intercept will be the amount of our tip)
kable(lunch_model$coefficients, col.names = &amp;quot;Cost&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;sandwich_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;4.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;apple_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;chip_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The coefficients (cost of the item) all match the cost of each item exactly. This is not at all a surprise since we built our dataset within the assumptions of linear models. As long as we operate precisely whithin all the assumptions, the model will be exact.&lt;/p&gt;
&lt;p&gt;Let us run a quick prediction to make sure that everything looks good. We will have 1 sandwich, and 2 apples (plus tip should be $8):&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dataset_test&amp;lt;-as.data.frame(cbind(
  sandwich_count = 1
  , apple_count = 2
  , chip_count = 0
  , cookie_count = 0
))

predict(lunch_model, dataset_test)%&amp;gt;%
  as.numeric()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 8&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, let us change the dataset to incorporate more realistic scenarios that operate outside of these assumptions to see how it affects the model.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;number_one&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;1. Item Cost Increase&lt;/h2&gt;
&lt;p&gt;The first assumption we will break is that the cost of each item doesn’t change day-to-day. Let us assume that halfway through the year, our lunch shop increased the price of their cookie from $.50 to $1. Beyond the tragedy of costing more, this change pushes us outside of the realm of the assumptions made by a linear model that the price of each item is constant. Again, this doesn’t mean that we can’t use the model, only that it won’t fit perfectly as before. So let us examine the isolated effects of this change by looking at the coefficients if we alternate between not buying anything and only buying 1 cookie (and no tip).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#dataset alternating between 1 and 2 cookies
dataset$cookie_count &amp;lt;-rep(0:1, 50)

#Update total to show change to price
dataset$total_pricechange&amp;lt;-(dataset$cookie_count * c(rep(.5, 50), rep(1, 50)))

#Build the model
lunch_model_pricechange&amp;lt;-lm(total_pricechange ~ cookie_count, data = dataset)

#Look at the coefficients (Intercept will be the amount of our tip)
kable(round(lunch_model_pricechange$coefficients, 2), col.names = &amp;quot;Cost&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.75&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;We can see that the model estimated the cost of a cookie as halfway between $.5 and $1. It is not a coincidence that the cost of the cookie changed halfway through the year and the coefficient is halfway between the old cost and the new cost. If it had changed later in the year, the cost would be closer to the original cost as we would have paid that price more often.&lt;/p&gt;
&lt;p&gt;We can do a quick check where it changed 3/4ths of the way through the year:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.630&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;Exact weighted average:&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.625&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Let us see how the price change half way through the year effects our model knowing that this situation is not perfectly modeled by linear regression:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dataset$total_pricechange&amp;lt;-(
  dataset$sandwich_count*4 
 + dataset$apple_count * 1.5
 + dataset$chip_count * 2.5
 + dataset$cookie_count * c(rep(.5, 50), rep(1, 50))
 +  1
)

lunch_model_pricechange&amp;lt;-lm(total_pricechange~ sandwich_count + apple_count + chip_count + cookie_count, data = dataset)

kable(round(lunch_model_pricechange$coefficients, 2), col.names = &amp;quot;Cost&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.96&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;sandwich_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;4.03&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;apple_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1.48&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;chip_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2.54&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.74&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The cost estimates for each item are very close, but they are slightly off. Now that our data no longer has linear coefficients, the model is going to attribute some of the changes to other items as it tries to minimize the squared error. Looking closely at the cookie coefficient, it is right about $.75, which we had seen before.&lt;/p&gt;
&lt;p&gt;In order to check our model, lets look at our previous lunch prediction which didn’t include a cookie, so it should be affected by the price increase (remember that it cost $8)&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;predict(lunch_model_pricechange, dataset_test)%&amp;gt;%
  as.numeric()%&amp;gt;%
  round(2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 7.95&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It still comes out to be $8, so the model still works okay in that situation. Now let us see what the model would show if we had a cookie. At the original price that would have been $8.50 and the new price would be $9&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dataset_test_wcookie&amp;lt;-dataset_test
dataset_test_wcookie$cookie_count&amp;lt;-1
predict(lunch_model_pricechange, dataset_test_wcookie)%&amp;gt;%
  as.numeric()%&amp;gt;%
  round(2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## [1] 8.69&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As we would expect: halfway between the two prices (minus 1 cent). Lets take a minute and consider the consequences of this alteration. Assuming this is a predictive model, for each cookie we purchase in the future, our predictions will be under by $.25. In this simple example, that might not seem like a big deal, but as the complexity and cost of errors increases, this could have a major effect.&lt;/p&gt;
&lt;p&gt;There are a few major take-aways from this change. The first is that the number of cookies we bought at each price will directly affect the coefficient, and ultimately the prediction. The second is that if this is a permanent price change (as opposed to a periodic promotional price), our predictions will be continually off and will need a retrain to be more precise. This is where knowing the shop enough to remember that they changed their prices (domain expertise) or seeing that how far the model is off changed at a specific point (data exploration).&lt;/p&gt;
&lt;p&gt;As we can see from the chart below, our predictions before the change were mostly under and the predicitons from after are mostly over with a clear distinction between the two prices.&lt;/p&gt;
&lt;div id=&#34;htmlwidget-1&#34; style=&#34;width:100%;height:500px;&#34; class=&#34;echarts4r html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-1&#34;&gt;{&#34;x&#34;:{&#34;theme&#34;:&#34;&#34;,&#34;tl&#34;:false,&#34;draw&#34;:true,&#34;renderer&#34;:&#34;canvas&#34;,&#34;events&#34;:[],&#34;buttons&#34;:[],&#34;opts&#34;:{&#34;yAxis&#34;:[{&#34;show&#34;:true}],&#34;xAxis&#34;:[{&#34;type&#34;:&#34;value&#34;}],&#34;legend&#34;:{&#34;data&#34;:[&#34;Cookie at $.50&#34;,&#34;Cookie at $1&#34;]},&#34;series&#34;:[{&#34;data&#34;:[{&#34;value&#34;:[1,-0.00646647625867415]},{&#34;value&#34;:[2,-0.227034778877421]},{&#34;value&#34;:[3,-0.0333423409647676]},{&#34;value&#34;:[4,-0.19336691056522]},{&#34;value&#34;:[5,0.0162104522844248]},{&#34;value&#34;:[6,-0.232877773264631]},{&#34;value&#34;:[7,-0.016508406808674]},{&#34;value&#34;:[8,-0.266545641576828]},{&#34;value&#34;:[9,-0.00646647625889087]},{&#34;value&#34;:[10,-0.276587572126611]},{&#34;value&#34;:[11,0.0498783205966202]},{&#34;value&#34;:[12,-0.253910643583296]},{&#34;value&#34;:[13,0.0103674578972073]},{&#34;value&#34;:[14,-0.237076709427197]},{&#34;value&#34;:[15,0.033044386440522]},{&#34;value&#34;:[16,-0.259753637970512]},{&#34;value&#34;:[17,0.033044386440522]},{&#34;value&#34;:[18,-0.276587572126611]},{&#34;value&#34;:[19,0.0498783205966202]},{&#34;value&#34;:[20,-0.227034778877415]},{&#34;value&#34;:[21,-0.0106654124214575]},{&#34;value&#34;:[22,-0.253910643583296]},{&#34;value&#34;:[23,0.0162104522844236]},{&#34;value&#34;:[24,-0.253910643583296]},{&#34;value&#34;:[25,0.033044386440522]},{&#34;value&#34;:[26,-0.232877773264631]},{&#34;value&#34;:[27,-0.0233004104149893]},{&#34;value&#34;:[28,-0.210200844721316]},{&#34;value&#34;:[29,-0.0333423409647721]},{&#34;value&#34;:[30,-0.259753637970512]},{&#34;value&#34;:[31,0.033044386440522]},{&#34;value&#34;:[32,-0.227034778877415]},{&#34;value&#34;:[33,-0.0233004104149893]},{&#34;value&#34;:[34,-0.276587572126611]},{&#34;value&#34;:[35,-0.0501762751208707]},{&#34;value&#34;:[36,-0.276587572126611]},{&#34;value&#34;:[37,-0.0106654124214575]},{&#34;value&#34;:[38,-0.232877773264631]},{&#34;value&#34;:[39,-0.0333423409647721]},{&#34;value&#34;:[40,-0.259753637970512]},{&#34;value&#34;:[41,0.023002455890739]},{&#34;value&#34;:[42,-0.210200844721316]},{&#34;value&#34;:[43,-0.00646647625889087]},{&#34;value&#34;:[44,-0.193366910565218]},{&#34;value&#34;:[45,0.0498783205966202]},{&#34;value&#34;:[46,-0.253910643583296]},{&#34;value&#34;:[47,0.0498783205966202]},{&#34;value&#34;:[48,-0.259753637970512]},{&#34;value&#34;:[49,0.023002455890739]},{&#34;value&#34;:[50,-0.237076709427197]}],&#34;name&#34;:&#34;Cookie at $.50&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20},{&#34;data&#34;:[{&#34;value&#34;:[51,-0.016508406808674]},{&#34;value&#34;:[52,0.246089356416704]},{&#34;value&#34;:[53,-0.0106654124214575]},{&#34;value&#34;:[54,0.233454358423172]},{&#34;value&#34;:[55,0.023002455890739]},{&#34;value&#34;:[56,0.306633089434782]},{&#34;value&#34;:[57,-0.016508406808674]},{&#34;value&#34;:[58,0.279757224728901]},{&#34;value&#34;:[59,0.0498783205966202]},{&#34;value&#34;:[60,0.262923290572803]},{&#34;value&#34;:[61,0.033044386440522]},{&#34;value&#34;:[62,0.206578493717291]},{&#34;value&#34;:[63,-0.00646647625889087]},{&#34;value&#34;:[64,0.267122226735369]},{&#34;value&#34;:[65,0.0103674578972073]},{&#34;value&#34;:[66,0.246089356416704]},{&#34;value&#34;:[67,-0.0233004104149893]},{&#34;value&#34;:[68,0.246089356416704]},{&#34;value&#34;:[69,-0.0233004104149893]},{&#34;value&#34;:[70,0.233454358423172]},{&#34;value&#34;:[71,0.033044386440522]},{&#34;value&#34;:[72,0.206578493717291]},{&#34;value&#34;:[73,-0.0106654124214575]},{&#34;value&#34;:[74,0.240246362029488]},{&#34;value&#34;:[75,-0.00646647625889087]},{&#34;value&#34;:[76,0.267122226735369]},{&#34;value&#34;:[77,-0.0501762751208707]},{&#34;value&#34;:[78,0.206578493717291]},{&#34;value&#34;:[79,0.023002455890739]},{&#34;value&#34;:[80,0.267122226735369]},{&#34;value&#34;:[81,-0.0106654124214575]},{&#34;value&#34;:[82,0.279757224728901]},{&#34;value&#34;:[83,-0.016508406808674]},{&#34;value&#34;:[84,0.233454358423172]},{&#34;value&#34;:[85,-0.0333423409647721]},{&#34;value&#34;:[86,0.233454358423172]},{&#34;value&#34;:[87,-0.0501762751208707]},{&#34;value&#34;:[88,0.262923290572803]},{&#34;value&#34;:[89,-0.0233004104149893]},{&#34;value&#34;:[90,0.246089356416704]},{&#34;value&#34;:[91,0.0498783205966202]},{&#34;value&#34;:[92,0.206578493717291]},{&#34;value&#34;:[93,-0.0501762751208707]},{&#34;value&#34;:[94,0.240246362029488]},{&#34;value&#34;:[95,-0.0501762751208707]},{&#34;value&#34;:[96,0.22341242787339]},{&#34;value&#34;:[97,0.033044386440522]},{&#34;value&#34;:[98,0.22341242787339]},{&#34;value&#34;:[99,-0.0233004104149893]},{&#34;value&#34;:[100,0.22341242787339]}],&#34;name&#34;:&#34;Cookie at $1&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20}],&#34;title&#34;:[{&#34;text&#34;:&#34;Price Change Residuals&#34;,&#34;subtext&#34;:&#34;How far the model was off each day&#34;}]},&#34;dispose&#34;:true},&#34;evals&#34;:[],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;/div&gt;
&lt;div id=&#34;number_two&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;2. Buy 2 And Save…&lt;/h2&gt;
&lt;p&gt;Let us assume that instead of changing the price of cookies part way through the year, cookies had a variable price, depending on how many you purchased. 1 cookie costs $1 but 2 cookies cost $.75 each. In our imaginary life where we eat cookies on a regular basis, lets assume that we alternate between 1 and 2 cookies repeatedly.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#Alternate between 1 and 2 cookies
dataset$cookie_count &amp;lt;-rep(1:2, 25)

#1 cookie costs $1 but 2 or more cookies cost $.75 each
dataset$total_buy2&amp;lt;-(
dataset$cookie_count * ifelse(dataset$cookie_count== 1, 1, .75)
)

#Build the cookie model
lunch_model_buy2&amp;lt;-lm(total_buy2 ~ cookie_count, data = dataset)

#Look at the model
kable(lunch_model_buy2$coefficients, col.names = &amp;quot;Cost&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Interestingly, the model assumed that each cookie cost $.50 and we gave a $.50 tip. If we chart this out, it actually makes sense why that is. The difference in cost between 1 cookie and 2 cookies is $.50, so the model assumed this is how much a single cookie cost and the rest it counted as tip:&lt;/p&gt;
&lt;div id=&#34;htmlwidget-2&#34; style=&#34;width:100%;height:500px;&#34; class=&#34;echarts4r html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-2&#34;&gt;{&#34;x&#34;:{&#34;theme&#34;:&#34;&#34;,&#34;tl&#34;:false,&#34;draw&#34;:true,&#34;renderer&#34;:&#34;canvas&#34;,&#34;events&#34;:[],&#34;buttons&#34;:[],&#34;opts&#34;:{&#34;yAxis&#34;:[{&#34;show&#34;:true,&#34;minInterval&#34;:0.5,&#34;maxInterval&#34;:0.5,&#34;axisLabel&#34;:{&#34;formatter&#34;:&#34;function(value, index) {\n        var fmt = new Intl.NumberFormat(&#39;en&#39;, {\&#34;style\&#34;:\&#34;currency\&#34;,\&#34;minimumFractionDigits\&#34;:2,\&#34;maximumFractionDigits\&#34;:2,\&#34;currency\&#34;:\&#34;USD\&#34;});\n        return fmt.format(value);\n    }&#34;}}],&#34;xAxis&#34;:[{&#34;data&#34;:[&#34;1 Cookie&#34;,&#34;2 Cookie&#34;],&#34;type&#34;:&#34;category&#34;,&#34;boundaryGap&#34;:true}],&#34;legend&#34;:{&#34;data&#34;:[&#34;Tip&#34;,&#34;Cookie_1&#34;,&#34;Cookie_2&#34;]},&#34;series&#34;:[{&#34;data&#34;:[{&#34;value&#34;:[&#34;1 Cookie&#34;,&#34;0.5&#34;]},{&#34;value&#34;:[&#34;2 Cookie&#34;,&#34;0.5&#34;]}],&#34;name&#34;:&#34;Tip&#34;,&#34;type&#34;:&#34;bar&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;stack&#34;:&#34;grp&#34;},{&#34;data&#34;:[{&#34;value&#34;:[&#34;1 Cookie&#34;,&#34;0.5&#34;]},{&#34;value&#34;:[&#34;2 Cookie&#34;,&#34;0.5&#34;]}],&#34;name&#34;:&#34;Cookie_1&#34;,&#34;type&#34;:&#34;bar&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;stack&#34;:&#34;grp&#34;},{&#34;data&#34;:[{&#34;value&#34;:[&#34;1 Cookie&#34;,&#34;0&#34;]},{&#34;value&#34;:[&#34;2 Cookie&#34;,&#34;0.5&#34;]}],&#34;name&#34;:&#34;Cookie_2&#34;,&#34;type&#34;:&#34;bar&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;stack&#34;:&#34;grp&#34;}],&#34;tooltip&#34;:{&#34;trigger&#34;:&#34;item&#34;},&#34;title&#34;:[{&#34;text&#34;:&#34;Buy 2 and Save Cost&#34;,&#34;subtext&#34;:&#34;Each cookie costs the same and the rest is constant&#34;}]},&#34;dispose&#34;:true},&#34;evals&#34;:[&#34;opts.yAxis.0.axisLabel.formatter&#34;],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;Before we go back to the full lunch, let us look at increasing the number of cookies we buy each day. We will increase from 1 to 4 each time we buy lunch (just trying to make it through the week).&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;#Cycle from 1 to 4 cookies
dataset$cookie_count &amp;lt;-c(rep(1:4, 25))

#1 cookie costs $1 but 2 or more cookies cost $.75 each
dataset$total_buy2_2&amp;lt;-(
dataset$cookie_count * ifelse(dataset$cookie_count== 1, 1, .75)
)

#Build the cookie model
lunch_model_buy2_2&amp;lt;-lm(total_buy2_2 ~ cookie_count, data = dataset)

#Look at the model
kable(lunch_model_buy2_2$coefficients, col.names = &amp;quot;Cost&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.250&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.675&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The model starts to spread out the error across all of the scenarios in order to split the difference based on the number of cookies at each price. One important thing to note is that the cookie coefficient is actually lower than the cost of the cookie, even when buying more than 2. The remaining cost of the cookie was bundled proporitonally into the constant (the tip) based on how many cookies we bought at each price.&lt;/p&gt;
&lt;div id=&#34;htmlwidget-3&#34; style=&#34;width:100%;height:500px;&#34; class=&#34;echarts4r html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-3&#34;&gt;{&#34;x&#34;:{&#34;theme&#34;:&#34;&#34;,&#34;tl&#34;:false,&#34;draw&#34;:true,&#34;renderer&#34;:&#34;canvas&#34;,&#34;events&#34;:[],&#34;buttons&#34;:[],&#34;opts&#34;:{&#34;yAxis&#34;:[{&#34;show&#34;:true,&#34;minInterval&#34;:0.1,&#34;maxInterval&#34;:0.1,&#34;axisLabel&#34;:{&#34;formatter&#34;:&#34;function(value, index) {\n        var fmt = new Intl.NumberFormat(&#39;en&#39;, {\&#34;style\&#34;:\&#34;currency\&#34;,\&#34;minimumFractionDigits\&#34;:2,\&#34;maximumFractionDigits\&#34;:2,\&#34;currency\&#34;:\&#34;USD\&#34;});\n        return fmt.format(value);\n    }&#34;}}],&#34;xAxis&#34;:[{&#34;data&#34;:[&#34;1 Cookie&#34;,&#34;2 Cookies&#34;,&#34;3 Cookies&#34;,&#34;4 Cookies&#34;],&#34;type&#34;:&#34;category&#34;,&#34;boundaryGap&#34;:true}],&#34;legend&#34;:{&#34;data&#34;:[&#34;1 Cookie&#34;,&#34;2 Cookies&#34;,&#34;3 Cookies&#34;,&#34;4 Cookies&#34;],&#34;show&#34;:false,&#34;type&#34;:&#34;plain&#34;},&#34;series&#34;:[{&#34;data&#34;:[{&#34;value&#34;:[&#34;1 Cookie&#34;,&#34;0.075&#34;]}],&#34;name&#34;:&#34;1 Cookie&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20,&#34;label&#34;:{&#34;show&#34;:true,&#34;position&#34;:&#34;top&#34;}},{&#34;data&#34;:[{&#34;value&#34;:[&#34;2 Cookies&#34;,&#34;-0.1&#34;]}],&#34;name&#34;:&#34;2 Cookies&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20,&#34;label&#34;:{&#34;show&#34;:true,&#34;position&#34;:&#34;top&#34;}},{&#34;data&#34;:[{&#34;value&#34;:[&#34;3 Cookies&#34;,&#34;-0.025&#34;]}],&#34;name&#34;:&#34;3 Cookies&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20,&#34;label&#34;:{&#34;show&#34;:true,&#34;position&#34;:&#34;top&#34;}},{&#34;data&#34;:[{&#34;value&#34;:[&#34;4 Cookies&#34;,&#34;0.05&#34;]}],&#34;name&#34;:&#34;4 Cookies&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20,&#34;label&#34;:{&#34;show&#34;:true,&#34;position&#34;:&#34;top&#34;}}],&#34;title&#34;:[{&#34;text&#34;:&#34;Buy 2 and Save Residual&#34;,&#34;subtext&#34;:&#34;Each cookie costs the same and the rest is constant&#34;}]},&#34;dispose&#34;:true},&#34;evals&#34;:[&#34;opts.yAxis.0.axisLabel.formatter&#34;],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;Lets take what we just saw from the previous coefficients and try to imagine what we should expect from the full lunch model. We know that the tip will probably be about $.25 more than the $1 we actually put in, and the cookie will be less than even the $.75 we pay for 2 or more cookies.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dataset$total_buy2_full_lunch&amp;lt;-(
  dataset$sandwich_count*4 
 + dataset$apple_count * 1.5
 + dataset$chip_count * 2.5
 + dataset$cookie_count * ifelse(dataset$cookie_count== 1, 1, .75)
 + 1
)

#Build the cookie model
lunch_model_buy2_full_lunch&amp;lt;-lm(total_buy2_full_lunch ~ sandwich_count + apple_count + chip_count + cookie_count, data = dataset)

#Look at the model
kable(round(lunch_model_buy2_full_lunch$coefficients, 2), col.names = &amp;quot;Cost&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th align=&#34;left&#34;&gt;&lt;/th&gt;
&lt;th align=&#34;right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;(Intercept)&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1.28&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;sandwich_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;3.99&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;apple_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;1.50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td align=&#34;left&#34;&gt;chip_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2.49&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td align=&#34;left&#34;&gt;cookie_count&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;0.68&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;And that is exactly what we see happened.&lt;/p&gt;
&lt;p&gt;So what are the implications of this and how is this different than the previous scenario? When there was a discrete prices change, as in our previous section, the direction of the error was affected by the whether the price went up or down. Also, that change was proportional to how much the cookie changed in price and how many times we purchased the cookie at each price. In fact, each of those things still holds true. The real difference in this type of situation is that it didn’t just affect the cookie coefficient, as in the first situation, but it affected the constant. This means that our model is affected regardless of if we actually purchase a cookie. It also has the effect of possbily being under or over our prediction, depending on the number of cookies we purchase.&lt;/p&gt;
&lt;div id=&#34;htmlwidget-4&#34; style=&#34;width:100%;height:500px;&#34; class=&#34;echarts4r html-widget&#34;&gt;&lt;/div&gt;
&lt;script type=&#34;application/json&#34; data-for=&#34;htmlwidget-4&#34;&gt;{&#34;x&#34;:{&#34;theme&#34;:&#34;&#34;,&#34;tl&#34;:false,&#34;draw&#34;:true,&#34;renderer&#34;:&#34;canvas&#34;,&#34;events&#34;:[],&#34;buttons&#34;:[],&#34;opts&#34;:{&#34;yAxis&#34;:[{&#34;show&#34;:true,&#34;name&#34;:&#34;Cost&#34;,&#34;nameLocation&#34;:&#34;center&#34;,&#34;nameGap&#34;:25,&#34;axisLabel&#34;:{&#34;formatter&#34;:&#34;function(value, index) {\n        var fmt = new Intl.NumberFormat(&#39;en&#39;, {\&#34;style\&#34;:\&#34;currency\&#34;,\&#34;minimumFractionDigits\&#34;:0,\&#34;maximumFractionDigits\&#34;:0,\&#34;currency\&#34;:\&#34;USD\&#34;});\n        return fmt.format(value);\n    }&#34;}}],&#34;xAxis&#34;:[{&#34;type&#34;:&#34;value&#34;,&#34;name&#34;:&#34;Cookies&#34;,&#34;nameLocation&#34;:&#34;center&#34;}],&#34;legend&#34;:{&#34;data&#34;:[&#34;Actual&#34;,&#34;Prediciton&#34;]},&#34;series&#34;:[{&#34;data&#34;:[{&#34;value&#34;:[1,2]},{&#34;value&#34;:[2,2.5]},{&#34;value&#34;:[3,3.25]},{&#34;value&#34;:[4,4]},{&#34;value&#34;:[5,4.75]},{&#34;value&#34;:[6,5.5]},{&#34;value&#34;:[7,6.25]}],&#34;name&#34;:&#34;Actual&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20},{&#34;data&#34;:[{&#34;value&#34;:[1,1.96]},{&#34;value&#34;:[2,2.63]},{&#34;value&#34;:[3,3.31]},{&#34;value&#34;:[4,3.98]},{&#34;value&#34;:[5,4.66]},{&#34;value&#34;:[6,5.33]},{&#34;value&#34;:[7,6.01]}],&#34;name&#34;:&#34;Prediciton&#34;,&#34;type&#34;:&#34;scatter&#34;,&#34;symbol&#34;:null,&#34;coordinateSystem&#34;:&#34;cartesian2d&#34;,&#34;yAxisIndex&#34;:0,&#34;xAxisIndex&#34;:0,&#34;symbolSize&#34;:20}]},&#34;dispose&#34;:true},&#34;evals&#34;:[&#34;opts.yAxis.0.axisLabel.formatter&#34;],&#34;jsHooks&#34;:[]}&lt;/script&gt;
&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; it should be pointed out that if we had presented the model some lunches where we didn’t buy any cookies, it wouldn’t have had such a drastic impact, but for demonstrating the effects of these scenarios, these were omitted.&lt;/p&gt;
&lt;div id=&#34;additional-sections-to-be-completed.&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Additional Sections to be completed.&lt;/h4&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Hire Heroes</title>
      <link>http://mreevesdsba.hopto.org/project/hire-heroes/</link>
      <pubDate>Sun, 28 Apr 2019 00:00:00 -0400</pubDate>
      <guid>http://mreevesdsba.hopto.org/project/hire-heroes/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;Hire Heroes USA is a 501c3 nonprofit organization that empowers U.S. military members, veterans and military spouses to succeed in the workforce. They have helped over 30,000 clients find job placement through a number of services. In order to ensure the highest rate of success, machine learning was leveraged in order to recommend offered services based on demographic information of the client.&lt;/p&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;h2 id=&#34;approach&#34;&gt;Approach&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;Traditional linear models, while offering excellent interpretability, assume that each part is independent of each other part. Whereas, in reality, something like a client’s willingness to travel a longer distance would be more significant if they had more dependents or had more severe disabilities. Additionally, the services provided are not isolated either. Receiving help with interviews and resumes will have a stronger effect when combined with creating a Linkedin account. In order to capture these complex interactions, non-linear, ensemble model structures were selected. This means that the precise, direct correlation between the model feature and the prediction cannot be defined, but the relative information gained from that feature can be calculated.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&#34;dashboard&#34;&gt;Dashboard&lt;/h2&gt;
&lt;hr&gt;
&lt;h4 id=&#34;prediction-view&#34;&gt;Prediction View&lt;/h4&gt;
&lt;p&gt;Through an interactive dashboard, users are able to quickly identify the best combination of services provided by Hire Heroes in order to either maximize the probability of being hired or the minimize the time between starting the search and finding a job. This was accomplished through exhaustive grid search that runs hundreds of thousands of combinations through the models and selects the optimized set of services.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/hirepred.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;hr&gt;
&lt;h4 id=&#34;client-view&#34;&gt;Client View&lt;/h4&gt;
&lt;p&gt;Users can also review existing client&amp;rsquo;s information with recommendations for which services would aid them the most and the percentage of improvement in probability.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/hireclient.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br/&gt;
&lt;hr&gt;
&lt;h4 id=&#34;service-analysis&#34;&gt;Service Analysis&lt;/h4&gt;
&lt;p&gt;More in-depth analysis of each service for that specific client can also be viewed in order to see the total isolated effect of that service in all combinations with other services&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/hireservice.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Specialty Produce AI</title>
      <link>http://mreevesdsba.hopto.org/project/specialty-produce/</link>
      <pubDate>Sun, 28 Apr 2019 00:00:00 -0400</pubDate>
      <guid>http://mreevesdsba.hopto.org/project/specialty-produce/</guid>
      <description>&lt;h3 id=&#34;__due-to-the-sensitive-nature-of-internal-financial-records-the-dashboard-is-currently-not-available-to-the-public__&#34;&gt;&lt;strong&gt;Due to the sensitive nature of internal financial records, the dashboard is currently not available to the public.&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Specialty Produce is a family owned and operated food service and retail fresh produce supplier located in San Diego, CA. They supply to local restaurants, business, and are also open to the public. This creates a particularly difficult task to predict volumes as orders can range from a single item to multiple palettes. In order to overcome this, machine learning was implemented in order to provide insights into current-day as well as future orders.&lt;/p&gt;
&lt;p&gt;Each product is modeled individually. This is a difficult task as they carry thousand of products, many of them perishable.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/specialtydash1.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Numerous models were created and incorporated into the AI:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Order Quantity Fit&lt;/li&gt;
&lt;li&gt;Order Quantity Upper Bound&lt;/li&gt;
&lt;li&gt;Order Probability&lt;/li&gt;
&lt;li&gt;Order Expiration Quantity&lt;/li&gt;
&lt;li&gt;Daily Order Quantity Sellout by Expiration Probability&lt;/li&gt;
&lt;li&gt;Expiration Order Quantity Sellout by Expiration Probability&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Each of those sets of models are built for&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Current-Day&lt;/li&gt;
&lt;li&gt;Next-Day&lt;/li&gt;
&lt;li&gt;Two Days&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This data is all plotted on an interactive chart in order to monitor the status of the models&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Point: Actual Order Quantity&lt;/li&gt;
&lt;li&gt;Cross: Same-Day Order Quantity Fit Prediction&lt;/li&gt;
&lt;li&gt;Colored Bar: Error (Color indicates direction of error)&lt;/li&gt;
&lt;li&gt;Dark Grey Bar: Same-Day Order Quantity Fit and Upper Bound&lt;/li&gt;
&lt;li&gt;Light Grey Bar: Next-Day Order Quantity Fit and Upper Bound&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/specialtydash2.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Models are batched daily. Each model is incorporated into final prediction based on the cost of the product (loss) and the price to rush-order that item (cost). Upper bounds are predicted in order to account for the loss associated with that product in general is less than the cost of rush-ordering additional quantity last-minute.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Exploratory Data Analysis Dashboard</title>
      <link>http://mreevesdsba.hopto.org/project/eda-dashboard/</link>
      <pubDate>Sat, 27 Apr 2019 00:00:00 -0400</pubDate>
      <guid>http://mreevesdsba.hopto.org/project/eda-dashboard/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;
&lt;p&gt;This started simply as a proof of concept for feature classification, but has the potential to be a fully-automated machine learning tool.
The idea is that, while no automation is perfect, some are helpful. By aiming to account for 80% of decisions to be correct and the remainder to be intuitively guided by the dashboard, this process can be extremely streamlined and remove a lot of the manual exploration. There are several key distinctions of this dashboard from other EDA tools. The first is NLP of the column name. While columns are not guaranteed to be named consistently, enough are to make the process valuable. The second is sorting by functional data types and not simply by data storage standards. Rather than numeric/character distinctions, data is sorted by how it is used. Free-form text is used much differently than categorical variables, despite both being character data fields. By setting thresholds on really simple parameters, a high level of accuracy can be achieved to sort columns. Once sorted, this drives the model feature engineering process.
&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2 id=&#34;current-state&#34;&gt;Current State&lt;/h2&gt;
&lt;hr&gt;
&lt;h4 id=&#34;project-overview&#34;&gt;Project Overview&lt;/h4&gt;
&lt;p&gt;Users can create a new project which will contain multiple data sets. Datasets are linked by primary-key-&amp;gt;foreign-key connections. These start by checking for columns with the same name and then verifying content, otherwise simply by content. Users can also select their own dataset connections.
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edaprojectnetwork.PNG&#34; alt=&#34;&#34;&gt;
&lt;br&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&#34;dataset-overview&#34;&gt;Dataset Overview&lt;/h4&gt;
&lt;h5 id=&#34;column-names&#34;&gt;Column Names&lt;/h5&gt;
&lt;p&gt;Users select the individual dataset that they want to explore. NLP parses column names in a number of ways&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Prefix/Suffix
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolname1.PNG&#34; alt=&#34;&#34;&gt;&lt;/li&gt;
&lt;li&gt;Common Terms
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolname2.PNG&#34; alt=&#34;&#34;&gt;&lt;/li&gt;
&lt;li&gt;Topic Modeling
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolname3.PNG&#34; alt=&#34;&#34;&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br&gt;
&lt;h5 id=&#34;column-type&#34;&gt;Column Type&lt;/h5&gt;
&lt;p&gt;Columns are automatically sorted into a number of functional categories, with the option for users to change those classifications. Users can highlight and filter columns based on the column name data in the previous step:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolcat1.PNG&#34; alt=&#34;&#34;&gt;
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolcat2.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;By expanding each category and selecting a column, a summary chart is provided based on the data type.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolcat3.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h5 id=&#34;column-network&#34;&gt;Column Network&lt;/h5&gt;
&lt;p&gt;Columns can also be visualized in a network. Color and shape can be selected by prefix/suffix or by column category. Columns can also be connected by mutual population (i.e. they are only populated when the other is also populated)&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/edacolnet1.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;future-state&#34;&gt;Future State&lt;/h2&gt;
&lt;p&gt;The next steps are to incorporate data wrangling and column creation. There is also the opportunity to incorporate automated feature engineering. Once that is completed, users will be able to select a target variable and create models based on applicable column types.&lt;/p&gt;
&lt;h3 id=&#34;link-to-dashboardhttpmreevesdsbahoptoorgeda&#34;&gt;&lt;a href=&#34;http://mreevesdsba.hopto.org/eda/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Link to Dashboard&lt;/a&gt;&lt;/h3&gt;
</description>
    </item>
    
    <item>
      <title>Budgeting App</title>
      <link>http://mreevesdsba.hopto.org/project/budget/</link>
      <pubDate>Fri, 26 Apr 2019 00:00:00 -0400</pubDate>
      <guid>http://mreevesdsba.hopto.org/project/budget/</guid>
      <description>&lt;h2 id=&#34;project-overview&#34;&gt;Project Overview&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;I am currently in the process of purchasing a house. Because it is far from move-in ready, I wanted to ensure that I tracked my expenses as thoroughly as possible. I created this simple app in under 5 hours. It is not meant to be a full-fledged budgeting app, but to capture the minimum-viable functionality that I required. Those functions were:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add new items to the budget&lt;/li&gt;
&lt;li&gt;Categorize expenses by stage, room, and type&lt;/li&gt;
&lt;li&gt;Mark items as purchased&lt;/li&gt;
&lt;li&gt;Upload and view receipts.&lt;/li&gt;
&lt;li&gt;Track important dates and phases of the process&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The app was developed in R using Shiny, is deployed to AWS EC2, and has a connection to a SQL database on RDS. Dynamic DNS allows it to be accessed from any internet connection.
&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2 id=&#34;dashboard&#34;&gt;Dashboard&lt;/h2&gt;
&lt;hr&gt;
&lt;h5 id=&#34;overview&#34;&gt;Overview&lt;/h5&gt;
&lt;p&gt;The overview tab shows the current budget as well as the remaining funds in order to quickly asses the current state of the budget.
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/total.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;A graph breaks down each budget item based on whether or not it is purchased and by the selected category
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/budget1.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;A detailed view is shown for the hovered section
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/budget2.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;The timeline shows upcoming important events as well as each stage of the process
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/timeline.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Notifications alert the user to upcoming events
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/notifications.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&#34;line-items&#34;&gt;Line Items&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;The line items tab lists each of the budgeted items.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/lineitem.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;A calendar shows how many purchases were made each day. Hovering over each day will highlight the items that were purchased that day.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/linetimecal.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;The user can click on items that have already been purchased and view the purchase info and receipt.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/receipt.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&#34;add&#34;&gt;Add&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;Items are added on the sidebar.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/menu.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h5 id=&#34;add-event&#34;&gt;Add Event&lt;/h5&gt;
&lt;p&gt;There are two kinds of events in the app: single-day and multi-day. Single-day events are categorized as Services or Documents and show up as pins on the timeline. Multi-day events are named individually and are shown as line segments.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/addevent.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h5 id=&#34;add-item&#34;&gt;Add Item&lt;/h5&gt;
&lt;p&gt;Each budget item has the following attributes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Stage:&lt;/b&gt; stage of the processes where incurred&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Room:&lt;/b&gt; which room the item is for (where applicable)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Type:&lt;/b&gt; what type of expense it is (e.g. furniture, material, service, etc.)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Amount:&lt;/b&gt; amount of the item&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Recurring:&lt;/b&gt; for tracking ongoing expenses&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/item.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h5 id=&#34;add-receipt&#34;&gt;Add Receipt&lt;/h5&gt;
&lt;p&gt;Receipts can be uploaded for tracking and tax purposes. The name of the store is selected as well as each of the budget items purchased and the total amount. The receipt can be uploaded from mobile or desktop. Once the save button is clicked, all of the items that were selected will bet marked as purchased and the receipt will be available to view.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/addreceipt.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h5 id=&#34;add-category&#34;&gt;Add Category&lt;/h5&gt;
&lt;p&gt;In case a category wasn&amp;rsquo;t added previously, it can be done on the fly.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/budget/category.PNG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;While it might not be perfectly seamless from a UI perspective, the functionality completes the need and will be much easier than trying to track in an application like Excel since it can be done from mobile devices. Interactivity is not necessary, but the development time is so minimal that it is worth the time.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h3 id=&#34;link-to-dashboardhttpmreevesdsbahoptoorgwsshinyhousebudget&#34;&gt;&lt;a href=&#34;http://mreevesdsba.hopto.org/wsshiny/HouseBudget/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Link to Dashboard&lt;/a&gt;&lt;/h3&gt;
&lt;br&gt;</description>
    </item>
    
    <item>
      <title>HOA Management Opportunity Dashboard</title>
      <link>http://mreevesdsba.hopto.org/project/hoa/</link>
      <pubDate>Fri, 26 Apr 2019 00:00:00 -0400</pubDate>
      <guid>http://mreevesdsba.hopto.org/project/hoa/</guid>
      <description>&lt;h2 id=&#34;project-overview&#34;&gt;Project Overview&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;The dashboard was designed to allow for easy exploration of the individual metrics as well as simple identification of similar neighborhoods.&lt;/p&gt;
&lt;p&gt;Analytically, the dashboard takes the selected metrics and normalizes them (scaling to between 0 and 1 to ensure uniformity) and calculates the distance between all neighborhoods. It then presents the user with the list of most similar areas&lt;/p&gt;
&lt;p&gt;Special care was given to protecting client data. It is not saved anywhere on the server, it can be cleared within the session, and will reset with a refresh button or closing the window.
&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2 id=&#34;dashboard&#34;&gt;Dashboard&lt;/h2&gt;
&lt;hr&gt;
&lt;h5 id=&#34;overview&#34;&gt;Overview&lt;/h5&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/hoa/Capture.JPG&#34; alt=&#34;&#34;&gt;
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/hoa/Capture1.JPG&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h2 id=&#34;data&#34;&gt;Data&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;The dataset profiles 462 neighborhoods in Mecklenberg County includes 26 separate metrics across multiple years.
The dataset was created in partnership among the City of Charlotte, Mecklenburg County, the UNC Charlotte Urban Institute, with the towns of Cornelius, Davidson, Huntersville, Matthews, Mint Hill, and Pineville.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;
&lt;h3 id=&#34;link-to-dashboardhttpmreevesdsbahoptoorgwsshinyhoa&#34;&gt;&lt;a href=&#34;http://mreevesdsba.hopto.org/wsshiny/hoa/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Link to Dashboard&lt;/a&gt;&lt;/h3&gt;
&lt;br&gt;</description>
    </item>
    
    <item>
      <title>Unisex Names Dashboard</title>
      <link>http://mreevesdsba.hopto.org/project/unisex-names-dashboard/</link>
      <pubDate>Fri, 26 Apr 2019 00:00:00 -0400</pubDate>
      <guid>http://mreevesdsba.hopto.org/project/unisex-names-dashboard/</guid>
      <description>&lt;hr&gt;
&lt;h2 id=&#34;domain-introduction&#34;&gt;Domain Introduction&lt;/h2&gt;
&lt;p&gt;Gender and naming convention are constantly shifting, from names shifting gender connotation, to the rise of unconventional names in recent years. However, Unisex name and their usage have shifted from being known as names for a certain gender to the other over time, or having a even split of gender usage. This study focused on identify unisex name and the prevalence of those names in the US populace. The analysis was focused on the US Baby Names dataset issued by the Social Security Administration which contains data collected names of babies born in the US from 1880 to 2013. R was used to analyze and visualize the data. The output of this study is an interactive Shiny App that can be used as a research tool in social science that reflects changing attitudes towards genders in the US.&lt;/p&gt;
&lt;h2 id=&#34;dataset&#34;&gt;Dataset&lt;/h2&gt;
&lt;p&gt;The dataset consisted of five columns; year, sex, name, n and prop. The contents of the columns are: Year has numeric values that span from 1880 to 2013, Sex has a character data type and has two possible values, male and female, Name also has character data type and consists of all unique names recorded in the time frame, n shows the number of people holding a certain name and prop shows the percentage of newborns having a certain name from each sex.
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/mf/table.PNG&#34; alt=&#34;Dashboard Unisex Names Dataset Tab Inputs&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;design&#34;&gt;Design&lt;/h2&gt;
&lt;h5 id=&#34;_unisex-name-definition_&#34;&gt;&lt;em&gt;Unisex Name Definition&lt;/em&gt;&lt;/h5&gt;
&lt;hr&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/mf/dashdataset.PNG&#34; alt=&#34;Dashboard Unisex Names Dataset Tab Inputs&#34;&gt;
An important part of the analysis was to give a clear definition of unisex names. The benefit of relying on an interactive dashboard is that it enables the user to manipulate this definition in several key ways. The user is presented two methodologies of identifying unisex names. In the first, the user is able to select the minimum usage of that name over time as well as the minimum percantage of either gender. Conceptually this allows the user to choose names that are more or less common and are more or less balanced. In the second, K Means clustering analysis is applied to the dataset based on the scaled log of count of male and female over time. The user is able to select the number of clusters. The plot automatically marks clusters as male, female, or unisex based on their mean composition.
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/mf/dashdatasetplot.PNG&#34; alt=&#34;Dashboard Unisex Names Dataset Tab Plot&#34;&gt;&lt;/p&gt;
&lt;h5 id=&#34;_popularity-metric_&#34;&gt;&lt;em&gt;Popularity Metric&lt;/em&gt;&lt;/h5&gt;
&lt;hr&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/mf/dashtrend.PNG&#34; alt=&#34;Dashboard Unisex Names Trends Tab Inputs&#34;&gt;
The third tab allows the user to dive deeper into the usage of specific names. The visualizations are designed to focus on the trends and shifting usage of names given two metrics of popularity. The first relies on the mean between sexes in a given year. A historical mean (based on the median of the dataset) and a current mean is calculated and the metric is the ratio between these means. The second is the is based on the relative difference between sexes at the maximum year of each. This maximizes the Male/Female ratio at time of highest popularity for that sex in that year&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://mreevesdsba.hopto.org/img/mf/metric.PNG&#34; alt=&#34;Dashboard Unisex Names Trends Tab Plot&#34;&gt;&lt;/p&gt;
&lt;p&gt;Users can select either metric and direction as well as the top N names for that combination. They can also select any set of names (up to 12) to compare from the dataset table.
&lt;img src=&#34;http://mreevesdsba.hopto.org/img/mf/dashtrendplot.PNG&#34; alt=&#34;Dashboard Unisex Names Trends Tab Plot&#34;&gt;&lt;/p&gt;
&lt;h3 id=&#34;link-to-dashboardhttpmreevesdsbahoptoorgwsshinymfdashboard&#34;&gt;&lt;a href=&#34;http://mreevesdsba.hopto.org/wsshiny/mfdashboard/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Link to Dashboard&lt;/a&gt;&lt;/h3&gt;
</description>
    </item>
    
  </channel>
</rss>
