Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How would you export ANOVA tables

    foreach var in Subclass {
    anova ATF4Targetgenes `var'
    export ??????????
    }


    Hello everyone, I have created a for each loop to make many ANOVA tables at once, however, I am not sure how I can export the ANOVA tables to my working directory. For graphs the code would be export graph, what would it be for ANOVA tables?

  • #2
    As an aside to what you asked, -foreach var in Subclass- is a loop the has only a single iteration, with `var' == "Subclass". So why bother with a loop? Just run -anova ATF4Targetgenes Subclass- and be done with it.

    With regard to how you might export an ANOVA table, there is, to my knowledge, no simple packaged command for doing this. You will have to build the table yourself. I would probably do it something like this:

    Code:
    frame create anova_table str32 source float partial_ss int df float (f)
    anova ATF4Targetgenes Subclass
    frame post anova_table ("Model") (e(mss)) (e(df_m)) (e(F))
    frame post anova_table ("Subclass") (e(ss_1)) (e(df_1)) (e(F_1))
    frame post anova_table ("Residual") (e(rss)) (e(df_r)) (.)
    
    frame change anova_table
    gen ms = partial_ss/df, after(df)
    gen p_value = Ftail(df, e(df_r), f)
    At that point the frame anova_table will contain a data set that is laid out similarly to the ANOVA table from the results window. You can save it as a Stata data set, or export it to any of the target formats available under the -export- command. See -help export-.

    Note: Above code is not tested. Beware of typos or other errors.
    Last edited by Clyde Schechter; 22 May 2022, 18:32.

    Comment

    Working...
    X