interactive_regression: compstatslib interactive_regression() function

View source: R/regression_interactive.R

interactive_regressionR Documentation

compstatslib interactive_regression() function

Description

Interactive visualization function that lets you point-and-click to add data points, while it automatically plots and updates a regression line and associated statistics.

Usage

interactive_regression(points, ...)

Click on the plotting area to add points and see a corresponding regression line (hitting ESC will stop the simulation).

Arguments

points

An optional dataframe of *x* and *y* points to plot and estimate the regression. If no points are provided, the user is free to click and create points on the plot area.

...

Further arguments passed to the plot_regr() function that produces the plot.

Value

A dataframe containing the points coordinates. Additionally, the following parameters are provided on the plot area:

Raw intercept

The y-coordinate at which the regression line crosses the y-axis.

Raw slope

The value of the slope parameter.

Correlation

The strength of the linear relationship.

SSR

The sum of squares regression.

SSE

The sum of squares error.

SST

The sum of squares total.

R-squared

The multiple coefficient of determination.

See Also

plot_regr

Examples

# Selecting coordinates on the plot area, storing them in 'pts'
pts <- interactive_regression()

# Replotting the points stored earlier in 'pts', allowing the user to continue the interactive regression
interactive_regression(pts)

# Providing coordinates beforehand
points <- data.frame(x = c(1, 4, 7), y = c(2, 5, 8))

# Replotting the coordinates and continuing the interactive regression
interactive_regression(points)


soumyaray/compstatslib documentation built on March 11, 2023, 8:39 p.m.