qspliner: Create a quadratic spline (inefficiently)

View source: R/qspliner.R

qsplinerR Documentation

Create a quadratic spline (inefficiently)

Description

A handmade function to construct quadratic splines.

Usage

qspliner(tilde, data, free = 0)

Arguments

tilde

A tilde expression of the form y ~ x specifying the output variable (on the LHS) and the input variable (on the RHS). Together with data, these (x,y) pairs will be the knots for the spline.

data

A data frame containing the variables in tilde.

free

A number specifying the slope of the output function at the last knot. Default is 0: that is, flat.

Details

Unless you have a good reason otherwise, you should be using spliner(), which generates cubic splines, rather than qspliner(). qspliner() is intended only for demonstration purposes.

Examples

Pts <- tibble(x = seq(-4,4, by=.7), y = dnorm(x))
f <- qspliner(y ~ x, data = Pts)
slice_plot(dnorm(x) ~ x, domain(x=-4:4)) %>%
  slice_plot(f(x) ~ x, color= "blue") %>%
  gf_point(y ~ x, data = Pts, color = "orange", size=4, alpha=0.3) %>%
  gf_lims(y= c(NA,.5))

mosaicCalc documentation built on Sept. 15, 2022, 9:06 a.m.