How con I regularize a partial correlation network graph with LASSO?

3 visualizaciones (últimos 30 días)
Luca Ammendola
Luca Ammendola el 28 de Feb. de 2024
Respondida: Ayush el 15 de Mzo. de 2024
I have the following ( where the .csv contains 408 observations of 26 random variables )
"
Rogers = readtable('dOCDRogers.csv');
netdata = table2array( Rogers );
nodesDepression = (1:16)';
nodesOCD = (17:26)';
nodeNames = cellstr( num2str([ nodesDepression; nodesOCD ]) );
pcormat = round( partialcorr( netdata ), 6 );
nrG = graph( pcormat, nodeNames );
"
I'd want to apply LASSO regularization method based on EBIC minimization onto this graph to reduce the number of edges. Any toolbox or code suggestions?

Respuestas (1)

Ayush
Ayush el 15 de Mzo. de 2024
Hi,
You can make use of the "lasso" function as a workaround. The "lasso" function is used for the linear models; for editing graphs, you can apply the function to each variable in the dataset as a response variable, with the other variables as predictors. After obtaining the "lasso" coefficients compute the EBIC and select the "lambda" that minimizes EBIC. Finally, reconstruct the graph. You can refer to the pseudo code below for a better understanding:
[nObservations, nVariables] = size(netdata);
% Placeholder for LASSO coefficients
lassoCoeffs = zeros(nVariables, nVariables);
% Loop over each variable
for i = 1:nVariables
% Define the target variable
Y = netdata(:, i);
% Define the predictor variables (all other variables)
X = netdata(:, setdiff(1:nVariables, i));
% Apply LASSO with Cross-Validation to find optimal Lambda
[B, FitInfo] = lasso(X, Y, 'CV', 10); % 10-fold cross-validation
% Placeholder: Compute EBIC for each Lambda in FitInfo.Lambda
% and select the index of the best Lambda (minimizing EBIC)
bestLambdaIndex = ...; % Compute the index of the best Lambda based on EBIC
% Store the coefficients of the best model
lassoCoeffs(:, i) = [FitInfo.Intercept(bestLambdaIndex); B(:, bestLambdaIndex)];
end
% Use lassoCoeffs to reconstruct the graph
% You'll need to decide how to interpret and use these coefficients to modify your graph
Refer to the documentation below for more information on the "lasso" function:

Categorías

Más información sobre Construction en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by