Announcement

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

  • Plot multiple time-series data using foreach?

    Hello stata experts,

    I want to check the means of imputed data for several variables. I want to do the graphing all at once and save it for review later on. To graph the plot for one variable, I have the following codes which run successfully:

    mi impute chained (pmm) v1 v5 (ologit) v2 (logit) v3 (mlogit) v4 = v6 v7, add(5) rseed(1234) augment savetrace(extrace, replace) burnin(100)
    use extrace, replace
    reshape wide *mean *sd, i(iter) j(m)
    tsset iter
    tsline v1_mean*, title("Mean of Imputed Values") note("Each line is for one imputation") legend(off)
    graph export v1_mean.png, replace


    I am hoping to do the above tsline codes for v1 to v5 at once. I assume this would mean to plot a series of variables (v1_mean*, v2_mean*, v3_mean*...) for each series (v1, v2, v3...). I tried foreach and couldn't get it right.

    Thanks in advance for your help!
    Ji




  • #2
    Ji,

    I'm not quite clear on what you are asking, so it would probably be good if you showed us what you tried and what the problem was. Naively, I would assume you want something like this:

    Code:
    forvalues x=1/5 { 
      tsline v`x'_mean*, title("Mean of Imputed Values") note("Each line is for one imputation") legend(off)
      graph export v`x'_mean.png, replace
    }
    If that is not what you want, please provide more details.

    Regards,
    Joe

    Comment


    • #3
      Thanks Joe. The codes helped!

      Comment

      Working...
      X