Robin! Really!!! ***Look*** at the code for your ``kdid'' function!
And look at all those bizarre plus signs!!!
They are .... well, plus signs. They mean ``add''.
So you're getting an expression which is syntactically valid,
but which is conceptually meaningless. And which does not define
a function ``Kidot''. So no wonder poor old R couldn't find such a
function.
You must have copied and pasted the code from an R session
where R prints the "+" symbol as a line-continuation symbol.
You have to edit out those plus signs.
Your code should read:
kdid <- function(X,..., i) {
Kidot <- Kdot(X,..., i=i)
K <- Kest(X,...)
dif <- eval.fv(Kidot-K)
return(dif)
}
I tried this out on the amacrine data (since I of course don't have
"B10size"
to play with):
E <- envelope(amacrine, kdid, nsim=39, i="on", simulate =
expression(rlabel(amacrine)))
and it ran like a charm.
cheers,
Rolf
On 28/11/11 17:30, 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
> [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo