Hello
I am using Stata 17 on Windows 10.
I have dataset of approximately 265,000 observations where I need to calculate McKelvey and Zavoina’s R2 (MZR2) from fitstat for everyday over a 18 month period and extract this with the relevant date to a new dBase.
Previously I was using statsby with cnreg which prefectly extracted the coefficients I was interested to a new file. But fitstat doesn't run with statsby.
Using runby I can calculate the MZR2 for each date but I can’t find a way of iteratively extracting the MZR2 into a new file (which statsby did so simply).
I would like to end up with a file that looks like this (there will be days with missing values in the data):
Any suggestions for iteratively extracting the MZR2 into a new file would be appreciated.
Many thanks
I am using Stata 17 on Windows 10.
I have dataset of approximately 265,000 observations where I need to calculate McKelvey and Zavoina’s R2 (MZR2) from fitstat for everyday over a 18 month period and extract this with the relevant date to a new dBase.
Previously I was using statsby with cnreg which prefectly extracted the coefficients I was interested to a new file. But fitstat doesn't run with statsby.
Code:
statsby _b nlc=(e(N_lc)) nrc=(e(N_rc)) total=e(N), by(date) sa(finaldlf): cnreg log10flow [aw=pop], censored(censorRED)
Code:
clear all program my_prog cnreg log10flow cases [aw=pop], censored(censorRED) estadd fitstat end use "cfcRED.dta" runby my_prog, by (date) verbose
date | mzr2 |
01dec2021 | .130215 |
02dec2021 | .2354 |
03dec2021 | .365987 |
04dec2021 | .236597 |
05dec2021 | .985524 |
06dec2021 | .32654 |
07dec2021 | |
08dec2021 | .32654 |
09dec2021 | .56841 |
Many thanks
Comment