How can i run an exact logistic regression analysis in matlab

13 ビュー (過去 30 日間)
Martin
Martin 2025 年 3 月 28 日
コメント済み: Martin 2025 年 3 月 29 日
i have 80 patients with a certain kind of stroke.
56 have a good outcome, 4 of them suffer from dibetes, all others not
24 have a poor outcome, 6 of them suffer from diabetes, all others not.
Due to the small numbers i have to run a exact logistic regression analysis to know whether diabetes is significantly associated with poor ooutcome.
Is it possible to run such an analysis with matlab considering the smalll number of patients ?
  1 件のコメント
Torsten
Torsten 2025 年 3 月 28 日
You can run an analysis for every number of patients in MATLAB. But to answer the question whether it makes sense statistically you should ask in a statistics forum.

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

回答 (1 件)

Umar
Umar 2025 年 3 月 28 日

Hi @Martin,

I do agree with @Torsten’s comments. To answer your question, yes it is indeed possible to perform an exact logistic regression analysis in MATLAB, even with a small sample size. The fitmnr function can be used for logistic regression, but for exact methods, you may need to utilize the stats toolbox or other specialized functions. Below is a sample code that demonstrates how to set up and run the analysis based on your data.

% Patient data setup
% Outcome labels: 1 for Good, 2 for Poor
outcomes = [ones(56, 1); 2 * ones(24, 1)]; % 56 good outcomes, 24 poor 
outcomes
% Diabetes status: 1 for Yes, 0 for No
% 4 out of the first 56 patients have diabetes (good outcome)
% 6 out of the last 24 patients have diabetes (poor outcome)
diabetes = [zeros(52,1); ones(4,1); zeros(18,1); ones(6,1)];
% Create a table to use with fitmnr
data = table(outcomes, diabetes);
% Fit multinomial regression model
MnrModel = fitmnr(data, 'outcomes ~ diabetes', 'ModelType', 'nominal');
% Display the results
disp(MnrModel);

Please see attached.

Explanation of Code Components:

Data Setup: defined the `outcomes` vector to represent good and poor recovery outcomes. The `diabetes` vector indicates whether each patient has diabetes.

Table Creation: A table is created combining both vectors.

Model Fitting: The `fitmnr` function fits a multinomial regression model where the response variable is `outcomes`, and the predictor is `diabetes`.

Results Display: Finally, display the fitted model's results.

Expected Output Interpretation

The output from `disp(MnrModel)` will provide coefficients and p-values associated with each predictor in your model. Here's how to interpret them:

Coefficients: Indicate the effect size of having diabetes on the odds of having a poor outcome relative to a good outcome.

p-values: Assess statistical significance; a p-value less than 0.05 typically indicates a significant association.

Given your small sample size:

1. Ensure that your data meets the assumptions required for logistic regression. 2. Consider bootstrapping methods or Bayesian approaches if standard methods yield unstable estimates due to limited data.

This approach will help you assess whether diabetes is significantly associated with poor outcomes in stroke patients using MATLAB's `fitmnr` function effectively. If you have any further questions or need assistance with interpreting specific results from your analysis, feel free to ask!

  1 件のコメント
Martin
Martin 2025 年 3 月 29 日
Many thanks for your great help !!
Martin

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

カテゴリ

Help Center および File ExchangeLinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by