0% found this document useful (0 votes)
7 views4 pages

Statistics Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Statistics Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Statistics assignment

set.seed(42)

n_samples <- 100


education_years <- rnorm(n_samples, mean = 16, sd = 3)

income <- 20000 + 5000 * education_years + rnorm(n_samples, mean = 0, sd


= 10000)

data <- data.frame(


education_years = education_years,
income = income

)
model <- lm(income ~ education_years, data = data)

summary(model)

plot(data$education_years, data$income,
xlab = "Years of Education",
ylab = "Income ($)",
main = "Income vs. Education Years",

pch = 19,
col = "blue",

alpha = 0.5)
abline(model, col = "red", lwd = 2)
Residuals:
Min 1Q Median 3Q Max
-18884.2 -5066.4 122.5 5410.6 28624.0

Coefficients:
Estimate Std. Error t value
Pr(>|t|)
(Intercept) 17667.8 4790.9 3.688
0.000371 ***
education_years 5090.5 292.2 17.420 <
2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05
‘.’ 0.1 ‘ ’ 1

Residual standard error: 9083 on 98 degrees of


freedom
Multiple R-squared: 0.7559, Adjusted R-
squared: 0.7534
F-statistic: 303.5 on 1 and 98 DF, p-value: <
2.2e-16

You might also like