Skip to contents

Fits a curve using a generalised additive model

Usage

fit_custom(x, y, k = NULL)

Arguments

x

vector of numeric predictor variable

y

vector of numeric response variable, of same length as x

k

passed onto smooth term of x. Default is length(x) - 1

Value

function that accepts x and returns y based on fitted model

Details

Fits a generalised additive model (GAM) using the mgcv package.

See also

Examples

my_func <- EndoSim:::fit_custom(
c(4, 8.87, 11.82, 14.22, 17.13, 19.92, 22.61, 25.77, 27.80, 30),
c(0, 0.06, 0.09, 0.11, 0.13, 0.15, 0.16, 0.14, 0.04, 0)
)
plot(seq(0, 50, by = 0.1), my_func(seq(0, 50, by = 0.1)), type = "l")