question

Upvotes
1 0 0 0

Is there a possibility to do a regression/correlation analysis of ESG KPIs and the ESG Score using API to see if these values influence 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.

workspace-data-api#contentwindows-osesg-scope
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
6.9k 21 3 6

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?


1726131098673.png



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.


1726131098673.png (43.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.