Model II regression to a linear model
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have previously used fitlm for linear models, however, I have data that requires model II regression. I have used the gmregress function and can determine the slope and y-intercept of my data from this. However, I would like to create a model similar to how fitlm does so. Does anyone know a way to do this?
0 Kommentare
Antworten (1)
Sai Pavan
am 4 Okt. 2023
Hi Casey,
I understand that you are trying to convert a model II regression model into a linear model.
As you have rightly said, we can determine the slope and y-intercept of the data using the “gmregress” function. This task can be performed using the following command:
[b, bintr, bintjm] = gmregress(X, Y);
To convert this model into a linear model, we can use the slope and intercept values stored in “b” to calculate the predicted Y values by multiplying the X values by the slope and adding the y-intercept. Then, we can calculate the residuals by subtracting the predicted Y values from the actual Y values in the dataset as demonstrated in the code snippet shown below:
Y_pred = X * b(2) + b(1); % Calculate predicted Y values
residuals = Y - Y_pred; % Calculate residuals
The relevant model information can be stored in a structure using the code snippet shown below:
model = struct('Coefficients', b, 'CoefficientIntervals', bintr, 'Residuals', residuals);
You can refer to the below documentation to learn more about the “gmregress” function:
Hope it helps.
Regards,
Sai Pavan
0 Kommentare
Siehe auch
Kategorien
Mehr zu Linear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!