在R和Stata当中计算回归系数效应量的方法 #48
chengjun
started this conversation in
Show and tell
Replies: 2 comments
-
如何在R里计算effect size?第一步,读入数据 同样使用上面stata使用的示例数据。使用foreign包当中的read.dta函数可以读入这个数据。 library(foreign)
library(effectsize)
library(car)
dat = read.dta('https://stats.idre.ucla.edu/stat/data/hsbdemo.dta') head(dat)
第二步,跑回归分析 m = lm(write ~ female + read + math + prog, data = dat)
summary(m)
第三步,看标准化回归系数 standardize_parameters(m)
第四步,跑方差分析并计算partical eta squared aov_table <- car::Anova(m, type = 3)
aov_table
eta_squared(aov_table)
|
Beta Was this translation helpful? Give feedback.
0 replies
-
了解更多 在R和Stata当中计算回归系数效应量的方法 https://www.douban.com/group/topic/267379314 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HOW CAN I COMPUTE EFFECT SIZE IN STATA FOR REGRESSION?
https://stats.oarc.ucla.edu/stata/faq/how-can-i-compute-effect-size-in-stata-for-regression/
Two of the more common measures of effect size for regression analysis are eta2 and partial eta2.
The formula differs from the eta squared formula in that the denominator includes the SSEffect plus the SSError rather than the SSTotal. The Stata regress postestimation command estat esize can be used to estimate eta2 for the model and partial eta2 for each effect in the model. Below, we run a linear regression analysis the hsbdemo dataset.
use https://stats.idre.ucla.edu/stat/data/hsbdemo, clear
We follow the regress command with estat esize, which displays estimates and confidence intervals for eta2 for the model and partial eta2 for each effect in the model.
An anova table of this regression allows us to see how eta2 and partial eta2 are calculated.
The model eta2 is SSModel/SStotal = 9602.2863/17878.875 = 0.53707441. This matches the estimated for R-squared. The familiar interpretation is that the model explains 53.71% of the total variance of write.
Each partial eta2 is SSEffect/(SSEffect+SSError). The SSError for all of these terms is SSResidual. We can thus calculate partial eta2 for female = SSEffect/(SSEffect+SSError) = 1431.7/(1431.7+8276.5887) = 0.14747192.
We can interpret this to mean that about 14.75% of the variance unexplained by effects other than female is explained by the female effect. If we need estimates of eta2 for each effect, it is simply SSEffect/SSTotal.
Beta Was this translation helpful? Give feedback.
All reactions