⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twoway_lfit.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 08apr2005}{...}
{cmd:help twoway lfit}{right:dialogs:  {dialog erfit:easy regression fit}}
	{right:{dialog twoway_overlay:overlaid twoway}{space 4}}
	{right:{dialog twoway_simple:single twoway}{space 6}}
{hline}
{* index lines, adding}{...}
{* index adding lines}{...}
{* index adding fits, see fits, adding}{...}
{* index fits, adding}{...}

{title:Title}

{p2colset 5 30 32 2}{...}
{p2col :{hi:[G] graph twoway lfit} {hline 2}}Twoway linear prediction plots{p_end}
{p2colreset}{...}


{title:Syntax}

{p 8 60 2}
{cmdab:tw:oway}
{cmd:lfit}
{it:yvar} {it:xvar}
{ifin}
{weight}
[{cmd:,}
{it:options}]

{p2colset 9 38 42 2}{...}
	{it:options}{col 38}description
	{hline 70}
	{cmdab:r:ange:(}{it:#} {it:#}{cmd:)}{...}
{col 38}range over which predictions calculated
	{cmd:n(}{it:#}{cmd:)}{...}
{col 38}number of prediction points
	{cmd:atobs}{...}
{col 38}calculate predictions at {it:xvar}
	{cmdab:est:opts:(}{it:regress_options}{cmd:)}{...}
{col 38}options for {cmd:regress}
	{cmdab:pred:opts:(}{it:predict_options}{cmd:)}{...}
{col 38}options for {cmd:predict}

	{it:{help cline_options}}{...}
{col 38}change look of predicted line

INCLUDE help gr_axlnk

INCLUDE help gr_twopt
	{hline 70}
{pin}
All options are {it:rightmost}; see {help repeated options}.

{phang}
{cmd:aweight}s,
{cmd:fweight}s, and
{cmd:pweight}s are allowed.  Weights, if specified, affect estimation but
not how the weighted results are plotted.  See {help weight}.


{title:Description}

{pstd}
{cmd:twoway} {cmd:lfit} calculates the prediction for {it:yvar} based on a
linear regression of {it:yvar} on {it:xvar} and plots the resulting line.


{title:Options}

{phang}
{cmd:range(}{it:#} {it:#}{cmd:)}
    specifies the {it:x} range over which predictions are to be calculated.
    The default is {cmd:range(. .)}, meaning the minimum and maximum
    values of {it:xvar}.  {cmd:range(0 10)} would make the range 0
    to 10, {cmd:range(. 10)} would make the range the minimum to 10, and
    {cmd:range(0 .)} would make the range 0 to the maximum.

{phang}
{cmd:n(}{it:#}{cmd:)}
    specifies the number of points at which predictions over
    {cmd:range()} are to be calculated.  The default is {cmd:n(3)}.

{phang}
{cmd:atobs}
is an alternative to {cmd:n()}.  It specifies that the predictions be
    calculated at the {it:xvar} values.  {cmd:atobs} is the default
    if {cmd:predopts()} is specified and any statistic other than the
    {cmd:xb} is requested.

{phang}
{cmd:estopts(}{it:regress_options}{cmd:)}
    specifies options to be passed along to {cmd:regress} to
    estimate the linear regression from which the line will be predicted;
    see {helpb regress}.  If this option is specified,
    {cmd:estopts(nocons)} is also often specified.

{phang}
{cmd:predopts(}{it:predict_options}{cmd:)}
    specifies options to be passed along to {cmd:predict} to
    obtain the predictions after estimation by {cmd:regress}.

{phang}
{it:cline_options}
     specify how the prediction line is rendered;
     see {it:{help cline_options}}.

INCLUDE help gr_axlnkf

INCLUDE help gr_twoptf


{title:Remarks}

{pstd}
Remarks are presented under the headings

	{help twoway lfit##remarks1:Typical use}
	{help twoway lfit##remarks2:Cautions}
	{help twoway lfit##remarks3:Use with by()}


{marker remarks1}{...}
{title:Typical use}

{pstd}
{cmd:twoway} {cmd:lfit} is nearly always used in conjunction with
other {cmd:twoway} plottypes, such as

	{cmd:. sysuse auto, clear}

	{cmd:. scatter mpg weight || lfit mpg weight}
	  {it:({stata "gr_example auto: scatter mpg weight || lfit mpg weight":click to run})}
{* graph gtlfit1}{...}

{pstd}
Results are visually the same as typing

	{cmd}. regress mpg weight
	. predict fitted
	. scatter mpg weight || line fitted weight{txt}


{marker remarks2}{...}
{title:Cautions}

{pstd}
Do not use {cmd:twoway} {cmd:lfit} when specifying the
{it:axis_scale_options} {cmd:yscale(log)} or {cmd:xscale(log)} to create log
scales.  Typing

	{cmd:. scatter mpg weight, xscale(log) || lfit mpg weight}
	  {it:({stata "gr_example auto: scatter mpg weight, xscale(log) || lfit mpg weight":click to run})}
{* graph gtlfit2}{...}

{pstd}
The line is not straight because the regression estimated for the prediction
was for mpg on weight, not mpg on log(weight).  (The default for {cmd:n()} is
3 so that, if you make this mistake, you will spot it.)


{marker remarks3}{...}
{title:Use with by()}

{pstd}
{cmd:lfit} may be used with {cmd:by()} (as can all the {cmd:twoway} plot
commands):

{phang2}
	{cmd:. scatter mpg weight || lfit mpg weight ||, by(foreign, total row(1))}
{p_end}
	  {it:({stata "gr_example auto: scatter mpg weight || lfit mpg weight ||, by(foreign, total row(1))":click to run})}
{* graph gtlfit3}{...}


{title:Also see}

{psee}
Manual:  {bf:[G] graph twoway lfit}

{psee}
Online:  
{helpb line},
{helpb twoway qfit},
{helpb twoway fpfit},
{helpb twoway mband},
{helpb twoway mspline};
{helpb twoway lfitci};
{helpb regress}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -