Statalist


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

Re: st: Create graph directly from matrix?


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: Create graph directly from matrix?
Date   Mon, 16 Nov 2009 18:57:51 -0500

If you've been defeated or at least found it aversive to construct your own sersets, that's good enough for me. Temporary variables it is, which has the added advantage that it's then easy to add an option to keep the variables.

- Nick

On 11/16/2009 6:23 PM, Sergiy Radyakin wrote:
Well Nick, you would probably want to save your graph in a *.gph
format, and be able to restore it later. So the data for the graph
must be stored within the gph file. It is stored in sersets there. How
does it get into a serset is up to you. I prefer creating temporary
variables and let Stata's engine to do the sersets. I had a rather
unpleasant experience in dealing with them directly in one of the
earlier commands and decided to minimize their use in the future.

See this link, for the presentation plotting some matrices:
http://www.adeptanalytics.org/radyakin/stata/graphics/radyakin_graphics.htm

Best wishes, Sergiy Radyakin

On Mon, Nov 16, 2009 at 11:38 AM, Nick Winter <[email protected]> wrote:
Hi,

I'm wondering if there is a way to convert the values held into a matrix
into a graph (ie, into a serset that serves as the basis for a graph)
directly, without first making the matrix into variables?

Why I'm curious:

I'm thinking about revising my -oprobpr- command, which plots predicted
probabilities after order l/probit models.  The new -margins- command can
fairly easily calculate what's required for the plotting, and those results
can be saved as a matrix, using -margins-'s -post- option.

So I'd like to plot the estimates returned in e(b) against values in e(at).

I can put this stuff all together in one matrix, eg:

sysuse auto
probit foreign mpg price weight

margins, atmeans at(mpg=(12(2.9)41)) post
mat b = e(b)
mat X = e(at)
mat Xy = X , b'

Then I'd like to create, eg, a line plot of the final column (named y1)
against the first column (mpg).

I can, of course, use -svmat-, graph the relevant variables, and drop the
variables.

But I'd love a more elegant solution.

Cheers,
Nick Winter

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   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/


*
*   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/

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index