[R] SDMTools package - calculating overlap?

David Winsemius dwinsemius at comcast.net
Mon Jul 18 17:22:05 CEST 2011


On Jul 18, 2011, at 11:07 AM, Ana Kolar wrote:

> Dear David,
>
> The toy example doesn't represent functions as such, but represents  
> type of data that I'm operating with. These data are product of an  
> analysis. If I understand you correctly, I would need to approximate  
> distribution functions of these data first and then integrate. This  
> makes sense, but any suggestion/ideas of how to do it in R?

Here's the deal.... posters are expected to read the Posting Guide and  
make good faith efforts at applying the information they get to their  
data using the help page information. In there you should find that  
the expectations on posts includes you providing as complete a  
description as will be needed to address the question. Data, code and  
error messages.... all should be included.

I also see no evidence that you have made any such attempt to use any  
of the functions I have pointed you to. The Posting Guide imposes a  
responsibility that you will consult the archives.  There are tons of  
worked examples in the archives of using `stepfun` or `approxfun`  
together with `integrate`.

RSiteSearch used to search the archives for you but they changed it in  
recent years, so I now use a modified version of it:

rhelpSearch <- function(string,
                   restrict = c("Rhelp10", "Rhelp08", "Rhelp02",  
"functions" ),
                   matchesPerPage = 100, ...)
          RSiteSearch(string=string,  restrict = restrict,
                      matchesPerPage = matchesPerPage, ...)

Try this:

rhelpSearch("approxfun integrate")

The answer by Lumley in the first ten itmes)  looks directly applicable.

-- 
David.
>
> Many thanks!
>
> Best regards,
>
> Ana
>
> From: David Winsemius <dwinsemius at comcast.net>
> To: Ana Kolar <annakolar at yahoo.com>
> Cc: R <r-help at r-project.org>
> Sent: Monday, 18 July 2011, 16:41
> Subject: Re: [R] SDMTools package - calculating overlap?
>
>
> On Jul 18, 2011, at 10:11 AM, Ana Kolar wrote:
>
> > Yes, indeed! I believe I should integrate differences of min of  
> both functions, no? I'm not quite sure how this should be done in R  
> therefore I was wondering if there are some build in functions that  
> do this job already. If not I would appreciate any help of how  
> should it be done otherwise.
>
> ?integrate  # would seem to be the glaringly obvious help query
>
> >
> > Toy example of data is here:
> >
> > a <- matrix(runif(30))
> > b <- matrix(runif(30))
>
> That's not a well-defined example of functions even if we take the  
> index to be the x value. Presumably you have some sort of value in  
> mind for "a" at an x-value of 1.5 but it is not clear from what you  
> have presented.
>
> ?stepfun
> ?approxfun
>
>
> A function takes inputs (on some continuous measurement scale) and  
> returns results. Perhaps you should be seeking some local  
> mathematical/statistical consulting resource.
>
> --David.
>
> >
> > I tried to calculate this overlap with "Istat" function but am not  
> sure that it does the job right! This is the example:
> >
> > library(SDMTools)
> > a <- matrix(runif(30))
> > b <- matrix(runif(30))
> > Istat(a,b)
> >
> > Many thanks for your response, David!
> >
> > Ana
> >
> >
> >
> > From: David Winsemius <dwinsemius at comcast.net>
> > To: Ana Kolar <annakolar at yahoo.com>
> > Cc: R <r-help at r-project.org>
> > Sent: Monday, 18 July 2011, 15:45
> > Subject: Re: [R] SDMTools package - calculating overlap?
> >
> >
> > On Jul 18, 2011, at 9:40 AM, Ana Kolar wrote:
> >
> > > Dear R users,
> > >
> > > Any idea of how to calculate an area of an overlap between two  
> functions? The only R build in function that I found is I Similarity  
> Statistic for Quantifying Niche Overlap and I am really not sure if  
> this function is producing exactly what I am interested in since I  
> was plotting functions and often got confused results (for example:  
> got high value for the overlap of one pair and low for the other  
> pair, while from the plot it looked like the first pair was  
> overlapping better.) Can anyone please explain what's the reason  
> behind such a behaviour? And does anyone has a suggestion of what  
> function could be used for a calculation of an overlap area? The  
> problem with 'Istat' function is also that it requires both data  
> sets to have the same length, while I would be more interested in a  
> function that enables overlap calculation even if data sets have  
> different length. Looking forward to hearing from you! Have a good  
> day. Ana
> >
> > Shouldn't you be integrating their difference (or the absolute  
> value of their differences depending on your definition of  
> "overlap"). I fail in understanding your example. Where is/are the  
> function(s)?
> >
> > >
> > > library(SDMTools)
> > > a <- matrix(runif(30))
> > > b <- matrix(runif(30))
> > > Istat(a,b)
> > >    [[alternative HTML version deleted]]
> > --
> > David Winsemius, MD
> > West Hartford, CT
> >
> >
> >
>
> David Winsemius, MD
> West Hartford, CT
>
>
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list