`rcopCAR`

simulates areal data from the copCAR model.

1 |

`rho` |
the spatial dependence parameter |

`beta` |
the vector of regression coefficients |

`X` |
the |

`A` |
the symmetric binary adjacency matrix for the underlying graph. |

`family` |
the marginal distribution of the observations and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See |

This function randomly generates Poisson or Bernoulli areal data with adjacency matrix *A* from the copCAR model with the given spatial dependence parameter *ρ*, regression coefficients *β = (β_1, …, β_p)'*, and design matrix *X*. For more details on the copCAR model, see `copCAR`

.

A vector of length *n* distributed according to the copCAR model with the given design matrix and parameter values.

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 | ```
## Not run:
require(lattice)
# Use the 20 x 20 square lattice as the underlying graph.
m = 20
A = adjacency.matrix(m)
# Set dependence parameter and regression coefficients.
rho = 0.8
beta = c(1, 1)
# Create design matrix by assigning coordinates to each vertex
# such that the coordinates are restricted to the unit square.
x = rep(0:(m - 1) / (m - 1), times = m)
y = rep(0:(m - 1) / (m - 1), each = m)
X = cbind(x, y)
# Draw Poisson data from copCAR model.
Z.pois = rcopCAR(rho, beta, X, A, family = poisson(link = "log"))
# Create a level plot of the simulated data.
dev.new()
levelplot(Z ~ x * y, aspect = "iso")
# Draw Bernoulli data from copCAR model.
Z.ber = rcopCAR(rho, beta, X, A, family = binomial(link = "logit"))
# Create a level plot of the simulated data.
dev.new()
levelplot(Z2 ~ x * y, aspect = "iso")
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.