nmod.lsgl: Number of Models

Description Usage Arguments Value Author(s) Examples

View source: R/navigate.R

Description

Returns the number of models used for fitting. Note that cv and subsampling objects does not containing any models even though nmod returns a positive number.

Usage

1
2
## S3 method for class 'lsgl'
nmod(object, ...)

Arguments

object

a lsgl object

...

ignored

Value

the number of models in object

Author(s)

Martin Vincent

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
set.seed(100) # This may be removed, it ensures consistency of the daily tests

## Simulate from Y=XB+E, the dimension of Y is N x K, X is N x p, B is p x K

N <- 100 #number of samples
p <- 50 #number of features
K <- 25  #number of groups

B<-matrix(sample(c(rep(1,p*K*0.1),rep(0, p*K-as.integer(p*K*0.1)))),nrow=p,ncol=K)

X<-matrix(rnorm(N*p,1,1),nrow=N,ncol=p)
Y<-X%*%B+matrix(rnorm(N*K,0,1),N,K)

lambda<-lsgl::lambda(X,Y, alpha=1, d = 25, lambda.min=.5, intercept=FALSE)
fit <-lsgl::fit(X,Y, alpha=1, lambda = lambda, intercept=FALSE)

# the number of models
nmod(fit)

lsgl documentation built on May 29, 2017, 11:43 a.m.