Linear regression is a model used in statistics that details the relationship between a dependent variable and one or more independent variables.
2024-04-07
Linear regression is a model used in statistics that details the relationship between a dependent variable and one or more independent variables.
Machine Learning, forecast modeling in various industries such as business, agriculture, weather, supply chain, among other ones.
The equation of a straight line is usually written as \(y = mx + c\).
The equation of a simple linear regression line is:
\[ y = \beta_0 + \beta_1x \]
This plot shows the linear relationship between various data points
## `geom_smooth()` using formula = 'y ~ x'
This example is like the previous one, but this one involves 2 groups of data points
## `geom_smooth()` using formula = 'y ~ x'
R code that generates a plotly as an example for linear regression
library(plotly) set.seed(123) data = data.frame( x = 1:100, y = 2 * (1:100) + rnorm(100, mean = 0, sd = 20) ) mod = lm(y ~ x, data = data) plot_ly(data, x = ~x, y = ~y, type = "scatter", mode = "markers", name= "values") %>% add_trace(x = ~x, y = fitted(mod), mode = "lines", name = "Regression Line")
Another example of linear regression with plotly