Hi Robin,

I bet you are beginning with R ;-)

The problem is that you tried to reproduce even 
the plus signs of the ASPP example.
Those '+' signs are printed by R at the begining 
of new lines to indicate continuation of the 
code, but you are not suposed to include them in your code.

You should  better order your function like this:


kdid <- function(X,..., i) {
    Kidot <- Kdot(X,..., i=i)
    K <- Kest(X,...)
   dif <- eval.fv(Kidot-K)
   return(dif)
  }

Just source this (or copy and paste on the R GUI) and try this


 > E2 <- envelope(amacrine, kdid, nsim = 39, i = 
"on", simulate = expression(rlabel(amacrine)))
Generating 39 simulations by evaluating expression  ...
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39.

Done.




Cheers,
Marcelino



At 05:30 28/11/2011, Robin W Hunnewell wrote:
>Dear all,
>
>I'd like to evaluate a null hypo of 'conditional 
>independence' on a marked point pattern dataset. 
>In scenario of random labelling: given the point 
>locations, marks attached to points are 
>conditionally independent and identically 
>distributed. Marks can be randomly reshuffled 
>among the full set of available points making up the overall pattern.
>
>To test this, I want to use the 'rlabel' 
>function in spatstat -- which performs a 
>resampling operation, allowing you to hold the 
>point locations fixed and shuffle the marks, 
>e.g., by randomly permuting them among all points in the pattern.
>
>In 'Analyzing Spatial Pt Patterns in R' (2010) 
>there's an example of how to set up a test 
>statistic for this, but for the life of me can't seem to reproduce it.
>
>The ASPP in R example suggests a nice way to do 
>it by evaluating the difference btw 'JDot' and 'Jest' as follows;
># cook up a little function to evaluate Ji•(r) âˆ’ J(r):
>
> >
> > Jdif <- function(X, ..., i) {
>+ Jidot <- Jdot(X, ..., i = i)
>+ J <- Jest(X, ...)
>+ dif <- eval.fv(Jidot - J) return(dif)
>+}
>
> > E <- envelope(amacrine, Jdif, nsim = 39, i = 
> "on", simulate = expression(rlabel(amacrine)))
>
>
>I tried to modify this to 'Kdot' and 'Kest' for 
>my own multitype point pattern and run the test using 'envelope' as above,
>
> > kdid <- function(X,..., i) {+ Kidot <- 
> Kdot(X,..., i=i) + K <- Kest(X,...) + dif <- eval.fv(Kidot-K) + return(dif)}
>
># but when I do 'envelope',
> > E <- envelope(B10size, kdid, nsim=39, 
> i="mega", simulate = expression(rlabel(B10size)))
>
># get following error,
>Error in get(x, envir = ee) : object 'Kidot' not found
>
>
>Have I just goofed the syntax and missed 
>something basic about how to functions?
>Thanks if anyone can help out as to where I'm going wrong?
>
>Robin
>
>
>------------------------------------------
>Robin Hunnewell
>University of New Brunswick
>Fredericton, NB
>Canada
>
>_______________________________________________
>R-sig-Geo mailing list
>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
____________________________________  
	[[alternative HTML version deleted]]

