How do I predict x for a given value of y using glmval?
4 ビュー (過去 30 日間)
古いコメントを表示
Hello!
I am using glmfit to fit a logistic regression to my data, where y varies from 0 to 1 and x can be from 0 to 1000s.
[logitCoef, dev, stats] = glmfit(xarray, yarray, 'binomial','logit');
Then I can use glmval to predict the values of y for a given x
logitFit = glmval(logitCoef,xarray,'logit');
Now, I want to use this fitted function to predict the value of x when y is 0.5. How can I do this?
Thank you for help!
0 件のコメント
採用された回答
Star Strider
2022 年 4 月 3 日
Using code from the documentation as an example —
x = [2100 2300 2500 2700 2900 3100 ...
3300 3500 3700 3900 4100 4300]';
n = [48 42 31 34 31 21 23 23 21 16 17 21]';
y = [1 2 0 3 8 8 14 17 19 15 17 21]';
b = glmfit(x,[y n],'binomial','Link','probit');
yfit = glmval(b,x,'probit','Size',n);
yval = 0.5;
xval = interp1(yfit./n, x, yval)
figure
plot(x,y./n,'o',x,yfit./n,'-')
hold on
plot(xval, yval, 'm+', 'MarkerSize',15)
hold off
text(xval, yval, sprintf(' (%0.2f, %0.2f)', xval, yval), 'Horiz','left', 'Vert','middle')
.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!