Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have questions on how to do this in R/Rstudio or smoothing methods. I have bee

ID: 2906569 • Letter: I

Question

I have questions on how to do this in R/Rstudio or smoothing methods. I have been struggling with using the codes. I have been practicing and tryign to do it, but I am really unsure at where I am with it. Just need something to compare it too! I don't understand why there isn't any information under the demand section!

(1) A memo written to the Chief Operations Officer of Transantiago that describes the model and method and presents the 3-day forecast (March 22, 23 and 24) at 15-minute intervals in as non-technical language as possible.

(2) A technical appendix to your memo that includes:

the name of the model/combination of model used

a description of the method or combination

all estimated equations, etc. associated with constructing the forecasts

the MAPE and MAE for the training period and the validation period

forecasts for the future period (March 22-24) at 15-minute intervals

a graph showing the fit of the final model for the entire period (including training, validation and future), fitted using the combined training and validation data

any additional information that would be useful in understanding or recreating your forecast

a list of any references consulting in preparing your answer

DATE TIME DEMAND 22-Mar-05 6:30 22-Mar-05 6:45 22-Mar-05 7:00 22-Mar-05 7:15 22-Mar-05 7:30 22-Mar-05 7:45 22-Mar-05 8:00 22-Mar-05 8:15 22-Mar-05 8:30 22-Mar-05 8:45 22-Mar-05 9:00 22-Mar-05 9:15 22-Mar-05 9:30 22-Mar-05 9:45 22-Mar-05 10:00 22-Mar-05 10:15 22-Mar-05 10:30 22-Mar-05 10:45 22-Mar-05 11:00 22-Mar-05 11:15 22-Mar-05 11:30 22-Mar-05 11:45 22-Mar-05 12:00 22-Mar-05 12:15 22-Mar-05 12:30 22-Mar-05 12:45 22-Mar-05 13:00 22-Mar-05 13:15 22-Mar-05 13:30 22-Mar-05 13:45 22-Mar-05 14:00 22-Mar-05 14:15 22-Mar-05 14:30 22-Mar-05 14:45 22-Mar-05 15:00 22-Mar-05 15:15 22-Mar-05 15:30 22-Mar-05 15:45 22-Mar-05 16:00 22-Mar-05 16:15 22-Mar-05 16:30 22-Mar-05 16:45 22-Mar-05 17:00 22-Mar-05 17:15 22-Mar-05 17:30 22-Mar-05 17:45 22-Mar-05 18:00 22-Mar-05 18:15 22-Mar-05 18:30 22-Mar-05 18:45 22-Mar-05 19:00 22-Mar-05 19:15 22-Mar-05 19:30 22-Mar-05 19:45 22-Mar-05 20:00 22-Mar-05 20:15 22-Mar-05 20:30 22-Mar-05 20:45 22-Mar-05 21:00 22-Mar-05 21:15 22-Mar-05 21:30 22-Mar-05 21:45 22-Mar-05 22:00 23-Mar-05 6:30 23-Mar-05 6:45 23-Mar-05 7:00 23-Mar-05 7:15 23-Mar-05 7:30 23-Mar-05 7:45 23-Mar-05 8:00 23-Mar-05 8:15 23-Mar-05 8:30 23-Mar-05 8:45 23-Mar-05 9:00 23-Mar-05 9:15 23-Mar-05 9:30 23-Mar-05 9:45 23-Mar-05 10:00 23-Mar-05 10:15 23-Mar-05 10:30 23-Mar-05 10:45 23-Mar-05 11:00 23-Mar-05 11:15 23-Mar-05 11:30 23-Mar-05 11:45 23-Mar-05 12:00 23-Mar-05 12:15 23-Mar-05 12:30 23-Mar-05 12:45 23-Mar-05 13:00 23-Mar-05 13:15 23-Mar-05 13:30 23-Mar-05 13:45 23-Mar-05 14:00 23-Mar-05 14:15 23-Mar-05 14:30 23-Mar-05 14:45 23-Mar-05 15:00 23-Mar-05 15:15 23-Mar-05 15:30 23-Mar-05 15:45 23-Mar-05 16:00 23-Mar-05 16:15 23-Mar-05 16:30 23-Mar-05 16:45 23-Mar-05 17:00 23-Mar-05 17:15 23-Mar-05 17:30 23-Mar-05 17:45 23-Mar-05 18:00 23-Mar-05 18:15 23-Mar-05 18:30 23-Mar-05 18:45 23-Mar-05 19:00 23-Mar-05 19:15 23-Mar-05 19:30 23-Mar-05 19:45 23-Mar-05 20:00 23-Mar-05 20:15 23-Mar-05 20:30 23-Mar-05 20:45 23-Mar-05 21:00 23-Mar-05 21:15 23-Mar-05 21:30 23-Mar-05 21:45 23-Mar-05 22:00 24-Mar-05 6:30 24-Mar-05 6:45 24-Mar-05 7:00 24-Mar-05 7:15 24-Mar-05 7:30 24-Mar-05 7:45 24-Mar-05 8:00 24-Mar-05 8:15 24-Mar-05 8:30 24-Mar-05 8:45 24-Mar-05 9:00 24-Mar-05 9:15 24-Mar-05 9:30 24-Mar-05 9:45 24-Mar-05 10:00 24-Mar-05 10:15 24-Mar-05 10:30 24-Mar-05 10:45 24-Mar-05 11:00 24-Mar-05 11:15 24-Mar-05 11:30 24-Mar-05 11:45 24-Mar-05 12:00 24-Mar-05 12:15 24-Mar-05 12:30 24-Mar-05 12:45 24-Mar-05 13:00 24-Mar-05 13:15 24-Mar-05 13:30 24-Mar-05 13:45 24-Mar-05 14:00 24-Mar-05 14:15 24-Mar-05 14:30 24-Mar-05 14:45 24-Mar-05 15:00 24-Mar-05 15:15 24-Mar-05 15:30 24-Mar-05 15:45 24-Mar-05 16:00 24-Mar-05 16:15 24-Mar-05 16:30 24-Mar-05 16:45 24-Mar-05 17:00 24-Mar-05 17:15 24-Mar-05 17:30 24-Mar-05 17:45 24-Mar-05 18:00 24-Mar-05 18:15 24-Mar-05 18:30 24-Mar-05 18:45 24-Mar-05 19:00 24-Mar-05 19:15 24-Mar-05 19:30 24-Mar-05 19:45 24-Mar-05 20:00 24-Mar-05 20:15 24-Mar-05 20:30 24-Mar-05 20:45 24-Mar-05 21:00 24-Mar-05 21:15 24-Mar-05 21:30 24-Mar-05 21:45 24-Mar-05 22:00

Explanation / Answer

The data that you have provided is insufficient, you need to have the demand column fully populated with numbers then only you can go ahead.

And the problem is from the concept called time series analysis.

As in your case "demand" is the dependent variable so you need to have some prior information about it then only you can go ahead with further analysis or you can say forecasting the demand for future.

I am giving you the R-Code for time series analysis.

Just run that code once you get your demand column populated with "numbers".

R-Code:

#Checking presence of trend:

install.packages("devtools")

library(devtools)

#installing trendseason package from github

install_github("abhishekumrawal/trendseason")

library(trendseason)

plot(con_exp, type= "l")

ro.test(con_exp$Consumption..C.)

#Fitting linear trend

model <- lm(con_exp$Consumption..C.~ con_exp$Year, data = con_exp)

abline(lm(con_exp$Consumption..C.~ con_exp$Year, data = con_exp))

model <- lm(con_exp$Consumption..C.~con_exp$Year, data = con_exp)

abline(a = model$coefficients[1], b = model$coefficients[2])

model$coefficients

LSE_trend <- model$fitted.values

#Detrending

detrended <- con_exp$Consumption..C. - LSE_trend

plot(detrended, type = "l")

#Forecasting

X <- c(2001,2002,2003,2004,2005)

model_forecast<- model$coefficients[1] + model$coefficients[2]*X

model_forecast

#2.

case2 <- read.csv("case2.csv")

#i. trending Gross National Income (GNI) per capita based on Purchasing

#Power Parity (PPP) Exchange Rates (ER) measured in current USD

#testing presence of trend:

plot(case2$X.GNI.per.capita..PPP..current.international...., type = "l")

ro.test(case2$X.GNI.per.capita..PPP..current.international....)

#Fitting linear trend:

model <- lm(case2$X.GNI.per.capita..PPP..current.international....

~as.ts(case2$Series.Name), data = case2)

abline(a = model$coefficients[1], b = model$coefficients[2])

LSE_trend <- model$fitted.values

LSE_trend

#Detrending

detrended <- case2$X.GNI.per.capita..PPP..current.international.... - model$fitted.values

detrended2 <- case2$X.GNI.per.capita..PPP..current.international.... - LSE_trend

plot(detrended2, type = "l")

#ii. Population Total

#testing presence of trend:

ro.test(case2$X.Population..total.)

plot(case2$X.Population..total. , type = "l")

#Fitting linear trend:

model <- lm(case2$X.Population..total.

~as.ts(case2$Series.Name), data = case2)

abline(a = model$coefficients[1], b = model$coefficients[2])

LSE_trend <- model$fitted.values

LSE_trend

#Detrending

detrended <- case2$X.Population..total. - model$fitted.values

plot(detrended, type = "l")

#iii. Gross Domestic Product (GDP) (current USD)

#testing presence of trend:

ro.test(case2$GDP..current.US..)

plot(case2$GDP..current.US.. , type = "l")

#Fitting linear trend:

model <- lm(case2$GDP..current.US..

~as.ts(case2$Series.Name), data = case2)

abline(a = model$coefficients[1], b = model$coefficients[2])

LSE_trend <- model$fitted.values

LSE_trend

#Detrending

detrended <- case2$GDP..current.US.. - model$fitted.values

plot(detrended, type = "l")

#iv. iv. Gross Domestic Product (GDP) Growth (annual %)

#testing presence of trend:

ro.test(case2$GDP.growth..annual...)

plot(case2$GDP.growth..annual... , type = "l")

#v.v. Life Expectancy at birth (years)

#testing presence of trend:

case2$X.Life.expectancy.at.birth..total..years..[9] <- NA

y <- as.vector(case2[c(1:8),6])

ro.test(y)

plot(y, type = "l")

#Fitting linear trend:

model <- lm(y ~as.ts(case2[c(1:8),1]), data = case2)

model$coefficients

abline(a = model$coefficients[1], b = model$coefficients[2])

LSE_trend <- model$fitted.values

LSE_trend

#Detrending

detrended <- c(64,64,65,65,65,66,66,66) - LSE_trend

plot(detrended, type = "l")

#3.

#reading data

case3 <- read.csv("case3.csv")

#testing for the presence of trend

ro.test(case3$Sales..in.million.dollars.)

plot(case3, type="l")

plot(MA_trend, type = "l")

#trend estimation using moving average

library(TTR)

MA_trend<-SMA(case3$Sales..in.million.dollars.,5)

?SMA

#detrending

detrended <- case3$Sales..in.million.dollars.- MA_trend

plot(detrended, type = "l")

#forecasting

require(forecast)

plot(forecast(case3$Sales..in.million.dollars., h = 3))

#4.

case4 <- read.csv("case4,5,7.csv")

y <- ts(case4$No..of.Airline.Passangers.in.Thousands,

start = c(1949,1), end = c(1960,12), frequency = 12)

#testing presence of trend

ro.test(y)

plot(y, type = "l")

#Fitting

MA_trend<-SMA(y, 12)

#detrending

detrended <- y- MA_trend

plot(detrended, type = "l")

#Seasonality

library(trendseason)

friedman.test(detrended,12)

#decomposition using OLSE

month <- seasonaldummy(y)

LM <- lm(y~time(y)+month)

plot(LM$fitted.values, type = "l")

plot(forecast(LM$fitted.values, h=5))

#5.

case5 <- read.csv("case4,5,7.csv")

y <- ts(case5$No..of.Airline.Passangers.in.Thousands,

start = c(1949,1), end = c(1960,12), frequency = 12)

#testing presence of trend

ro.test(y)

plot(y, type = "l")

#Fitting

MA_trend<-SMA(y, 12)

#detrending

detrended <- y- MA_trend

plot(detrended, type = "l")

#Seasonality

#library(trendseason)

friedman.test(detrended,12)

#decomposition

decomp <- stl(y, s.window = 12, t.window = 12)

plot(decomp)

#forecasting

#require(forecast)

plot(forecast(decomp, h = 5))

#6.

case6 <- read.csv("case8.csv")

y <- ts(case6$Demand..in.thousand.units.,

start = c(2001,1), end = c(2005,4), frequency = 4)

#testing presence of trend

ro.test(y)

plot(y, type = "l")

#Seasonality

#library(trendseason)

friedman.test(detrended,12)

#decomposition

decomp <- stl(y, s.window = 12, t.window = 12)

plot(decomp)

#forecasting

#require(forecast)

plot(forecast(decomp, h = 2))

#7.

case7 <- read.csv("case4,5,7.csv")

y <- ts(case7$No..of.Airline.Passangers.in.Thousands,

start = c(1949,1), end = c(1960,12), frequency = 12)

#testing presence of trend

ro.test(y)

plot(y, type = "l")

#Fitting

MA_trend<-SMA(y, 12)

#detrending

detrended <- y- MA_trend

plot(detrended, type = "l")

#Seasonality

#library(trendseason)

friedman.test(detrended,12)

#decomposition

decomp <- decompose(y, type = "additive")

plot(decomp)

#forecasting

#require(forecast)

plot(forecast(decomp$x, h = 5))

#8.

case8 <- read.csv("case6.csv")

y <- ts(case8[c(116:1),2],

start = c(2005,4), end = c(2014,11), frequency = 12)

#testing presence of trend

ro.test(y)

plot(y, type = "l")

#Seasonality

#library(trendseason)

friedman.test(detrended,12)

#decomposition

decomp <- decompose(y, type = "additive")

plot(decomp)

#forecasting

#require(forecast)

plot(forecast(decomp$x, h = 5))

Just change my variables to your variables once you get the data !!!