/* harmony default export */

/* harmony import */

/*#__PURE__*/

/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Calculates the current model fitted values (yhat) and residuals (e = y - yhat).
*
* @returns {Object} fitted values and residuals
*/

/**
* Calculates the dot product between j-th column vectors of the two input matrices skipping zero elements.
*
* @param {Matrix} x - first input matrix
* @param {Matrix} y - second input matrix
* @param {number} j - column index
* @returns {number} dot product value
*/

/**
* Calculates the dot product between two arrays.
*
* @param {NumberArray} x - first vector
* @param {NumberArray} y - second vector
* @returns {number} dot product
*/

/**
* Checks the Karush-Khun-Tucker (KKT) conditions for an optimal solution.
*
* @returns {boolean} returns true if optimal conditions are satisfied, false otherwise
*/

/**
* Computes a matrix product of a n x p matrix and a column vector of length p.
*
* @param {Matrix} A - n x p matrix
* @param {Array} b - p x 1 column vector
* @returns {Array} result of matrix multiplication
*/

/**
* Computes an element-wise division.
*
* @param {NumberArray} arr - input array
* @param {(NumberArray|number)} x - either an array of equal length or a scalar
* @returns {NumberArray} output array
*/

/**
* Computes an element-wise multiplication.
*
* @param {NumberArray} arr - input array
* @param {(NumberArray|number)} x - either an array of equal length or a scalar
* @returns {NumberArray} output array
*/

/**
* Computes an element-wise subtraction.
*
* @param {NumberArray} arr - input array
* @param {(NumberArray|number)} x - either an array of equal length or a scalar
* @returns {NumberArray} output array
*/

/**
* Define a non-enumerable property.
*
* @module @stdlib/utils/define-nonenumerable-property
*
* @example
* var objectKeys = require( '@stdlib/utils/keys' );
* var setNonEnumerableProperty = require( '@stdlib/utils/define-nonenumerable-property' );
*
* var obj = {};
*
* setNonEnumerableProperty( obj, 'foo', 'bar' );
*
* var v = obj.foo;
* // returns 'bar'
*
* var keys = objectKeys( obj );
* // returns []
*/

/**
* Defines a non-enumerable property.
*
* @param {Object} obj - object on which to define the property
* @param {(string|symbol)} prop - property name
* @param {*} value - value to set
*
* @example
* var objectKeys = require( '@stdlib/utils/keys' );
*
* var obj = {};
*
* setNonEnumerableProperty( obj, 'foo', 'bar' );
*
* var v = obj.foo;
* // returns 'bar'
*
* var keys = objectKeys( obj );
* // returns []
*/

/**
* Exclusion test for all predictors not in active set. If one or more predictors fail the test, they are included in the active set.
*
* @returns {boolean} returns true if active set was changed, false otherwise
*/

/**
* Fit lasso regression via coordinate descent.
*
* @param {Matrix|Array} x - design matrix
* @param {NumberArray} y - response vector
* @param {number} lambda - L1 penalty value
* @returns {Object} regression model
*/

/**
* Iterate over the active set of predictors and perform coordinate descent until convergence.
*
* @returns {void}
*/

/**
* LASSO regression.
*
* @property {Object} data - object of value arrays
* @property {string} y - outcome variable
* @property {Array<string>} x - one or more predictor variables
* @property {Array<string>} quantitative - array of variables in `data` that are `quantitative`
* @property {number} lambda - regularization parameter
* @property {boolean} intercept - controls whether to fit a model with an intercept term
* @property {Function} onPredict - callback invoked with predictions and residuals after model fitting
*/

/**
* Lasso object to fit regression.
*
* @constructor
* @returns {LassoFit} instance
*/

/**
* Soft-thresholding operator.
*
* @param {number} x - input value
* @param {number} t - threshold value
* @returns {number} return value
*/

/**
* Standardizes elements in input array.
*
* @param {Array} x - input array
* @param {boolean} demean - controls whether the mean should be subtracted from the values
* @param {boolean} scale - controls whether values should be divided by the standard deviation
* @returns {Array} output array with added `mu` and `sigma` properties
*/

/**
* Test if a value is an array of arrays.
*
* @module @stdlib/assert/is-array-array
*
* @example
* var isArrayArray = require( '@stdlib/assert/is-array-array' );
*
* var bool = isArrayArray( [ [], [] ] );
* // returns true
*
* bool = isArrayArray( [ {}, {} ] );
* // returns false
*
* bool = isArrayArray( [] );
* // returns false
*/

/***/

// Case 1: x is an array

// Case 2: scalar

// Convert back coefficients to original scale:

// Convert fitted values and residuals back to original scale before standardizing:

// EXPORTS //

// FUNCTIONS //

// Initialize active set to all predictors:

// Initialize model parameters to zero:

// MAIN //

// MODULES //

// Matrix holding partial residuals:

// PROPERTIES //

// Recompute active set:

// See whether non-active variables all pass exclusion test:

// Test failed: include predictor in active set -> iterate again

// VARIABLES //
