coef.amias: Extract cefficients from a amias or samias object

Description Usage Arguments Value See Also Examples

Description

This function extracts coefficients from a amias or samias object.

Usage

1
2
3
4
## S3 method for class 'amias'
coef(object, type=c("coef","primal", "dual", "active"), ...)
## S3 method for class 'samias'
coef(object, type = c("coef","primal", "dual", "active"), k, ...)

Arguments

object

A list with class attribute 'amias' or 'samias'.

type

A character string, one of "coef", "primal", "dual", or "active", indicating whether generalized l_0 coefficients, primal coefficients, dual coefficients, or active sets, should be returned. Default is "coef", which corresponds to the solution of the original generalized l_0 problem.

k

An integer vector of numbers of knots at which coefficients should be calculated. The user can choose to a subset of index from 1,2,…, kmax; none are specified, then it returns the optimal coefficient determined by miniming the BIC value.

...

additional arguments passed to coef.

Value

Returns a list with the following components:

alpha

If the type is "coef", a matrix containing the generalized l_0 coefficients, each column corresponding to a value of k.

v

If the type is "primal", a matrix containing the primal variables, each column corresponding to a value of k.

u

If the type is "dual", a matrix containing the dual variables, each column corresponding to a value of k.

A

If the type is "active", a list containing the active sets, each sublist corresponding to a value of k.

k

An integer that specifies the optimal k or an integer vector containing the sequence of k values corresponding to the columns of beta, v, and u.

See Also

amias, samias.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  ##----- A toy example -------
  set.seed(0)
  n <- 100
  x = seq(1/n, 1,length.out = n)
  y0 = 0*x; y0[x>0.5] = 1
  y = y0 + rnorm(n, sd = 0.1)
  
  
  # For 'amias' object
  fit <- amias(y, k = 1) 
  coef(fit)                # extract the fitting coefficients
  coef(fit, type="active") # extract the detected knots
  
  # For 'samias' object
  fit <- samias(y, kmax = 6)
  coef(fit)                         # get the coefficients with the minimum BIC value
  coef(fit, k = 3:5)                # get the coefficients that number of knots being 3, 4, and 5 
  
  coef(fit, type="active")          # get the active set with minimum BIC value
  coef(fit, type="active", k = 3:5) # get the active sets that number of knots being 3, 4, and 5 

AMIAS documentation built on May 2, 2019, 2:10 a.m.

Related to coef.amias in AMIAS...