How to obtain a single beta coefficient for a categorical predictor while using fitlme?

6 Ansichten (letzte 30 Tage)
Hi All,
I am using the fitlme function to predict a response variable (y) with two predictor variables (x1,x2).
x1 is a continuous predictor variable while x2 is a categorical variable with 3 categories. As a result, I have used the input 'DummyVarCoding' and used the Effects coding for the cateogorical variable.
When I run the model, I get a separate beta coefficient for the continuous predictor variable x1. However, for x2 I get a separate coefficient for each of the two categories of x2 and the reference group. I know that these coefficients need to be interpreted with reference to the intercept.
But, I am looking for a single beta coefficient for the predictor x2 and not three different coefficients for each category.
That is, in y = b0 + b1*x1 + b2*x2, I would like to obtain b2.
How can I do that?
Thank you,
Prashanti

Antworten (1)

Paras Gupta
Paras Gupta am 29 Jan. 2024
Hi Prashanti,
I understand that you want a single beta coefficient for a categorical predictor using 'fitlme' function. However, in standard regression analysis, the separate coefficients for the categories of 'x2' are because each level has its own impact on the response variable.
If you want to test the overall significance of the categorical variable 'x2' (i.e., test whether there is any difference among the categories of x2 in their association with y), you can perform an F-test. The 'fitlme' function provides a method 'anova' for this purpose, which will tell you if 'x2' as a whole is statistically significant.
lme = fitlme(...); % Your model fitting with 'DummyVarCoding', 'effects'
anova(lme)
The 'anova' function will give you a p-value for 'x2' indicating whether the differences among the levels of 'x2' are statistically significant. Please refer to the following documentation for more information on 'anova' function.
If you insist on obtaining a single beta coefficient for a categorical variable with multiple levels, you might need to reconsider the coding of your categorical variable or the interpretation of the model
Hope this helps with your query.

Kategorien

Mehr zu Analysis of Variance and Covariance finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by