📄 twoway_mspline.hlp
字号:
{smcl}
{* 08apr2005}{...}
{cmd:help twoway mspline}{right:dialogs: {dialog twoway_overlay:overlaid twoway}{space 0}}
{right:{dialog twoway_simple:single twoway}{space 2}}
{hline}
{title:Title}
{p2colset 5 33 35 2}{...}
{p2col :{hi:[G] graph twoway mspline} {hline 2}}Twoway median-spline plots{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 56 2}
{cmdab:tw:oway}
{cmd:mspline}
{it:yvar}
{it:xvar}
{ifin}
[{cmd:,}
{it:options}]
{p2colset 9 31 33 2}{...}
{it:options}{col 40}description
{p2line}
{cmdab:b:ands:(}{it:#}{cmd:)}{...}
{col 31}number of cross-median knots
{cmd:n(}{it:#}{cmd:)}{...}
{col 31}number of points between knots
INCLUDE help gr_clopt
INCLUDE help gr_axlnk
INCLUDE help gr_twopt
{p2line}
{pin}
All options are {it:rightmost}; see {help repeated options}.
{title:Description}
{pstd}
{cmd:twoway} {cmd:mspline} calculates
cross medians and then uses the cross medians as knots to fit a cubic
spline. The resulting spline is graphed as a line plot.
{title:Options}
{phang}
{cmd:bands(}{it:#}{cmd:)}
specifies the number of bands for which cross medians should be
calculated. The default is max[10, round{10*log10(N)}], where N is the
number of observations.
{pmore}
The {it:x} axis is divided into {it:#} equal-width intervals and then the
median of {it:y} and the median of {it:x} are calculated in each interval.
It is these cross medians to which a cubic spline is then fit.
{phang}
{cmd:n(}{it:#}{cmd:)}
specifies the number of points between the knots for which the
cubic spline should be evaluated. {cmd:n(10)} is the default.
{cmd:n()} does not affect the result that is calculated, but it does
affect how smooth the result appears.
{phang}
{it:cline_options}
specify how the median-spline line is rendered and its appearance;
see {it:{help cline_options}}.
INCLUDE help gr_axlnkf
INCLUDE help gr_twoptf
{title:Remarks}
{pstd}
Remarks are presented under the headings
{help twoway mspline##remarks1:Typical use}
{help twoway mspline##remarks2:Cautions}
{help twoway mspline##remarks3:Use with by()}
{marker remarks1}{...}
{title:Typical use}
{pstd}
Median splines provide a convenient way to show the relationship
between {it:y} and {it:x}:
{cmd:. sysuse auto, clear}
{cmd:. scatter mpg weight, msize(*.5) || mspline mpg weight}
{it:({stata "gr_example auto: scatter mpg weight, msize(*.5) || mspline mpg weight":click to run})}
{* graph gtmspline1}{...}
{pstd}
The important part of the above command is "{cmd:mspline} {cmd:mpg}
{cmd:weight}". On the {cmd:scatter}, we specified {cmd:msize(*.5)} to make
the marker symbols half their normal size; see {it:{help relativesize}}.
{marker remarks2}{...}
{title:Cautions}
{pstd}
The graph shown above illustrates a common problem with this technique:
it tracks wiggles that may not be real and can introduce
wiggles if too many bands are chosen. An improved version of the
graph above would be
{phang2}
{cmd:. scatter mpg weight, msize(*.5) || mspline mpg weight, bands(8)}
{p_end}
{it:({stata "gr_example auto: scatter mpg weight, msize(*.5) || mspline mpg weight, bands(8)":click to run})}
{* graph gtmspline2}{...}
{marker remarks3}{...}
{title:Use with by()}
{pstd}
{cmd:mspline} may be used with {cmd:by()} (as can all the {cmd:twoway} plot
commands):
{cmd:. scatter mpg weight, msize(*.5) ||}
{cmd:mspline mpg weight, bands(8) ||, by(foreign, total row(1))}
{it:({stata "gr_example auto: scatter mpg weight, msize(*.5) || mspline mpg weight, bands(8) ||, by(foreign, total row(1))":click to run})}
{* graph gtmspline3}{...}
{title:Also see}
{psee}
Manual: {bf:[G] graph twoway mspline}
{psee}
Online:
{helpb line},
{helpb twoway mband},
{helpb twoway lfit},
{helpb twoway qfit},
{helpb twoway fpfit};
{helpb mkspline}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -