Observed, fitted and residuals plotted versus time variable
ofrtplot7 [varname] [ , super tfrac(#) graph_options nlabel(#) ]
ofrtplot7 plots observed, fitted and residuals from the last model against a covariate. It is designed for time series models and by default the covariate is whatever has been tsset as the time variable. However, other variables may be specified, whether or not data have been tsset.
Observed values are for the response or dependent variable from the last model, fitted values are whatever predict produces by default and residuals are whatever predict, res produces. The plot is restricted to the estimation sample.
By default, the plot has two panels. In the top panel, observed and fitted are plotted against the covariate. In the bottom panel, residuals are plotted against the covariate, by default as spikes from zero.
This is the original version of ofrtplot for Stata 7, renamed ofrtplot7. Users of Stata 8 upwards should upgrade to ofrtplot.
the time variable has a %t or %d format, and
neither xlabel nor xlabel() is specified, and
values span more than one year
ofrtplot7 attempts to select for the time (x) axis nice labels based on the years included in the time series. For daily, weekly, monthly, quarterly or half-yearly data, it attempts to show the first time period within each of various years which are nice numbers. For yearly data, it attempts to show years which are nice numbers. Nice numbers here are preferably multiples of 10, 5 or 2. The main algorithm used is based on code by Hardin (1995).
super specifies that plots are to be superimposed, not separate.
tfrac(#) specifies the fraction of the graph image taken up by the top panel. The default is 0.625. If the fraction specified is 1, the bottom panel is suppressed, while if it is 0, the top panel is suppressed.
graph_options are options of graph, twoway, except for by() and rescale. The defaults include gap(5) and (if varname is specified) sort.
If symbol() is specified, the first two symbol specifications refer to observed and fitted and the second two symbol specifications refer to residuals and zeros. The default is sy(iiii).
If connect() is specified, the first two connect specifications refer to observed and fitted and the second two connect specifications refer to residuals and zeros. The default is c(ll[-]||).
By default, with no super option, the plot shows two separate panels, and rlabel, rlabel(), rline, rline(), rtick, rtick(), rscale(), r1title() and r2title() refer to the corresponding y axis options of the bottom panel. That is, rlabel is the ylabel option for the y or residual axis, r1title() is the l1title() option for that axis, and so forth. Thus these options may be thought of as specifying options referring to the residual axis.
Correspondingly, ylabel, ylabel(), yline, yline(), ytick, ytick(), yscale(), l1title() and l2title() refer to the y axis options of the top panel.
With the super option, only one panel is produced, and these options all have their usual meanings.
Note, however, that saving() and title() refer to the combined graph image, whatever other options are specified.
nlabel(#) suggests the number of nice labels to be shown on the time axis. The suggestion may or may not be taken literally. This option is independent of xlabel or xlabel().
. tsset time
. regress whatever time
. ofrtplot7, tfrac(0.7)
. gen gpm = 1 / mpg
. regress gpm weight
. ofrtplot7 weight, c(.l||) sy(oiii)
Nicholas J. Cox, University of Durham, U.K. firstname.lastname@example.org
Denis de Crombrugghe suggested this program. Kit Baum made several useful suggestions.
Hardin, J.W. 1995. Calculate nice numbers for labeling or drawing grid lines. Stata Technical Bulletin 25, 2-3. (Also in STB Reprints Volume 5, 19-20.)
On-line: help for graph, predict, tsset