Description Usage Arguments Details Value See Also Examples
View source: R/simple_linear_regression_movie.R
A movie to help to visualize the fitting of a regression line using least squares in the case of a simple linear regression, that is, a linear regression of one response variable on one explanatory variable.
1 | lin_reg_movie(data, delta_alpha = 0.1, delta_beta = 1e-04, ...)
|
data |
A data frame with two variables or a numeric matrix with 2 columns. The first column must contain the response data, the second column the explanatory data. |
delta_alpha, delta_beta |
Numeric scalars. The respective amounts by
which the values of the intercept and gradient of the line are
increased/decreased after one click of the +/- button.
The default values are set with the |
... |
Further arguments, such as graphical parameters
(see |
A scatter plot of response data against the explanatory data is produced. On this plot is superimposed a dashed line that the user can move, by changing its intercept alpha and gradient beta using +/- buttons. The initial value of alpha is the mean of the response data and the initial value of beta is 0. The sizes of the residuals are shown using red lines. One of the legends gives the current sum of squares residuals (SS).
Another +/- button allows the user to add the least squares regression line to the plot, and the associated residual sum of squares (RSS) to the legend, for comparison.
Nothing is returned, only the animation is produced.
movies
: general information about the movies.
1 2 3 4 5 6 7 8 9 10 | # Load package rpanel
# [Use install.packages("rpanel") if necessary]
library(rpanel)
# Produce movie using values from the Aussie births data
## Not run:
lin_reg_movie(hubble, pch = 16, xlab = "recession velocity (km/sec)",
ylab = "distance (megaparsecs)")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.