Question
library(tseries)library(forecast)library(fredr)fredr_set_key('25e01a7269f9d0fdd83a00ee95e51aee')HP=fredr( series_id = NYSTHPI, observation_start = as.Date(1980-01-01), observation_end = as.Date(2023-01-01))head(HP)plot(HP$date,HP$value, type=l)HP_INY=ts(HP$value, frequency=4, start=c(1980,01))plot(HP_INY)head(HP_INY)trend=seq(HP_INY)trendtrend=1:173plot(trend)trendLinearModel_HPNY=tslm(HP_INY~trend)summary(LinearModel_HPNY)checkresiduals(LinearModel_HPNY)AIC(LinearModel_HPNY)BIC(LinearModel_HPNY)accuracy(LinearModel_HPNY)forecast_LinearModel_HPNY=forecast(LinearModel_HPNY, h=4)plot(forecast_LinearModel_HPNY)summary(forecast_LinearModel_HPNY)LinearModel_HPNY2=tslm(HP_INY~trend+season)checkresiduals(LinearModel_HPNY2) summary(LinearModel_HPNY2)AIC(LinearModel_HPNY2)BIC(LinearModel_HPNY2)accuracy(LinearModel_HPNY2)forecast_LinearModel_HPNY2=forecast(LinearModel_HPNY2, h=4)plot(forecast_LinearModel_HPNY2)summary(forecast_LinearModel_HPNY2)accuracy(forecast_LinearModel_HPNY2) gdp=fredr( series_id = gdp, observation_start = as.Date(1980-01-01), observation_end =
library(tseries)library(forecast)library(fredr)fredr_set_key('25e01a7269f9d0fdd83a00ee95e51aee')HP=fredr( series_id = "NYSTHPI", observation_start = as.Date("1980-01-01"), observation_end = as.Date("2023-01-01"))head(HP)plot(HP$date,HP$value, type="l")HP_INY=ts(HP$value, frequency=4, start=c(1980,01))plot(HP_INY)head(HP_INY)trend=seq(HP_INY)trendtrend=1:173plot(trend)trendLinearModel_HPNY=tslm(HP_INY~trend)summary(LinearModel_HPNY)checkresiduals(LinearModel_HPNY)AIC(LinearModel_HPNY)BIC(LinearModel_HPNY)accuracy(LinearModel_HPNY)forecast_LinearModel_HPNY=forecast(LinearModel_HPNY, h=4)plot(forecast_LinearModel_HPNY)summary(forecast_LinearModel_HPNY)LinearModel_HPNY2=tslm(HP_INY~trend+season)checkresiduals(LinearModel_HPNY2) summary(LinearModel_HPNY2)AIC(LinearModel_HPNY2)BIC(LinearModel_HPNY2)accuracy(LinearModel_HPNY2)forecast_LinearModel_HPNY2=forecast(LinearModel_HPNY2, h=4)plot(forecast_LinearModel_HPNY2)summary(forecast_LinearModel_HPNY2)accuracy(forecast_LinearModel_HPNY2) gdp=fredr( series_id = "gdp", observation_start = as.Date("1980-01-01"), observation_end = as.Date("2023-01-01"))gdp=ts(gdp$value, frequency=4, start=c(1980,01))plot(gdp,HP_INY)LinearModel_HPNY3=tslm(HP_INY~trend+gdp)checkresiduals(LinearModel_HPNY3) # this is a wrongly specified model: mising an important variable or wrong functional form.head(gdp)summary(LinearModel_HPNY3)AIC(LinearModel_HPNY3)BIC(LinearModel_HPNY3)accuracy(LinearModel_HPNY3)predict(LinearModel_HPNY3, data.frame(trend=c(174,175,176), gdp=c(24000, 25000, 27000)), interval="confidence")plot(gdp,residuals(LinearModel_HPNY3))plot(fitted(LinearModel_HPNY3), residuals(LinearModel_HPNY3))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started