---
title: "intro-to-RANSAC.Rmd"
author: "Jadson Abreu"
date: "2025-04-29"
output: html_document
---
title: "Introduction to the RANSAC Package"
author: "Jadson Abreu"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to the RANSAC Package}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# Introduction

This package provides robust fitting methods for linear and nonlinear models using the RANSAC algorithm.

# Basic Usage

## Linear Example

```r
library(RANSAC)

# Simulate data
set.seed(123)
x <- 1:20
y <- 2*x + rnorm(20)
y[c(18,19,20)] <- y[c(18,19,20)] + 30 # Add outliers
dados <- data.frame(x = x, y = y)

# Fit using ransac_reg
modelo <- ransac_reg(y ~ x, data = dados, n_min = 2, tol = 5)

summary(modelo)

# Simulate data
set.seed(456)
x <- seq(1, 10, length.out = 20)
y <- 2 * x^1.5 + rnorm(20)
y[c(18,19,20)] <- y[c(18,19,20)] + 50
dados <- data.frame(x = x, y = y)

# Fit using ransac_nls
modelo <- ransac_nls(y ~ a * x^b, data = dados, start = list(a = 1, b = 1.5), n_min = 3, tol = 10)

summary(modelo)