Description Usage Arguments Details Value Author(s) References Examples
Fit a smoothing spline with constraints on derivatives
1 2 3 | constrained.smoothspline(y, times, pen.degree, constraint = "fixed",
derivative.values = NA, initial.value = NA, times.new,
num.folds = "leave-one-out", lambda = "optim")
|
y |
a vector of response variables. |
times |
a vector of time points at which y was measured, same length as y. |
pen.degree |
desired degree of the derivative in smoothing penalty. |
constraint |
one of 'none', 'fixed' or 'bounded' depending on whether the derivatives should not be constrained, fixed to a constant or bounded in an interval, respectively. |
derivative.values |
either a vector with the same length as y if contraint=='fixed' or a matrix with 2 columns conatining the lower and upper bounds on the derivatives if contraint=='bounded'. |
initial.value |
optional paramter that specifies an initial value of the spline incase it should be fixed. |
times.new |
optional vector of new time points at which the spline should be evaluated. |
num.folds |
either a numeric value of the number of folds or the string "leave-one-out" for a leave one out type cross-validation in determining the penalty parameter. |
lambda |
either a numeric value if the penalty parameter is fixed explicitely or one of the values 'optim' or 'grid.search' depending on the desired optimization procedure. |
For further details see the references.
a list consisting of the following elements
smooth.vals |
predicted values at points times |
residual |
residuals |
smooth.vals.new |
predicted values at time points times.new |
smooth.deriv |
predicted derivative values at points times |
pen.par |
penality parameter used for smoothing |
Niklas Pfister, Stefan Bauer and Jonas Peters
Pfister, N., S. Bauer, J. Peters (2018). Identifying Causal Structure in Large-Scale Kinetic Systems ArXiv e-prints (arXiv:1810.11776).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Example
x <- seq(0,4,length.out=200)
x.long <- seq(0,4,length.out=200)
y <- x^2+rnorm(200,0,2)
dy <- 2*x
dybdd <- cbind(dy-0.5,dy+0.5)
plot(x,y)
ptm <- proc.time()
fit <- constrained.smoothspline(y=y,
times=x,
pen.degree=2,
constraint="none",
derivative.values=NA,
times.new=x.long,
num.folds=5,
lambda="optim")
print(proc.time()-ptm)
fit2 <- smooth.spline(x,y)
lines(x.long,fit[[3]],col="blue")
lines(fit2, col="green")
lines(x.long, x.long^2, col="black")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.