Learn R Programming

spqdep (version 0.1.3.3)

jc.test: A function to compute joint-count test for binomial and multinomial (asymptotic and permutation distributions).

Description

A function to compute joincount tests for spatial qualitative data. This function is a wrapper of joincount.multi and joincount.test in spdep package.

Usage

jc.test(formula = NULL,
               data = NULL,
               fx = NULL,
               listw = NULL,
               na.action,
               zero.policy = NULL,
               distr = "asymptotic",
               alternative = "greater",
               control =list())

Value

An spjctest object. This type of object is a list of htest objects. The length of the list is the number of factor variables included in the

formula or the number of columns in fx. Each element of the list can be a

jclist object, for binomial factors, or a jcmulti object for multinomial factors. See joincount.test

or joincount.multi

for additional details.

Arguments

formula

a symbolic description of the factor(s).

data

an (optional) data frame or a sf object with points/multipolygons geometry containing the variable(s) to be tested.

fx

a factor or a matrix of factors in columns

listw

A listw object created for example by nb2listw from spdep package; if nb2listw not given, the spatial weights are built using the object given in listw argument (usually an sf object). Default = NULL.

na.action

A function (default options("na.action")), can also be na.omit or na.exclude. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations.

zero.policy

Similar to the corresponding parameter of lagsarlm function in spatialreg package. If TRUE assign zero to the lagged value of zones without neighbours. Default = NULL.

distr

character. Distribution type "asymptotic" (default) or "mc".

alternative

character string specifying the alternative hypothesis, must be one of "greater" (default), or "less".

control

list of additional arguments.

Control arguments

nsimnumber of permutations used in the Monte Carlo distribution. Default nsim = 999.
seedinitseed to select the initial element during the simulations. Default seedinit = 1111.
adjust.ndefault *TRUE*, if *FALSE* the number of observations is not adjusted for no-neighbour observations, if *TRUE*, the number of observations is adjusted consistently. See joincount.multi for aditional information.
spChkshould the data vector names be checked against the spatial objects for identity integrity, *TRUE*, or *FALSE*, default *NULL* to use *get.spChkOption()*. See joincount.multi for aditional information.
samplingdefault *nonfree*, may be *free*. See joincount.test for additional information.
queendefault *TRUE*. Defines the neighborhood criteria for *sf* objects.
styledefines the style for listw. Default = *B* (binary).
knnchooses the number of neighboors when this criteria is used. Default knn = 5.

Author

Fernando Lópezfernando.lopez@upct.es
Román Mínguezroman.minguez@uclm.es
Antonio Páezpaezha@gmail.com
Manuel Ruizmanuel.ruiz@upct.es

References

  • Cliff, A. D., Ord, J. K. 1981 Spatial processes, Pion, pp. 19-20.

  • Upton, G., Fingleton, B. 1985 Spatial data analysis by example: point pattern and qualitative data, Wiley, pp. 158–170.

See Also

print.summary.spqtest, joincount.test, joincount.multi

Examples

Run this code

## Case 1
## Multinomial + Binomial using a sf multipolygon
# \donttest{
data("provinces_spain")
# sf::sf_use_s2(FALSE)
provinces_spain$Mal2Fml <- factor(provinces_spain$Mal2Fml > 100)
levels(provinces_spain$Mal2Fml) = c("men","woman")
provinces_spain$Older <- cut(provinces_spain$Older, breaks = c(-Inf,19,22.5,Inf))
levels(provinces_spain$Older) = c("low","middle","high")
f1 <- ~ Older + Mal2Fml
jc1 <- jc.test(formula = f1,
               data = provinces_spain,
               distr = "mc",
               alternative = "greater",
               zero.policy = TRUE)
summary(jc1)

provinces_spain$Coast <- factor(provinces_spain$Coast)
levels(provinces_spain$Coast) = c("no","yes")
f2 <- ~ Mal2Fml + Coast
jc2 <- jc.test(formula = f2,
               data = provinces_spain,
               distr = "mc",
               zero.policy = TRUE)
summary(jc2)
# }

# Case 2:
## Multinomial using a sf multipoint
data("FastFood.sf")
# sf::sf_use_s2(FALSE)
f1 <- ~ Type
jc3 <- jc.test(formula = f1,
               data = FastFood.sf,
               distr = "asymptotic",
               control = list(knn = 6))
 summary(jc3)

# Examples function joincount.test
data(oldcol, package = "spdep")
HICRIME <- cut(COL.OLD$CRIME, breaks = c(0,35,80), labels = c("low","high"))
names(HICRIME) <- rownames(COL.OLD)
jc4 <- jc.test(fx = HICRIME,
               listw = spdep::nb2listw(COL.nb,
               style="B"))
summary(jc4)
 jc5 <- jc.test(fx = HICRIME,
                listw = spdep::nb2listw(COL.nb, style="B"),
                distr = "mc")
 summary(jc5)
 HICRIME <- cut(COL.OLD$CRIME, breaks = c(0, 35, 80),
                labels = c("low","high"))
 names(HICRIME) <- rownames(COL.OLD)
 jc6 <- jc.test(fx = HICRIME,
                listw = spdep::nb2listw(COL.nb,
                                 style = "B"))
summary(jc6)

Run the code above in your browser using DataLab