gR2: gR2

Description Usage Arguments Details Value Author(s) References Examples

View source: R/1_gR2.R

Description

Add description of gR2 here

Usage

1
2
3
gR2(x, y, z = NULL, K = NULL, cand.Ks = 1:4, nstart = 30,
  mc.cores = detectCores() - 1, inference = FALSE, conf.level = 0.95,
  method = c("general", "binorm"))

Arguments

x

Add description here

y

Add description here

z

Add description here

K

Add description here

cand.Ks

Add description here

nstart

Add description here

mc.cores

Add description here

inference

Add description here

conf.level

Add description here

method

Add description here

Details

Add details here

Add details here

Add details here

Value

gR2 returns a list consisting of the following items:

estimate

Add description here

conf.level

Add description here

conf.int

Add description here

p.val

Add description here

K

Add description here

membership

Add description here

Author(s)

Heather J Zhou, heatherjzhou@ucla.edu

Jingyi Jessica Li, jli@stat.ucla.edu

References

Li, J.J., Tong, X., and Bickel, P.J. (2018). Generalized R2 Measures for a Mixture of Bivariate Linear Dependences. arXiv.

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
library(mvtnorm)
#Simulate data from a mixture of bivariate normal distributions
n=200 #sample size
K=2 #number of components (lines)
p_s=c(0.5,0.5) #proportions of components
mu_s=list(c(0,-2),c(0,2)) #mean vectors
Sigma_s=list(rbind(c(1,0.8),c(0.8,1)),rbind(c(1,0.8),c(0.8,1))) #covariance matrices
z=sample(1:K,size=n,prob=p_s,replace=TRUE) #line memberships
data=matrix(0,nrow=n,ncol=2)
for (i in 1:K){
  idx=which(z==i)
  data[idx,]=rmvnorm(n=length(idx),mean=mu_s[[i]],sigma=Sigma_s[[i]])
}

x<-data[,1]
y<-data[,2]
plot(x,y)

#Specified scenario
gR2(x,y,z) #No inference
gR2(x,y,z,inference=TRUE) #Inference

#Unspecified scenario
gR2(x,y,K=2,mc.cores=2) #K chosen, no inference
#gR2(x,y,K=2,inference=TRUE,mc.cores=2) #K chosen, inference
#gR2(x,y,mc.cores=2) #K not chosen, no inference
#gR2(x,y,inference=TRUE,mc.cores=2) #K chosen, inference

heatherjzhou/gR2.2 documentation built on Nov. 14, 2019, 12:14 a.m.