Search notes:

R function: lm

lm builds a statistical model.
set.seed(555)

x <- 1:20

A <- 15
B <- 0.4
E <- runif(length(x), -1, 1) * (2 + x/20) 

y <- A + B*x + E

X11()

plot(x, y, pch=16, col='blue')

model <- lm(y~x)

model

abline(model, col='red'  , lwd=3)
abline(A, B , col='green', lwd=3)

# wait for mouse click or enter pressed
z <- locator(1)
Github repository about-r, path: /functions/lm.R

See also

Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759406334, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/lm(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78