0% found this document useful (0 votes)
2 views

Document (1)

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)
2 views

Document (1)

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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy