detect.pv: detect.pv

Description Usage Arguments Value Examples

View source: R/detectTH.R

Description

Returns the potential partitioning variable(s)

Usage

1
detect.pv(membership, X.p, size = 1, No.return)

Arguments

membership

a length-n vector of membership labels

X.p

A subset of covariates to be examined

size

the maximum number of threshold variables allowed in the model; default size = the total number of covariates provided

No.return

number of results to be returned; default is the total number of threshold variables explored

Value

a list consisting of two items: the first item is the p values of Moran's I, ranked in an ascending order; the second item contains the corresponding covariates that yield those p values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
set.seed(121)

n <- 50
p <- 3

X <- matrix(rnorm(n * p), nrow = n)
Xj <- X[,1] # the threshold variable
beta1 <- rep(3,p)
beta2 <- rep(-3,p)

index.g1 <- which(Xj <= 0)
index.g2 <- which(Xj > 0)

y.g1 <- X[index.g1,] %*% beta1
y.g2 <- X[index.g2,] %*% beta2

y <- rep(0,n)
y[index.g1] <- y.g1
y[index.g2] <- y.g2

y <- y + rnorm(n = n, sd = 0.5)
m <- HP(X,y, method = "latent", max.no.cluster = 2)$membership
detect.pv(m, X.p = X)

wenda-1121/RHP documentation built on Feb. 18, 2020, 9:36 p.m.