Hi Steve,

syrjala function  requires that the columns of the "coords" 
data.frame are named "x" and "y". From the help page of syrjala:

coords A data.frame with '$x' and '$y' components.

So you have only to rename it:

 > names(coords)=c("x","y")
 > syrjala(coords, var1, var2, 9999)
Cramer-von Misses test for the difference between
the spatial distributions of  var1 and var2
based on 9999 permutations.

    psi:     9.591629
    p-value: 0.0053

Kolmogorov-Smirnov test for the difference between
the spatial distributions of  var1 and var2
based on 9999 permutations.

    psi:     0.3895349
    p-value: 6e-04


HTH,

Marcelino

At 22:01 06/05/2011, Steve Hong wrote:
>Hi Marcelino,
>
>Using the attached data sets from the previous email, I conducted 
>this analysis below.  In summary, I aggregated duplicated rows 
>within each data set.  And then, I selected duplicated rows between 
>two data sets and extract them to make new data set.  After then, I 
>compared distribution between two readings using 'syrjala' in 
>'ecespa'.  However, I got an error message.  I could not figure out 
>what I did wrong.  The code and error message are below.  If anyone 
>has suggestion and/or comment, I would greatly appreciate.
>
>Thanks!!
>
>Steve
>
>## Combine insect abundance within the same pairs of coordinates 
>within data set
>#n.df96 <- df96[!duplicated(df96[, c("n.longi", "n.lati")]),]
>#n.df97 <- df97[!duplicated(df97[, c("n.longi", "n.lati")]),]
>n.df96 <- aggregate(x=df96$gjb, by = list(df96$n.longi, 
>df96$n.lati), FUN = "sum")
>n.df97 <- aggregate(x=df97$gjb, by = list(df97$n.longi, 
>df97$n.lati), FUN = "sum")
>nrow(n.df96)
>nrow(n.df97)
># Rename column names
>colnames(n.df96) <- c("n.longi", "n.lati", "x")
>colnames(n.df97) <- c("n.longi", "n.lati", "x")
>n.df96$year <- rep(1996, nrow(n.df96))
>n.df97$year <- rep(1997, nrow(n.df97))
>## Select duplicated rows between two data set
>library(sp)
>head(n.df96)
>n.crd96 <- SpatialPoints(cbind(n.df96$n.longi, n.df96$n.lati))
>n.crd97 <- SpatialPoints(cbind(n.df97$n.longi, n.df97$n.lati))
>dn <- zerodist2(n.crd96, n.crd97, zero=0)
># Get duplicated rows in two data sets using row information in'dn'
>s.df96 <- n.df96[dn[,1],]
>s.df97 <- n.df97[dn[,2],]
># Checking long lat between two years to make sure the differences 
>are all zeros.
>s.df96$n.longi-s.df97$n.longi
>s.df96$n.lati-s.df97$n.lati
># Combine two data
>f.df <- data.frame(cbind(s.df96, s.df97))
>head(f.df)
># Compare distribution of two species
>library(ecespa)
>library(spatstat)
>coords <- data.frame(f.df$n.longi, f.df$n.lati)
>var1 <- f.df$x
>var2 <- f.df$x.1
>syrjala(coords, var1, var2, 9999)
>
>Error in syrjala(coords, var1, var2, 9999) :
>   `coords` contains no $x or $y component.
>
>
>
>On Thu, Apr 28, 2011 at 5:44 AM, Marcelino de la Cruz 
><<mailto:marcelino.delacruz@upm.es>marcelino.delacruz@upm.es> wrote:
>Hi Steve,
>
>For Syrjala's you must use the same coordinates.
>
>To make the locations to the same longitude and latitude (i.e., to 
>the longitude and latitude of the same cell of the grid were each 
>set of "slightly different" beong) you must first define your grid 
>(i.e., the limits of each cell).
>For example,  lets say that your longitude and or 
>latitude  data  goes from 0 to 1000 in wathever units and you think 
>it is convenient to define  a grid of 100 x 100:
>
>xgrid <- seq(from=0, to = 1000, by=100)
>ygrid <- seq(from=0, to = 1000, by=100)
>
>Now you can assign each of your observations (e.g. "mylatitude" and 
>"mylongitude") to one of the cells that you have just defined:
>
>newlatitude <- as.numeric(cut(mylatitude, xgrid))
>newlongitude <- as.numeric(cut(mylongitude, xgrid))
>
>This new latitude and longitude are not in the same units that the 
>original latitude and longitude meassurements, but to run Syrjala's 
>test is enough. If you want to transform to the original coordinate 
>system, assigning to each cell the coordinat of its center, you must 
>multiply each newlatitude and newlongitude  by the increment of the 
>sequence and add the lower x and y limits. In the above example:
>
>newlatitude2 <- newlatitude* 100 + 0
>newlongitude2 <- newlongitude* 100 + 0
>
>Cheers,
>
>Marcelino
>
>
>
>At 03:37 28/04/2011, Steve Hong wrote:
>>Thank you Marcelino for your response.
>>
>> From my understanding, Syrjala's test use the same coordinate 
>> readings.  In that case do I have to make the "slightly different" 
>> locations to the same longitude and latitude?  Or is there a way 
>> to use two different coordinates?  If I have to make the locations 
>> to the same longitude and latitude, do you have any efficient way 
>> to do that?  I have total about 13000 obs for 14 years.  If there 
>> is a way to convert different locations within certain criteria 
>> into the same locations, would you please let me know?
>>
>>Thanks again!!!
>>
>>Steve
>>
>>On Tue, Apr 26, 2011 at 3:58 AM, Marcelino de la Cruz 
>><<mailto:marcelino.delacruz@upm.es> marcelino.delacruz@upm.es> wrote:
>>Just one more suggestion:
>>If you can assume that the "slightly different" locations are 
>>inside the same cell of the grid, you could consider using 
>>Syrjala's test (although it deals with testing difference between 
>>the spatial distributions of two populations irrespectively of each 
>>species abundance).
>>See 
>><http://finzi.psych.upenn.edu/R/library/ecespa/html/syrjala.html>http://finzi.psych.upenn.edu/R/library/ecespa/html/syrjala.html
>>Marcelino
>>
>>
>>
>>At 15:<tel:57%2018%2F04%2F2011>57 18/04/2011, Steve Hong wrote:
>>>Thank you for all valuable comments and suggestions.
>>>I will try those methods in the comments and will post questions/progresses
>>>whether or not it is successful in my particular case.
>>>Thank you very much again!!
>>>Steve
>>>On Fri, Apr 15, 2011 at 4:27 PM, Steve Hong 
>>><<mailto:emptican@gmail.com>emptican@gmail.com> wrote:
>>> > Dear List,
>>> >
>>> > I hope this is not a redundant question.  I tried to find the issue from
>>> > the previous lists but could not find although there are 
>>> several comments
>>> > about comparing two species distribution in the same area and 
>>> coordinates.
>>> >
>>> > I have a data set with species counts in a study area, however, the GPS
>>> > location is slightly different from species to species.  The 
>>> sampling was
>>> > conducted in a grid pattern covering uniformly the area.
>>> >
>>> > My question are:
>>> > Is there any package(s) and/or way(s) to compare spatial distribution of
>>> > two species with different coordinate readings in the same study area?
>>> > If so, is there any (potential) problem(s) in doing that?
>>> >
>>> > Thanks for your any comment and suggestion in advance!
>>> >
>>> > Steve
>>> >
>>> >
>>> >
>>> >
>>>          [[alternative HTML version deleted]]
>>>
>>>_______________________________________________
>>>R-sig-Geo mailing list
>>><mailto:R-sig-Geo@r-project.org>R-sig-Geo@r-project.org
>>>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>____________________________________
>
>Marcelino de la Cruz Rot
>Depto. Biologia Vegetal
>EUIT Agricola
>Universidad Politecnica de Madrid
>
>tel: 34 + 913365435
>____________________________________
>
>____________________________________
>
>Marcelino de la Cruz Rot
>Depto. Biologia Vegetal
>EUIT Agricola
>Universidad Politecnica de Madrid
>
>tel: 34 + 913365435
>____________________________________
>
>
>Content-Type: text/plain; charset=US-ASCII; name="df96.txt"
>Content-Disposition: attachment; filename="df96.txt"
>X-Attachment-Id: f_gndjtrg20
>
>Content-Type: text/plain; charset=US-ASCII; name="df97.txt"
>Content-Disposition: attachment; filename="df97.txt"
>X-Attachment-Id: f_gndjub481

____________________________________

Marcelino de la Cruz Rot
Depto. Biologia Vegetal
EUIT Agricola
Universidad Politecnica de Madrid

tel: 34 + 913365435
____________________________________  
	[[alternative HTML version deleted]]

