Client wants to pull ESG KPIs and the ESG Score through API and do a regression analysis to see if the values affect each other.
Client wants to pull ESG KPIs and the ESG Score through API and do a regression analysis to see if the values affect each other.
Hi @grae.tejada, Please note that this Forum is for technical LSEG API questions only. For answers about content, such as the data item names (e.g.: what is the name of a "ESG KPI" field in the LDL), please use the DIB; failing that, please reach out to my.refinitiv.com.
I looks into the DIB myself and tested out an answer for you with the fields ["TR.TRESGScore","TR.TRESGCControversiesScore"], and came up with:
df = ld.get_history( universe="LSEG.L", fields=["TR.TRESGScore","TR.TRESGCControversiesScore"], start="2020-01-01", end="2024-09-01") df.corr()
This is the output; is it what you're after?
You can go further in your analysis with:
# Assuming df contains the necessary columns X = df[['TR.TRESGCControversiesScore']] y = df['TR.TRESGScore'] # Handle any missing values if necessary X = X.fillna(X.mean()) y = y.fillna(y.mean()) # Initialize and fit the regression model model = LinearRegression() model.fit(X, y) # Print the coefficients print("Coefficient:", model.coef_[0]) print("Intercept:", model.intercept_) # Predict ESG Score based on Controversies Score y_pred = model.predict(X) from sklearn.metrics import r2_score r2 = r2_score(y, y_pred) print("R-squared:", r2)
Don't hesitate to let me know what Data Items you would prefer using, and I can entre them in the code above for you. Alternatively, I would suggest you do so yourself using Codebook.