qasy: A funcion to compute q test for spatial qualitative data...

Description Usage Arguments Details Value Examples

View source: R/qasy.R

Description

This function ....

Usage

1
2
3
qasy(formula = NULL, data = NULL, na.action,
            m = 3, r = 1, type = "p", control = NULL,
            xf = NULL, coord = NULL)

Arguments

m

length of m-surrounding

r

solapamiento máximo entre cualesquiera dos m-surroundings

distr

distribución entre "asymptotic" (default) o "bootstrap"

control

Argumento opcional.

xf

input sf object with points/multipolygons geometry or matrix of spatial coordinates

type

"p" or "c"

typems

type of m-surrounding ("cbl","cdt","no"). Default = "no"

distance

Dentro de control: character dando tipo de distancia a calcular. Default = "Euclidean" for Cartesian coordinates only: one of Euclidean, Hausdorff or Frechet; for geodetic coordinates, great circle distances are computed (see sf::st_distance())

nsim

Dentro de control: número de simulaciones para distribución bootstrap. Default = 999

seedinit

Dentro de control: semilla inicial para selección observación inicial en algoritmo para obtener m-surroundings o para iniciar proceso bootstrap

Details

Aquí Antonio escribe una linda historia

Value

Por definir, probablemente un objeto tipo spq que herede también de h-test, ANOVA test o similar...

Examples

 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Ejemplos Fernando
# Ejemplo 1
data("FastFood")
# Add other dependent variable to test...
FastFood.sf$TypeII <- sample(FastFood.sf$Type,
  length(FastFood.sf$Type), replace = TRUE)
f1 <- ~ Type + TypeII
vm <- c(3, 4)
vr <- c(1, 2, 3)
lq <- qasy(formula = f1, data = FastFood.sf, m = vm, r = vr,
           distr = "asymptotic",
           #typems = "no",
           control = list(distance = "Euclidean",
           seedinit = 1111))
summary(lq)
summary.spqtest(lq)
lq
lqboot <- qasy(formula = f1, data = FastFood.sf, m = vm, r = vr,
           distr = "bootstrap",
           #typems = "no",#'
           control = list(distance = "Euclidean",
           seedinit = 1111, nsim = 50))
 # Ejemplo 2

data("Spain")
f1 <- ~ COSTA
lq <- qasy(formula = f1, data = spain.sf, m = 4, r = 3,
           typems = "no", control = list(seedinit = 1111))
summary(lq)
lq
# Examples with multipolygons
library(sf)
fname <- system.file("shape/nc.shp", package="sf")
nc <- st_read(fname)
qb79 <- quantile(nc$BIR79)
nc$QBIR79 <- (nc$BIR79 > qb79[2]) + (nc$BIR79 > qb79[3]) +
(nc$BIR79 >= qb79[4]) + 1
nc$QBIR79 <- as.factor(nc$QBIR79)
plot(nc["QBIR79"], pal = c("#FFFEDE","#FFDFA2", "#FFA93F", "#D5610D"),
     main = "BIR79 (Quartiles)")
sid79 <- quantile(nc$SID79)
nc$QSID79 <- (nc$SID79 > sid79[2]) + (nc$SID79 > sid79[3]) +
(nc$SID79 >= sid79[4]) + 1
nc$QSID79 <- as.factor(nc$QSID79)
plot(nc["QSID79"], pal = c("#FFFEDE","#FFDFA2", "#FFA93F", "#D5610D"),
     main = "SID79 (Quartiles)")
f1 <- ~ QSID79 + QBIR79
lq1nc <- qasy(formula = f1, data = nc, m = 5, r = 2,
           typems = "no", control = list(seedinit = 1111,
                                         dtmaxpc = 0.5) )
lq1nc$QSID79; lq1nc$QBIR79

lq2nc <- qasy(formula = f1, data = nc, m = 5, r = 2,
              typems = "cbl", control = list(dtmaxpc = 0.2) )
lq2nc$QSID79; lq2nc$QBIR79

lq3nc <- qasy(formula = f1, data = nc, m = 5, r = 2,
              typems = "cdt", control = list(dtmaxpc = 0.2) )
lq3nc$QSID79; lq3nc$QBIR79
# Examples with points and matrix of variables

xf <- matrix(c(nc$QBIR79, nc$QSID79), ncol = 2, byrow = TRUE)
mctr <- suppressWarnings(sf::st_centroid(sf::st_geometry(nc)))
mcoor <- sf::st_coordinates(mctr)[,c("X","Y")]
lq <- qasy(xf = xf, mcoor = mcoor, m = 5, r = 2, typems = "no",
           control = list(seedinit = 1111,
                          dtmaxpc = 0.5))
lq

rominsal/spqdata documentation built on Jan. 24, 2021, 11:11 a.m.