title: “Density Plot of lag.quarterly.revenue” author: “Pinkie Akinyi” date: “February 16th 2024” output: word_document: default

# Set a CRAN mirror (you can choose one that's geographically close to you)
options(repos = c(CRAN = "https://cran.rstudio.com"))


# Load the datasets package to access the freeny dataset
library(datasets)

# Access the freeny dataset
data("freeny")

# Accessing lag.quarterly.revenue using $
lag_quarterly_revenue <- freeny$lag.quarterly.revenue
head(lag_quarterly_revenue)
## [1] 8.79636 8.79236 8.79137 8.81486 8.81301 8.90751
# Generate Estimated Density
Estimated.density <- density(lag_quarterly_revenue, bw = "ucv")
## Warning in bw.ucv(x): minimum occurred at one end of the range
Estimated.density
## 
## Call:
##  density.default(x = lag_quarterly_revenue, bw = "ucv")
## 
## Data: lag_quarterly_revenue (39 obs.);   Bandwidth 'bw' = 0.1728
## 
##        x                y           
##  Min.   : 8.273   Min.   :0.001893  
##  1st Qu.: 8.778   1st Qu.:0.089166  
##  Median : 9.283   Median :0.547424  
##  Mean   : 9.283   Mean   :0.494298  
##  3rd Qu.: 9.789   3rd Qu.:0.887491  
##  Max.   :10.294   Max.   :0.908763
# Plotting
plot(Estimated.density, main = "Density Plot of lag.quarterly.revenue", xlab = "Value", ylab = "Density")
lines(Estimated.density, col = "red")
legend("topright", legend = c("Estimated Density"), col = c("red"), lty = 1)