[R-sig-eco] output from ordisurf

Jari Oksanen jari.oksanen at oulu.fi
Mon Oct 27 12:23:50 CET 2008


On Thu, 2008-10-23 at 14:44 -0500, Christopher Chizinski wrote:
> Is there a way to output the X,Y,Z values for the contour lines from 
> ordisurf?  
> 
> For example, I am using this statement:
> tmp<-with(enviro,ordisurf(fish.nmds,enviro$Temp,choices=c(1,2),add=TRUE))
> 
> names(tmp)
>  [1] "coefficients"      "residuals"         "fitted.values"   
>  [4] "family"            "linear.predictors" "deviance"        
>  [7] "null.deviance"     "iter"              "weights"         
> [10] "prior.weights"     "df.null"           "y"               
> [13] "converged"         "sig2"              "edf"             
> [16] "hat"               "boundary"          "sp"              
> [19] "nsdf"              "Ve"                "Vp"              
> [22] "mgcv.conv"         "gcv.ubre"          "aic"             
> [25] "rank"              "gcv.ubre.dev"      "method"          
> [28] "smooth"            "formula"           "cmX"             
> [31] "model"             "control"           "terms"           
> [34] "pterms"            "assign"            "offset"          
> [37] "data"              "df.residual"       "min.edf"         
> [40] "call"
> 
> I would like to get these XYZ values or find a way to calculate them 
> from the output for inclusion into SigmaPlot.  It is probably an easy 
> solution but I could not find what I needed.
> 
Dear Christopher Chizinski,

I assume you mean the ordisurf() function in the vegan package. If you
mean something else, this message is not appropriate and you may stop
reading. 

Function ordisurf (of vegan) returns visibly an object of function gam
of the mgcv package (like documented). You can use all mgcv:::gam tools
to handle this object, including predict.gam (of mgcv) which can be used
to predict new values of surface (z) for any values of the coordinates
(x, y). These results can be exported to SigmaPlot or anywhere. If you
look inside the function ordisurf, you can see how predict.gam is used
to find the predicted value of the surface for a grid of axis values.

I changed the ordisurf function in
http://r-forge.r-project.org/projects/vegan so that it now adds the data
used by the contour() function in a new item called "grid" in the
result. The returned data in "grid" contain vectors "x" and "y" for the
grid values on the axis, and matrix "z" for the fitted surface values
for each combination of "x" and "y" vectors. The values of "z" outside
the convex hull of observed site are marked as NA. You can directly
export these items or reuse them to draw the surface with the contour()
command. The grid item is available from vegan working version 1.16-3
(revision 532) in R-Forge, and Windows binary is available (probably)
from tomorrow morning (Central European Standard Time).

Best wishes, Jari Oksanen

-- 
Jari Oksanen <jari.oksanen at oulu.fi>



More information about the R-sig-ecology mailing list