-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmyscript1.R
More file actions
20 lines (16 loc) · 423 Bytes
/
myscript1.R
File metadata and controls
20 lines (16 loc) · 423 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Regression analysis of two random vectors
# random data
x <- rnorm(20)
y <- x + rnorm(20)
# regression line
reg <- lm(y ~ x)
# scatter diagram with fitted regression line
png('scatterplot.png')
plot(x, y, las = 1, pch = 19, col = "#555555")
abline(reg, col = "#0000DD59", lwd = 2)
dev.off()
# residuals plot
png('residuals_plot.png')
plot(x, reg$residuals, las = 1, pch = 19, col = "#606060")
abline(h = 0)
dev.off()