Please enable JavaScript.
Coggle requires JavaScript to display documents.
FORECASTING 2 - INTERESTING PART - Coggle Diagram
FORECASTING 2 - INTERESTING PART
REGRESSION MODEL
model with times series
simple regression
model(lm = TSLM(consumptiom ~ income) - or y~x
multiple linear regression
errors assumption
0 mean
not autocorrelated
unrelated to predictor variables
useful to normally distributed n constant variance
us_change %>% ggpairs(columns = 2:6), creates a matrix. page 12 week 9
Least Squares Estimations
minimum sum square errors
Finding coefficients = “fitting” the model to the data,
only prediction of the data in the model
Goodness-of-fit
Rsq = (y - yi)/(x-xi)
good --> closer to 1
Standard Error of Regression
Evaluate Regression Model
evalueate the residual
Residual Plots Against Predictors should random
Residual Plots Against Predictors
ìnluential observation = value that greatly afect model (úually far right ò x)
Some useful Predictors
trend
dummy variables (like 1 for yes 0 for no)
Seasonal Dummy variables
slide 40
trap: always use 1 less variable than category, because 1 needs to be the intercept
The TSLM() function handle if specify season(). fit_beer <- recent_production %>% model(TSLM(Beer ~ trend() + season()))
Intervention Variables: 0 before intervention, 1 after
Trading days
each day (monday, tuesday) as predictor, since vary
Distributed Lags: advertising has lag of effect
Holidays: 1 for holidays, 0 for other
Fouriers
useful long seasonal period
every periodic function can summed by sin and cos
TSLM(y ~ trend() + fourier(K)) - K = how many pairs
SELECTING PREDICTORS
when too many, which to use? 5 ways, selected by glance() function
Adjusted R-squared
cross validation
smaller better
might be time consuming
akaike, info criterion AIC (penalized likelyhood) - smaller better
bayesian information criterion BIC, smaller better
example : us consumtion
Forward/backward stepwise regression
start with model with intercept then add variables/start will all then subtract
this is like when there are 4 predictors, which is more important
FORECASTING WITH REGRESSION
ex-ante vs ex-post forecast: use info available in advance/later information
so for example, know that consumption has relations with income and production, but to predict consumption next 6 months we need data for those in next 6 months. Need forecast predictors = ex-ante forecast
NON LINEAR REGRESSION
can transform log(), or create piecewise linear
= introduce points where change in slope
the periods between points have different slopes
its like creating different slopes within a model
piecewise = TSLM(Minutes ~ trend(knots = c(1940, 1980)))
Correlation
ADVANCED FORECASTING METHODS
Complex seasonality
seasonality may be complex,
complex seasonal pattern
weekly + seasonal pattern
prophet model
developed by fb
works best with strong seasonality
is a non-linear regreassion model
𝑦𝑡 = 𝑔 𝑡 + 𝑠 𝑡 + ℎ 𝑡 + 𝜀𝑡
g = piecewise-linear (growth) - choosen knots automatically
s = seasonal patterns
h = holiday effectr
e = white noise
prophet = prophet(Cement ~ season(period = 4, order = 2, type = "multiplicative")) - period = 4 cuz quarterly data
Artificial Neural network
model brain
nodes in layer
stronger connection, stronger weights
Neural Network Autoregression NNAR
NNAR(p,k)
p lagged inputs and k nodes in hidden layer
k =
NNETAR() in R
JUDGEMENTAL FORECAST
bias + limiation
anchoring, conservatism
recency
relying only on complete available info
Must be structured. Ways:
Delphi method
question exprts
rely on fact that group more reliable in person
must remain anonymous
question -> analysis -> reformulation of questions -> back
Historical Analogies
example: to know house price, look at nearby price
Scenarios forecasting: prepare different scenarios
Sales force option: aggregate salespeople opinions/ or executive options
consumer survey
PRACTICAL FORECASTING PROBLEM
ensure stay in limit
expenditure on eating out - combination of mutate to find average of the two
missing values
functions can handle
can take the last or estimate
outliners, best dealt by replace