Module 12

 


Module 12


```R

# Install and load necessary packages

install.packages("forecast")

library(forecast)


# Create a data frame with the provided data

data <- data.frame(

  Month = month.abb,

  Year_2012 = c(31.9, 27, 31.3, 31, 39.4, 40.7, 42.3, 49.5, 45, 50, 50.9, 58.5),

  Year_2013 = c(39.4, 36.2, 40.5, 44.6, 46.8, 44.7, 52.2, 54, 48.8, 55.8, 58.7, 63.4)

)


# Convert the data to a time series object

ts_data <- ts(cbind(data$Year_2012, data$Year_2013), start = c(2012, 1), frequency = 12)


# Plot the time series

plot(ts_data, main = "Student Credit Card Charges Over Time", xlab = "Month", ylab = "Charges", col = c("blue", "red"), lty = 1:2)


# Apply exponential smoothing model

fit <- ets(ts_data)

summary(fit)

```


This code does the following:


1. Installs and loads the `forecast` package.

2. Creates a data frame with the provided data.

3. Converts the data frame into a time series object.

4. Plots a time series plot for the student credit card charges.

5. Applies an exponential smoothing model using the `ets()` function.

6. Prints a summary of the model.


### Time Series Plot:


The time series plot visually represents the student credit card charges over the months of 2012 and 2013. The x-axis denotes the months, while the y-axis represents the charges. Two lines, distinguished by color (blue for 2012 and red for 2013), show the trend in charges over time.  

Looking at the plot:

- There is a noticeable increasing trend in charges over the months for both years.

- There might be seasonality, as there seems to be a recurring pattern of peaks and valleys.


### Exponential Smoothing Model:

The exponential smoothing model is applied to capture the underlying patterns in the time series data and make predictions.

- The model automatically selects the type of exponential smoothing (e.g., additive or multiplicative) based on the data.

- It provides estimates for the smoothing parameters (alpha, beta, and gamma).

- The model summary includes measures of goodness-of-fit, such as AIC (Akaike Information Criterion) and BIC (Bayesian Information Criterion).


### Discussion:

   The increasing trend observed in the time series plot aligns with the common expectation that credit card charges may rise over time due to various factors such as increased spending habits, inflation, or economic growth.

   The recurring pattern suggests there might be seasonality in credit card charges. Seasonal fluctuations could be influenced by external factors like holidays, school terms, or other events impacting spending behavior.

   - The automatic selection of the smoothing parameters indicates that the model adjusts to the data's characteristics.

   - The AIC and BIC values provide a measure of how well the model fits the data, with lower values indicating a better fit.

   - The exponential smoothing model can be used for forecasting future credit card charges based on the identified patterns in the historical data.

   - Forecasting results would help in financial planning and risk management.

   - While the model provides insights, it's essential to consider external factors not captured in the data that could influence credit card charges.

   - Continuous monitoring and updating of the model are crucial as spending patterns may change over time.


Comments