Description Usage Arguments Details Value Author(s) References Examples
Add description of gR2
here
1 2 3 |
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 |
Add details here
Add details here
Add details here
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 |
Heather J Zhou, heatherjzhou@ucla.edu
Jingyi Jessica Li, jli@stat.ucla.edu
Li, J.J., Tong, X., and Bickel, P.J. (2018). Generalized R2 Measures for a Mixture of Bivariate Linear Dependences. arXiv.
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.