STATISTICS Course

Simple linear regression (example)

Go back

This is an example of simple linear regression.

# preparing some data
data('mtcars')
v <- mtcars
# now we want to check if the number is
# cylinders (cyl) is impacting the horsepower (hp)
model <- lm(v$hp ~ v$cyl)
# or
model <- lm(hp ~ cyl, data = v)
# and we can check the result
summary(model)