# Detects clusters and computes their significance.

### Description

Detects clusters and computes their significance.

### Usage

1 2 3 |

### Arguments

`stfdf` |
spatio-temporal class object containing the data. See STFDF-class spacetime for details. It contains an object of class Spatial with the coordinates, a POSIXct object with the time, and a data.frame with vectors Observed, Expected and potential covariates in each location and time. |

`thegrid` |
two-columns matrix containing the points of the grid to be used. If it is null, a rectangular grid is built. |

`radius` |
maximum radius of the clusters. |

`step` |
step of the thegrid built. |

`fractpop` |
maximum fraction of the total population inside the cluster. |

`alpha` |
significance level used to determine the existence of clusters. |

`typeCluster` |
type of clusters to be detected. "ST" for spatio-temporal or "S" spatial clusters. |

`minDateUser` |
start date of the clusters. |

`maxDateUser` |
end date of the clusters. |

`R` |
If the cluster's significance is calculated based on the chi-square distribution, R is NULL. If the cluster's significance is calculated using a Monte Carlo procedure, R represents the number replicates under the null hypothesis. |

`numCPUS` |
Number of cpus used when using snowfall to run the method. If snowfall is not used numCPUS is NULL. |

`model0` |
Initial model (including covariates). This can be "glm" for generalized linear models (glm stats), "glmer" for generalized linear mixed model (glmer lme4), or "zeroinfl" for zero-inflated models (zeroinfl pscl). |

### Details

Searches all possible clusters with start and end dates within minDateUser and maxDateUser, so that the maximum fraction of the total population inside the cluster is less than fractpop, and the maximum distance to the center is less than radius. The search can be done for spatial or spatio-temporal clusters. The significance of the clusters is obtained with a Monte Carlo procedure or based on the chi-square distribution.

### Value

data frame with information of the detected clusters ordered by its log-likelihood ratio value. Each row represents the information of one of the clusters. It contains the coordinates of the center, the size, the start and end dates, the log-likelihood ratio, a boolean indicating if it is a cluster (TRUE in all cases), and the p-value of the cluster.

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.