Bookmark and Share

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: Re: st: modify axis range in scatter graphs


From   "Klink, Andrew" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: Re: st: modify axis range in scatter graphs
Date   Tue, 23 Mar 2010 13:20:38 -0400

Thank you, Maarten. That is very helpful.

There is one caveat: when I graphed the curve using the post-estimation
variables as you suggest, it generates the same shape curve, but on a
different scale on the y-axis. The initial -fpfitci- I ran generated a curve
whose y-axis range is within 0-1 (or as a percent: 0-100, as it will be
labeled). When I graph the curve from the generated variables as you
describe, the y-axis range is from 0.5-3 (the curve should remain within
0-1). I can get around this by ylabel(.5(.5)3 .5"0" 1"20" 1.5"40" 2"60"
2.5"80" 3"100") to make it look exactly like the initial -fpfitci- graph.
However, this may artificially shrink the real 95% CI. What should I look
into to correct the y-axis issue?
-- 
Andrew Klink, MPH
Senior Clinical Research Assistant
Children's Hospital of Philadelphia

--- 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index