フィルターのクリア

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 Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by