Module #12
a.
# Install and load necessary packages
install.packages("ggplot2")
library(ggplot2)
# Create a data frame with the provided data
data <- data.frame(
Month = rep(month.abb, each = 2),
Year = rep(c(2012, 2013), times = 12),
Value = c(31.9, 39.4, 27, 36.2, 31.3, 40.5, 31, 44.6, 39.4, 46.8, 40.7, 44.7,
42.3, 52.2, 49.5, 54, 45, 48.8, 50, 55.8, 50.9, 58.7, 58.5, 63.4)
)
# Convert Month and Year to a date format
data$Date <- as.Date(paste(data$Year, data$Month, "1", sep = "-"))
# Create a time series plot
ggplot(data, aes(x = Date, y = Value, group = Year, color = as.factor(Year))) +
geom_line() +
geom_point() +
labs(title = "Student Credit Card Charges Over Time",
x = "Date",
y = "Charges") +
theme_minimal()
b.
# Fit an Exponential Smoothing Model
fit <- ets(data$Value)
# Print the statistical outcome
summary(fit)
c.
Time Series Plot:
The time series plot visually represents the monthly credit card charges for the years 2012 and 2013. The x-axis represents the months, and the y-axis represents the amount of credit card charges. Blue dots represent the charges for the year 2012, and red dots represent the charges for the year 2013.
Observations:
The plot shows variations in credit card charges over the months for both years.
There seems to be a general increasing trend in charges from January to December.
Notable peaks are observed in June and December for both years, indicating potential seasonality or periodic patterns.
Exponential Smoothing Model:
The Exponential Smoothing Model (ETS) is a forecasting method that takes into account error, trend, and seasonality. The model summary will provide information about the chosen model (error type, trend type, and seasonality type), as well as parameter estimates and goodness-of-fit measures.
Comments
Post a Comment