Handling missing observations while using fmincon

11 ビュー (過去 30 日間)
Selcen Cakir
Selcen Cakir 2024 年 11 月 12 日
回答済み: Matt J 2024 年 11 月 13 日
Hello,
I have data that consists of 70 variables that I observe for 100,000 observations but I don't observe a few of those 70 variables for some random observations and MATLAB codes them as NaN. I'm using fmincon to find the minimum of a function with 70 parameters. My function is of the form f(). When I run the algorithm, I notice that MATLAB does not compute the index function when there is a missing value for one of the k variables for some observation i. How should I handle such missing observations?
Thank you in advance,
Selcen

回答 (2 件)

Walter Roberson
Walter Roberson 2024 年 11 月 13 日
Use this kind of structure:
XY = [X, Y];
XY = rmmissing(XY);
Xm = XY(:,1:end-1);
Ym = XY(:,end);
objfun = @(PARAMS) sum((YourFunction(PARAMS,Xm)-Ym).^2);
bestPARAMS = fmincon(objfun, PARAMS0);

Matt J
Matt J 2024 年 11 月 13 日
They should be zeros rather than NaNs, shouldn't they? With zeros, they will make no contribution to the linear part of the prediction.
X(isnan(X))=0;

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by