Introduction
In order for one to consider investing in a certain company, it is always important to conduct a background check on the company and its reputation. Companies with good rapport will tend to gain more investors hence the company growing at large. This also reflects growth in its revenue and expansion. Performing statistical analysis on the company also comes in handy during decision making.
In this study we are going to look into the data provided in the yahoo finance to come up with potential companies that one can invest in.
Data used The dataset used in this study was from 5 companies.
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(plyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following objects are masked from 'package:xts':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
#First we need to prepare the data for analysis
variables <- yahooQF(c("Price/Sales",
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Dividend Yield",
"Market Capitalization"))
tickers <- c("AMZN","AAPL", "FB", "GOOG", "HPQ", "IBM", "MSFT", "ORCL", "SAP","SP500")
#loading the dataset
dt <- getQuote(paste(tickers, sep="", collapse=";"), what=variables)
#Add tickers as the first column and remove the first column which had date stamps
dt <- data.frame(Symbol=tickers, dt[,2:length(dt)])
# viewing the data
head(dt)
## Symbol P.E.Ratio Price.EPS.Estimate.Next.Year Dividend.Yield
## AMZN AMZN 89.387390 61.627330 0.000000000
## AAPL AAPL 23.561375 21.390789 0.006344283
## FB FB NA NA NA
## GOOG GOOG 19.713718 19.105974 0.000000000
## HPQ HPQ 9.511476 7.904632 0.034855350
## IBM IBM 22.080801 13.233268 0.000000000
## Market.Capitalization
## AMZN 1.012213e+12
## AAPL 2.279779e+12
## FB NA
## GOOG 1.273889e+12
## HPQ 2.849205e+10
## IBM 1.205102e+11
str(dt)
## 'data.frame': 10 obs. of 5 variables:
## $ Symbol : chr "AMZN" "AAPL" "FB" "GOOG" ...
## $ P.E.Ratio : num 89.39 23.56 NA 19.71 9.51 ...
## $ Price.EPS.Estimate.Next.Year: num 61.6 21.4 NA 19.1 7.9 ...
## $ Dividend.Yield : num 0 0.00634 NA 0 0.03486 ...
## $ Market.Capitalization : num 1.01e+12 2.28e+12 NA 1.27e+12 2.85e+10 ...
The dataset was made up of 10 observations and 5 variables.
Sales
## Warning: Removed 2 rows containing missing values (`geom_bar()`).
The bar plot above shows the number of sales from different companies. The graph shows that amazon had the most sales followed by Microsoft. Hp had the least amount of sales.
P.E Ratio
## Warning: Removed 2 rows containing missing values (`geom_bar()`).
The above amazon shows that amazon and SAP had the highest ratio. Comparing the P.E ratio and sales, the plots shows that the same companies recorded higher values in both hence it would be important to compare the two variables to check if they have any kind of relationship.
Relationship between Sales and P.E ratio
## Warning: Removed 2 rows containing missing values (`geom_point()`).
The above scatterplot shows a linear relationship between the two variables, This means that an increase in sales will show an increase in P.E ratio and vice versa. In order to make a significant statistical conclusion it would be important to carry out a Pearson correlation test on the two variables.
Relationship between dividend and amount of sales
## Warning: Removed 2 rows containing missing values (`geom_point()`).
The scatterplot above does not show a linear relationship between the
two variables. This means that the more a company makes sales or a
significant growth, the higher it’s dividends and vice versa.
Conclusion The analysis above shows that one should consider investing with amazon since it is more profitable in terms of sales hence higher dividends.