In: Statistics and Probability
A social scientist would like to analyze the relationship between educational attainments (years in higher ed) and annual salary (in $1,000s). He collects the data above.
Salary | Education |
40 | 3 |
53 | 4 |
80 | 6 |
41 | 2 |
70 | 5 |
54 | 4 |
110 | 8 |
38 | 0 |
42 | 3 |
55 | 4 |
85 | 6 |
42 | 2 |
70 | 5 |
60 | 4 |
140 | 8 |
40 | 0 |
76 | 5 |
65 | 4 |
125 | 8 |
38 | 0 |
a | What is the equation for predicting salary based on educational attainment? | ||||||
b | What is the coefficient for education? | ||||||
c | what is the predicted salary for someone with 4 years of higher ed? |
Y-salary
X-education
use R studio.
use lm function to fit linear model of salary on experience
summary function to get the summary of thr model output.
Rcode:
df1 =read.table(header = TRUE, text ="
Salary Education
40 3
53 4
80 6
41 2
70 5
54 4
110 8
38 0
42 3
55 4
85 6
42 2
70 5
60 4
140 8
40 0
76 5
65 4
125 8
38 0
"
)
df1
linmod = lm(Salary~Education,data=df1)
summary(linmod)
Output:
Call:
lm(formula = Salary ~ Education, data = df1)
Residuals:
Min 1Q Median 3Q Max
-14.817 -8.169 -2.658 4.661 30.980
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 22.296 5.636 3.956 0.000927 ***
Education 10.841 1.195 9.072 3.91e-08 ***
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 12.92 on 18 degrees of freedom
Multiple R-squared: 0.8206, Adjusted R-squared:
0.8106
F-statistic: 82.31 on 1 and 18 DF, p-value: 3.908e-08
a | What is the equation for predicting salary based on educational attainment? |
salary= 22.29585 +10.84053 *Education
b | What is the coefficient for education? |
coeffcient of education =slope= 10.84053
c | what is the predicted salary for someone with 4 years of higher ed |
we have
salary= 22.29585 +10.84053 *Education
For education=4 we get
salary= 22.29585 +10.84053 *4
=65.65797
Predicted salary for someone with 4 years of higher ed=65.65797