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: 3D Surface Plot Interpolation
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: 3D Surface Plot Interpolation
Date
Wed, 24 Jul 2013 18:20:08 +0000
Sergiy,
Yes, -twoway contour- does have some interpolation features but the methods are specific to contour plots (based on cuts of the y-variable rather than dividing the x- and y-variables into smaller pieces). Moreover, -twoway contour- does not provide the interpolated values as an intermediate step (although going through the .ado file one can find the mata functions that do this and re-purpose them for some other project).
You are right that contour plots could be adequate for many situations, but for aesthetic reasons, I think some people like surface plots. I got interested in this because I had someone with a data set with sparse x and y values and the SAS surface plot (dividing each unit in x and y into 10 subunits) was much nicer to look at than either the contour or surface modules in Stata.
I did find the Fortran code for Akima's algorithm and I also have Bill's Mata Matters article on Fortran->Mata conversion, so I think I will just plow ahead with that. Putting the resulting data set into -surface- should do the trick.
Thanks for your suggestions!
Regards,
Joe
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Sergiy Radyakin
Sent: Wednesday, July 24, 2013 1:44 PM
To: [email protected]
Subject: Re: st: 3D Surface Plot Interpolation
Hi Joe,
Recently Stata added support for contour plots, I assume there is a similar task there, to smooth the color transitions. Check them out for bits and pieces. Perhaps you don't need a 3D plot after all, and can simply produce a contour plot?
That said, smoothing and plotting are two separate tasks, though some of the Stata commands like lowess do both.
for smoothing check Kolenikov's message:
http://www.stata.com/statalist/archive/2012-01/msg00355.html
Akima's algorithm is here:
http://dl.acm.org/citation.cfm?doid=79505.79510
the article seems to require a purchase, but the code was available for download (Fortran).
After smoothing is done in Stata, plotting can be done with either the user-written command you quoted, or by means of exporting to e.g.
Excel, which supports surface plots.
Best, Sergiy
On Wed, Jul 24, 2013 at 10:17 AM, Joe Canner <[email protected]> wrote:
> At the recent Stata Conference "wishes and grumbles" session, several of us expressed interest in 3D Surface plots. StataCorp did not give much reason for optimism in this area. There is currently a user-written module "surface" which does an OK job of 3D surface plots, but does not have a feature for interpolating and smoothing.
>
> In SAS, for example, there is PROC G3GRID, which provides a data set with interpolated/smoothed points which can then be plotted with PROC G3D. G3GRID uses, among other methods, an interpolation method by Akima (1978) which involves forming triangles with existing (x,y) points, fitting a quintic bivariate polynomial for the three vertices of the triangle, and using the resulting model to fill in additional interpolated points.
>
> There is a set of Fortran subroutines for this algorithm and I would like to try my hand at converting them to Mata, but before I spend a lot of time doing that, is anybody aware of existing Stata functions or commands (user-written or native) that are available for this?
>
> Thanks,
> Joe Canner
> Johns Hopkins University School of Medicine Department of Surgery
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/