Displaying 20 results from an estimated 3000 matches similar to: "package spline - default value of Boundary.knots of ns"
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
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
2006 Sep 08
0
boundary constraints with smooth.spline
Hi R Community.
I would like to use smooth.spline to fit a set of data and constrain the
endpoints of the fit to have specific derivatives. I know this is
possible with cubic splines, but I can't figure out how to specify this
with arguments to the smooth.spline function. In general, is it possible
to specify a set of "knots" w/locations and derivatives to constrain the
fit? I
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
2002 Jul 29
0
Choosing knots of B-splines
Dear Sir,
I am taking about the choosing knots of B-splines. Can you tel me the R
docomentation for choosing the knots of B-splines automatically? It is
possible to choose the knots by eye, but which is time consuming and a
little arbitrary.
Thanks for your reply.
Shahid
PhD Student
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read
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 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
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
2013 Nov 01
0
Impose constraint on first order derivative at a point for cubic smoothing spline
Hello,
Dr. Simon Wood told me how to force a cubic spline passing through a
point. The code is as following. Anyone who knows how I can change the code
to force the first derivative to be certain value. For example, the first
derivative of the constrained cubic spline equals 2 at point (0, 0.6).
I really appreciate your help!
Thanks!
Best
Victor
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 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
2012 Nov 29
1
[mgcv][gam] Manually defining my own knots?
Dear List,
I'm using GAMs in a multiple imputation project, and I want to be able
to combine the parameter estimates and covariance matrices from each
completed dataset's fitted model in the end. In order to do this, I
need the knots to be uniform for each model with partially-imputed
data. I want to specify these knots based on the quantiles of the
unique values of the non-missing
2003 May 26
0
knots fixed in gam(), library(mgcv)
Dear all,
I have a problem with specifying the no. of knots in our function which
include gam(). I last worked with this in mid September but since then I
have reinstalled R and Simon Wood's library(mgcv), which he has changed
since then. The statistician (and good R-coder) with whom I co-operate is
now unfortunately overloaded with teaching, and I'm in the sprut of my
thesis.... I
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
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
2009 Oct 13
2
How to choose a proper smoothing spline in GAM of mgcv package?
Hi, there,
I have 5 datasets. I would like to choose a basis spline with same knots in
GAM function in order to obtain same basis function for 5 datasets.
Moreover, the basis spline is used to for an interaction of two covarites.
I used "cr" in one covariate, but it can only smooth w.r.t 1 covariate. Can
anyone give me some suggestion about how to choose a proper smoothing spline
2010 May 06
0
spm() default knots
Hi,
When you use the default knot choice in spm() (library(SemiPar)) a figure
showing the knot locations is sent to the screen and you have to accept the
knots to move on.
I am trying to run simulations using this function. Is there a way to get
spm() to use the default "REML" knots without needing to approve each set of
knots?
Here is an example:
library(SemiPar)
data(scallop)
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
2008 Nov 06
0
Inference and confidence interval for a restricted cubic spline function in a hurdle model
Dear list,
I'm currently analyzing some count data using a hurdle model. I've used
the rcspline.eval function in the Hmisc-library to contruct the spline
terms for the regression model, and what I want in the end is the ability
to compute coefficients and confidence intervals for different changes in
the smooth function as well as plotting the smooth function along with the