フィルターのクリア

The most likely point closest to best fit line?

3 ビュー (過去 30 日間)
Ronan
Ronan 2015 年 11 月 30 日
コメント済み: Ronan 2015 年 12 月 1 日
So I m using regression to best fit a plot of data. Each data point is represented by distance and value. If the residuals are defined as the error of the points away from the best fit line, I can plot a normal probability density function plot of the likelihood of the residuals. So I have 2 plots. The first plot shows distance(of points, not residual distance) vs value and the second plot shows residuals vs density(normal probability density function). I m trying to find the minimum distance of the points in terms of the first plots x values and at the same time chose the point that has the smallest residual (closest to best fit line) based on the normal probability density function. So I cant just pick the minimum value of the residuals because the data may be different each time. My knowledge of statistics is very limited so i m not sure if this is the best way to find the most likely point that is closest to best fit line. Attached is the code,
yVals = zeros(1,10);
yVals(1,1) = 2;
yVals(1,2) = 5;
yVals(1,3) = 6;
yVals(1,4) = 9;
yVals(1,5) = 14;
yVals(1,6) = 18;
yVals(1,7) = 25;
yVals(1,8) = 21;
yVals(1,9) = 23;
yVals(1,10) = 27;
xVals = 1:10;
xVals = xVals';
yVals = yVals/max(yVals);
yVals = yVals'
scatter(xVals, yVals);
hold on;
[logitCoef,dev, stats] = glmfit(xVals,yVals,'binomial','logit');
logitFit = glmval(logitCoef,xVals,'logit');
figure(1);
plot(xVals,logitFit,'g-','MarkerSize', 2 );xlabel('Distance'); ylabel('Value');
legend('logit');
A = stats.resid;
M = mean(A);
S = std(A);
MAX = max(A);
MIN = min(A);
[residuals residualIndex] = sort(stats.resid);
figure(2);
PDF = normpdf(residuals, M, S);
plot(residuals, PDF);xlabel('Residuals'); ylabel('Density');
  1 件のコメント
Ronan
Ronan 2015 年 11 月 30 日
So if you look at the peak of the normal probability density function it contains the points that are on the best fit line so they are likely. However I want to find the most likely at the smallest distance. eg the very first point has a very small distance but has a larger residual then the most likely residuals. So perhaps I need to get the weighted sum of smallest distance/smallest residual to identify the optimal one? Any suggestions?

サインインしてコメントする。

回答 (1 件)

the cyclist
the cyclist 2015 年 11 月 30 日
It sounds like you are effectively doing an optimization problem. If you have the Optimization Toolbox -- I don't, so I can't help you specifically -- there will be lots of tools available to you.
In core MATLAB, you might just be able to use fminsearch.
Regardless, you are going to have to decide on the function you want to optimize. MATLAB won't be able to do that for you.
  1 件のコメント
Ronan
Ronan 2015 年 12 月 1 日
thank you for your suggestion. I will try out fminsearch once i get to grips with applying the function parameter fun in regards to my application.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by