Displaying 20 results from an estimated 6000 matches similar to: "Choosing knots of B-splines"
2024 Jul 08
0
package spline - default value of Boundary.knots of ns
Dear Maintainer,
Thanks for the excellent package splines. I am writing this email to request you to consider a suggestion I have with regards to the function ns.
While trying to rework an example from a textbook, I couldn't call ns with appropriate arguments to reproduce the results. The package documentation also couldn't help me find the problem. Finally, I found a stack exchange
2008 Jul 29
1
tensor product of equi-spaced B-splines in the unit square
Dear all,
I need to compute tensor product of B-spline defined over equi-spaced
break-points.
I wrote my own program (it works in a 2-dimensional setting)
library(splines)
# set the break-points
Knots = seq(-1,1,length=10)
# number of splines
M = (length(Knots)-4)^2
# short cut to splineDesign function
bspline = function(x) splineDesign(Knots,x,outer.ok = T)
# bivariate tensor product of
2013 Feb 27
1
Finding the knots in a smoothing spline using nknots
Hi r-helpers.
Please forgive my ignorance, but I would like to plot a smoothing spline
(smooth.spline) from package "stats", and show the knots in the plot, and I
can't seem to figure out where smooth.spline has located the knots (when I
use nknots). Unfortunately, I don't know a lot about splines, but I know
that they provide me an easy way to estimate the location of local
2024 Jul 26
1
Automatic Knot selection in Piecewise linear splines
dear all,
I apologize for my delay in replying you. Here my contribution, maybe
just for completeness:
Similar to "earth", "segmented" also fits piecewise linear relationships
with the number of breakpoints being selected by the AIC or BIC
(recommended).
#code (example and code from Martin Maechler previous email)
library(segmented)
o<-selgmented(y, ~x, Kmax=20,
2024 Jul 16
2
Automatic Knot selection in Piecewise linear splines
>>>>> Anupam Tyagi
>>>>> on Tue, 9 Jul 2024 16:16:43 +0530 writes:
> How can I do automatic knot selection while fitting piecewise linear
> splines to two variables x and y? Which package to use to do it simply? I
> also want to visualize the splines (and the scatter plot) with a graph.
> Anupam
NB: linear splines, i.e. piecewise
2010 Jun 11
1
Documentation of B-spline function
Goodmorning,
This is a documentation related question about the B-spline function in R.
In the help file it is stated that:
"df degrees of freedom; one can specify df rather than knots; bs() then chooses df-degree-1 knots at suitable quantiles of x (which will ignore missing values)."
So if one were to specify a spline with 6 degrees of freedom (and no intercept) then a basis
2008 May 01
1
Optimal knot locations for splines
Suppose I have two variables, x and y. For a fixed number of knots, I want
to create a spline transformation of x such that a loss function is
minimized. Presumably, this loss function would be least squares, i.e. sum
(f(x)-y)^2. The spline transformations would be linear, quadratic or
cubic. I know I can solve this problem using some optimization function in
R, but I was wondering if anyone
2012 Mar 12
1
Fwd: Re[2]: B-spline/smooth.basis derivative matrices
--- On Mon, 3/12/12, aleksandr shfets <a_shfets at mail.ru> wrote:
> From: aleksandr shfets <a_shfets at mail.ru>
> Subject: Fwd: Re[2]: [R] B-spline/smooth.basis derivative matrices
> To: "Vassily Shvets" <shv736 at yahoo.com>
> Received: Monday, March 12, 2012, 5:15 PM
>
>
>
> -------- ???????????? ?????????
> --------
> ?? ????:
2010 Apr 19
0
Natural cubic splines produced by smooth.Pspline and predict function in the package "pspline"
Hello,
I am using R and the smooth.Pspline function in the pspline package to
smooth some data by using natural cubic splines. After fitting a
sufficiently smooth spline using the following call:
(ps=smooth.Pspline(x,y,norder=2,spar=0.8,method=1)
[the values of x are age in years from 1 to 100]
I tried to check that R in fact had fitted a natural cubic spline by
checking that the resulting
2007 Jul 04
3
Problem/bug with smooth.spline and all.knots=T
Dear list,
if I do
smooth.spline(tmpSec, tmpT, all.knots=T)
with the attached data, I get this error-message:
Error in smooth.spline(tmpSec, tmpT, all.knots = T) :
smoothing parameter value too small
If I do
smooth.spline(tmpSec[-single arbitrary number], tmpT[-single arbitrary number], all.knots=T)
it works!
I just don't see it. It works for hundrets other datasets, but not for
2003 May 08
2
natural splines
Apologies if this is this too obscure for R-help.
In package splines, ns(x,,knots,intercept=TRUE) produces an n by K+2
matrix N, the values of K+2 basis functions for the natural splines with K
(internal) knots, evaluated at x. It does this by first generating an
n by K+4 matrix B of unconstrained splines, then postmultiplying B by
H, a K+4 by K+2 representation of the nullspace of C (2 by K+4),
2024 Jul 09
1
Automatic Knot selection in Piecewise linear splines
How can I do automatic knot selection while fitting piecewise linear
splines to two variables x and y? Which package to use to do it simply? I
also want to visualize the splines (and the scatter plot) with a graph.
Anupam
[[alternative HTML version deleted]]
2007 Dec 07
1
Make natural splines constant outside boundary
Hi,
I'm using natural cubic splines from splines::ns() in survival
regression (regressing inter-arrival times of patients to a queue on
queue size). The queue size fluctuates between 3600 and 3900.
I would like to be able to run predict.survreg() for sizes <3600 and
>3900 by assuming that the rate for <3600 is the same as for 3600 and
that for >4000 it's the same as for
2005 Jun 14
0
bs() function of the splines package
Laurent 14 juin 12:02 afficher les options
De : "Laurent" <eddy_l... at hotmail.com> - Rechercher les messages de cet
auteur
Date : Tue, 14 Jun 2005 03:02:37 -0700
Local : Mar 14 juin 2005 12:02
Objet : bs() function of the splines package
R??pondre | R??pondre ?? l'auteur | Transf??rer | Imprimer | Message individuel
| Afficher l'original | Retirer | Signaler un
2005 Jul 24
1
Buglet in src/appl/splines.c (PR#8030)
--AZaLVt6Pw+
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit
Dear all,
I was looking at "splinefun" and the underlying C code and believe
that there is a memory access error in the C routine "spline_eval".
Specifically, on line 368 and following the following code appears:
if(ul < x[i] || x[i+1] < ul)
2011 May 14
0
obscure error message from splines::ns
In the following case,
library(splines)
tt <- c(55, 251, 380, 289, 210, 385, 361, 669)
nn <- rep(0:7,tt)
ns(nn,4)
## knots are located at (0.25,0.5,0.75); quantiles = (2,5,7)
we get the error
Error in qr.default(t(const)) :
NA/NaN/Inf in foreign function call (arg 1)
because the 75th quantile (the location of the last "interior" knot)
ends up on the boundary. As a
2010 Nov 17
1
where are my pspline knots?
Hi All,
I am trying to figure out how to get the position of the knots in a pspline used in a cox model.
my.model = coxph(Surv(agein, ageout, status) ~ pspline(x), mydata) # x being continuous
How do I find out where the knot of the spline are? I would like to know to figure out how many cases are there between each knot.
Best,
Federico
--
Federico C. F. Calboli
Department of Epidemiology
2013 May 28
3
R-3.0.1 - "transient" make check failure in splines-EX.r
Hello.
I seem to be having the same problem that Paul had in the thread titled "[Rd] R 2.15.2 make check failure on 32-bit --with-blas="-lgoto2"" from October of last year <https://stat.ethz.ch/pipermail/r-devel/2012-October/065103.html> Unfortunately, that thread ended without an answer to his last question.
Briefly, I am trying to compile an Rblas for Windows NT 32bit
2005 Jun 14
0
bs() function of the splines package with intercept=FALSE
Hello,
I'm implementing a function using non uniform B-Splines. Looking at the
code of the bs() function, I realized that if the intercept was set to
FALSE, the behavior of the function was the following (df is the number
of degrees of freedom that I believe can be interpreted as the number
of control points):
- Compute df- ord + 1 _internal_ knots (ord is the order of the spline)
- Add ord
2009 Sep 20
1
How to choose knots for GAM?
Hi, all
I want to choose same knots in GAM for 10 different studies so that they has
the same basis function. Even though I choose same knots and same dimensions
of basis smoothing, the basis representations are still not same.
My command is as follows:
data.gam<-gam(y~s(age,bs='cr',k=10)+male,family=binomial,knots=list(age=seq(45,64,length=10)))
What is my mistake for choice of