Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(readxl)
- data1=read.csv("D:/4-2/research project/trade_value_by_section_and_year_ind_bd_imp_exp (1).csv")
- View(data1)
- #selecting cases of bangladesh
- bangladesh<-data1[data1$Country=="Bangladesh",]
- india<-data1[data1$Country=="India",]
- View(bangladesh)
- library(urca)
- library(tseries)
- # gdp1<-diff(log(bangladesh$Import.Total))
- #
- # gdp<-diff(LABOR)
- # plot(GDP,type='l')
- # adf.test(gdp,k=9)
- #
- #
- #
- # #AIC TEST FOR OPTIMAL LAG Length
- #
- # install.packages('urca')
- #
- # library(vars)
- # VARselect(gdp)
- #
- #
- #
- # # Define a custom function
- # plot_and_adf_test <- function(data, variable_name) {
- # # Plot the variable
- # # plot(data[[variable_name]], type = 'l', main = variable_name)
- # plot.ts(data[[variable_name]])
- #
- # # Perform ADF test
- # adf_result<-adf.test(data[[variable_name]])
- # print(adf_result)
- #
- # }
- #
- #
- #
- # adf_gdp <- plot_and_adf_test(bangladesh, "GDP.GROWTH..ANNUAL...")
- # adf_import<-plot_and_adf_test(bangladesh,"Import.Total")
- # adf_export<-plot_and_adf_test(bangladesh, "EXPORT.TOTAL")
- # adf_capital<-plot_and_adf_test(bangladesh,"Gross.Capital.Formation")
- # adf_labor<-plot_and_adf_test(bangladesh, "Total.Labor")
- #adf test of gdp growth, capital, import, export, labor
- gdp<-bangladesh$GDP
- gdp_X=ur.df(gdp,type="drift",selectlags = "AIC")
- gdp_X
- plot(gdp,type="l")
- summary(gdp_X)
- gdp_X@lags
- import<-bangladesh$Import.Total
- import_x=ur.df(import,type="drift",selectlags ="AIC")
- import_x
- summary(import_x)
- import_x@lags
- export<-bangladesh$EXPORT.TOTAL
- export_x=ur.df(export,type="drift",selectlags = "AIC")
- export_x
- plot(export,type=)
- summary(export_x)
- export_x@lags
- labor<-diff(bangladesh$Total.Labor)
- labor_x=ur.df(labor, type="drift", selectlags = "AIC")
- labor_x
- summary(labor_x)
- labor_x@lags
- capital<-bangladesh$Gross.Capital.Formation
- capital_x=ur.df(capital,type="drift",selectlags = "AIC")
- capital_x
- summary(capital_x)
- capital_x@lags
- # gdp[1:,]
- #granger causality test
- #null hypothesis: Time series X does not cause time series Y to Granger-cause itself.
- library(lmtest)
- grangertest(gdp~import,order=2)
- gdp_ind<-diff(india$GDP)
- gdp_x_ind=ur.df(gdp_ind,type="drift",selectlags = "AIC")
- gdp_x_ind
- plot(gdp_ind,type="l")
- summary(gdp_x_ind)
- gdp_x_ind@lags
- import_ind<-diff(india$Import.Total)
- import_x_ind=ur.df(import_ind,type="drift",selectlags ="AIC")
- import_x_ind
- summary(import_x_ind)
- import_x_ind@lags
- export_ind<-diff(india$EXPORT.TOTAL)
- export_x_ind=ur.df(export_ind,type="drift",selectlags ="AIC")
- export_x_ind
- summary(export_x_ind)
- export_x_ind@lags
- grangertest(gdp_ind~export_ind,order=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement