place.knots: Automatically place a set of knots evenly through covariate...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/smooth.r

Description

Given a univariate array of covariate values, places a set of knots for a regression spline evenly through the covariate values.

Usage

1
 place.knots(x,nk)

Arguments

x

array of covariate values (need not be sorted).

nk

integer indicating the required number of knots.

Details

Places knots evenly throughout a set of covariates. For example, if you had 11 covariate values and wanted 6 knots then a knot would be placed at the first (sorted) covariate value and every second (sorted) value thereafter. With less convenient numbers of data and knots the knots are placed within intervals between data in order to achieve even coverage, where even means having approximately the same number of data between each pair of knots.

Value

An array of knot locations.

Author(s)

Simon N. Wood simon.wood@r-project.org

References

https://www.maths.ed.ac.uk/~swood34/

See Also

smooth.construct.cc.smooth.spec

Examples

1
2
3
4
require(mgcv)
x<-runif(30)
place.knots(x,7)
rm(x)

Example output

Loading required package: nlme
This is mgcv 1.8-28. For overview type 'help("mgcv-package")'.
[1] 0.01650589 0.10431085 0.26495561 0.46208547 0.60472471 0.68397452 0.91692271

mgcv documentation built on Oct. 6, 2021, 9:07 a.m.