Learn R Programming

sirt (version 1.14-0)

sirt-utilities: Utility Functions in sirt

Description

Utility functions in sirt.

Usage

# bounds entries in a vector bounds_parameters( pars , lower = NULL , upper = NULL) # improper density function which always returns a value of 1 dimproper(x)
# generalized inverse of a symmetric function ginverse_sym(A, eps= 1E-8)
# hard thresholding function hard_thresholding(x, lambda)
# soft thresholding function soft_thresholding(x, lambda) # power function x^a, like in Cpp pow(x, a)
# trace of a matrix tracemat(A)

Arguments

pars
Numeric vector
lower
Numeric vector
upper
Numeric vector
x
Numeric vector
eps
Numerical. Shrinkage parameter of eigenvalue in ginverse_sym
a
Numeric vector
lambda
Numeric value
A
Matrix

Examples

Run this code
#############################################################################
## EXAMPLE 1: Trace of a matrix
#############################################################################	

set.seed(86)
A <- matrix( stats::runif(4) , 2 ,2 )
tracemat(A)
sum(diag(A))	# = tracemat(A)

#############################################################################
## EXAMPLE 2: Power function
#############################################################################

x <- 2.3
a <- 1.7
pow(x=x,a=a)
x^a			# = pow(x,a)

#############################################################################
## EXAMPLE 3: Soft and hard thresholding function (e.g. in LASSO estimation)
#############################################################################

x <- seq( -2 , 2 , length=100 )
y <- soft_thresholding( x , lambda = .5)
graphics::plot( x , y , type="l")

z <- hard_thresholding( x , lambda = .5)
graphics::lines( x , z , lty=2 , col=2)

#############################################################################
## EXAMPLE 4: Bounds on parameters
#############################################################################

pars <- c( .721 , .346 )
bounds_parameters( pars = pars , lower=c(-Inf, .5) , upper = c(Inf,1) )

Run the code above in your browser using DataLab