Group Members:
We analyzed effect of TCMB interest rates on economy and our results :
We get TCMB interest rate as a main data and USD/TRY, technology indicators exports, data it was a small data but very open the interpretation
Our main dataset was small and clean but when we need comparisons other data we needed the make it compatible with main data. Firstly, we need necessary libraries:
Explore the interest_rate data frame with str() function.
## Classes 'tbl_df', 'tbl' and 'data.frame': 20 obs. of 2 variables:
## $ year: POSIXct, format: "2010-05-20" "2010-12-17" ...
## $ rate: num 7 6.5 6.25 5.75 5.5 5 4.5 10 9.5 8.75 ...
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 120 obs. of 6 variables:
## $ Date : chr "Dec 19" "Nov 19" "Oct 19" "Sep 19" ...
## $ Price : num 5.78 5.75 5.71 5.65 5.83 ...
## $ Open : num 5.75 5.71 5.65 5.83 5.58 ...
## $ High : num 5.79 5.79 5.94 5.84 5.86 ...
## $ Low : num 5.73 5.67 5.64 5.63 5.44 ...
## $ Change %: chr "0.54%" "0.60%" "1.13%" "-3.12%" ...
## - attr(*, "spec")=
## .. cols(
## .. Date = col_character(),
## .. Price = col_double(),
## .. Open = col_double(),
## .. High = col_double(),
## .. Low = col_double(),
## .. `Change %` = col_character()
## .. )
## Classes 'tbl_df', 'tbl' and 'data.frame': 151 obs. of 5 variables:
## $ Date : chr "2007-05" "2007-06" "2007-07" "2007-08" ...
## $ Turkey : num 140 140 139 139 140 ...
## $ Region_1: num 144 144 142 142 144 ...
## $ Region_2: num 141 141 141 140 141 ...
## $ Region_3: num 142 142 141 141 142 ...
## Classes 'tbl_df', 'tbl' and 'data.frame': 151 obs. of 5 variables:
## $ Date : chr "2007-05" "2007-06" "2007-07" "2007-08" ...
## $ Turkey : num 139 139 139 140 142 ...
## $ ppi_region_1: num 152 152 153 158 156 ...
## $ ppi_region_2: num 154 155 155 162 162 ...
## $ ppi_region_3: num 197 196 199 211 197 ...
Since the “year” column appears a categorical variable on consumer price index, producer price index and interest rate datasets, it should be converted it to date with as.Date functon to more convenient analysis. Also, some columns are renamed to easy understanding.
interest_rate <- interest_rate %>%
mutate(date = year(year))
usd_tl_dp <- usd_tl %>% select("Date","Price")
usd_tl_dp$Date <- parse_date_time(usd_tl_dp$Date,orders = c("my"))
usd_tl_dp$Date <- as.Date(as.POSIXct(usd_tl_dp$Date))
consumer_price_index$Date <- as.Date(paste(consumer_price_index$Date,"-01",sep=""))
producer_price_index$Date <- as.Date(paste(producer_price_index$Date,"-01",sep=""))
colnames(tech) <- c("country_name","country","date","indicator_name","indicator_code","value")
A new dataset was prepared for changes in the CPI and PPI overall Turkey. At the same time, the dataset was manipulated by normalizing the datatable with gather() function.
general_price_index <- data.frame(consumer_price_index$Date, consumer_price_index$Turkey, producer_price_index$Turkey)
names(general_price_index) <- c("Date", "CPI" , "PPI")
general_price_index <- general_price_index %>%
gather(key = "index_type", "index_value", "CPI", "PPI")
general_price_index$index_type <- as.factor(general_price_index$index_type)
str(general_price_index)
## 'data.frame': 302 obs. of 3 variables:
## $ Date : Date, format: "2007-05-01" "2007-06-01" ...
## $ index_type : Factor w/ 2 levels "CPI","PPI": 1 1 1 1 1 1 1 1 1 1 ...
## $ index_value: num 140 140 139 139 140 ...
Let’s look at the graph of the interest rates change over the years.
c <- ggplot(interest_rate, aes(x=year, y=rate, group=1)) +
geom_line(color = "blue") +
geom_point(color = "blue") +
labs(title = "TCMB Interest Rates",
x = "Year of observation",
y = "Interest Rates") +
theme_light() +
theme(axis.text.x = element_text(colour = "grey0", size = 10, angle = 30, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(colour = "grey20", size = 10),
text = element_text(size = 12))
c <- ggplotly(c)
c
interest_rate$year <- as.POSIXct(interest_rate$year)
usd_tl_dp$Date <- as.POSIXct(usd_tl_dp$Date)
graph_usdTL <- ggplot(interest_rate,aes(interest_rate$year,interest_rate$rate)) +
geom_line(color="blue") +
scale_y_continuous("Interest Rate(%)",
sec.axis = sec_axis(~ . * 0.33, name = "USD/TRY")) +
theme_light() +
ggtitle("TCMB Interest Rates")+
xlab("Years") +
theme(plot.title = element_text(color = "cadetblue4", size=20))
graph_usdTL <- graph_usdTL +
geom_line(data=usd_tl_dp, aes(Date,Price*3), color="red") +
ggtitle(("TCMB Interest Rates vs USD/TRY"))
graph_usdTL
There are many discussions on the relationship between interest and inflation. Inflation refers to the rate at which prices for goods and services rise. To examine this relationship, let us examine the producer price index and consumer price index data. Although the graph values show an increasing change, it is also necessary to calculate the monthly and annual changes in interest rates in order to more convenient analysis.
general_price_index <- general_price_index %>% group_by(index_type) %>%
mutate(monthly_change = (index_value / lag(index_value) -1)*100, yearly_change = (index_value / lag(index_value, 12) -1)*100) %>%
gather(key = "change_type", "change_value", "monthly_change", "yearly_change")
We have changed the column names for easier visualizing.
general_price_index$change_type[general_price_index$change_type == "monthly_change"] <- "Monthly"
general_price_index$change_type[general_price_index$change_type == "yearly_change"] <- "Yearly"
The relationship between CPI and PPI is shown below.
graph_index <- general_price_index %>% ggplot() + # basic graphical object
geom_line(aes(Date, index_value, color = index_type)) +
labs(title = "Price Indexes",
x = "Year of observation",
y = "Indexes")+
theme_light() +
theme(axis.text.x = element_text(colour = "grey10", size = 10, angle = 45, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(colour = "grey10", size = 10),
text = element_text(size = 12),
legend.title = element_text("Index Type"))
graph_index <- ggplotly(graph_index)
graph_index
graph_index_change <- general_price_index %>% ggplot() +
geom_line(aes(x=Date, y=change_value, color = change_type), linetype = 0) +
facet_wrap(general_price_index$index_type, dir = "v") +
coord_cartesian()+
labs(title = "Change in price indexes",
x = "Year of observation",
y = "Change")+
theme_light() +
theme(legend.title = element_text("Change Type"),
axis.text.x = element_text(colour = "grey20", size = 10, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(colour = "grey20", size = 10),
text = element_text(size = 12))
graph_index_change <- ggplotly(graph_index_change)
graph_index_change
average <- general_price_index %>%
mutate(Year = year(Date)) %>%
group_by(Year, index_type) %>%
summarize(average = mean(index_value))
graph_average <- ggplot(data = average) +
geom_bar(mapping = aes(x=Year, y=average, fill = index_type), stat = "identity") +
facet_wrap(average$index_type) +
coord_cartesian()+
labs(title = "Change in price indexes",
x = "Year of observation",
y = "Change") +
theme_light() +
theme(legend.title = element_text("Change Type"),
axis.text.x = element_text(colour = "grey20", size = 10, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(colour = "grey20", size = 10),
text = element_text(size = 12))
graph_average <- ggplotly(graph_average)
graph_average
##
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
##
## col_factor
theme_set(theme_classic())
# Plot
ggplot(tech, aes(x=indicator_name, y=value)) +
geom_point(col='#e67e22', size=3) + # Draw points
geom_segment(aes(x=indicator_name,
xend=indicator_name,
y=min(value),
yend=max(value)),
linetype="dashed",
size=0.1) + # Draw dashed lines
labs(title="Dot Plot",
subtitle="İndicators vs Values") +
coord_flip()
In this plot show us, high techonology exports are above the other so we can take this indicator to do analysis with interest rate. However, we are gonna use two more indicators which are Charges for the use of intellectual property, payments (BoP, current US\() and Charges for the use of intellectual property, receipts (BoP, current US\)) to be sure for our analysis.
ht <- tech %>%
group_by(indicator_name, value, date) %>%
filter(indicator_name == "High-technology exports (current US$)") %>%
summarise(mean_value = mean(value/1000000)) %>%
arrange(desc(value)) %>% group_by(date)
ch <- tech %>% group_by(indicator_name,value,date) %>%
filter(indicator_name == "Charges for the use of intellectual property, payments (BoP, current US$)")%>%
arrange(desc(value))%>%group_by(date)
unht <- tech %>% group_by(date) %>%
summarise(mean_value = mean(value/1000000)) %>%
arrange(desc(mean_value))%>%
filter(date > 2010 & date < 2018)
Analysis for hig tech to make usable data for compare interest rate. We are going to calculate mean value for all indicators to compare other plots. The other one which is using just high tech to find any increasing, then take just Charges for the use of intellectual property, payments (BoP, current US$). The last one is going to filter significant dates used the same with interest rate.
Firstly we looked the indictaors which can be usable the select the benefical one.
all <- inner_join(ht,unht,by = c("date"))
ggplot(all, aes(x = date)) +
geom_line(aes(y = mean_value.x, colour = "High-technology exports")) +
geom_line(aes(y = mean_value.y, colour = "other mean")) +
xlab("Years") + ylab("Values") +
theme_light()
The plot shows us there is a relation between indicators and interest rate. When the interest rate is going to down, some indicators which are making big exports are going to up.
indicators <- tech %>% group_by(date, indicator_name) %>%
filter(indicator_name %in% c("High-technology exports (current US$)", "Charges for the use of intellectual property, payments (BoP, current US$)","Charges for the use of intellectual property, receipts (BoP, current US$)")) %>%
group_by(indicator_name)
all2 <- inner_join(interest_rate, indicators, by = c("date"))
g <- ggplot(indicators, aes(x = date, y = value/100000000, colour=indicator_name)) +
geom_line() +
geom_point()+
labs(x="",
y = "Tech Export Value") +
theme(legend.position = "bottom",
legend.title = element_blank(),
axis.text.x = element_text(size = 10))
g <- g + geom_smooth(data=all2, aes(date,rate)) +
ggtitle(("Tech Export Rates vs Interest rates")) +
theme(axis.text.x = element_text(colour = "grey20", size = 10, angle = 45, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(colour = "grey20", size = 10),
text = element_text(size = 7),
legend.position = "top", legend.box = "vertical" )
g
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
theme_set(theme_bw())
g <- ggplot(all2, aes(date, value/100000000)) +
labs(title="TECH Export VS INTEREST RATE")
g + geom_jitter(aes(col=indicator_name, size=rate)) +
geom_smooth(aes(col=indicator_name), method="lm", se=F)+theme_light() +
theme(axis.text.x = element_text(colour = "grey20", size = 10, angle = 45, hjust = 0.5, vjust = 0.5),
axis.text.y = element_text(colour = "grey20", size = 10),
text = element_text(size = 8),
legend.position = "right", legend.box = "vertical" )
graph1 <- ggplot(unht,aes(date,mean_value/35)) +
ggtitle("Tech Export Rates")+xlab("Years")+ylab("Rates(%)") +
geom_smooth(se = FALSE, stat='summary',
fun.y=quantile,fun.args=list(probs=0.9),color='blue') +
theme(plot.title = element_text(color = "grey20",size=20)) +
scale_y_continuous("Interest Rate(%)",
sec.axis = sec_axis(~ . * 0.5,name = "Interest rates"))
graph1 <- graph1 +
geom_smooth(se = FALSE, data=all2,aes(date,rate),color='red') +
ggtitle(("Tech Export Rates vs Interest rates")) +
theme(plot.title = element_text(color = "grey20",size=20))
graph1
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
And again we are going to see rates and indicators name. The last tech exports analysis is going to compare between tech export and interest rates. However we are not going to say that there is not enough evidence to make a decision.
The last day of each month were added as a date, the foreign trade figure of each month were added as a value and the valid interest rate for each date were added to rows for each date. Interest rates which did not coincide with any date were excluded from the dataset. 2010-05-31 is the first date and 2019-10-31 is the last date. Foreign trade data source is TÜİK.
ggplot(foreign_trade, aes(x = Date, y = Balance)) +
geom_bar(stat ='identity', color = 'brown', fill ='brown') +
geom_line(stat ='identity', color = 'brown') +
labs(title = 'Foreign Trade Balance (USD in billions)',
caption="Source: TÜİK",
y = "Balance",
x = "Year") +
scale_y_reverse() +
theme_classic()
The graph shows the relationship between interest rate and current account deficit. It shows that they are inversely proportional to each other. Except for some periods, while one moves upwards, the other moves downwards.
ggplot(foreign_trade, aes(x = Date)) +
geom_line(aes(y = Deficit, color = 'CAD (USD in billions)')) +
geom_line(aes(y = Rate, color = 'Interest Rate (%)')) +
labs(title = 'Current Account Deficit',
caption="Source: TÜİK, TCMB",
y = "",
x = "Year") +
theme_classic()
ggplot(foreign_trade, aes(x = Date)) +
geom_line(aes(y = Deficit, fill = 'CAD (USD in billions)'), color = 'red') +
geom_smooth(aes(y = Deficit),
color = 'red', alpha = TRUE) +
geom_line(aes(y = Rate), color = 'blue') +
geom_smooth(aes(y = Rate, color = 'Rate', fill = 'Interest Rate (%)'),
color = 'blue', alpha = TRUE) +
labs(title = 'Current Account Deficit',
caption="Source: TÜİK, TCMB",
y = "",
x = "Year") +
theme_classic()