Version:

Loading TOC...

math.linearModel( $arg as Array[] ) as math.linearModel?

Returns a linear model that fits the given data set. The size of the input array should be 2, as currently only simple linear regression model is supported. The first element of the array should be the value of the dependent variable while the other element should be the value of the independent variable.

The function eliminates all pairs for which either the first element or the second element is empty. After the elimination, if the length of the input is less than 2, the function returns the empty sequence. After the elimination, if the standard deviation of the independent variable is 0, the function returns a linear model with intercept = the mean of the dependent variable, coefficients = NaN and r-squared = NaN. After the elimination, if the standard deviation of the dependent variable is 0, the function returns a linear model with r-squared = NaN.

For the version of this function that uses Range Indexes, see cts:linear-model.

Parameters | |
---|---|

$arg | The input data set. Each array should contain a pair of values. |

var arr = new Array(); for (i=1; i < 11; i++) { var x = new Array(); var j = 2 * i + 1; x.push(j, i); arr.push(x); }; math.linearModel(arr); => math:linear-model( <math:linear-model intercept="1" coefficients="2" rsquared="1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:math="http://marklogic.com/xdmp/math"/>)

Copyright © 2017 MarkLogic Corporation. MARKLOGIC is a
registered trademark of MarkLogic Corporation.

## Comments