作者riirene (♪)
看板Statistics
标题Re: [程式] Save p values in Stata
时间Fri Jul 31 19:23:16 2020
https://www.stata.com/manuals/dby.pdf
*Technical note: -by- repeats the stata_cmd for each group defined by
varlist. If stata_cmd stores results, only the results from the last group on
which stata_cmd executes will be stored.
foreach var of varlist fob_* sob_* {
quietly summarize country_id
forvalues ctry = 1/`r(max)' {
anova `var' age3 if country_id == `ctry'
matrix storeMyP[`n', 1] = Ftail(e(df_m), e(df_r), e(F))
local ++n
}
}
※ 引述《evilove (愿意感动就是一种享受)》之铭言:
: 我觉得我满接近了,但不晓得为什麽只有存到第一轮的loop
: * generate country N
: egen country_id = group(CountryofLiving)
: qui summarize country_id
: * display number of countries
: display `r(max)'
: * create empty matrix with 55 * 8 rows, 1 column
: set matsize 450
: matrix storeMyP = J(`r(max)' * 8, 1, .)
: * count the iterations
: local n = 1
: * anlysis by countries
: foreach var of varlist fob_* sob_* {
: bysort CountryofLiving: anova `var' age3
: matrix storeMyP[`n', 1] = Ftail(e(df_m), e(df_r), e(F))
: local ++n
: }
: * display storeMyP
: matrix list storeMyP
: storeMyP[440,1]
: c1
: r1 .27275597
: r2 .0909248
: r3 .24468857
: r4 .00023781
: r5 .87538963
: r6 .07680316
: r7 .34257757
: r8 .00722484
: r9 .
: r10 .
: r11 .
: r12 .
: r13 .
: ※ 引述《evilove (愿意感动就是一种享受)》之铭言:
: : [软体程式类别]: Stata
: : [程式问题]: ANOVA
: : [软体熟悉度]:
: : 熟悉
: : [问题叙述]:
: : 需要跑上百个ANOVA 想知道怎麽另外把 P values 储存起来
: : [程式范例]:
: : foreach var of varlist fob_* sob_* {
: : bysort CountryofLiving: oneway `var' age3, tabulate
: : }
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 123.194.172.206 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Statistics/M.1596194599.A.FE0.html
1F:推 evilove: Thank you!! 08/01 00:21