Learn R Programming

momentuHMM (version 1.2.0)

w2n: Scaling function: working to natural parameters

Description

Scales each parameter from the set of real numbers, back to its natural interval. Used during the optimization of the log-likelihood.

Usage

w2n(wpar, bounds, parSize, nbStates, nbCovs, estAngleMean, circularAngleMean,
  stationary, cons, fullDM, DMind, workcons, nbObs, dist, Bndind, nc, meanind,
  covsDelta)

Arguments

wpar

Vector of working parameters.

bounds

Named list of 2-column matrices specifying bounds on the natural (i.e, real) scale of the probability distribution parameters for each data stream.

parSize

Named list indicating the number of natural parameters of the data stream probability distributions

nbStates

The number of states of the HMM.

nbCovs

The number of beta covariates.

estAngleMean

Named list indicating whether or not to estimate the angle mean for data streams with angular distributions ('vm' and 'wrpcauchy').

circularAngleMean

Named list indicating whether to use circular-linear (FALSE) or circular-circular (TRUE) regression on the mean of circular distributions ('vm' and 'wrpcauchy') for turning angles.

stationary

FALSE if there are covariates. If TRUE, the initial distribution is considered equal to the stationary distribution. Default: FALSE.

cons

Named list of vectors specifying a power to raise parameters corresponding to each column of the design matrix for each data stream.

fullDM

Named list containing the full (i.e. not shorthand) design matrix for each data stream.

DMind

Named list indicating whether fullDM includes individual- and/or temporal-covariates for each data stream specifies (-1,1) bounds for the concentration parameters instead of the default [0,1) bounds.

workcons

Named list of vectors specifying constants to add to the regression coefficients on the working scale for each data stream.

nbObs

Number of observations in the data.

dist

Named list indicating the probability distributions of the data streams.

Bndind

Named list indicating whether DM is NULL with default parameter bounds for each data stream.

nc

indicator for zeros in fullDM

meanind

index for circular-circular regression mean angles with at least one non-zero entry in fullDM

covsDelta

data frame containing the delta model covariates (if any)

Value

A list of:

...

Matrices containing the natural parameters for each data stream (e.g., 'step', 'angle', etc.)

beta

Matrix of regression coefficients of the transition probabilities

delta

Initial distribution

Examples

Run this code
# NOT RUN {
m<-example$m
nbStates <- 2
nbCovs <- 2
parSize <- list(step=2,angle=2)
par <- list(step=c(t(m$mle$step)),angle=c(t(m$mle$angle)))
bounds <- m$conditions$bounds
beta <- matrix(rnorm(6),ncol=2,nrow=3)
delta <- c(0.6,0.4)

#working parameters
wpar <- momentuHMM:::n2w(par,bounds,beta,log(delta[-1]/delta[1]),nbStates,
m$conditions$estAngleMean,NULL,m$conditions$cons,m$conditions$workcons,m$conditions$Bndind)

#natural parameter
p <-   momentuHMM:::w2n(wpar,bounds,parSize,nbStates,nbCovs,m$conditions$estAngleMean,
m$conditions$circularAngleMean,m$conditions$stationary,m$conditions$cons,m$conditions$fullDM,
m$conditions$DMind,m$conditions$workcons,1,m$conditions$dist,m$conditions$Bndind,
matrix(1,nrow=length(unique(m$data$ID)),ncol=1),covsDelta=m$covsDelta)
# }
# NOT RUN {

# }

Run the code above in your browser using DataLab