r语言 - Meaning of e(F)



我目前正在尝试将Stata脚本转换为R脚本。我无法找到文档来准确解释e(F(是什么。

该脚本随机选择 5,000 个客户作为控制,12,000 个客户作为处理。然后,它执行某种统计测试,以确定随机选择是否会创建统计上严格的样本。不过,谷歌搜索只能让我走到这一步,因为我并不真正理解 Stata 语法。

我真的很感激任何帮助。这是有问题的脚本...

import delimited $datadata.csv
gen random=0
gen rank=0
scalar treattail=0
scalar controltail=0
gen control=0
gen treat=0
local treatment treat control
while treattail <0.25 {
foreach y in `treatment' {
qui replace `y'=0
}
qui replace random=100*runiform()
sort random
replace rank=_n
replace control=1 if rank>=0 & rank<=5000
replace treat=1 if rank>5000 & rank<=17000
foreach y in `treatment' { 
reg `y' meanconsumption varconsumption
scalar `y'tail = Ftail(`e(df_m)',`e(N)'-`e(df_m)',`e(F)') # I don't quite understand this line
}
scalar dir
}
local treatment treat control
....
foreach y in `treatment' { 

将在大括号和匹配的右大括号之间运行一次代码,将本地宏 y 设置为treat,第二次设置为control

reg `y' meanconsumption varconsumption

第一次通过,这将回归变量treat两个变量meanconsumptionvarconsumption。第二次通过,变量control将在相同的两个变量上回归。

scalar `y'tail = Ftail(`e(df_m)',`e(N)'-`e(df_m)',`e(F)')

这将使用前两个参数给出的参数和第三个参数给出的 F 统计量来计算 F 分布的尾部,其中估计结果e()来自刚刚运行的回归命令,定义如下。

e(N)                number of observations
e(df_m)             model degrees of freedom
e(F)                F statistic 

第一次通过,计算值将存储在 Stata 标量treattail中,第二次通过存储在 Stata 标量controltail中。换句话说,它似乎正在计算和保存来自两次回归的 F 统计量的 p 值。

相关内容

最新更新