smooth.construct.cx.smooth.spec(scam)
smooth.construct.cx.smooth.spec()所属R语言包:scam
Constructor for convex P-splines in SCAMs
凸P-样条的构造诈骗
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This is a special method function for creating smooths subject to convexity constraint which is built by the mgcv constructor function for smooth terms, smooth.construct. It is constructed using the mixed constrained P-splines. This smooth is specified via model terms such as s(x,k,bs="cx",m=2), where k denotes the basis dimension and m+1 is the order of the B-spline basis.
这是一种特殊的方法,用于创建平滑功能凸性约束,是建立在mgcv的构造函数的光滑条款,smooth.construct。这是构建使用的混合约束的P-样条曲线。这种平稳的规定,通过模型计算,如s(x,k,bs="cx",m=2),这里k为基础尺寸和m+1是B样条基的顺序。
用法----------Usage----------
smooth.construct.cx.smooth.spec(object, data, knots)
参数----------Arguments----------
参数:object
A smooth specification object, generated by an s term in a GAM formula.
光滑的规范对象,产生的s术语一个GAM公式中。
参数:data
A data frame or list containing the data required by this term, with names given by object$term. The by variable is the last element.
一个数据框或列表,其中包含这个词所需要的数据,的名字的object$term。 by变量的最后一个元素。
参数:knots
An optional list containing the knots supplied for basis setup. If it is NULL then the knot locations are generated automatically.
一个可选的列表,其中包含基础设置中提供的疙瘩。如果是NULL然后结位置自动生成。
值----------Value----------
An object of class "cx.smooth".
对象的类"cx.smooth"。
(作者)----------Author(s)----------
Natalya Pya <nat.pya@gmail.com>
参考文献----------References----------
参见----------See Also----------
smooth.construct.cv.smooth.spec, smooth.construct.mpi.smooth.spec, smooth.construct.mdcv.smooth.spec, smooth.construct.mdcx.smooth.spec, smooth.construct.micv.smooth.spec, smooth.construct.mpd.smooth.spec
smooth.construct.cv.smooth.spec,smooth.construct.mpi.smooth.spec,smooth.construct.mdcv.smooth.spec,smooth.construct.mdcx.smooth.spec,smooth.construct.micv.smooth.spec,smooth.construct.mpd.smooth.spec
实例----------Examples----------
## Not run: [#不运行:]
## Convex P-splines example [#凸P-样条曲线的例子]
## simulating data...[#模拟数据...]
set.seed(1)
n <- 100
x <- sort(2*runif(n)-1)
f <- 4*x^2
y <- f + rnorm(n)*0.4
dat <- data.frame(x=x,y=y)
b <- scam(y~s(x,k=15,bs="cx",m=2),family=gaussian,data=dat)
# UNCONSTRAINED FIT *****************[无约束FIT *****************]
b1 <- scam(y~s(x,k=15,bs="cr",m=2),family=gaussian, data=dat)
## plot results ...[#图...]
plot(x,y,xlab="x",ylab="y")
lines(x,f) ## the true function[#真正的功能]
lines(x,b$fitted,col=2) ## constrained fit [#制约适合]
lines(x,b1$fitted,col=3) ## unconstrained fit [#不受约束的契合]
## Poisson version...[#泊松版本...]
y <- rpois(n,exp(f))
dat <- data.frame(x=x,y=y)
## fit model ...[#拟合模型...]
b <- scam(y~s(x,k=15,bs="cx",m=2),family=poisson(link="log"),data=dat)
# UNCONSTRAINED FIT *****************[无约束FIT *****************]
b1 <- scam(y~s(x,k=15,bs="cr",m=2),family=poisson(link="log"), data=dat)
## plot results ...[#图...]
plot(x,y,xlab="x",ylab="y")
lines(x,exp(f)) ## the true function[#真正的功能]
lines(x,b$fitted,col=2) ## constrained fit [#制约适合]
lines(x,b1$fitted,col=3) ## unconstrained fit [#不受约束的契合]
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|