for my econometrics class we had to investigate the relationship between co2 emission and GDP for a specific country. The project was in GRETL, but i am personally trying to convert it in python. The problem is that i am obtaining different results compared to the GRETL's ones.
The model that i want to regress is: co2=const + b1GDP + b2GDP_LAG1 + b2co2_LAG1 + DUMMYfor1989 + DUMMYfor2003 with robust standard errors
My code:
from LoadData import *
import statsmodels.api as sm
import pandas as pd
import numpy as np
data = loadAll() #just returns the dataset
data['GDP_lag1'] = data['GDP_perCap'].shift() #lag column for GDP variable
data['CO2_lag1'] = data['Annual_CO2_emissions_TperCap'].shift() #lag column for co2 variable
y=data[['Annual_CO2_emissions_TperCap']] #independet variable
x=data[['GDP_perCap', 'GDP_lag1', 'CO2_lag1']] #regressors
x['dummy']=0 #dummies column
x.loc['1989', 'dummy']=1 #setting 1 for specific years....
x.loc['2003', 'dummy']=1
x['GDP_lag1']=x['GDP_lag1'].fillna(0) #fixing na values
x['CO2_lag1']=x['CO2_lag1'].fillna(0)
x=sm.add_constant(x)
reg_ols = sm.OLS(y, x).fit()
print(reg_ols.summary())
to be more clear, this is what i have inside my regressor variable:
Thank you all!