ransac_reg {RANSAC}R Documentation

Robust Linear Model Fitting via RANSAC

Description

Fits a robust linear model ('lm') using the RANSAC algorithm.

Usage

ransac_reg(formula, data, n_min, n_iter = 100, tol = 0.2, verbose = FALSE)

Arguments

formula

Model formula (as in 'lm').

data

Data frame containing the model variables.

n_min

Minimum number of points to fit the model (e.g., 2 for a straight line).

n_iter

Number of iterations (higher values make the model more robust).

tol

Absolute tolerance to consider a point as an inlier.

verbose

If 'TRUE', shows progress messages.

Value

An 'lm' model fitted only to the inliers, with an additional class '"ransac_model"' and an '"inliers"' attribute.

Examples

set.seed(123)
x <- 1:10
y <- c(1, 2, 3, 4, 5, 6, 7, 8, 50, 60) # some outliers
data <- data.frame(x = x, y = y)
model <- ransac_reg(y ~ x, data = data, n_min = 2, tol = 5)
summary(model)


[Package RANSAC version 0.1.0 Index]