Find standardized coefficient in linear regression?

24 visualizzazioni (ultimi 30 giorni)
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)

Risposte (1)

Sandeep
Sandeep il 25 Apr 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 Commento
Faezeh Manesh
Faezeh Manesh il 25 Apr 2023
Modificato: Faezeh Manesh il 27 Apr 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.

Accedi per commentare.

Categorie

Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by