jc.test: A function to compute joint-count test for binomial and...

jc.testR Documentation

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())

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.

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.

Control arguments

nsim number of permutations used in the Monte Carlo distribution. Default nsim = 999.
seedinit seed to select the initial element during the simulations. Default seedinit = 1111.
adjust.n default *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.
spChk should 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.
sampling default *nonfree*, may be *free*. See joincount.test for additional information.
queen default *TRUE*. Defines the neighborhood criteria for *sf* objects.
style defines the style for listw. Default = *B* (binary).
knn chooses the number of neighboors when this criteria is used. Default knn = 5.

Author(s)

Fernando López fernando.lopez@upct.es
Román Mínguez roman.minguez@uclm.es
Antonio Páez paezha@gmail.com
Manuel Ruiz manuel.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


## Case 1
## Multinomial + Binomial using a sf multipolygon

data("provinces_spain")
sf::sf_use_s2(FALSE)
provinces_spain$Male2Female <- factor(provinces_spain$Male2Female > 100)
levels(provinces_spain$Male2Female) = 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 + Male2Female
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 <- ~ Male2Female + 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)


spqdep documentation built on March 28, 2022, 5:06 p.m.