作者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/m.aspx?n=bbs/Statistics/M.1596194599.A.FE0.html
1F:推 evilove: Thank you!! 08/01 00:21