mlsolve: Maximum likelihood inferences

Description Usage Arguments Details Value Author(s) Examples


mlsolve uses maximum likelihood estimation to infer environmental conditions from biological observations.


mlsolve(ss, coef0, site.sel = "all", bruteforce = FALSE)



A site-species matrix, with sample identifiers in the first column, and abundances. Typically, the result of makess.


Character vector of sample id's at which inferences should be computed. Default selection of 'all' forces script to compute inferences for all samples in the matrix.


Coefficient file with model specifications and regression coefficients defining taxon-environment relationships. See taxon.env for more details.


Logical flag. Select TRUE to compute solution by brute force rather than by conjugate gradients. Provides a means of examining likelihood contours when needed.


mlsolve uses maximum likelihood estimation to infer environmental conditions from biological observations. Maximum likelihood estimation in this context is a constrained optimization problem, in which we wish find the point at which the likelihood function is maximized, constrained by the range of the environmental variables in the calibration data. mlsolve formulates the likelihood function and calls optim to solve the optimization problem.

The option bruteforce can be used to check the performance of the iterative solver. When bruteforce is set to be TRUE, the script also computes likelihood values for a uniformly-spaced grid that spans the ranges of the environmental variables. This is a time-consuming calculation, and therefore should only be attempted on a few samples. Once the grid is computed, though, contours of the likelihood surface are plotted.

mlsolve requires that the taxa included in ss each have associated taxon-environment information in coef0. The best way to ensure that this condition is satisfied is to make sure that get.otu is run with the same coef0 as used in mlsolve, and that the results from get.otu are used to generate ss (see makess).


The script returns a dataframe containing inferences for each sample as well as a logical flag indicating whether solutions computing with four different starting locations are consistent with one another.


Lester L. Yuan



Search within the bio.infer package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.