Description Usage Arguments Details Value Author(s) References See Also Examples
Uses the glmnet package for elastic-net computation and the cvTools package for cross-validation error. Use optimalGraph
to select the optimal graph.
1 2 3 4 |
data |
A binary dataset |
nLambda |
Number of lambda tuning parameters |
lambda.min.ratio |
Lambda min ratio, see details. |
alpha |
Vector with values of alpha to test |
cost |
Cost functions from the cvTools package to use. |
K |
The number of splits in k-fold cross-validation. |
and |
Should an AND-rule be used? If |
For each alpha, the maximum lambda is obtained from glmnet. The minimum lambda for ALL levels of alpha is lambda.min.ratio * lambda.max obtained when alpha = 1.
An elasticIsing
object, with the following elements:
minimal |
Values with minimal predictive cost |
costs |
Predictive cost |
lambdaMatrix |
Matrix indicating lambda values used. Columns correspond to the alpha values. |
alpha |
Alpha values used |
data |
Dataset used |
and |
AND-rule |
Sacha Epskamp <mail@sachaepskamp.com>
Jerome Friedman, Trevor Hastie, Robert Tibshirani (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1-22. URL http://www.jstatsoft.org/v33/i01/.
Andreas Alfons (2012). cvTools: Cross-validation tools for regression models. R package version 0.3.2. https://CRAN.R-project.org/package=cvTools
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 | library("IsingSampler")
# Input:
P <- 5 # Number of nodes
nSample <- 250 # Number of samples
# Chain graph:
Graph <- matrix(0, P, P)
for (i in 1:P){
Graph[i,i%%P+1] <- Graph[i%%P+1,i] <- 0.5
}
# Thresholds:
Thresh <- rep(0, P)
# Response options (0,1 or -1,1):
Resp <- c(0L,1L)
# Simulate with metropolis:
Data <- IsingSampler(nSample, Graph, Thresh)
## Not run:
# Estimate:
Res <- elasticIsing(Data)
# Optimal graph:
optimalGraph(Res)
# Plot result:
plot(Res)
# Cost plots:
costPlots(Res)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.