# Titel: Patriotism and Homebias in East Contries
```
library(stargazer)
install.packages("stargazer")
install.packages("haven")
library(foreign)
library(haven)
library(ggplot2)
database = read_sav("C:/Users/Beatrice Fontana/OneDrive/Desktop/UNI ZÜRICH/2° ANNO/Cultural Finance 2020/Research CLF 2020/main-data-2.4.sav")
attach(database)
View(dataset)
```
Now I create a new variable (Domestic-S&P500)/Summation in this case we will see from a scale from 0 to 1 the propensity to invest in the domestic stock market.
0 = not willing to invest in stocks; and 1 = indifferent between the two; [0-1] higher preference for Domestic stocks
```
homebias_ind = round((XFD8 - XFD9)/(XFD8 + XFD9), digits = 2)
homebias_db_extra = cbind(country_code, XFD8, XFD9, homebias_ind)
homebias_database = cbind(country_code, homebias_ind)
View(homebias_db_extra)
detach(database)
```
Creation of the dummy variables per country
```
taiwan = database[database[, "country_code"] == 3,]
estonia = database[database[, "country_code"] == 1,]
hongkong = database[database[, "country_code"] == 9,]
germany = database[database[, "country_code"] == 8,]
vietnam = database[database[, "country_code"] == 5,]
china = database[database[, "country_code"] == 4,]
japan = database[database[, "country_code"] == 10,]
```
Creation of variables of homebias divided per country code
```
tw_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 3,1:2])
est_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 1,1:2])
hg_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 9,1:2])
ge_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 8,1:2])
vit_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 5,1:2])
ci_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 4,1:2])
jp_hb = data.frame(homebias_database[homebias_database[, "country_code"] == 10,1:2])
```
Many values are defined as Nan or Na, meaning that the respondent decided "not to invest in neither stock market".Shall we keeep them or ignore them? If we keep them, we should substitue the Nan/Na with a fictitious value.
```
ggplot(est_hb, aes(x = est_hb$homebias_ind))+ geom_histogram(fill = "blue", color="white")
```

First Regression analysis (without "lit").
```
m1 = lm(homebias_ind ~ female + age + XP1 + uni_degree +wstock+ patient + Taiwan_D +Germany_D + Estonia_D +Vietnam_D +China_D +Japan_D, data = database)
stargazer(m1, type = "text")
```

```
m2 = lm(homebias_ind ~ female + age + XP1 + uni_degree +wstock+ patient + risk +USD_ppp_income + Taiwan_D +Germany_D + Estonia_D +Vietnam_D +China_D +Japan_D, data = database)
```

# New Codes and Regressions 13/09/2020:
Setting up libraryies:
```{r message=FALSE, warning=FALSE}
library(stargazer)
library(foreign)
library(haven)
library(ggplot2)
library(AER)
library(rmarkdown)
```
Open the database:
```{r message=FALSE, warning=FALSE}
database = read_sav("C:/Users/Beatrice Fontana/OneDrive/Desktop/UNI ZURICH/2 ANNO/Cultural Finance 2020/Research CLF 2020/data-patrick1.sav")
attach(database)
```
Creation of transformed variables in the database, namely homebias at individual level, inversion of the patriotism variable, and financial literacy.
```{r}
patriotism = database$XP1
patriotism_inv <- 5-patriotism
homebias_ind = round((XFD8 - XFD9)/(XFD8 + XFD9), digits = 2)
flr = cbind(database$XF1, database$XF2, database$XF3)
finlit_score = c()
for(i in 1:nrow(flr)){
finlit_score= c(finlit_score, (flr[i,1]==1)+(flr[i,2]==3)+(flr[i,3]==2))
}
```
**Regression Analysis for each easian Country**
We try to regress patriottism and other relevant varibles for the model on homebias at individual level but for every single country.
The HongKong database is too small to provide significant results, only 23 observations.
The new databases are:
```{r}
taiwan = database[database[, "country_code"] == 3,]
estonia = database[database[, "country_code"] == 1,]
germany = database[database[, "country_code"] == 8,]
vietnam = database[database[, "country_code"] == 5,]
china = database[database[, "country_code"] == 4,]
japan = database[database[, "country_code"] == 10,]
detach(database)
```
The new dependent variable per country is as follows (the NA values have been replaced with 0)
```{r}
homebias_database = cbind(database$country_code, homebias_ind)
colnames(homebias_database)[1] = "country_code"
homebias_database[is.na(homebias_database)] = 0
homebias_database[is.nan(homebias_database)] = 0
tw_hb = as.matrix(data.frame(homebias_database[homebias_database[, "country_code"] == 3,2]))
est_hb = as.matrix(data.frame(homebias_database[homebias_database[, "country_code"] == 1,2]))
ge_hb = as.matrix(data.frame(homebias_database[homebias_database[, "country_code"] == 8,2]))
vit_hb = as.matrix(data.frame(homebias_database[homebias_database[, "country_code"] == 5,2]))
ci_hb = as.matrix(data.frame(homebias_database[homebias_database[, "country_code"] == 4,2]))
jp_hb = as.matrix(data.frame(homebias_database[homebias_database[, "country_code"] == 10,2]))
```
The new variables finlit per country:
```{r}
countries_finlit = cbind(finlit_score, database$country_code)
colnames(countries_finlit)[2] = "country_code"
countries_finlit[is.na(countries_finlit)] = 0
countries_finlit[is.nan(countries_finlit)] = 0
ci_fl = as.matrix(data.frame(countries_finlit[countries_finlit[, "country_code"] == 4,1]))
vit_fl = as.matrix(data.frame(countries_finlit[countries_finlit[, "country_code"] == 5,1]))
tw_fl =as.matrix(data.frame(countries_finlit[countries_finlit[, "country_code"] == 3,1]))
jp_fl = as.matrix(data.frame(countries_finlit[countries_finlit[, "country_code"] == 10,1]))
ge_fl = as.matrix(data.frame(countries_finlit[countries_finlit[, "country_code"] == 8,1]))
est_fl =as.matrix(data.frame(countries_finlit[countries_finlit[, "country_code"] == 1,1]))
```
The new vriable patriotism_inv per country:
```{r}
ptm = cbind(patriotism_inv,database$country_code)
colnames(ptm)[2] = "country_code"
ptm[is.na(ptm)] = 0
ptm[is.nan(ptm)] = 0
ci_ptm = as.matrix(data.frame(ptm[ptm[, "country_code"] == 4,1]))
vit_ptm = as.matrix(data.frame(ptm[ptm[, "country_code"] == 5,1]))
tw_ptm = as.matrix(data.frame(ptm[ptm[, "country_code"] == 3,1]))
jp_ptm = as.matrix(data.frame(ptm[ptm[, "country_code"] == 10,1]))
ge_ptm = as.matrix(data.frame(ptm[ptm[, "country_code"] == 8,1]))
est_ptm = as.matrix(data.frame(ptm[ptm[, "country_code"] == 1,1]))
```
Other variables cleaning Marxism and income :
```{r}
marx = cbind(database$Marxism, database$country_code)
colnames(marx)[2] = "country_code"
marx[is.na(marx)] = 0
marx[is.nan(marx)] = 0
ci_marx = as.matrix(data.frame(marx[marx[, "country_code"] == 4,1]))
vit_marx = as.matrix(data.frame(marx[marx[, "country_code"] == 5,1]))
tw_marx = as.matrix(data.frame(marx[marx[, "country_code"] == 3,1]))
jp_marx = as.matrix(data.frame(marx[marx[, "country_code"] == 10,1]))
ge_marx = as.matrix(data.frame(marx[marx[, "country_code"] == 8,1]))
est_marx = as.matrix(data.frame(marx[marx[, "country_code"] == 1,1]))
income = cbind(database$income_eu_capita, database$country_code)
colnames(income)[2] = "country_code"
income[is.na(income)] = 0
income[is.nan(income)] = 0
ci_income = as.matrix(data.frame(income[income[, "country_code"] == 4,1]))
vit_income = as.matrix(data.frame(income[income[, "country_code"] == 5,1]))
tw_income = as.matrix(data.frame(income[income[, "country_code"] == 3,1]))
jp_income = as.matrix(data.frame(income[income[, "country_code"] == 10,1]))
ge_income = as.matrix(data.frame(income[income[, "country_code"] == 8,1]))
est_income = as.matrix(data.frame(income[income[, "country_code"] == 1,1]))
```
**Rapresentation of homebias**
Looking at the graph we can deduct that the majoriity of respondents are indifferent between investing either in the domestic stock-market or in the internationa S&P 500.
However, this value is influenced by the great number of non-respondedns that increases the density distribution in the plot.
```{r}
china_hb_graph = data.frame(homebias_database[homebias_database[, "country_code"] == 4,1:2])
g = ggplot(china_hb_graph, aes(x=china_hb_graph$homebias_ind)) + geom_histogram(aes(y=..density..), fill = "white", color="black")
h = g + ggtitle("Home Bias Distribution in China") + xlab("Home Bias") + ylab("Respondents")
h + geom_density(alpha=.5, fill="#FF6666")
```

#Regression on China
The regression on china has provided significant results, patriotism positively affects homebias by 0.036 points and it is significant at 5% level. The positive relation is what expected, namely the more patriotic the respondent is, more is expected to have a greater home bias with respect to stock market. However, financial literacyhas a negative effect on the home bias suggesting that respondent who know more about finance tend to invest more in the international stock market.
```{r message=FALSE, warning=FALSE}
attach(china)
m1c = lm(ci_hb ~ ci_ptm + female + age + ci_fl + ci_marx , data = china)
stargazer(m1c, type = "text", title = "Patriotism and Home Bias in China", dep.var.labels = "Home Bias", covariate.labels=c("Patriotism", "Gender", "Age", "Financial Literacy", "Marxism"), omit.stat=c("LL","ser","f"), no.space=TRUE)
detach(china)
```

#Regression Vietnam
Contrary to expectations in this model the patriotism variable has a negative impact on home bias for Vietnamese respondends. On the other hand, the financial literacy variable is strongly significant at 1% level suggesting further a strong positive impact on homebias. This results suggest that vietnamese respondendts believe in the domestic market.
```{r}
attach(vietnam)
m1v = lm(vit_hb ~ vit_ptm + female +age +vit_fl +vit_marx , data = vietnam)
stargazer(m1v, type = "text")
stargazer(m1c, m1v, type = "text", title = "Patriotism and Home Bias in East Asia", dep.var.labels = c("OLS China", "OLS Vietnam"), omit.stat=c("LL","ser","f"),covariate.labels=c("Chinese Patriotism", "Vietnamese Patriotism", "Gender", "Age", "Financial Literacy CN", "Marxism in China", "Financial Literacy VT", "Marxism in Vietnam"), no.space=TRUE, align = TRUE)
detach(vietnam)
```

```{r}
vietnam_hb_graph = data.frame(homebias_database[homebias_database[, "country_code"] == 5,1:2])
v = ggplot(vietnam_hb_graph, aes(x=vietnam_hb_graph$homebias_ind)) + geom_histogram(aes(y=..density..), fill = "white", color="black")
j = v + ggtitle("Home Bias Distribution in Vietnam") + xlab("Home Bias") + ylab("Respondents")
j + geom_density(alpha=.5, fill="#FF6666")
```

#Regression Taiwan
Patriotism and homebias in Taiwan have a positive relation, but it is not signficant.
```{r message=FALSE, warning=FALSE}
attach(taiwan)
m1t = lm(tw_hb ~tw_ptm + female +age +tw_fl +tw_marx , data = taiwan)
stargazer(m1t, type = "text")
stargazer(m1c, m1v,m1t, type = "text", title = "Patriotism and Home Bias in East Asia", dep.var.labels = c("OLS China", "OLS Vietnam", "OLS Taiwan"), omit.stat=c("LL","ser","f"),covariate.labels=c("Chinese Patriotism", "Vietnamese Patriotism","Taiwanese Patriotism", "Gender", "Age", "Financial Literacy CN", "Marxism in China", "Financial Literacy VT", "Marxism in Vietnam","Financial Literacy TW", "Marxism in TW"), no.space=TRUE, align = TRUE)
detach(taiwan)
```
#Regression Japan
```{r message=FALSE, warning=FALSE}
attach(japan)
m1j = lm(jp_hb ~jp_ptm + female +age +jp_fl , data = japan)
stargazer(m1j, type = "text")
detach(japan)
```
#Regression Models together East Asia
```{r warning=FALSE}
stargazer(m1c, m1v,m1t,m1j, type = "text", title = "Patriotism and Home Bias in East Asia", dep.var.labels = c("OLS China", "OLS Vietnam", "OLS Taiwan", "OLS Japan"), omit.stat=c("LL","ser","f"),covariate.labels=c("Chinese Patriotism", "Vietnamese Patriotism","Taiwanese Patriotism","Japanese Patriotism", "Gender", "Age", "Financial Literacy CN", "Marxism in China", "Financial Literacy VT", "Marxism in Vietnam","Financial Literacy TW", "Marxism in TW", "Financial Literacy JP"), no.space=TRUE, align = TRUE)
```

#Regression model in East Asia (Japan+Taiwan+China+Vietnam)
```{r message=FALSE, warning=FALSE}
attach(database)
m1Asia = lm(homebias_ind ~ patriotism_inv + female + age + finlit_score + patient+ uni_degree+ Taiwan_D +Japan_D+Vietnam_D+ China_D, data = database)
m3Asia = lm(homebias_ind ~ patriotism_inv + female + age + finlit_score + Marxism + wstock +Taiwan_D +Japan_D+Vietnam_D+ China_D, data = database)
stargazer(m1Asia,m3Asia, type = "text")
```
#Regression model Europe and Asia
The regression models per area reveals a particular significant positive relationship in the Europe area (Germany and Estonia) rather than in Asia between patriotism and homebias. This result is unexpected since in East Asia, socialism (Marxism) still influences the life of its citizens.However, the regression model run on chinese respondents has given strong significance levels on the relation betweeen patriotism and home bias, suggesting that Chinese respondents have stronger patriotic feelings and trust towards their own domestic stock market with respect to the other neighboor countries.The high significance level of patriotism for the Europe area suggests that overall Germany and Estonia tend to invest much more in the domestic stock market.
In both macro Areas, we observe that female respondents are more home biased than other genders (males and transgender), and this variable is significant at 5% level representing a notable effect on home bias. This seems to bring a common cultural factor among the macro areas.
German respondents believe much more in their stock market, with a significance level of 1%. This resuilt is counterbalanced with the negative relationship between Estonian respondents and home bias, germans respondents are more home biased with respect to estonians.
```{r}
m1EU = lm(homebias_ind ~patriotism_inv + female + age + finlit_score + patient+ uni_degree+wstock+ Germany_D +Estonia_D, data = database)
stargazer(m1Asia,m3Asia,m1EU, type = "text", title = "Comprehensive Regression models per Area", dep.var.labels = c("M1 Asia M2 Asia M1 Europe"),covariate.labels=c("Patriotism", "Gender", "Age", "Financial Literacy Score", "Patience", "University Degree", "Marxism", "Willingness to Invest in Stocks", "Taiwan","Japan","Vietnam","China","Germany","Estonia"), omit.stat=c("LL","ser","f"),no.space = TRUE, align = TRUE )
```

#Graphs Europe:Germany and Estonia
```{r}
germany_hb_graph = data.frame(homebias_database[homebias_database[, "country_code"] == 8,1:2])
d = ggplot(germany_hb_graph, aes(x=germany_hb_graph$homebias_ind)) + geom_histogram(aes(y=..density..), fill = "white", color="black")
e = d + ggtitle("Home Bias Distribution in Germany") + xlab("Home Bias") + ylab("Respondents")
e + geom_density(alpha=.5, fill="#FF6666")
```
