Package 'starm'

Title: Spatio-Temporal Autologistic Regression Model
Description: Estimates the coefficients of the two-time centered autologistic regression model based on Gegout-Petit A., Guerin-Dubrana L., Li S. "A new centered spatio-temporal autologistic regression model. Application to local spread of plant diseases." 2019. <arXiv:1811.06782>, using a grid of binary variables to estimate the spread of a disease on the grid over the years.
Authors: Yannis Barboni [aut, cre], Anne Gegout-Petit [aut], Shuxian Li [aut]
Maintainer: Yannis Barboni <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2024-11-02 06:29:17 UTC
Source: CRAN

Help Index


Creation of the neighbourhood's matrix.

Description

Creation of the neighbourhood's matrix.

Usage

build(data = 0, vx = 3, vy = 3, dx = 1, dy = 1, selec = FALSE,
  t = 0, norm = "euclidean", returnplot = FALSE)

Arguments

data

dataset with first column the X-coordinates of the sites and the second the Y-coodinates of the sites.

vx

integer, first parameter of the neighbourhood ( i.e. first parameter of ellipse if norm = "euclidean" for instance). vx = 3 by default.

vy

integer, second parameter of the neighbourhood ( i.e. second parameter of ellipse if norm = "euclidean" for instance). vy = 3 by default.

dx

positive real, distance between sites on a row. dx = 1 by default.

dy

positive real, distance between sites on a column. dy = 1 by default.

selec

see t.

t

double. If selec = TRUE, each neighborhood will contain only elements which the type is in t (see examples).

norm

Response type : "euclidean" "inf" "abs" "lin". norm = "euclidean" by default.

returnplot

If TRUE, will return the plot of the most recent neighborhhod in addition to the neighborhood matrix.

Details

The function will return the neighborhood matrix of a dataset which must contain coodinates in the two first columns and a third column at least with the "type" of each site (it can be only "0" or "1" for example). The parameter norm let you choose between 4 sorts of neighborhood : 3 ellipses in norm 1, 2 or infinite (resp "abs","euclidean" and "inf") with the parameters vx and vy which are the width and the height of the ellipse, and the norm lin will condider only sites on the same row and column with the same parameters vx and vy.

Value

The neighborhood matrix

Note

If returnplot = TRUE, variable$plot will return an exemple of the choosen neighborhood on a center point of the dataset.

Examples

data <- plantillness
v <- which((data$NRang <= 20))
data <- data[v,]
v <- which(data$NCep <= 20)
data<-data[v,]
res <- build(data = data)



#Example with the plantillness dataset and the plot available :

res <- build(data = plantillness,returnplot = TRUE,vx = 5,vy = 5)



#Example with the plantillness dataset, only considering the sites of the type "0" :

res <- build(data = plantillness, selec = TRUE, t = c(0),vx = 5,vy = 7,norm = "inf")

Covariate data

Description

covplant is the dataset of the spatial covariate of the plantillness dataset. Each column can be used as a covariate along the plantillness dataset in the estima function. Each row of a selected covariate matches a point of the plantillness dataset, that's why there is no coordinates in the covplant dataset.

Usage

covplant

Format

An object of class data.frame with 2366 rows and 3 columns.

Details

  • $v1 spatial covariate

  • $v2 spatial covariate

  • $v3 spatial covariate

Source

no source


Estimation of parameters of autologistic regression model for data on a grid

Description

Estimation of parameters of autologistic regression model for data on a grid

Usage

estima(data = 0, covariate1 = NULL, covariate2 = NULL,
  covariate3 = NULL, norm = "euclidean", vxpresent = 3,
  vypresent = 3, vxpast = 3, vypast = 3, dx = 1, dy = 1,
  swpresent = TRUE, swpast = TRUE, graph = FALSE, pastcov = FALSE,
  buildpres = NULL, buildpast = NULL)

Arguments

data

dataset with the coordinates in the two first columns.

covariate1

spatio-temporal covariate. The covariate dataframe must have dim(data)[1] = dim(covariate)[1] (same numbers of individuals) and dim(data)[1] = dim(covariate)[1] + 3 as the covaiate dataset must not contain coordinates, but must match the coodinates of the dataset; and T-1 years (T is the number of years in the dataset "data") as the model needs the first year to initialize. See "User guides, package vignettes and other documentation" the "estima" vignette.

covariate2

spatio-temporal covariate. The covariate dataframe must have dim(data)[1] = dim(covariate)[1] (same numbers of individuals) and dim(data)[1] = dim(covariate)[1] + 3 as the covaiate dataset must not contain coordinates, but must match the coodinates of the dataset; and T-1 years (T is the number of years in the dataset "data") as the model needs the first year to initialize. See "User guides, package vignettes and other documentation" the "estima" vignette.

covariate3

spatio-temporal covariate. The covariate dataframe must have dim(data)[1] = dim(covariate)[1] (same numbers of individuals) and dim(data)[1] = dim(covariate)[1] + 3 as the covaiate dataset must not contain coordinates, but must match the coodinates of the dataset; and T-1 years (T is the number of years in the dataset "data") as the model needs the first year to initialize. See "User guides, package vignettes and other documentation" the "estima" vignette.

norm

"euclidean", "inf", "abs", "lin". norm = "euclidean" by default. See vignette Build.

vxpresent

positive real. Parameter of the ellipse for the tested neighborhood on x-axes in norm "norm" if swpresent = FALSE. If swpresent = TRUE, vxpresent will be the upper bound of the tested neighborhoods on x-axes in norm norm. See swpresent.

vypresent

positive real. Parameter of the ellipse for the tested neighborhood on y-axes in norm "norm" if swpresent = FALSE. If swpresent = TRUE, vypresent will be the upper bound of the tested neighborhoods on y-axes in norm norm. See swpresent.

vxpast

positive real. Parameter of the ellipse for the tested neighborhood on x-axes in norm "norm" if swpast = FALSE. If swpast = TRUE, vxpast will be the upper bound of the tested neighborhoods on x-axes in norm norm. See swpast. Only use if pastcov = TRUE.

vypast

positive real. Parameter of the ellipse for the tested neighborhood on y-axes in norm "norm" if swpast = FALSE. If swpast = TRUE, vypast will be the upper bound of the tested neighborhoods on y-axes in norm norm. See swpast. Only use if pastcov = TRUE.

dx

positive real : distance between sites on x-axis. dx = 1 by default.

dy

positive real : distance between sites on y-axis. dy = 1 by default.

swpresent

if TRUE the programm will test all possible neighborhood for the spatial autocorrelation (coefficient rho1) with parameters vxmaxpresent, vymaxpresent, dx and dy, otherwise the programm will test the neighborhood with the parameters vxpresent and vypresent. swpresent = TRUE by default.

swpast

if TRUE the programm will test all possible neighborhood for the autoregression on on the sum of the Zi,t-1 (coefficient Betapast) with parameters vxmaxpast, vymaxpast, dx and dy, otherwise the programm will test the neighborhood with the parameters vxpast and vypast. swpast = TRUE by default.

graph

if graph = TRUE, the program will also return the plot of the dataset for the last time (and the year before if estima = 3). graph = FALSE by default.

pastcov

boolen. If pastcov = TRUE, the function will use the past neighborhood as a covariate. See "User guides, package vignettes and other documentation" the "estima" vignette. pastcov = FALSE by default.

buildpres

boolean which allow the use of a custom neighborhood matrix. buildpres = NULL by default.

buildpast

boolean which allow the use of a custom neighborhood matrix. buildpast = NULL by default.

Details

See "User guides, package vignettes and other documentation" the "estima" vignette.

Value

list : estimate parameters using the pseudo-likelihood.

Examples

data <- plantillness
v <- which(data$NRang <= 10)
data <- data[v,]
v <- which(data$NCep <= 10)
data<-data[v,]
result <- estima(data = data)




#Example in "lin" norm, with a fixed neighborhood :

result <- estima(data = plantillness, norm = "lin",swpresent = FALSE,vxpresent = 3, vypresent = 4)



#Example with a spatial covariate (adapted to the dimension of the dataset) :

cov <- covplant[,1]
for (i in (1:(dim(plantillness)[2] - 4))){
 cov <- cbind(cov,covplant[,1])
}
result <- estima(data = plantillness,covariate1 = cov)



#Example with the past neighborhood as covariate:

result <- estima(data = plantillness,pastcov = TRUE)



#Exemple with a custom neighborhood matrix

custompres <- build(data = plantillness)
custompast <- build(data = plantillness, vx = 5,vy = 6)
result <- estima(data = plantillness,pastcov = TRUE,buildpres = custompres,buildpast = custompast)

Illness data

Description

plantillness is a dataset representing a vineyard of the Bordeaux region

Usage

plantillness

Format

An object of class data.frame with 2366 rows and 16 columns.

Details

  • $NRang : rows of the vines

  • $NCep : position in the row of the vines

  • $X2004 : state of the vine at the position (NRang,NCep) in 2004

  • $X2005 : state of the vine at the position (NRang,NCep) in 2005

  • $X2006 : state of the vine at the position (NRang,NCep) in 2006

  • $X2007 : state of the vine at the position (NRang,NCep) in 2007

  • $X2008 : state of the vine at the position (NRang,NCep) in 2008

  • $X2009 : state of the vine at the position (NRang,NCep) in 2009

  • $X2010 : state of the vine at the position (NRang,NCep) in 2010

  • $X2011 : state of the vine at the position (NRang,NCep) in 2011

  • $X2012 : state of the vine at the position (NRang,NCep) in 2012

  • $X2013 : state of the vine at the position (NRang,NCep) in 2013

  • $X2014 : state of the vine at the position (NRang,NCep) in 2014

  • $X2015 : state of the vine at the position (NRang,NCep) in 2015

  • $X2016 : state of the vine at the position (NRang,NCep) in 2016

  • $X2017 : state of the vine at the position (NRang,NCep) in 2017

Source

no source