Install these packages if not installed
install.packages("readxl") #run if not installed
install.packages("neverhpfilter") #run if not installed
install.packages("writexl") #run if not installed
Run these packageslibrary(readxl)
library(neverhpfilter)
library(xts)
library(writexl)
#setting working directory
setwd("I:/My Drive/...")
#extracting the dataset
credit_gdp_data <- read_excel("file_name.xlsx",sheet = "sheet_name")
attach(credit_gdp_data)
credit_gdp <- credit_gdp_data$Credit/credit_gdp_data$NGDP*100
#hamilton filter
dates <- seq(as.Date("1975-07-15"),length=48,by="year")
credit_gdp1 <- as.xts(credit_gdp, order.by = dates)
names(credit_gdp1) <- "c_y"
c_y_filter <- yth_filter(credit_gdp1[,"c_y"],h=1,p=4)
c_y <- data.frame(dates,c_y_filter)
write_xlsx(c_y,"Hamilton.xlsx")
shell.exec("Hamilton.xlsx")
Post a Comment