elasticIsing: Estimate Ising model using elastic-net and cross-validation.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Uses the glmnet package for elastic-net computation and the cvTools package for cross-validation error. Use optimalGraph to select the optimal graph.

Usage

1
2
3
4
elasticIsing(data, nLambda = 100, lambda.min.ratio = 0.01, 
          alpha = seq(0, 1, length = 10), cost = c("mspe", 
          "rmspe", "mape", "tmspe", "rtmspe"), K = 10, 
          and = TRUE)

Arguments

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 TRUE, both A -> B and B <- A need to be non-zero to obtain the egde A – B. If FALSE, an OR-rule is used.

Details

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.

Value

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

Author(s)

Sacha Epskamp <mail@sachaepskamp.com>

References

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

See Also

optimalGraph, costPlots

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
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)

elasticIsing documentation built on May 2, 2019, 5:58 a.m.