-------------------------------------------------------------------------------
help for linkplot
-------------------------------------------------------------------------------

Linked scatter plots

linkplot yvarlist xvar [if exp] [in range] [weight] , link(linkvar) [ asyvars cmissing({y|n}) sort(sort_varlist) plot(plot) graph_options ]

Description

linkplot plots yvarlist versus xvar such that data points are linked (i.e. connected) within groups defined by distinct values of linkvar. For example, with paired data it might be desired to link each pair, or with panel data it might be desired to link observations within each panel.

aweights, fweights and pweights are allowed; see help weights.

Options link(linkvar) specifies that values of each variable in yvarlist are to be linked if they have the same value of linkvar. This option is required.

asyvars specifies that the groups defined by linkvar should be plotted as if they were separate y variables.

cmissing({y|n}) specifies whether missing values are ignored. The default is to ignore missing values. Note that this is a slight variant on cmissing() as explained at help connect_options. The only allowed arguments are y, to ignore, and n, not to ignore. These are automatically expanded to all variables plotted.

sort(sort_varlist) specifies that values are to be linked in order of sort_varlist. By default values are linked in sort order of xvar, the last variable specified before the option comma. Do not specify linkvar, as this will automatically be used.

plot(plot) provides a way to add other plots to the generated graph; see help plot option.

graph_options are options of twoway connected.

Examples

Box, Hunter and Hunter (1978, p.100) gave data for 10 boys on the wear of shoes made using materials A and B. The data are also analysed by Wild and Seber (2000, p.446). The units are not specified. Before exemplifying linkplot we make some general comments on graphing such paired data. One natural data structure would be something like this:

A B id 13.2 14.0 1 8.2 8.8 2 10.9 11.2 3 14.3 14.2 4 10.7 11.8 5 6.6 6.4 6 9.5 9.8 7 10.8 11.3 8 8.8 9.3 9 13.3 13.6 10

This data structure permits some Stata graphs, but inhibits others. A scatter plot such as scatter A B may be useful, but does not allow easy decoding of the difference, say A - B, which is here of central interest. Similarly, it is difficult to read off ratios such as A / B. If A and B are plotted versus id, or vice versa, the resulting graphs suffer from the arbitrariness of id. See also the possibilities offered by pairplot, which may be installed using ssc.

Other possibilities are available after a reshape:

. rename A wearA . rename B wearB . reshape long wear, string i(id) j(j) . encode j, gen(material)

Now we have a choice, including

. linkplot material wear, link(id) yla(1 2, valuelabel) ysc(r(0.5 2.5)) yla(, ang(h)) . linkplot wear material, link(id) xla(1 2, valuelabel) xsc(r(0.5 2.5)) yla(, ang(h))

Acknowledgements

Vince Wiggins made encouraging noises.

Author

Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

References

Box, G.E.P., W.G. Hunter and J.S. Hunter. 1978. Statistics for experimenters: an introduction to design, data analysis, and model building. New York: John Wiley.

Wild, C.J. and G.A.F. Seber. 2000. Chance encounters: a first course in data analysis and inference. New York: John Wiley.

Also see

On-line: help for pairplot (if installed)