grouping
This commit is contained in:
25
Prediction/2. timeseries.r
Normal file
25
Prediction/2. timeseries.r
Normal file
@@ -0,0 +1,25 @@
|
||||
install.packages("WDI")
|
||||
library(WDI)
|
||||
|
||||
gdp = WDI(country = "KR", indicator = c("NY.GDP.PCAP.CD", "NY.GDP.MKTP.CD"), start = 1960, end = 2017)
|
||||
|
||||
head(gdp)
|
||||
names(gdp) = c("country", "iso2c", "iso3c", "year", "perCapGDP", "GDP")
|
||||
head(gdp)
|
||||
|
||||
kr = gdp$perCapGDP[gdp$country=="Korea, Rep."]
|
||||
kr
|
||||
|
||||
kr = ts(kr, start=min(gdp$year), end=max(gdp$year))
|
||||
kr
|
||||
|
||||
install.packages("forecast")
|
||||
library(forecast)
|
||||
|
||||
krts = auto.arima(x=kr)
|
||||
krts
|
||||
|
||||
forecastResult = forecast(object=krts, h=5)
|
||||
forecastResult
|
||||
|
||||
plot(forecastResult)
|
Reference in New Issue
Block a user