sim_quasianscombe_set_3: Generate _quasi_ Anscombe data sets Type 3: Extreme values...

View source: R/quasianscombe.R

sim_quasianscombe_set_3R Documentation

Generate quasi Anscombe data sets Type 3: Extreme values (a.k.a Outliers)

Description

Data sets Type 3 get some outliers but conserving the $x$ mean and the same coefficients -but different significance- of the adjusted linear model.

Usage

sim_quasianscombe_set_3(
  df,
  prop = 0.05,
  beta1_factor = 0.5,
  residual_factor = 0.25
)

Arguments

df

A data frame from sim_quasianscombe_set_1 (or similar).

prop

The proportion of value to modify as outliers.

beta1_factor

Numeric value to modify the beta1 value.

residual_factor

Numeric value to multiply residual to modify their variance.

Details

This function will:

  • Calculate the linear regression model and will calculate new trend using 0.5 times beta1

  • Take prop% values from the greater 2*prop x values and modify the related y value to get the original estimation of beta1

  • Apply residual_factor factor to residual to get minor variance and better visual impression of the outliers effect.

Examples


df <- sim_quasianscombe_set_1()

dataset3 <- sim_quasianscombe_set_3(df)

dataset3

plot(dataset3)

plot(sim_quasianscombe_set_3(df, prop = 0.1, residual_factor = 0))


jbkunst/klassets documentation built on Dec. 7, 2022, 9:18 p.m.