In the function of Lasso (function [B,stats] = lasso(X,Y,varargin)), X is A numeric matrix (NxP). There is an optional input parameter called 'Weights'.
% 'Weights' Observation weights. Must be a vector of non-negative
% values, of the same length as columns of X. At least
% two values must be positive. (default ones(N,1) or
% equivalently (1/N)*ones(N,1)).
Since N is the number of samples and P is the number of features, Weights should be the ones(P,1). If Weights is ones(N,1), that is the weight of samples.
If my thoughts are wrong, I hope someone helps me correct. Thanks!
function [B,stats] = lasso(X,Y,varargin)
%LASSO Perform lasso or elastic net regularization for linear regression.
% [B,STATS] = lasso(X,Y,…) Performs L1-constrained linear least
% squares fits (lasso) or L1- and L2-constrained fits (elastic net)
% relating the predictors in X to the responses in Y. The default is a
% lasso fit, or constraint on the L1-norm of the coefficients B.
%
% Positional parameters:
%
% X A numeric matrix (dimension, say, NxP)
% Y A numeric vector of length N
%
% Optional input parameters:
%
% 'Weights' Observation weights. Must be a vector of non-negative
% values, of the same length as columns of X. At least
% two values must be positive. (default ones(N,1) or
% equivalently (1/N)*ones(N,1)).
Best Answer