Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: modify axis range in scatter graphs
From
Maarten buis <[email protected]>
To
[email protected]
Subject
Re: st: modify axis range in scatter graphs
Date
Tue, 23 Mar 2010 01:50:17 -0700 (PDT)
--- On Mon, 22/3/10, Klink, Andrew wrote:
> I am having a similar issue trying to restrict my y-axis, which
> cannot be circumvented by using "if yvar<=0", -yscale()-, or
> -ylabel()- options. The problem is that I am including a fitted
> line (-fpfitci- in this case) whose left end extends in negative
> values for yvar. It does not make sense to show the curve where
> y < 0; as such, I am trying to restrict the y-axis from 0 to
> 100. Any suggestions?
There is a subtle difference here. Graphs like -twoway fpfitci-,
-twoway lfit-, etc. are wrappers that combine fitting a model and
graphing the result. So what you see is the consequence of your
(implicit) model. You can adjust the model if you think the model
is inappropriate. I tried the -estcmd- and -estopts- and -predopts-
options, but it seemed to me that by default -fpfitci- plots the
linear predictor, and specifying -predopts(mu)- results in an error.
*-------------------- begin example --------------------------
sysuse auto, clear
// seems to plot the linear predictor rather than the
// predicted weight
twoway fpfitci weight mpg, estcmd(glm) estopts(link(log))
// produces the error message "option mu not allowed"
twoway fpfitci weight mpg, estcmd(glm) estopts(link(log)) predopts(mu)
*---------------------- end example --------------------------
However, since these are only convience commands, you can just as
easy reproduce these graphs from first principle:
*------------- begin example --------------------
sysuse auto, clear
fracpoly : glm weight mpg, link(log)
predict xb , xb
predict se , stdp
gen lb = exp(xb - invnormal(0.975)*se)
gen ub = exp(xb + invnormal(0.975)*se)
gen mu = exp(xb)
twoway rarea lb ub mpg, sort astyle(ci) || ///
line mu mpg, sort lpattern(solid)
*------------- end example ----------------------
Hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/