|
| 1 | +methods::setGeneric("slm", function(data, ...) standardGeneric("slm")) |
| 2 | + |
| 3 | +.slm_sf_method= \(data,x,y=NULL,z=NULL, |
| 4 | +k=4,step=20,alpha_x=0.77,alpha_y=0,alpha_z=0, |
| 5 | +beta_xy=0,beta_xz=0,beta_yx=0,beta_yz=0,beta_zx=0,beta_zy=0, |
| 6 | +threshold=1e10,nb=NULL){ |
| 7 | +vx= .uni_lattice(data,x,FALSE) |
| 8 | +vy= .uni_lattice(data,y,FALSE) |
| 9 | +vz= .uni_lattice(data,z,FALSE) |
| 10 | +if (is.null(nb))nb= .internal_lattice_nb(data) |
| 11 | +return(.bind_slm(RcppSLMTri4Lattice(vx,vy,vz,nb,k,step,alpha_x,alpha_y,alpha_z,beta_xy,beta_xz,beta_yx,beta_yz,beta_zx,beta_zy,threshold),y,z)) |
| 12 | +} |
| 13 | + |
| 14 | +.slm_spatraster_method= \(data,x,y=NULL,z=NULL, |
| 15 | +k=4,step=20,alpha_x=0.77,alpha_y=0,alpha_z=0, |
| 16 | +beta_xy=0,beta_xz=0,beta_yx=0,beta_yz=0,beta_zx=0,beta_zy=0, |
| 17 | +threshold=1e10){ |
| 18 | +mx= .uni_grid(data,x,FALSE) |
| 19 | +my= .uni_grid(data,y,FALSE) |
| 20 | +mz= .uni_grid(data,z,FALSE) |
| 21 | +return(.bind_slm(RcppSLMTri4Grid(mx,my,mz,k,step,alpha_x,alpha_y,alpha_z,beta_xy,beta_xz,beta_yx,beta_yz,beta_zx,beta_zy,threshold),y,z)) |
| 22 | +} |
| 23 | + |
| 24 | +#' spatial logistic map |
| 25 | +#' |
| 26 | +#' @param data observation data. |
| 27 | +#' @param x first spatial variable. |
| 28 | +#' @param y (optional) second spatial variable. |
| 29 | +#' @param z (optional) third spatial variable. |
| 30 | +#' @param k (optional) number of neighbors to used. |
| 31 | +#' @param step (optional) number of simulation time steps. |
| 32 | +#' @param alpha_x (optional) growth parameter for x. |
| 33 | +#' @param alpha_y (optional) growth parameter for y. |
| 34 | +#' @param alpha_z (optional) growth parameter for y. |
| 35 | +#' @param beta_xy (optional) cross-inhibition from x to y. |
| 36 | +#' @param beta_xz (optional) cross-inhibition from x to z. |
| 37 | +#' @param beta_yx (optional) cross-inhibition from y to x. |
| 38 | +#' @param beta_yz (optional) cross-inhibition from y to z. |
| 39 | +#' @param beta_zx (optional) cross-inhibition from z to x. |
| 40 | +#' @param beta_zy (optional) cross-inhibition from z to y. |
| 41 | +#' @param threshold (optional) set to `NaN` if the absolute value exceeds this threshold. |
| 42 | +#' @param nb (optional) neighbours list. |
| 43 | +#' |
| 44 | +#' @return A list |
| 45 | +#' @export |
| 46 | +#' |
| 47 | +#' @name slm |
| 48 | +#' @rdname slm |
| 49 | +#' @aliases slm,sf-method |
| 50 | +#' @references |
| 51 | +#' Willeboordse, F.H., The spatial logistic map as a simple prototype for spatiotemporal chaos, Chaos, 533–540 (2003). |
| 52 | +#' |
| 53 | +#' @examples |
| 54 | +#' columbus = sf::read_sf(system.file("case/columbus.gpkg", package="spEDM")) |
| 55 | +#' columbus$inc = sdsfun::normalize_vector(columbus$inc) |
| 56 | +#' slm(columbus,"inc") |
| 57 | +#' |
| 58 | +methods::setMethod("slm", "sf", .slm_sf_method) |
| 59 | + |
| 60 | +#' @rdname slm |
| 61 | +methods::setMethod("slm", "SpatRaster", .slm_spatraster_method) |