比较R中的回归模型 [英] Comparing regression models in R
问题描述
我需要测试自2002-2004年以来1999-2001年期间的数字是否显着改善.我尝试将数据汇总到这两个时段中,并比较线性回归模型(例如lm(Y〜A + B))的调整后R平方,但这并不能得出正确的结论.我认为公司之间的回归将更为相关,因为回归系数自然会因公司而异.
I need to test if figures from the 1999-2001 period significantly improved since 2002-2004 period. I tried pooling the data into these two periods and comparing adjusted R-squares of a linear regression model (e.g., lm(Y~A+B)) but that does not lead to the right conclusion. I suppose a by-company regression would be more relevant because regression coefficients will naturally differ from company to company.
如何在R中进行这样的公司固定回归?还是有另一种方法可以测试我的模型在两个时期内是否变得更合适"?谢谢
How can I do such a by-firm regression in R? Or is there another way of testing if my model has become a 'better fit' over the two periods? Thanks
数据看起来像这样(当然会有更多的公司):
Data looks something like this (way more companies of course):
Company Year Y A B
11308 1999 -0,0208100 0,014718891 -0,006672241
11308 2000 -0,0073200 0,01513105 -0,001765405
11308 2001 -0,0242500 0,026331427 0,011924914
11308 2002 0,0071770 0,033910057 -2,55861E-05
11308 2003 -0,0161000 0,039996572 0,003413556
11308 2004 -0,0283000 0,038958565 0,004018833
11850 1999 -0,0001400 0,044492288 0,008268478
11850 2000 -0,0023400 0,057337917 0,028973756
11850 2001 -0,0113100 0,049981605 -0,002928416
11850 2002 0,0055080 0,04095854 -0,015228795
11850 2003 -0,0150000 0,089150637 0,042316779
11850 2004 0,0065680 0,093468014 0,016125354
推荐答案
听起来像从r到z的转换在这里可能效果很好: http://vassarstats.net/rdiff.html
Sounds like an r-to-z transformation might work quite well here: http://vassarstats.net/rdiff.html
R中的此程序包可以为您做到: https://cran.r-project.org/web/packages/cocor/cocor.pdf
This package in R can do it for you: https://cran.r-project.org/web/packages/cocor/cocor.pdf
这篇关于比较R中的回归模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!