<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karol Orozco on Medium]]></title>
        <description><![CDATA[Stories by Karol Orozco on Medium]]></description>
        <link>https://medium.com/@karolorozcoe?source=rss-aaf5b7d8a74b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8j7qMdclwUbr8krb</url>
            <title>Stories by Karol Orozco on Medium</title>
            <link>https://medium.com/@karolorozcoe?source=rss-aaf5b7d8a74b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:34:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karolorozcoe/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Recreating FiveThirtyEight Hurricanes Graph]]></title>
            <link>https://medium.com/@karolorozcoe/fivethirtyeight-hurricanes-graph-62c7f412a3a7?source=rss-aaf5b7d8a74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/62c7f412a3a7</guid>
            <category><![CDATA[ggplot2]]></category>
            <category><![CDATA[fivethirtyeight]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Karol Orozco]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 01:41:54 GMT</pubDate>
            <atom:updated>2023-01-02T01:59:21.310Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello there,</p><p>Today, I will be recreating the graph from the article “<a href="https://fivethirtyeight.com/features/why-past-hurricane-seasons-dont-tell-us-much-about-the-future/">Why Past Hurricane Seasons Don’t Tell Us Much About The Future</a>” by <a href="https://fivethirtyeight.com/contributors/anna-wiederkehr/">Anna Wiederkehr</a>.</p><p>You can find the raw data in the National Oceanic and Atmospheric Administration’s <a href="https://www.nhc.noaa.gov/data/#hurdat">HURDAT2</a> database, which has records of all Atlantic basin tropical cyclones dating back to 1851.</p><p>This exercise focuses on practicing our data visualization skills with ggplot2, so I’ll skip the data manipulation steps. You can find the dataset for the graph in my <a href="https://github.com/karolo89/Raw_Data/blob/main/Hurricane.csv">GitHub repository.</a></p><p>This is the original graph from the article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WC9fn_4oJz9MlIab.png" /></figure><p>Let’s start!</p><pre>x &lt;- getURL(&quot;https://raw.githubusercontent.com/karolo89/Raw_Data/main/Hurricane.csv&quot;)<br>hurricane &lt;- read.csv(text = x)</pre><pre>graph1 &lt;- ggplot(hurricane, aes(year,average, color = type)) +<br>  geom_step(size=.7) +<br>  <br>## Adding the text<br>  geom_textline(aes(label = ifelse(type == &quot;avg_h_15year&quot;, <br>                    &quot;All Hurricanes&quot;,<br>                    &quot;Major Hurricanes&quot;), <br>                    y = average + .8), <br>                text_smoothing = 50, <br>                fontface = 2,<br>                hjust = 0,  <br>                linetype = 0, <br>                size = 3) +<br>  annotate(&quot;text&quot;, x = 1886, y = 2.2, label = &quot;Category 3 - 5&quot;, hjust = 0,<br>           color = &quot;#3b2d74&quot;, size= 2.5) +<br><br>## Scales<br>  <br>  scale_x_continuous(breaks = seq(1860,2020,20)) +<br>  scale_y_continuous(limits = c(0,8.5),<br>                     breaks = seq(2,8,2),<br>                     expand = c(0,0)) +<br>  scale_color_manual(values = c(&quot;#735ad2&quot;, &quot;#3b2d74&quot;)) +<br><br>## Labs<br>  <br>  labs(<br>    y = &quot; &quot;,<br>    x = &quot; &quot;, <br>    title = &quot;15-year average recorded Atlantic basin hurricanes, 1851-2019&quot;) +<br>  <br>## Theme <br>  <br>  theme_minimal() +<br>  <br>  theme(<br>    <br>    panel.grid.minor = element_blank(),<br>    panel.grid.major.x = element_blank(),<br>    <br>    ## Customize x axis<br>    axis.ticks.x = element_line(colour = &quot;#e1e1e1&quot;),<br>    axis.ticks.length.x =unit(0.3,&quot;cm&quot;),<br>    axis.line.x.bottom = element_line(colour = &quot;#313131&quot;),<br>    <br>    ## axis text<br><br>    axis.text = element_text(size= 6, color= &quot;#8f8f8f&quot;, <br>                             face = &quot;bold&quot;),<br>    <br>    ## We don&#39;t want a legend<br>    <br>    legend.position = &quot;none&quot;,<br>    <br>    ## title<br>    plot.title = element_text(size =8, face = &quot;bold&quot;, colour= &quot;#545454&quot;,<br>                              hjust = 0.50, vjust = 1)<br>  )<br>graph1</pre><p>I used the <a href="https://imagecolorpicker.com/en">https://imagecolorpicker.com/en</a> tool to get the hex colors from the original graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*pVx18rjaNKPTwLAhv9yGww.png" /></figure><p>We are still missing the footer, so let’s add it.</p><pre>footer&lt;- grobTree( <br>                  textGrob(&quot;      FiveThirtyEight&quot;, x=unit(.05, &quot;npc&quot;), <br>                      gp=gpar(col=&quot;#868686&quot;, <br>                              family=&quot;sans&quot;, <br>                              fontsize= 5.5,<br>                              fontface= &quot;bold&quot;),<br>                      hjust=0,<br>                      vjust = -2),<br>                  <br>                  textGrob(&quot;SOURCES: HURDAT2, VECCHI ET AL      &quot;,<br>                        x=unit(1, &quot;npc&quot;), <br>                        gp=gpar(col=&quot;#868686&quot;, <br>                                family= &quot;sans&quot;,<br>                                fontsize=5.5,<br>                              fontface= &quot;bold&quot;),<br>                        hjust=1,<br>                      vjust = -2))<br>                  <br># Plot All Together<br><br> plt.final &lt;- grid.arrange(graph1, footer, heights=unit(c(0.72, 0.03), <br>                                                    c(&quot;npc&quot;, &quot;npc&quot;)))</pre><p>And <em>Ta-da!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*E2kcKYxHthtDFS3gV6X4yw.png" /></figure><p>There is a real person behind this blog, too! If you have a different way to tackle this visualization, I would love to hear all about it! <a href="https://www.linkedin.com/in/karolorozcoe/">https://www.linkedin.com/in/karolorozcoe/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62c7f412a3a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recreating FiveThirtyEight Voter Registrations Graph]]></title>
            <link>https://medium.com/@karolorozcoe/recreating-fivethirtyeight-graph-d00bf5e9de8e?source=rss-aaf5b7d8a74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d00bf5e9de8e</guid>
            <category><![CDATA[ggplot2]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[fivethirtyeight]]></category>
            <dc:creator><![CDATA[Karol Orozco]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 01:24:21 GMT</pubDate>
            <atom:updated>2023-01-02T02:00:13.430Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s practice our visualization skills with ggplot2 and recreate the graph from the “<a href="https://fivethirtyeight.com/features/voter-registrations-are-way-way-down-during-the-pandemic/">Voter Registrations Are Way, Way Down During The Pandemic</a>” article.</p><p>First, Let’s get and prepare the data</p><pre><br># Import data <br>vreg&lt;-read.csv(&quot;https://raw.githubusercontent.com/fivethirtyeight/data/master/voter-registration/new-voter-registrations.csv&quot;,<br>header=TRUE)<br><br># Level the Month variable so that its in the right order (ie not alphabetical)<br>vreg$Month&lt;-factor(vreg$Month,<br>levels=c(&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;))<br><br>### USE spread() FROM tidyr<br>vreg&lt;-vreg%&gt;%<br>spread(Year, New.registered.voters)<br><br>### RENAME THE COLUMNS<br>colnames(vreg)&lt;-c(&quot;Jurisdiction&quot;, &quot;Month&quot;, &quot;Y2016&quot;, &quot;Y2020&quot;)<br><br>### mutate() FROM dplyr()<br>vreg&lt;-vreg%&gt;%<br>mutate(change= Y2020-Y2016)%&gt;%<br>  mutate(Color = ifelse(change &gt; 0,&quot;#48E5E8&quot;, &quot;#F56C6A&quot;))<br><br>a&lt;- function(change){number_format(accuracy = 1,<br>                                  scale = 1/1000,<br>                                  suffix = &quot;K&quot;)(change)}</pre><pre>## &#39;data.frame&#39;:    53 obs. of  6 variables:<br>##  $ Jurisdiction: chr  &quot;Arizona&quot; &quot;Arizona&quot; &quot;Arizona&quot; &quot;Arizona&quot; ...<br>##  $ Month       : Factor w/ 5 levels &quot;Jan&quot;,&quot;Feb&quot;,&quot;Mar&quot;,..: 1 2 3 4 1 2 3 4 1 2 ...<br>##  $ Y2016       : int  25852 51155 48614 30668 87574 103377 174278 185478 17024 20707 ...<br>##  $ Y2020       : int  33229 50853 31872 10249 151595 238281 176810 38970 20260 33374 ...<br>##  $ change      : int  7377 -302 -16742 -20419 64021 134904 2532 -146508 3236 12667 ...<br>##  $ Color       : chr  &quot;#48E5E8&quot; &quot;#F56C6A&quot; &quot;#F56C6A&quot; &quot;#F56C6A&quot; ...</pre><p>Now the graph</p><pre>ggplot(vreg, aes(x= Month, y= change, fill = Color))+<br>geom_col()+ <br>geom_hline( yintercept = 0, color= &quot;black&quot;)+<br><br>geom_rect(data = data.frame(Jurisdiction = &quot;Arizona&quot;), <br>              aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>              color = &quot;lightgrey&quot;, <br>              fill = &quot;white&quot;, <br>              alpha = 0, <br>              linetype = &quot;dotted&quot;, <br>              inherit.aes = FALSE)+<br>  geom_rect(data = data.frame(Jurisdiction = &quot;California&quot;), <br>            aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>            color = &quot;lightgrey&quot;, <br>            fill = &quot;white&quot;, <br>            alpha = 0, <br>            linetype = &quot;dotted&quot;, <br>            inherit.aes = FALSE)+<br>   geom_rect(data = data.frame(Jurisdiction = &quot;Colorado&quot;), <br>             aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>             color = &quot;lightgrey&quot;, <br>             fill = &quot;white&quot;, <br>             alpha = 0, <br>             linetype = &quot;dotted&quot;, <br>             inherit.aes = FALSE)+<br>  geom_rect(data = data.frame(Jurisdiction = &quot;Delaware&quot;), <br>            aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>            color = &quot;lightgrey&quot;, fill = &quot;white&quot;, <br>            alpha = 0, <br>            linetype = &quot;dotted&quot;, <br>            inherit.aes = FALSE)+<br>  geom_rect(data = data.frame(Jurisdiction = &quot;Florida&quot;), <br>            aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>            color = &quot;lightgrey&quot;, <br>            fill = &quot;white&quot;, <br>            alpha = 0, <br>            linetype = &quot;dotted&quot;, inherit.aes = FALSE)+<br>  geom_rect(data = data.frame(Jurisdiction = &quot;Georgia&quot;), <br>            aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>            color = &quot;lightgrey&quot;, <br>            fill = &quot;white&quot;, <br>            alpha = 0, <br>            linetype = &quot;dotted&quot;, <br>            inherit.aes = FALSE)+<br>  geom_rect(data = data.frame(Jurisdiction = &quot;Illinois&quot;), <br>            aes(xmin = 4.5, xmax= 5.5, ymin= -Inf, ymax = Inf), <br>            color = &quot;lightgrey&quot;, <br>            fill = &quot;white&quot;, <br>            alpha = 0, <br>            linetype = &quot;dotted&quot;, <br>            inherit.aes = FALSE)+<br>  <br>  facet_wrap(~Jurisdiction, scales = &quot;free_y&quot;)+<br><br>  scale_fill_identity(guide= FALSE)+<br>  scale_x_discrete(limits=c(&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;), <br>                   breaks=c(&quot;Jan&quot;,&quot;May&quot;))+<br>  scale_y_continuous(labels = label_number_si(a =! 0), n.breaks = 4)+<br><br>  labs(<br>        x=&quot;&quot;,<br>        y=&quot;&quot;,<br>      title = &quot;Voter registration dropped dramatically during the pandemic&quot;,<br>      subtitle = &quot;Difference in the number of newly registered voters for each month in 2020 compared to the same month in 2016&quot;,<br>      caption = &quot;Some states treat voters who move between counties within a state as new registrants because they&#39;re unregistered from their old county and nearly registered in the new ones.          &quot;,<br>      <br>      tag= &quot;FiveThirtyEight&quot;) +<br><br>    theme_classic()+<br>    theme(<br>          axis.line.y=element_blank(),<br>          axis.line.x = element_blank(),<br>          axis.ticks = element_blank(),<br>          axis.text.y = element_text(size = 6.5, color = &quot;gray&quot;), <br>          axis.text.x = element_text(size= 6.5, color = &quot;gray&quot;),<br>          <br>          <br>          plot.title = element_text(size =9, face = &quot;bold&quot;, hjust = 0.55),<br>          plot.title.position = &quot;plot&quot;,<br>          plot.subtitle= element_text(size = 8, hjust = 0.55),<br>          <br>          plot.caption = element_text(hjust = 0, size = 6, color = &quot;grey50&quot;,<br>                                      margin = margin(r=5)),<br>          plot.background = element_rect(fill= &quot;white&quot;),<br>          plot.tag.position = &quot;bottom&quot;,<br>          plot.tag = element_text(size= 5, color = &quot;gray&quot;, hjust =0.1, <br>                                  margin=margin(t=1, <br>                                                r=5, <br>                                                b=1, <br>                                                l=20, <br>                                                unit=&quot;pt&quot;)),<br>          panel.grid.minor.y = element_blank(),<br>          panel.grid.major.y = element_line(size= 0.1, color= &quot;lightgrey&quot;,<br>                                            linetype= &quot;solid&quot;),<br>          panel.background = element_rect(fill = &quot;white&quot;),<br>          panel.border = element_blank(),<br>          panel.spacing = unit(1, &quot;lines&quot;),<br>          <br>          strip.background= element_rect(fill= &quot;white&quot;, linetype = &quot;blank&quot;),<br>          strip.text = element_text(color= &quot;black&quot;, face= &quot;bold&quot;),<br>          strip.text.x = element_text(face = &quot;bold&quot;, size= 7),<br><br>          <br>          legend.title = element_blank(),<br>          legend.position = &quot;none&quot;<br>    <br>)</pre><p>Here is the result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*L_39VLwR7Qop6T79aHC5Mg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d00bf5e9de8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Instacart Dataset Analysis]]></title>
            <link>https://medium.com/@karolorozcoe/instacart-dataset-analysis-166b38eb216e?source=rss-aaf5b7d8a74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/166b38eb216e</guid>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[ggplot2]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Karol Orozco]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 00:32:29 GMT</pubDate>
            <atom:updated>2022-12-28T00:32:29.456Z</atom:updated>
            <content:encoded><![CDATA[<p>The data analyzed came from Kaggle, <a href="https://www.kaggle.com/c/instacart-market-basket-analysis/data">https://www.kaggle.com/c/instacart-market-basket-analysis/data</a>. The dataset is anonymized and contains a sample of over 3 million grocery orders from more than 200,000 Instacart users.</p><p>For this analysis, we will use the order_products_train.csv, which offers a data sample of the order_products_prior.csv</p><h4>Review the Data</h4><pre>head(data)</pre><pre>##   order_id product_id add_to_cart_order reordered department_id aisle_id<br>## 1        1      13176                 6         0             4       24<br>## 2        1      49302                 1         1            16      120<br>## 3        1      22035                 8         1            16       21<br>## 4        1      11109                 2         1            16      108<br>## 5        1      47209                 7         0             4       24<br>## 6        1      49683                 4         0             4       83<br>##                                    product_name    category n department<br>## 1                        Bag of Organic Bananas     Organic 1    Produce<br>## 2                              Bulgarian Yogurt Non-organic 1 Dairy Eggs<br>## 3                   Organic Whole String Cheese     Organic 1 Dairy Eggs<br>## 4 Organic 4% Milk Fat Whole Milk Cottage Cheese     Organic 1 Dairy Eggs<br>## 5                          Organic Hass Avocado     Organic 1    Produce<br>## 6                                Cucumber Kirby Non-organic 1    Produce<br>##                  aisle user_id eval_set order_number order_dow<br>## 1         fresh fruits  112108    train            4         4<br>## 2               yogurt  112108    train            4         4<br>## 3      packaged cheese  112108    train            4         4<br>## 4 other creams cheeses  112108    train            4         4<br>## 5         fresh fruits  112108    train            4         4<br>## 6     fresh vegetables  112108    train            4         4<br>##   order_hour_of_day days_since_prior_order<br>## 1                10                      9<br>## 2                10                      9<br>## 3                10                      9<br>## 4                10                      9<br>## 5                10                      9<br>## 6                10                      9</pre><p><strong>Data Visualization with ggplot2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*Oc5vQ5fPKbGht3uzDbqudA.png" /></figure><p>From the above graph, it&#39;s clear that the Maximum No. of orders is placed between 10:00 AM and 5:00 PM on Sunday and Monday.</p><p>Actions: Develop strategies to increase sales during the quietest days of the week:</p><ul><li>Offer discounts on certain items.</li><li>Offer free delivery with orders over a specific dollar amount.</li></ul><p>Positive note: Customers can shop on a Wednesday or Thursday, and most likely, they will never encounter &quot;out of stock&quot; items or delivery/pick delays.</p><h4>Portfolio</h4><p>You can see an animated version of this plot <a href="https://rpubs.com/KAROLO/845520">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*zRnJ-VeFHwxOI9iOZutfew.png" /></figure><h4>Bestsellers Products</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*HI9I0t_zVPhBK_HXdQ7yxg.png" /></figure><p>The highest-ordered products are Bananas, Bags of Organic Bananas, Organic Strawberries, and Organic Baby Spinach. To increase the sale and visibility of less popular products, the retailer can put them near the top ones and come up with ideas on how to use them together, perhaps a smoothie recipe.</p><h4>Future Steps</h4><ul><li>Conduct a Cluster Analysis to identify and understand the customer’s behavior. Then, the buying behavior of each group can be examined separately on measures such as brand loyalty, price willing to pay, frequency of purchase, etc. To do this analysis, refer to the K-means clustering Analysis, Gap Statistic Method, Average Silhouette, or Elbow Method.</li><li>Conduct a Basket Analysis by department or aisles and increase the model&#39;s confidence. Refer to the lift metric to find the strong association and randomly sample those associations.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=166b38eb216e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Central Park Squirrel Census, 2018]]></title>
            <link>https://medium.com/@karolorozcoe/central-park-squirrel-census-2018-651612e5534e?source=rss-aaf5b7d8a74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/651612e5534e</guid>
            <category><![CDATA[squirrels]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[ggplot2]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Karol Orozco]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 18:52:54 GMT</pubDate>
            <atom:updated>2022-12-24T18:52:54.155Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/390/0*39Z2N-eqKy67c8gI.jpg" /></figure><p>Have you wondered how many squirrels are in Central Park and what they do all day? I only did it once I found this open dataset, which is perfect for exploring and experimenting with ggplot2 in RStudio.</p><p>You can get the data with the following code:</p><pre># install.packages(&quot;remotes&quot;) <br># remotes::install_github(&quot;mine-cetinkaya-rundel/nycsquirrels18&quot;) <br>library(nycsquirrels18) <br>?squirrels<br>data(&quot;squirrels&quot;)</pre><p>This is how the data looks like</p><pre>## # A tibble: 6 x 35<br>##    long   lat unique_squirrel_id hectare shift date       hectare_squirre~ age  <br>##   &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt;              &lt;chr&gt;   &lt;chr&gt; &lt;date&gt;                &lt;dbl&gt; &lt;chr&gt;<br>## 1 -74.0  40.8 13A-PM-1014-04     13A     PM    2018-10-14                4 &lt;NA&gt; <br>## 2 -74.0  40.8 15F-PM-1010-06     15F     PM    2018-10-10                6 Adult<br>## 3 -74.0  40.8 19C-PM-1018-02     19C     PM    2018-10-18                2 Adult<br>## 4 -74.0  40.8 21B-AM-1019-04     21B     AM    2018-10-19                4 &lt;NA&gt; <br>## 5 -74.0  40.8 23A-AM-1018-02     23A     AM    2018-10-18                2 Juve~<br>## 6 -74.0  40.8 38H-PM-1012-01     38H     PM    2018-10-12                1 Adult<br>## # ... with 27 more variables: primary_fur_color &lt;chr&gt;,<br>## #   highlight_fur_color &lt;chr&gt;,<br>## #   combination_of_primary_and_highlight_color &lt;chr&gt;, color_notes &lt;chr&gt;,<br>## #   location &lt;chr&gt;, above_ground_sighter_measurement &lt;chr&gt;,<br>## #   specific_location &lt;chr&gt;, running &lt;lgl&gt;, chasing &lt;lgl&gt;, climbing &lt;lgl&gt;,<br>## #   eating &lt;lgl&gt;, foraging &lt;lgl&gt;, other_activities &lt;chr&gt;, kuks &lt;lgl&gt;,<br>## #   quaas &lt;lgl&gt;, moans &lt;lgl&gt;, tail_flags &lt;lgl&gt;, tail_twitches &lt;lgl&gt;, ...</pre><p>Let’s take a look at our missing values <strong>vis_miss</strong>(squirrels)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*HAW2wcKi1dl9YVVyPHq-Dw.png" /></figure><p>To deal with the missing observations, I will filter my dataset using the <strong>filter</strong>(!<strong>is.na</strong>()) function, and then I will start exploring with ggplot2.</p><pre>ggplot(sq, aes(long,lat, shape = factor(age))) +<br>  geom_point(aes(color = factor(age)), alpha = 0.6, size= 1.5)+<br>    labs(<br>      title= &quot;Where do squirrels like to hang out?&quot;,<br>    caption = &quot;The graph tells us that there is a large concentration of squirrels on the ground plane at all hours\nof the day. I was hoping to find more of these small mammals above the ground during the day.&quot;)+<br>    facet_grid(~shift~location)+<br>    theme_bw()+<br>    theme(plot.title = element_text(size = 12, face = &quot;bold&quot;, <br>                                  hjust = 0.5, vjust = 0.5),<br>      strip.background = element_rect(color = &quot;black&quot;, <br>                                      fill= &quot;white&quot;, <br>                                      size= 0.5, <br>                                      linetype= &quot;dotted&quot;),<br>      strip.text.x = element_text(face = &quot;bold.italic&quot;),<br>      panel.background = element_blank(),<br>      panel.spacing = unit(3, &quot;lines&quot;),<br>      legend.position = &quot;bottom&quot;,<br>      legend.title = element_blank(),<br>      legend.text = element_text(face= &quot;bold.italic&quot;, size= 10),<br>      plot.caption.position = &quot;panel&quot;,<br>      plot.caption = element_text(hjust = 0, size= 10)<br>       )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*5bBelRNLnh9n1mGN4by1bg.png" /></figure><p><strong><em>What do the squirrels do during the day?</em></strong></p><pre>sq_act &lt;- sq %&gt;%<br>  select(c(shift, &quot;running&quot;, &quot;chasing&quot;, &quot;climbing&quot;, &quot;eating&quot;, &quot;foraging&quot;, &quot;other_activities&quot;)) %&gt;%<br>  mutate(running =as.integer(running),<br>         chasing= as.integer(chasing),<br>         climbing =as.integer(climbing),<br>         eating= as.integer(eating),<br>         foraging= as.integer(foraging),<br>         others = as.integer(other_activities))%&gt;%<br>  select(c(shift, running, chasing, climbing, eating, foraging, others))%&gt;%<br>  pivot_longer(-(shift), names_to = &quot;Activities&quot;, values_to= &quot;Value&quot;)%&gt;%<br>    filter(Value== TRUE)<br><br>ggplot(sq_act, aes(x= Activities, fill =shift))+<br>  geom_bar(position = &quot;dodge&quot;)+ <br>    scale_fill_manual(values= c(&quot;#56B4E9&quot;,&quot;#000000&quot;)) +<br>  labs( y= &quot;Number of Squirrels&quot;,<br>        x= &quot; &quot;,<br>        title= &quot;What the squirrels do during the day?&quot;,<br>      caption = &quot;The graph clearly shows us that the activity that stands out the most is foraging at night.\nThe other activities are distributed more evenly throughout the day.&quot;) +<br>   theme_classic()+<br>   theme(<br>        axis.line=element_blank(),<br>        text = element_text(size = 11),<br>        plot.title = element_text(size = 12, face = &quot;bold&quot;, <br>                                  hjust = 0.5, vjust = 0.5),<br>        legend.title = element_blank(),<br>        plot.caption.position = &quot;panel&quot;,<br>        plot.caption = element_text(hjust = 0, size= 10))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*tGy9tK9Bw6Z1Ra8I_EfZFw.png" /></figure><p>Let’s take a look at the young squirrels.</p><pre>sq %&gt;% <br>  filter(age == &quot;Juvenile&quot;) %&gt;%<br>  <br>  ggplot(aes(lat, long, color = shift))+<br>  labs(<br>    title= &quot;Moves of the Juvenile Squirreles During the Day&quot;,<br>    caption = &quot;How we can see in the graph, they are active all over the park, but during the AM shift\nthey tend to visit less the coordenates between -73.96 and 40.78&quot;<br>  )+<br>  <br>  geom_line(aes(x= lat, y= long, linetype= shift))+ <br>  geom_point()+<br>  geom_smooth()+<br>  scale_linetype_manual(values=c(&quot;twodash&quot;, &quot;dotted&quot;))+<br>  scale_color_manual(values=c(&quot;#56B4E9&quot;,&quot;#000000&quot;))+<br>  scale_size_manual(values=c(1, 1.5))+<br>  <br><br>  theme_minimal()+<br>      theme(legend.position=&quot;top&quot;,<br>             plot.caption.position = &quot;panel&quot;,<br>        plot.caption = element_text(hjust = 0, size= 10),<br>        plot.title = element_text(size = 12, face = &quot;bold&quot;, <br>                                  hjust = 0.5, vjust = 0.5)<br>        )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*YC8FAbUw91oaQ8ye2pImDA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=651612e5534e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing House Prices in Portland, OR]]></title>
            <link>https://medium.com/@karolorozcoe/analyzing-house-prices-in-portland-or-2d21d7a039e?source=rss-aaf5b7d8a74b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d21d7a039e</guid>
            <category><![CDATA[arima]]></category>
            <category><![CDATA[rstudio]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[price-prediction]]></category>
            <dc:creator><![CDATA[Karol Orozco]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 06:35:10 GMT</pubDate>
            <atom:updated>2022-12-27T03:26:22.862Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi there!</p><p>My husband and I are considering buying a house in Portland, OR!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/0*i-aBJZ6LCoNNfOKc.jpg" /></figure><p>I want to know how home prices have fluctuated in the past few years in Portland, Oregon, and how they will look in the coming months. In my time-series analysis, I will focus on four-bedroom homes, using the Zillow Home Value Index (ZHVI) dataset: a smoothed, seasonally adjusted measure of typical home value and changes from 2014–2022, reflecting the specific value of homes in the 35th to 65th percentile range.</p><p>Here is the link: <a href="https://www.zillow.com/research/data/">https://www.zillow.com/research/data/</a></p><p>This is how the data looked like once I transferred it into RStudio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Otli8q8Sdtnzw37E4ggqwg.png" /></figure><p>So, my next steps to manipulate the data and have it ready for the time series analysis are:</p><ol><li>Make this dataset tidy. Tidy Data is a way of structuring data so that it can be easily understood by people and analyzed by machines</li><li>Remove the X at the beginning of the dates (X2000.01.31, X2000.02.29,…)</li><li>Filter by Region: Portland, Metropolitan Area</li><li>Deal with missing values and data transformation</li><li>Record time series as a tsibble object in R</li></ol><p>In this case, the Monthly_parsed containing the data-time is the index, and the RegionID is the key. Other columns can be considered as measured variables.</p><p>From this analysis, we can see:</p><ul><li>This Data goes from 01/01/2014 to 10/31/2022</li><li>The median price of a 4-bedroom house in Portland is <strong>$564,917</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*-uz-2s6f34WEJbNxq__D5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*fri77YehBBf2oxG4.png" /></figure><pre><br># A tibble: 1 × 3<br>  RegionName kpss_stat kpss_pvalue<br>  &lt;chr&gt;          &lt;dbl&gt;       &lt;dbl&gt;<br>1 Portland        1.95        0.01</pre><p>Our Data Data is non-stationary; we see a trend-cycle component in the above graph. Likewise, I conducted the Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test (Kwiatkowski et al., 1992). In this test, the null hypothesis is that the data are stationary, and we look for evidence that the null hypothesis is false.</p><p>The p-value is reported as 0.01 if it is less than 0.01 and 0.1 if it is more significant than 0.1. In this case, the test statistic (1.946) is more important than the 1% critical value, so the p-value is less than 0.01, indicating that the null hypothesis is rejected. That is, the data are not stationary. Consequently, small p-values (e.g., less than 0.05) suggest that differencing is required.</p><p>And using the unitroot_ndiffs () function, one difference (d) is required to make the tsibble_pdx data stationary.</p><pre># A tibble: 1 × 2<br>  RegionName ndiffs<br>  &lt;chr&gt;       &lt;int&gt;<br>1 Portland        1</pre><p>We aim to find an appropriate forecasting model with ARIMA or ETS.</p><h3>Seasonal Arima Model</h3><pre># A mable: 4 x 3<br># Key:     RegionName, Model name [4]<br>  RegionName `Model name`                             Orders<br>  &lt;chr&gt;      &lt;chr&gt;                                   &lt;model&gt;<br>1 Portland   arima212012           &lt;ARIMA(2,1,2)(0,1,2)[12]&gt;<br>2 Portland   arima210011           &lt;ARIMA(2,1,0)(0,1,1)[12]&gt;<br>3 Portland   stepwise                &lt;ARIMA(3,1,2) w/ drift&gt;<br>4 Portland   search       &lt;ARIMA(2,1,3)(0,0,1)[12] w/ drift&gt;</pre><pre># A tibble: 4 × 6<br>  .model      sigma2 log_lik   AIC  AICc   BIC<br>  &lt;chr&gt;        &lt;dbl&gt;   &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;<br>1 arima212012   2.86   -189.  391.  392.  409.<br>2 search        2.17   -190.  396.  398.  418.<br>3 stepwise      2.25   -193.  399.  400.  418.<br>4 arima210011   4.58   -205.  419.  419.  429.</pre><p>Of these models, the best is the ARIMA(2,1,2)(0,1,2)[12]model (i.e., it has the smallest AICc value).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hb9-DCQu5uH828ZM.png" /></figure><h3>ETS</h3><pre>Series: Prices <br>Model: ETS(M,Ad,N) <br>  Smoothing parameters:<br>    alpha = 0.9999 <br>    beta  = 0.9987271 <br>    phi   = 0.9108026 </pre><pre>  Initial states:<br>     l[0]     b[0]<br> 407.9964 3.526883</pre><pre>  sigma^2:  0</pre><pre>     AIC     AICc      BIC <br>650.8419 651.6904 666.8225</pre><p>The model selected is ETS(M,Ad,N)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CSzQrBfUHTdJaM8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3SH9skhnP01u1UBK.png" /></figure><pre># A tibble: 2 × 8<br>  RegionName .model      .type     RMSE   MAE  MAPE   MASE  RMSSE<br>  &lt;chr&gt;      &lt;chr&gt;       &lt;chr&gt;    &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt;<br>1 Portland   arima212012 Training  1.53  1.14 0.194 0.0286 0.0310<br>2 Portland   ETS(Prices) Training  2.27  1.60 0.271 0.0403 0.0459</pre><p>In this case, the ARIMA model is accurate based on the test set RMSE, MAPE, and MASE, and the forecasting results are shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wBexIfeUQAX7uRgI.png" /></figure><pre># A fable: 24 x 5 [1M]<br># Key:     RegionName, .model [1]<br>   RegionName .model                                  year_m…¹      Prices .mean<br>   &lt;chr&gt;      &lt;chr&gt;                                      &lt;mth&gt;      &lt;dist&gt; &lt;dbl&gt;<br> 1 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2022 Nov   N(737, 3)  737.<br> 2 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2022 Dec  N(737, 22)  737.<br> 3 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Jan  N(739, 76)  739.<br> 4 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Feb N(742, 157)  742.<br> 5 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Mar N(748, 257)  748.<br> 6 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Apr N(753, 369)  753.<br> 7 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 May N(758, 487)  758.<br> 8 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Jun N(761, 609)  761.<br> 9 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Jul N(764, 734)  764.<br>10 Portland   ARIMA(Prices ~ pdq(2, 1, 2) + PDQ(0, 1… 2023 Aug N(765, 860)  765.<br># … with 14 more rows, and abbreviated variable name ¹​year_month</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d21d7a039e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>