![]() See also this Tip.Īlthough the example dataset is well behaved, extra options sort connect(L) will help in some case to remove spurious connections between individuals or panels. To get distinct colours, distinct variables suffice, which is where separate has a role. When frustrated by its wired-in choices, people often just reach for line. There is nothing very special about xtline. Line alcuse? age, legend(off) sort connect(L) There is considerable ingenuity in the question code in working through all the identifiers, but a broad-brush approach seems to work as well. Even with this modest dataset there are 82 distinct identifiers, so any attempt to show them distinctly fails to be useful, if only because the resulting legend takes up most of the real estate. It is difficult (for me) to separate the programming issue here from statistical or graphical views on what kind of graph works well, or at all. Xtline alcuse, legend(off) scheme(s1mono) overlay `m_plot_opt' `f_plot_opt' Loc f_plot_opt "`f_plot_opt' plot`i'opts(recast(connected) mcolor(black) msize(medsmall) msymbol(triangle) lcolor(black) lwidth(medthin) lpattern(solid))"ĭi "xtline alcuse, legend(off) scheme(s1mono) overlay `m_plot_opt' `f_plot_opt'" The code below, using publicly available data from UCLA's excellent Stata guide shows my basic code and reproduces the error: use, clear I am aware of this solution which employs combined graphs but that is also not practical given the large number of unique individuals in my data.ĭoes a more simple solution to this problem exist? Does Stata have the capacity to overlay multiple -xtline- plots like it can -twoway- plots? When I try this solution Stata produces the "too many options" error, which is perhaps predictable given the large number of unique persons. Taking cues from this question on Statalist, I produced code similar to what is below. I chose to recast the xtline plot as "connected" and show males using circle markers and females as triangle markers. quietly regress alcuse i.id#c.I am attempting to produce an overlayed -xtline- plot that distinguishes between males and females (or any number of multiple groups) by displaying different plot styles for each group. Predicted values from this regression can then be plotted. In the nextĮxample, we regress alcuse on age interacted with id. We can also plot fitted lines using the xtline command. xtline alcuse if id < 10, overlay t(age) i(id) legend(off) scheme(s2mono) To do this, we add overlay to our command. Suppose we are interested in seeing all of the above lines in one plot. This example generates plots for the first 9 children’s observations in the file xtline alcuse if id < 10, t(age) i(id) scheme(s2mono) A separate plot will be created for eachĭifferent id value. The time variable we specify willĪppear on the horizontal axis. ![]() The outcome that we wish to examine,Īlcohol use, will appear on the vertical axis. We indicate that our time variable is age with t(age) and our This first example shows a line connecting the three time points broken downīy id (one plot per child). Produces plots in grayscale, because publications often require monochromatic plots.įirst, we read in the data file. Of alcohol use, alcuse, taken at ages 14, 15 and 16 for 82 children We will show a number of examples from a data file which contains a measurement The xtline command allows you to generate linear plots for panel data. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |