Learn R Programming

TestFunctions (version 0.2.2)

subtractlm: Subtract linear model from a function

Description

This returns a new function which a linear model has an r-squared of 0.

Usage

subtractlm(func, d, n = d * 100)

Value

A new function

Arguments

func

A function

d

Number of input dimensions

n

Number of points to use for the linear model

Examples

Run this code
subtractlm(ackley, 2)

# \donttest{
  f <- function(x) {
    if (is.matrix(x)) x[,1]^2
    else x[1]^2
  }
  ContourFunctions::cf(f)
  ContourFunctions::cf(subtractlm(f, 2), batchmax=Inf)
# }

Run the code above in your browser using DataLab