Displaying 6 results from an estimated 6 matches for "smoothcon".
2009 Feb 25
1
monotonic GAM with more than one term
...quot;one","two"), class="factor")
yy <- predict(f.ug, newdata=data.frame(m=mm,x=xx))
bool <- mm=="one"
lines(xx[bool],yy[bool], lty=2) # show effect of extrapolation
lines(xx[!bool],yy[!bool], lty=2)
# this is where I start running into trouble
sm<-smoothCon(s(x,k=10,by=m,bs="cr"),dat,knots=NULL)[[1]]
FF<-mono.con(sm$xp); # get constraints
G<-list(y=y,
w=rep(1, n),
X=sm$X,
C=matrix(0,0,0),
S = sm$S,
off = 0,
sp=f.ug$sp,
p=sm$xp,
Ain = FF$A,...
2013 Mar 11
1
Use pcls in "mgcv" package to achieve constrained cubic spline
...*4-1;x<-sort(x);
f<-exp(4*x)/(1+exp(4*x));y<-f+rnorm(100)*0.1;plot(x,y)
dat<-data.frame(x=x,y=y)
# Show regular spline fit (and save fitted object)
f.ug<-gam(y~s(x,k=10,bs="cr"));lines(x,fitted(f.ug))
# Create Design matrix, constraints etc. for monotonic
spline....
sm<-smoothCon(s(x,k=10,bs="cr"),dat,knots=NULL)[[1]]
F<-mono.con(sm$xp); # get constraints
G<-list(X=sm$X,C=matrix(0,0,0),sp=f.ug$sp,p=sm$xp,y=y,w=y*0+1)
G$Ain<-F$A;G$bin<-F$b;G$S<-sm$S;G$off<-0
p<-pcls(G); # fit spline (using s.p. from unconstrained fit)
fv<-Predict.matrix(sm,d...
2005 Mar 11
0
mgcv 1.2-0
...ing
tensor product smooths. See ?fixDependence and ?gam.side for details.
* By default all smooths are now parameterized to be centred, without
requiring additional constraints (this is automatic and applies also to
user defined smooths). The old behaviour is still available as an option.
See ?smoothCon for details. (This should be user transparent.)
* Smoothing parameter initialization has been modified for better
performance with tensor product smooths. See ?initial.sp.
* By default, tensor product smooths have been modified to use more
interpretable penalties. See ?te for details. This lea...
2005 Mar 11
0
mgcv 1.2-0
...ing
tensor product smooths. See ?fixDependence and ?gam.side for details.
* By default all smooths are now parameterized to be centred, without
requiring additional constraints (this is automatic and applies also to
user defined smooths). The old behaviour is still available as an option.
See ?smoothCon for details. (This should be user transparent.)
* Smoothing parameter initialization has been modified for better
performance with tensor product smooths. See ?initial.sp.
* By default, tensor product smooths have been modified to use more
interpretable penalties. See ?te for details. This lea...
2010 May 19
1
Displaying smooth bases - mgcv package
Dear all,
for demonstration purposes I want to display the basis functions used by a
thin plate regression spline in a gamm model. I've been searching the help
files, but I can't really figure out how to get the plots of the basis
functions. Anybody an idea?
Some toy code :
require(mgcv)
require(nlme)
x1 <- 1:1000
x2 <- runif(1000,10,500)
fx1 <- -4*sin(x1/50)
fx2 <-
2013 Nov 01
0
Impose constraint on first order derivative at a point for cubic smoothing spline
...exp(4*x));y <- f+rnorm(100)*0.1;plot(x,y)
dat <- data.frame(x=x,y=y)
## Create a spline basis and penalty, making sure there is a knot
## at the constraint point, (0 here, but could be anywhere)
knots <- data.frame(x=seq(-1,3,length=9)) ## create knots
## set up smoother...
sm <- smoothCon(s(x,k=9,bs="cr"),dat,knots=knots)[[1]]
## 3rd parameter is value of spline at knot location 0,
## set it to 0 by dropping...
X <- sm$X[,-3] ## spline basis
S <- sm$S[[1]][-3,-3] ## spline penalty
off <- y*0 + .6 ## offset term to force curve through (0, .6)
##...