sim_quasianscombe_set_2: Generate _quasi_ Anscombe data sets Type 2: No linear...

View source: R/quasianscombe.R

sim_quasianscombe_set_2R Documentation

Generate quasi Anscombe data sets Type 2: No linear relationship

Description

Data sets Type 2 shows how a no linear relationship between x and y can lead in the same regression model (in terms of parameter values) of the Type 1.

Usage

sim_quasianscombe_set_2(
  df,
  fun = function(x) {
     x^2
 },
  residual_factor = 0.25
)

Arguments

df

A data frame from sim_quasianscombe_set_1 (or similar).

fun

A function to apply, this is applied to normalized version of x.

residual_factor

Numeric value to multiply residual to modify their variance.

Examples


df <- sim_quasianscombe_set_1()

dataset2 <- sim_quasianscombe_set_2(df)

dataset2

plot(dataset2)

plot(sim_quasianscombe_set_2(df, residual_factor = 0))

fun1 <- function(x){ 2 * sin(x*diff(range(x))) }

plot(sim_quasianscombe_set_2(df, fun = fun1))

fun2 <- abs

plot(sim_quasianscombe_set_2(df, fun = fun2))

fun3 <- function(x){ (x - mean(x)) * sin(x*diff(range(x))) }

plot(sim_quasianscombe_set_2(df, fun = fun3))


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