Skip to content

[Fwd: Re: [R-sig-Geo] Windows binaries for DCluster updated]

1 message · Virgilio Gómez Rubio

#
Hi,
Thank you!
Well, I think you can write your own function to do that and pass it to
opgam as argument 'iscluster'. The default value is
'opgam.iscluster.default':

opgam.iscluster.default<-function (data, idx, idxorder, alpha, ...)
{
    localO <- sum(data$Observed[idx])
    localE <- sum(data$Expected[idx])
    if (localE == 0)
        return(c(localO, NA, NA))
    localP <- sum(data$Population[idx])
    pvalue <- ppois(localO, localE, lower.tail = FALSE)
    return(c(localO, alpha > pvalue, pvalue))
}

What you can do is to change the line where the pvalue is calculated
and, instead of using 'ppois' use a function that performs a Monte Carlo
test. Probably you will not need localR nor localP if you use Monte
Carlo.

So, the function could be simething like:

montecarlo.iscluster<-function(data, idx, idxorder, alpha, ...)
{
	localO <- sum(data$Observed[idx])
	pvalue <- return_pvalue_from_monte_carlo_simulations(data, localO) 
	return(c(localO, alpha > pvalue, pvalue))
}

where 'return_pvalue_from_monte_carlo_simulations' performs the M.C.
simulations and compare localO with the values obtained to compute
the pvalue.

I hope it's clear... if not, just tell me. :D
Not at the moment, but 'opgam' returns the coordinates of the centres of
the balls that were significant, so I guess that you can use other R
packages to calculate a density from this table.

I have also written some code (not released yet) to calculate how many
times a centroid is included in these circles, in case you are
interested. I know it's not GAM/K but it can be useful for some
purposes...

Best regards,