install used packages

install.packages(“WDI”)

install.packages(“plm”)

install.packages(“dplyr”)

install.packages(“ggplot2”)

install.packages(“stargazer”)

library used packages

library(WDI)

library(plm)

library(dplyr)

library(ggplot2)

library(stargazer)

Downloading data from the WB

install.packages(“WDI”)

library(WDI)

Assignment <- WDI(country <- c(“BEL”,“DEU”,“BGR”,“CZE”,“DNK”,“EST”,“IRL”,“GRC”,“ESP”,“FRA”, “HRV”,“ITA”,“CYP”,“LVA”,“LTU”,“LUX”,“HUN”,“MLT”,“NLD”,“AUT”, “POL”,“PRT”,“ROU”,“SVN”,“SVK”,“FIN”,“SWE”,“GBR”), indicator <- c(“NY.GDP.PCAP.CD”,“SE.SEC.ENRR”,“NE.GDI.TOTL.CD”,“SP.POP.GROW”), start= 2000, end= 2018, extra=FALSE)

Naming the columns

colnames(Assignment) <- c(“country”,“ABB1”,“ABB2”, “year”,“GDP”,“Enrollment”,“capital”,“population”)

Identifying the data as panel

install.packages(“plm”)

library(“plm”)

Assignment\(Enrollment[is.na(Assignment\)Enrollment)] <-
mean(Assignment$Enrollment, na.rm = TRUE)

Assignment.p <- pdata.frame(Assignment, index <- c(“country”, “year”))

inherits(Assignment.p, “pdata.frame”)

pdim(Assignment.p)

is.pbalanced(Assignment.p)

correlation matrix

attach(Assignment.p)

cor.mat<-data.frame(GDP,Enrollment,capital,population)

cor(cor.mat)

Cross sectional means

install.packages(“dplyr”)

library(dplyr)

average_by_country<- Assignment.p %>% group_by(country) %>%

summarise_all(mean, na.rm=FALSE)

average_by_country

average_by_year<- Assignment.p %>% group_by(year) %>%

summarise_all(mean, na.rm=FALSE)

average_by_year

Bar chart

install.packages(“ggplot2”)

library(ggplot2)

ggplot(average_by_country,aes(x=country,y=Enrollment))+ geom_bar(stat = “identity”,fill=“gray”)+ theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = “Average Enrollment by Country”, x = “Country”, y = “Enrollment”)

ggplot(average_by_country,aes(x=country,y=GDP))+ geom_bar(stat = “identity”,fill=“black”)+ theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = “Average GDP per capita by Country”, x = “Country”, y = “GDP”)

ggplot(average_by_country,aes(x=country,y=capital))+ geom_bar(stat = “identity”,fill=“red”)+ theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = “Average Gross capital foramtion by Country”, x = “Country”, y = “Capital”)

ggplot(average_by_country,aes(x=country,y=population))+ geom_bar(stat = “identity”,fill=“purple”)+ theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = “Average population growth by Country”, x = “Country”, y = “pop”)

Scatter plot

ggplot(average_by_country, aes(x= GDP, y= capital))+ geom_point(size= 2, shape= 23, fill=“black”)+ geom_smooth(method = lm)+ geom_label( aes(label = country), size = 3, fill=“maroon”, color=“white”)

ggplot(average_by_country, aes(x= GDP, y=Enrollment))+ geom_point(size=2, shape=23, color=“black”)+ geom_smooth(method = lm)+ geom_label(aes(label = country), size = 3, fill=“pink”, color=“black”)

ggplot(average_by_country, aes(x=GDP, y=population))+ geom_point(size=2, shape=23, color=“black”)+ geom_smooth(method = lm)+ geom_label(aes(label=country), size=3, fill=“skyblue”, color=“black”)

Basic linear regression form of the SOLOW model

pooled

pooled = plm(log(GDP) ~log(capital) + log(population), data = Assignment.p, model = “pooling”)

pooled

summary(pooled)

Random

random = plm(log(GDP) ~log(capital) + log(population), data = Assignment.p, model = “random”)

random

summary(random)

Fixed effect

fixed = plm(log(GDP) ~ log(capital) + log(population), data = Assignment.p, model = “within”)

fixed

summary(fixed)

Hausman test

phtest(fixed,random)

fixed effect is more appropriate , p value is significant

Smart table by stargazer

tabel<- stargazer(fixed,random,pooled,type=“text”)

visualization