Microsoft Stocks from 1986 to 2023: A Lot of Growth Recently

Loading Packages

library(tidyverse)
library(here)
library(janitor)
library(skimr)
library(RColorBrewer)

Read Data & Explore

Data showing Microsoft stock prices from 1986 to 2023 from Kaggle.

## Rows: 9369 Columns: 6
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): Date
## dbl (5): Price, Open, High, Low, Volume
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
## [1] 9369    6
## spc_tbl_ [9,369 x 6] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ Date  : chr [1:9369] "05/15/2023" "05/12/2023" "05/11/2023" "05/10/2023" ...
##  $ Price : num [1:9369] 309 309 310 312 307 ...
##  $ Open  : num [1:9369] 309 311 310 309 308 ...
##  $ High  : num [1:9369] 310 311 311 313 310 ...
##  $ Low   : num [1:9369] 308 307 306 308 306 ...
##  $ Volume: num [1:9369] 16290000 19770000 31680000 30080000 21340000 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   Date = col_character(),
##   ..   Price = col_double(),
##   ..   Open = col_double(),
##   ..   High = col_double(),
##   ..   Low = col_double(),
##   ..   Volume = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr>
## Rows: 9,369
## Columns: 6
## $ Date   <chr> "05/15/2023", "05/12/2023", "05/11/2023", "05/10/2023", "05/09/~
## $ Price  <dbl> 309.46, 308.97, 310.11, 312.31, 307.00, 308.65, 310.65, 305.41,~
## $ Open   <dbl> 309.10, 310.55, 310.10, 308.62, 308.00, 310.13, 305.72, 306.24,~
## $ High   <dbl> 309.90, 310.65, 311.12, 313.00, 310.04, 310.20, 311.97, 307.76,~
## $ Low    <dbl> 307.59, 306.60, 306.26, 307.67, 306.31, 306.09, 304.27, 303.40,~
## $ Volume <dbl> 16290000, 19770000, 31680000, 30080000, 21340000, 21320000, 282~
## # A tibble: 6 x 6
##   Date       Price  Open  High   Low   Volume
##   <chr>      <dbl> <dbl> <dbl> <dbl>    <dbl>
## 1 05/15/2023  309.  309.  310.  308. 16290000
## 2 05/12/2023  309.  311.  311.  307. 19770000
## 3 05/11/2023  310.  310.  311.  306. 31680000
## 4 05/10/2023  312.  309.  313   308. 30080000
## 5 05/09/2023  307   308   310.  306. 21340000
## 6 05/08/2023  309.  310.  310.  306. 21320000
## # A tibble: 6 x 6
##   Date       Price  Open  High   Low    Volume
##   <chr>      <dbl> <dbl> <dbl> <dbl>     <dbl>
## 1 03/21/1986  0.09  0.09   0.1  0.09  59990000
## 2 03/20/1986  0.1   0.1    0.1  0.09  58440000
## 3 03/19/1986  0.1   0.1    0.1  0.1   47890000
## 4 03/18/1986  0.1   0.1    0.1  0.1   66470000
## 5 03/17/1986  0.1   0.1    0.1  0.1  133169999
## 6 03/14/1986  0.1   0.1    0.1  0.1  308160000
##      Date               Price             Open             High       
##  Length:9369        Min.   :  0.09   Min.   :  0.09   Min.   :  0.09  
##  Class :character   1st Qu.:  5.37   1st Qu.:  5.34   1st Qu.:  5.43  
##  Mode  :character   Median : 27.09   Median : 27.05   Median : 27.34  
##                     Mean   : 48.09   Mean   : 48.08   Mean   : 48.60  
##                     3rd Qu.: 43.50   3rd Qu.: 43.45   3rd Qu.: 44.00  
##                     Max.   :343.11   Max.   :344.62   Max.   :349.67  
##       Low             Volume         
##  Min.   :  0.09   Min.   :  2300000  
##  1st Qu.:  5.25   1st Qu.: 33570000  
##  Median : 26.82   Median : 51090000  
##  Mean   : 47.55   Mean   : 57805233  
##  3rd Qu.: 42.94   3rd Qu.: 71680000  
##  Max.   :342.20   Max.   :788690000
Data summary
Name microsoft
Number of rows 9369
Number of columns 6
_______________________
Column type frequency:
character 1
numeric 5
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Date 0 1 10 10 0 9369 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Price 0 1 48.09 70.14 9.0e-02 5.370e+00 2.709e+01 4.350e+01 3.4311e+02 ▇▁▁▁▁
Open 0 1 48.08 70.12 9.0e-02 5.340e+00 2.705e+01 4.345e+01 3.4462e+02 ▇▁▁▁▁
High 0 1 48.60 70.85 9.0e-02 5.430e+00 2.734e+01 4.400e+01 3.4967e+02 ▇▁▁▁▁
Low 0 1 47.55 69.36 9.0e-02 5.250e+00 2.682e+01 4.294e+01 3.4220e+02 ▇▁▁▁▁
Volume 0 1 57805233.20 37012425.48 2.3e+06 3.357e+07 5.109e+07 7.168e+07 7.8869e+08 ▇▁▁▁▁
## [1] "Date"   "Price"  "Open"   "High"   "Low"    "Volume"

Tidying the Data

While we have the end of day stock price, the opening, the high price during the day, and the low price during the day tied to a date we still need to do a bit of tidying. We need to separate the date out so charts can be made on a per year basis, and it’s of interest to us to have the logarithm of prices to get a sense of the general direction of stock price since nominal dollar amounts can be misleading. We also need to set the date as a date data type in the right format so the charts will come out correctly.

#tidying ----

clean_microsoft <- microsoft %>%
  select_all(tolower) %>%
  separate(date, c("month", "day", "year"), 
           remove = FALSE) %>%
  mutate(log_price = log(price),
         intra_day_range = high-low,
         log_intra_day = log(intra_day_range),
         date=as.Date(date, format = "%m/%d/%Y"))

Plots

First, let’s look at a simple line graph of just the price so we can get as full of a picture as possible of what’s closest to the raw data.

# Plot showing line graph of the stock price over the course of all the data
clean_microsoft %>%
  ggplot(aes(x= date, y=price))+
  geom_line()+
  labs(title = "Microsoft Stock 1986 - 2023",
       subtitle = "Line Graph of Stock Price Since Microsoft Went Public",
       caption = "Data from https://www.kaggle.com/datasets/bilalwaseer/microsoft-stocks-from-1986-to-2023",
       x = "Date",
       y = "Stock Price ($)")
Figure 1. When using nominal amounts over such a long span of time you can see a large amount of the growth leading to today's price occurred in recent years.  While there is a small jump from 1986 until 2000.

Figure 1. When using nominal amounts over such a long span of time you can see a large amount of the growth leading to today’s price occurred in recent years. While there is a small jump from 1986 until 2000.

Second, let’s look at a line graph showing the logarithm of the stock price so we can get a feel for the general direction of how the stock price was moving over time adjusted so it doesn’t look like it has had growth just because of time in the market.

# Log price over time shows just how much growth occurred from inception to
# around the year 2000 before it stagnates until around 2013 or so
clean_microsoft %>%
  ggplot(aes(x= date, y=log_price))+
  geom_line() +
  labs(title = "Microsoft Stock Since 1986 (Logarithm)",
       subtitle = "Line Graph of Logarithm of Stock Price",
       caption = "Data from https://www.kaggle.com/datasets/bilalwaseer/microsoft-stocks-from-1986-to-2023",
       x = "Date",
       y = "Logarithm of Stock Price")
Figure 2.As we can see, there is a tremendous amount of growth from 1986 to around 2000, then remains around the same level until around 2013 before growing more again.  The insane growth seen until 2000 can be explained by remarking that during that time Microsoft was establishing itself as a dominant software player until running into antitrust legal issues around 2000.

Figure 2.As we can see, there is a tremendous amount of growth from 1986 to around 2000, then remains around the same level until around 2013 before growing more again. The insane growth seen until 2000 can be explained by remarking that during that time Microsoft was establishing itself as a dominant software player until running into antitrust legal issues around 2000.

Third, let’s take a look at the price since 2008 where Microsoft, like all companies, would be coming out of the Great Recession. We are focusing on these 15 years or so to look at the growth that seemingly occurred only in recent years.

#Price since 2008 while also showing intra day range as a color to indicate
# volatility 
clean_microsoft %>%
  filter(year > 2008) %>%
  ggplot(aes(x=date, y=price, color=intra_day_range))+
  geom_line() +
  scale_color_distiller(palette = "Reds", direction=1) +
  labs(title = "Microsoft Stock Since 2008",
       subtitle = "Line Graph with Color Representing Intraday Volatility",
       caption = "Data from https://www.kaggle.com/datasets/bilalwaseer/microsoft-stocks-from-1986-to-2023",
       x = "Date",
       y = "Stock Price ($)",
       color = "Intraday Range ($)")
Figure 3. We can see the growth really accelerated after 2015 with it going into overdrive during COVID.

Figure 3. We can see the growth really accelerated after 2015 with it going into overdrive during COVID.

Fourth, let’s take a look at the stock price from COVID onward. Each point represents a day and you can see how the regression line smooths over the extreme highs and sudden lows.

clean_microsoft %>%
  filter(year >= 2020) %>%
  ggplot(aes(date, y=price))+
  geom_point()+
  geom_smooth()+
  labs(title = "Microsoft Stock 2020-2023",
       subtitle = "Daily Price Point Data with Regression Line",
       caption = "Data from https://www.kaggle.com/datasets/bilalwaseer/microsoft-stocks-from-1986-to-2023",
       x = "Date",
       y = "Stock Price ($)")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Figure 4. In 2022, like many tech companies, Microsoft's price was insanely valued.  And despite a large decline since that peak, it is still significantly higher than it was at the start of 2020.  This includes very recently where the price has surged off of AI hype.

Figure 4. In 2022, like many tech companies, Microsoft’s price was insanely valued. And despite a large decline since that peak, it is still significantly higher than it was at the start of 2020. This includes very recently where the price has surged off of AI hype.

So while Microsoft has had a record of tremendous growth over a long period of time, suffice to say most of it either occurred from 1986-2000 or 2013 onward. There is a large period where it was relatively flat when dealing with antitrust issues, the fallout from said issues, and missing technological shifts like smart phones. The recent growth coincides with the current CEO’s tenure mainly, advent of cloud computing and subscription based software models, and now AI.