简体   繁体   English

plot 如何用一个图形(例如u 形)来显示面板数据回归中的非线性关系?

[英]How to plot a graph (e.g. u-shape) to show the non-linear relationship in panel data gression?

I am a freshman in doing regerssion and also in using python / r I am now studying the non-linear relationship between ESG performance and Financial Performance of companies, with a set of panel data and the following equation:我是做回归的大一新生,也在使用 python / r 我现在正在研究公司的ESG绩效和财务绩效之间的非线性关系,有一组面板数据和以下等式:

ROA = C(1) + C(2)*ENV + C(3)*ENV2 + C(4)*SOC + C(5)*SOC2 + C(6)*GOV + 
             C(7)*GOV2 + C(8)*LNA + C(9)*LEV + C(10)*PB + C(11)*LNOE

ENV2, SOC2 & GOV2 are the quadratic terms for ENV, SOC & GOV respectively, and C(8)-C(11) are control variables. ENV2、SOC2、GOV2分别为ENV、SOC、GOV的二次项,C(8)-C(11)为控制变量。

I would like to plot a graph to show the marginal effect of ENV/SOC/GOV on ROA, so my question is how can I do that the plot the u-shaped or inverse u-shaped fitting curve via python or r?我想要 plot 一张图表来显示 ENV/SOC/GOV 对 ROA 的边际效应,所以我的问题是我怎样才能通过 python 或 r 得到 plot U 形或反 U 形拟合曲线?

Many thanks!非常感谢!

You can use the plot_cap() function from the marginaleffects package for R (disclaimer: I am the author).您可以marginaleffects效应 package 中的plot_cap() function 用于R (免责声明:我是作者)。 For example, here is a model with a quadratic term:例如,这是一个带有二次项的 model:

library(marginaleffects)

# simulate
x <- rnorm(100)
y <- x + x^2 + rnorm(100)

# fit
mod <- lm(y ~ x + I(x^2), data = mtcars)

# plot
plot_cap(mod, condition = "x")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM