Description Usage Arguments Value Examples
greg
calculate regularization graphical model
1 |
z |
n * p dimensional matrix |
A |
p * p true graph |
eps |
a tolerence level for thresholding |
gamma |
the adaptive lasso penalty parameter |
trace |
whether to trace to estimation process. |
a list.
roc.lasso |
roc results for lasso |
roc.scad |
roc results for scad |
roc.alasso |
roc results for adaptive lasso |
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 | p=30;
n=120;
tmp=runif(p-1,1,3)
s=c(0,cumsum(tmp));
s1=matrix(s,p,p)
cov.mat.true=exp(-abs(s1-t(s1)))
prec.mat.true=solve(cov.mat.true);
a=matrix(rnorm(p*n),n,p)
data.sa=a%*%chol(cov.mat.true);
true.graph = outer(1:p,1:p,f<-function(x,y){(abs(x-y)==1)})
fit = greg(data.sa, true.graph)
plot(fit$roc.lasso[,1],fit$roc.lasso[,2],type='l')
lines(fit$roc.alasso[,1],fit$roc.alasso[,2],col=2)
lines(fit$roc.scad[,1],fit$roc.scad[,2],col=3)
methodlist = c("ridge","lasso","sam")
fit = vector(mode="list", length=3)
info = vector(mode="list", length=3)
auc = NULL
#plot.new()
for(i in 1:3){
method = methodlist[i]
fit[[i]] = pgraph(data.sa, method = method)
info[[i]] = roc(fit[[i]]$statmat.pearson, true.graph)
auc[i] = sum(-diff(info[[i]]$fpr)*info[[i]]$tpr[-1])
lines(info[[i]]$fpr,info[[i]]$tpr, xlab='FPR',ylab='TPR', type='s', col=i+3)
cat(method, ': auc=', auc[i],'\n')
}
auc
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.