Find standardized coefficient in linear regression?
24 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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)
0 Commenti
Risposte (1)
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
Vedere anche
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!