# observed.sim: Randomly Generate Observed Cases from Different Statistical... In DCluster: Functions for the Detection of Spatial Clusters of Diseases

## Description

Simulate Observed number of cases according to a Multinomial, Poisson or Negative Binomial distribution.

These functions are used when performing a parametric bootstrap and they must be passed as argument ran.gen when calling function boot.

multinom.sim generates observations from a Multinomial distribution.

poisson.sim generates observations from a Poisson distribution.

negbin.sim generates observations from a Negative Binomial distribution.

## Usage

 ```1 2 3 4 5``` ```multinom.sim(data, mle=NULL) poisson.sim(data, mle=NULL) negbin.sim(data, mle=NULL) ```

## Arguments

 `data` A dataframe as described in the DCluster manual page. `mle` List containing the parameters of the distributions to be used. If they are not provided, then they are calculated from the data. Its value argument mle in function boot. The elements in the list depend on the distribution to be used: Multimonial Total observed cases (n) and vector of probabilities (p). Poisson Total number of regions (n) and vector of means (lambda). Negative Binomial Total number of regions (n) and parameters nu and alpha of the Gamma distribution.

## Value

A dataframe equal to the argument data, but in which the Observed column has been substituted by sampled observations. See DCluster manual page for more details.

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16``` ```library(spdep) data(nc.sids) sids<-data.frame(Observed=nc.sids\$SID74) sids<-cbind(sids, Expected=nc.sids\$BIR74*sum(nc.sids\$SID74)/sum(nc.sids\$BIR74)) sids<-cbind(sids, x=nc.sids\$x, y=nc.sids\$y) #Carry out simulations datasim<-multinom.sim(sids, mle=calculate.mle(sids, model="multinomal") ) #Estimators for Poisson distribution datasim<-poisson.sim(sids, mle=calculate.mle(sids, model="poisson") ) #Estimators for Negative Binomial distribution datasim<-negbin.sim(sids, mle=calculate.mle(sids, model="negbin") ) ```