Description Usage Arguments Value Examples
One of the main functions in the JNNI package. Fits a path of JNNI models over different values of the tunning parameters.
1 | GANAIr.path(X, pathway, L = NULL, t, s_init, a_init)
|
X |
a matrix of predictor variable |
pathway |
a vector of pathway information, for instance, value 1 represent the corresponding node location belongs to pathway 1 |
L |
a list of Laplace information, each of which is a matrix capturing the relationship between node in the corresponding pathway, default is NULL |
t |
a vector of the response variable |
s_init |
a vector of tunning parameter related to the variance |
a_init |
a vector of tunning parameter related to the initial selecting probability |
a list, each element corresponding to its tunning parameters contains values as follows:
mean_w_red |
The coefficients vector |
beta_interaction |
The coefficients of interaction terms |
beta_main |
The coefficients of main effects |
BIC |
Bayesian Information Criterion |
df |
The number of nonzero coefficients |
index_path |
Selected networks' number |
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | set.seed(11)
u=runif(4,0.8,1.2)
u=round(u,2)
rrr=5
rate=round(1/sqrt(rrr),2)
n=300
p=1000
rho=0.6
a1=c(u[1],rate*rep(u[1],5))
a2=c(u[2],rate*rep(u[2],5))
a3=c(u[3],rate*rep(u[3],5))
b1=rate*rep(u[1],5)
b2=rate*rep(u[2],5)
b3=rate*rep(u[3],2)
c1=rate*rep(u[4],5)
M=100
set.seed(1)
X=matrix(NA,n,p)
p0=p/M
for(i in 1:n){
trans=rnorm(M)
for(j in 1:M){
start = (j-1)*p0+1
X[i,start]= trans[j]
xx=matrix(rnorm((p0-1), mean =(trans[j]*rho), sd=sqrt(1-rho^2)),ncol=1)
X[i,(start+1):(start+(p0-1))]=xx
}
}
x=list()
for(i in 1:M){
x[[i]]=X[,(1+(i-1)*p0):(p0*i)]
}
Mm=M+M*(M-1)/2
Phix=list()
for(m in 1:M){
r=0
p_hat=p0+p0*(p0-1)/2
temp1=matrix(NA,n,p_hat)
temp1[,1:p0]=x[[m]]
for(i in 1:(p0-1)){
for(j in (1+i):p0){
r=r+1
temp1[,p0+r]=(x[[m]][,i])*(x[[m]][,j])
}
}
Phix[[m]]=temp1
}
cp=0
R1=matrix(0,M,M)
for(k in 1:(M-1)){
for(m in (k+1):M){
cp=cp+1
R1[k,m]=cp
temp1=matrix(NA,n,(p0*p0))
r=1
for(i in 1:p0){
temp1[,r:(r+p0-1)]=(x[[m]][,1:p0])*(x[[k]][,i])
r=r+p0
}
Phix[[M+cp]]=temp1
}
}
real_w=list()
for(i in 1:M)
real_w[[i]]=rep(0,times=p0+(p0-1)*p0/2)
for(i in (1+M):Mm){
indexp1=which(R1==(i-M),arr.ind = TRUE)[1]
indexp2=which(R1==(i-M),arr.ind = TRUE)[2]
real_w[[i]]=rep(0,times=p0*p0)
}
real_w[[1]][1:length(a1)]=a1
real_w[[1]][(p0+1):(p0+length(b1))]=b1
real_w[[2]][1:length(a2)]=a2
real_w[[2]][(p0+1):(p0+length(b2))]=b2
real_w[[3]][1:length(a3)]=a3
real_w[[3]][(p0+1):(p0+length(b3))]=b3
real_w[[M+1]][1:length(c1)]=c1
real_y=0
for(m in c(1:3,(M+1))){
real_y=Phix[[m]]%*%real_w[[m]]+real_y
}
t = real_y + rnorm(n)
adj=matrix(0,p0,p0)
for(i in 2:p0)
adj[1,i]=1
adj = adj +t(adj)
C=NULL
for(k in 1:M)
C[[k]] = adj
#laplacian matrix
L=NULL
for(k in 1:M){
dd = rowSums(adj)
ee = dd^(-0.5)
ee = diag(ee)
L[[k]] = diag(1,p0,p0)-ee%*%C[[k]]%*%ee
}
pathway=matrix(0,p,1)
p_each=p0
for (i in 1:M){
pathway[(p_each*(i-1)+1):(p_each*i),1]=i
}
s_init=2e-4
a_init=0.96
ls=length(s_init)
la=length(a_init)
temp_1<-GANAIr.path(X,pathway,L=L,t,s_init,a_init)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.