bs(splines)
bs()所属R语言包:splines
B-Spline Basis for Polynomial Splines
多项式样条B样条基
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Generate the B-spline basis matrix for a polynomial spline.
生成多项式样条B样条基矩阵。
用法----------Usage----------
bs(x, df = NULL, knots = NULL, degree = 3, intercept = FALSE,
Boundary.knots = range(x))
参数----------Arguments----------
参数:x
the predictor variable. Missing values are allowed.
预测变量。遗漏值是不允许的。
参数:df
degrees of freedom; one can specify df rather than knots; bs() then chooses df-degree (minus one if there is an intercept) knots at suitable quantiles of x (which will ignore missing values).
自由度;可以指定df而不是knots;bs()然后选择df-degree(减一,如果有一个拦截)节在合适的x位数(会忽略缺失值)。
参数:knots
the internal breakpoints that define the spline. The default is NULL, which results in a basis for ordinary polynomial regression. Typical values are the mean or median for one knot, quantiles for more knots. See also Boundary.knots.
定义样条曲线的内部断点。默认是的NULL,导致在一个普通的多项式回归的基础上。典型值的均值或中位数为一个结,位数多海里。还可以看Boundary.knots。
参数:degree
degree of the piecewise polynomial—default is 3 for cubic splines.
度分段多项式默认的是了3为三次样条。
参数:intercept
if TRUE, an intercept is included in the basis; default is FALSE.
如果TRUE截距包括在基础;默认是FALSE。
参数:Boundary.knots
boundary points at which to anchor the B-spline basis (default the range of the data). If both knots and Boundary.knots are supplied, the basis parameters do not depend on x. Data can extend beyond Boundary.knots.
锚边界点的B样条的基础上(默认情况下,数据的范围)。如果这两个knots和Boundary.knots提供基础参数不依赖于x。数据可以延长超出Boundary.knots。
值----------Value----------
A matrix of dimension c(length(x), df), where either df was supplied or if knots were supplied, df = length(knots) + degree plus one if there is an intercept. Attributes are returned that correspond to the arguments to bs, and explicitly give the knots, Boundary.knots etc for use by predict.bs().
维矩阵c(length(x), df),其中任一df提供或如果knots提供,df = length(knots) + degree加一,如果有一个拦截。返回的属性,对应的参数bs,并明确给knots,Boundary.knots等predict.bs()。
bs() is based on the function spline.des(). It generates a basis matrix for representing the family of piecewise polynomials with the specified interior knots and degree, evaluated at the values of x. A primary use is in modeling formulas to directly specify a piecewise polynomial term in a model.
bs()是基于功能spline.des()。它生成分段多项式的家庭代表与指定的内部结和程度的基础矩阵,评估值x。一个主要用途是在建模公式直接在模型中指定一个分段多项式项。
参考文献----------References----------
Generalized additive models. Chapter 7 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
参见----------See Also----------
ns, poly, smooth.spline, predict.bs, SafePrediction
ns,poly,smooth.spline,predict.bs,SafePrediction
举例----------Examples----------
require(stats); require(graphics)
bs(women$height, df = 5)
summary(fm1 <- lm(weight ~ bs(height, df = 5), data = women))
## example of safe prediction[#例如安全预测]
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
ht <- seq(57, 73, length.out = 200)
lines(ht, predict(fm1, data.frame(height=ht)))
## Not run: [#无法运行:]
## Consistency:[#一致性:]
x <- c(1:3,5:6)
stopifnot(identical(bs(x), bs(x, df = 3)),
!is.null(kk <- attr(bs(x), "knots")),# not true till 1.5.1[没有真正到1.5.1]
length(kk) == 0)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|