How to specify a specific constant for a multiple linear regression?
이전 댓글 표시
I would like to know if it is possible to specify a certain constant to a multiple linear regression abd how?
댓글 수: 2
jean claude
2017년 10월 14일
would you clarify your question with an example that we can help ?
Khaled Ahmat
2017년 10월 14일
채택된 답변
추가 답변 (4개)
Khaled Ahmat
2017년 10월 15일
0 개 추천
댓글 수: 3
Image Analyst
2017년 10월 15일
I thought a*x1 + b*x2 + c*x3 was a multiple linear regression. What formula are you thinking about?
Khaled Ahmat
2017년 10월 15일
편집: Khaled Ahmat
2017년 10월 15일
Image Analyst
2017년 10월 15일
But we already solved that in the first answer. If you don't know how to do it, then just attach vectors x1, x2, x3, and y in a .mat file.
Khaled Ahmat
2017년 10월 15일
0 개 추천
댓글 수: 2
Image Analyst
2017년 10월 16일
Not familiar with regress(). Why didn't you use the method of John D'Errico?
Khaled Ahmat
2017년 10월 16일
편집: Khaled Ahmat
2017년 10월 16일
Image Analyst
2017년 10월 17일
I'm not sure I've got the columns correct for x1, x2, x3, and y, but this is essentially how you'd do it (again, thanks to John D'Errico):
% Read in data file.
data = importdata('Data_case1.txt')
% Extract columns into separate variables.
% Make sure the column numbers are the correct ones!!!!
x1 = data(:, 1);
x2 = data(:, 2);
x3 = data(:, 3);
y = data(:, 4);
% Construct x matrix
x = [x1, x2, x3];
% Construct y
y = y - 30;
% Get the cofficients:
coefficients = x \ y; % Estimate Parameter: x*coefficients = y
% Get fitted values for y. Be sure to add back in the 30 we subtracted!
y_estimated = x*coefficients + 30;
% Print them out
fprintf(' x1 x2 x3 y y_estimated\n');
for row = 1 : length(x1)
fprintf('%8.4f, %8.4f, %8.4f, %8.4f, %8.4f\n', ...
x1(row), x2(row), x3(row), y(row), y_estimated(row));
end
카테고리
도움말 센터 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!