Borrar filtros
Borrar filtros

Find standardized coefficient in linear regression?

14 visualizaciones (últimos 30 días)
Faezeh Manesh
Faezeh Manesh el 17 de Abr. de 2023
Editada: Faezeh Manesh el 27 de Abr. de 2023
How can I get the standardized coefficient (beta) in linear regression? (e.g. the following code):
[overal,s,r] = xlsread('overal.csv');
alpha = overal(:,1);
beta= overal(:,2);
max_slope = overal(:,3);
age= overal(:,4);
Td=overal(:,5);
Diffstress=overal(:,6);
X1=[beta,max_slope,age,Td,Diffstress];
myFit1= LinearModel.stepwise(X1,alpha,'PEnter',0.09)

Respuestas (1)

Sandeep
Sandeep el 25 de Abr. de 2023
Hi Faezeh Manesh,
To obtain the standardized coefficients (beta) in linear regression, you can use the Coefficients property of the fitted LinearModel object.
You can refer the below code to understand how Coefficients can be used,
[overal,~,~] = xlsread('overal.csv');
alpha = overal(:,1);
beta = overal(:,2);
max_slope = overal(:,3);
age = overal(:,4);
Td = overal(:,5);
Diffstress = overal(:,6);
X1 = [beta, max_slope, age, Td, Diffstress];
myFit1 = LinearModel.stepwise(X1, alpha, 'PEnter', 0.09);
% Get the standardized coefficients
beta_hat = myFit1.Coefficients.Estimate(2:end); % exclude the intercept term
x_means = mean(X1, 1);
x_sds = std(X1, [], 1);
y_sd = std(alpha);
beta = beta_hat .* (x_sds ./ y_sd);
The estimated coefficients are obtained from the Estimate property of Coefficients returned by the LinearModel object. The x_means, x_sds, and y_sd variables are used to compute the standardized coefficients.
  1 comentario
Faezeh Manesh
Faezeh Manesh el 25 de Abr. de 2023
Editada: Faezeh Manesh el 27 de Abr. de 2023
Thanks @Sandeep. I used the code that you provided, however, the beta values that are calculated are as follows:
beta =
-0.3294 -16.3266 -19.6832 -1.4097 -0.4325
-0.1212 -6.0053 -7.2400 -0.5185 -0.1591
It is a 2*5 matrix and the coefficients are not standardized ( Standardized values need to be between 0 and 1). Could you please help me modify this.

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by