Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: modify axis range in scatter graphs


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index