Stata 15 help for twoway_fpfit

[G-2] graph twoway fpfit -- Twoway fractional-polynomial prediction plots


twoway fpfit yvar xvar [if] [in] [weight] [, options]

options Description ------------------------------------------------------------------------- estcmd(est_cmd) estimation command; default is regress estopts(est_opts) specifies est_opts to estimate the fractional polynomial regression

cline_options change look of predicted line

axis_choice_options associate plot with alternative axis

twoway_options titles, legends, axes, added lines and text, by, regions, name, aspect ratio, etc. ------------------------------------------------------------------------- est_cmd may be clogit, glm, intreg, logistic, logit, mlogit, nbreg, ologit, oprobit, poisson, probit, regress, rreg, stcox, stcrreg, streg, or xtgee. Options estcmd() and estopts() are unique; see repeated options. aweights, fweights, and pweights are allowed. Weights, if specified, affect estimation but not how the weighted results are plotted. See weight.

est_opts Description ------------------------------------------------------------------------- degree(#) degree of fractional polynomial to fit; default is degree(2)

noscaling suppress scaling of first independent variable noconstant suppress constant term powers(numlist) list of fractional polynomial powers from which models are chosen center(cent_list) specification of centering for the independent variables all include out-of-sample observations in generated variables

log display iteration log compare compare models by degree display_options control column formats and line width

other_est_opts other options allowed by est_cmd ------------------------------------------------------------------------- cent_list is a comma-separated list with elements varlist:{mean|#|no}, except that the first element may optionally be of the form {mean|#|no} to specify the default for all variables.


Graphics > Twoway graph (scatter, line, etc.)


twoway fpfit calculates the prediction for yvar from estimation of a fractional polynomial of xvar and plots the resulting curve.


estcmd(est_cmd) specifies the estimation command to be used; estcmd(regress) is the default.

estopts(est_opts) specifies the options to estimate the fractional polynomial regression from which the curve will be predicted. Available est_opts are

degree(#) determines the degree of FP to be fit. The default is degree(2), that is, a model with two power terms.

noscaling suppresses scaling of xvar1 and its powers.

noconstant suppresses the regression constant if this is permitted by est_cmd.

powers(numlist) is the set of FP powers from which models are to be chosen. The default is powers(-2, -1, -.5, 0, .5, 1, 2, 3) (0 means log).

center(cent_list) defines the centering for the covariates xvar1, xvar2, ..., xvarlist. The default is center(mean). A typical item in cent_list is varlist:{mean|#|no}. Items are separated by commas. The first item is special because varlist: is optional, and if omitted, the default is (re)set to the specified value (mean or # or no). For example, center(no, age:mean) sets the default to no and sets the centering for age to mean.

all includes out-of-sample observations when generating the best-fitting FP powers of xvar_1, xvar_2, etc. By default, the generated FP variables contain missing values outside the estimation sample.

log displays deviances and (for regress) residual standard deviations for each FP model fit.

compare reports a closed-test comparison between FP models.

display_options: cformat(%fmt), pformat(%fmt), sformat(%fmt), and nolstretch; see [R] estimation options.

other_est_opts are options appropriate to the est_cmd; see the documentation for that est_cmd. For example, for stcox, other_est_opts may include efron or some alternate method for handling tied failures.

cline_options specify how the prediction line is rendered; see [G-3] cline_options.

axis_choice_options associate the plot with a particular y or x axis on the graph; see [G-3] axis_choice_options.

twoway_options are a set of common options supported by all twoway graphs. These options allow you to title graphs, name graphs, control axes and legends, add lines and text, set aspect ratios, create graphs over by() groups, and change some advanced settings. See [G-3] twoway_options.


Remarks are presented under the following headings:

Typical use Cautions Use with by()

Typical use

twoway fpfit is nearly always used in conjunction with other twoway plottypes, such as

. sysuse auto

. scatter mpg weight || fpfit mpg weight (click to run)


Do not use twoway fpfit when specifying the axis_scale_options yscale(log) or xscale(log) to create log scales. Typing

. scatter mpg weight, xscale(log) || fpfit mpg weight

will produce a curve that will be fit from a fractional polynomial regression of mpg on weight rather than log(weight).

Use with by()

fpfit may be used with by() (as can all the twoway plot commands):

. scatter mpg weight || fpfit mpg weight ||, by(foreign, total row(1)) (click to run)

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index