필터 지우기
필터 지우기

Find standardized coefficient in linear regression?

조회 수: 14 (최근 30일)
Faezeh Manesh
Faezeh Manesh 2023년 4월 17일
편집: Faezeh Manesh 2023년 4월 27일
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)

답변 (1개)

Sandeep
Sandeep 2023년 4월 25일
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
Faezeh Manesh
Faezeh Manesh 2023년 4월 25일
편집: Faezeh Manesh 2023년 4월 27일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by