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

__Syntax__

__tw__**oway** **fpfit** *yvar* *xvar* [*if*] [*in*] [*weight*] [**,** *options*]

*options* Description
-------------------------------------------------------------------------
__estc__**md(***est_cmd***)** estimation command; default is **regress**
__est__**opts(***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.
**aweight**s, **fweight**s, and **pweight**s are allowed. Weights, if specified,
affect estimation but not how the weighted results are plotted. See
weight.

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

__nosca__**ling** suppress scaling of first independent variable
__nocons__**tant** suppress constant term
__po__**wers(***numlist***)** list of fractional polynomial powers from which
models are chosen
__cent__**er(***cent_list***)** specification of centering for the independent
variables
**all** include out-of-sample observations in generated
variables

**log** display iteration log
__com__**pare** 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.

__Menu__

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

__Description__

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

__Options__

**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__

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**)*

__Cautions__

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**)*