R: Check whether parameters are in ranges.

is.in.ranges {PhylogeneticEM} | R Documentation

## Check whether parameters are in ranges.

### Description

`is.in.ranges.params` checks whether calculated parameters in the EM are in the defined ranges.

### Usage

    is.in.ranges(p, min, max)

### Arguments

`min` | list of minimum values for the parameters
`max` | list of maximum values for the parameters
`params` | list of parameters with the correct structure

### Details

###################################################### ## Finite parameters ? ######################################################

is.finite.params.BM <- function(params) if (params$root.state$random) return(is.finite.params.BM.randroot(params)) else return(is.finite.params.BM.fixedroot(params))

is.finite.params.BM.randroot <- function(params) if (is.finite(params$variance) && is.finite(params$root.state$exp.root) && is.finite(params$root.state$var.root) ) return(TRUE) else return(FALSE)

is.finite.params.BM.fixedroot <- function(params) if ( is.finite(params$variance) && is.finite(params$root.state$value.root) ) return(TRUE) else return(FALSE)

is.finite.params.OU <- function(stationary.root, shifts_at_nodes, alpha_known) if (stationary.root && shifts_at_nodes && alpha_known) return(is.finite.params.OU.specialCase) else if (stationary.root && shifts_at_nodes) return(is.finite.params.OU.stationary.root_AND_shifts_at_nodes) else stop("The EM algorithm for the OU is only defined (for the moment) for a stationary root and shifts at nodes !")

is.finite.params.OU.specialCase <- function(params) if (is.finite(params$variance) && is.finite(params$root.state$exp.root) && is.finite(params$root.state$var.root) ) return(TRUE) else return(FALSE)

is.finite.params.OU.stationary.root_AND_shifts_at_nodes <- function(params) if (is.finite(params$variance) && is.finite(params$root.state$exp.root) && is.finite(params$root.state$var.root) && is.finite(params$selection.strength)) return(TRUE) else return(FALSE)

This function is used to test the convergence of the algorithm.

### Value

boolean

[Package PhylogeneticEM version 1.1.0 Index]