Linear regression - extracting info using matrix algebra

Hello!
I have a preloaded data which contains four columns and each column contains the following data in the following order:
  1. Income (dollars)
  2. Education
  3. A dummy variable, 1 for male and 0 for female
  4. Another dummy variable, 1 for STEM and 0 for not STEM
I've been given the linear model:
INCOME = α + β1EDUCATION + β2MALE + β3STEM
I should answer the following questions:
a) How large is α in the above equation
b) How many dollars greater is the salary of a male than the salary of a female
From what I understand, I should start with storing each column in the data in separate variables. How would I do this?
Any hints to get me started with this task are appreciated!

 채택된 답변

Stephan
Stephan 2019년 10월 12일
편집: Stephan 2019년 10월 12일
add a column of ones to your matrix DATA in pos. 4. isolate income as a column vector and remove this column from DATA then use:
X = DATA\INCOME
you get the beta values (1-3) and the last one is alpha.
Also possible:
DATA = [DATA ones(size(DATA,1),1]
vals = DATA(:,2:end)\DATA(:,1)
The other stuff should be not a problem by using logical indexing.

댓글 수: 5

Hello, thank you for the help! This sounds logical, however I'd need advice on doing this:
"add a column of ones to your matrix DATA in pos. 4. isolate income as a column vector and remove this column from DATA"
I'm still very new to MATLAB so it's all quite challenging.
Thanks in advance!
DATA = [DATA ones(size(DATA,1),1]
vals = DATA(:,2:end)\DATA(:,1)
Thank you so much! I'll try to solve as much as I can on my own from here on.
Did you notice that you can accept and or vote for useful answers? If you have more problems come back with a new question.
Cheers, I forgot to do that!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품

질문:

2019년 10월 12일

댓글:

2019년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by