Questions tagged [splines]

Splines are flexible functions, knit together from polynomial parts, used for approximation or smoothing. This tag is for any kind of spline (eg, B-splines, regression splines, thin-plate splines, etc).

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

In R, how to estimate the spline curve by Least Square method? [closed]

n = 50 set.seed(100) x = matrix(runif(n, -2, 2), nrow=n) y = 2 + 0.75*sin(x) - 0.75*cos(x) + rnorm(n, 0, 0.2) In R, I want to estimate above spline function by ...
0
votes
0answers
10 views

p-value in restricted cubic splines regression

How to calculate the p for overall and p for nonlinearity for a RCS model in STATA? Like what they did in this picture.
1
vote
0answers
34 views

Replicating a Tweedie corrected experiment from Computer Age Statistical Inference

I have been attempting to replicate an experiment from Computer Age Statistical Inference by Bradley Efron and Trevor Hastie on page 411. In this experiment 100 datasets are populated normal random ...
0
votes
0answers
21 views

Representation of cubic-linear spline in mgcv::gam

I have a dataset of empirical hazard rates which I would like to model to produce a reasonable forecast of the survival rate. I'd like to use a cubic-linear spline to fit the logit-transformed hazards ...
1
vote
1answer
41 views

Trying to smooth small 'bumps' in graph data using spline interpolation for changepoint detection

I'm trying to detect changes in my data, I want to identify points that are like local minima and shoot upwards. I have used the changepoint package to do so, and upon running it and selecting my ...
0
votes
0answers
10 views

How do cubic natural spline fit the last and last but one regions?

Consider natural cubic splines with three knots having the basis functions suggested from Elements of statistical learning: $$h_1(X) = 1,\quad h_2(X) = X, \quad h_3(X) = d_1(X) -d_2(X) \\ \text{with} ...
1
vote
0answers
37 views

Why aren't quadratic terms considered in cubic splines?

When generalizing from linear to cubic splines, in 3 regions with two knots, I have imagined a continuous basis such as: $$h_1(X) =1, \quad h_2(X) =X,\quad h_3(X) =X^2,\quad h_4(X) = X^3,\\ h_5(X) = ...
3
votes
1answer
38 views

DOF of Natural Cubic Spline

I am curious as to what the answer to the below question is? The question specifies a modeler has a cubic spline with knots at {10, 20, 30, 50}. They realize their model is overfitting at the ends of ...
1
vote
1answer
38 views

Spline basis function notation to include constraint for continuity at the knots

I know splines use basis functions to approximate a function locally, so that the function in one region is approximated with a weighted sum of these basis functions. Suppose the input is one-...
1
vote
0answers
12 views

Can we get the specific formulation form of thin plate regression spline in GAM?

In mgcv package, the default smoother is thin plate regression spline. After building a GAM model, can we "write" the formula form of the thin plate regression ...
1
vote
2answers
68 views

What are the exact factors used in smooth.spline by R?

What exactly is optimized mathematically when I use: smooth.spline(x, y, lambda) in terms of the integrated second derivative? Is it $$\min_{f\in C^2} \sum_{i=1}...
0
votes
0answers
36 views

Demmler-Reinsch basis for smoothing splines

I have seen some papers about using the so-called Demmler-Reinsch basis for smoothing spline because it is a basis for natural spline space and also Sobolev space. For example, these papers: A ...
2
votes
1answer
26 views

How to incorporate splines of random effects in lme4?

Are splines of random effects allowed in nlme but not in lme4? How to incorporate splines of random effects in lme4? ...
0
votes
0answers
13 views

What are the alternatives to basis functions like a B-spline or polynomial?

Let $f_1, ..., f_n$ be basis functions so that we consider $F = \sum f_i \alpha_i$ where $\alpha_i \in R$ are constants. This is what we do when we use e.g. generalized additive models. I am ...
2
votes
1answer
74 views

Fitting flexible spline using ODEs

I'm fitting a series of ordinary differential equations (describing movement through disease states: susceptible, infected, recovered) to weekly counts of a disease through time. I'm solving the ODEs ...
0
votes
0answers
15 views

Cross-validation vs. F-test : Curve fitting using penalized spline regression

This question relates to a previous post here. I have a curve with a disturbance in the middle (at t=9) which causes a downturn (t<9) and an upturn (t>9) in my data. I would like to use curve ...
13
votes
3answers
277 views

How can I fit a spline to data that contains values and 1st/2nd derivatives?

I have a dataset that contains, let's say, some measurements for position, speed and acceleration. All come from the same "run". I could construct a linear system and fit a polynomial to all of those ...
0
votes
0answers
12 views

Cox regression and penalised spline

I am doing a time-to-event investigation and am using a Cox proportional hazards regression model. It is the first time I have worked with this technique. The time-to-event is the number of trials a ...
0
votes
0answers
27 views

predicting X values from smooth.spline

I have an existing smooth.spline object, and I wish to estimate X values for a set of new Y values. I see that ...
2
votes
0answers
46 views

'pspline ' or 'rms' in a Cox model?

I am quite new in the spline subject and I have a question! I am using a Cox model and I was afraid that some of the variables included in the model have a non-linear effect on survival. So I tested ...
1
vote
1answer
70 views

Assessing Continuous Predictor with HR in Cox Model

I would like to recreate the following figure The authors state this about the figure: "Multivariate Cox regression models witha cubic natural spline analysis were used to determine the potential ...
0
votes
0answers
8 views

With the same number of knots, will the cubic Truncated power basis (cubic spline) produce the same results as B-spline?

I wrote a thesis on expanding a model with cubic truncated power basis and B-spline. In the defense, one professor pointed out that I should get the same results with the two methods when the number ...
1
vote
0answers
38 views

First derivative of splines in bayesian model

Inspired by this post https://www.fromthebottomoftheheap.net/2014/05/15/identifying-periods-of-change-with-gams/, I'm trying to identify periods of change in a GAM model, using bayesian inference. ...
1
vote
3answers
41 views

Interaction terms in regression when variables can be negative

Suppose I have a regression $y = b_0 + b_1 x_1 + b_2 x_2 $ where both $x_1$ and $x_2$ have a range from $-\infty$ to $\infty$ and have been centered. The correlation between $x_1$ and $x_2$ is $0.3$...
2
votes
1answer
44 views

what is the advantage of b-splines over other splines?

I only read that it is due to numerical reasons, e.g. on http://einspline.sourceforge.net/background.shtml, but I don't really get it. Can someone please explain it more simple? Is it because they are ...
2
votes
1answer
45 views

How to predict by hand in R using splines regression? [closed]

The R package splines allows one to fit a non linear model using splines. For instance, ...
6
votes
1answer
222 views

Proper terminology for what happens at knots in a cubic spline function

Linear splines are easy to discuss. Knots are where the slopes change, and only one level of continuity is enforced. When discussing cubic splines (with the usual 3 levels of continuity) or natural ...
0
votes
0answers
24 views

How to generate b-splines that are orthogonal to the corresponding variables in non-linear regression?

I want to fit a non-linear regression model of the type $$y_i = \alpha_0 + x_i\alpha_1 + s_i^T\beta + e_i,$$ $i=1,\dots,n$, $\alpha_0,\alpha_1\in{\mathbb R}$, $\beta\in {\mathbb R}^p$. I am only ...
0
votes
1answer
46 views

How to simulate non-linear regression model with splines?

I want to simulate a non linear regression model of the type $$y_i = 1 + x_i + bs(x_i)+ e_i,$$ $i=1,...,1000$, where $bs(x_i)$ is a b-spline. I have tried to use the ...
0
votes
0answers
55 views

How can i find a suitable distribution that fits my data?

I have some data on prevalence of a given infection, provided for each country for 6 different age groups. I am trying to find a suitable distribution that may be suitable to model capture the ...
6
votes
1answer
340 views

An easy decision when to use a spline or a polynomial

I read a lot about polynomials and splines (and in case of the latter also lots of it derivates) and often some special cases were introduced to explain, mostly, why a spline is more suitable than a ...
0
votes
0answers
11 views

Difference between spline approximation and models with spline [duplicate]

I am familiar with splines and fitting them. I have recently encountered the possibility to add splines in models (GLM / GAM for exemple). I am under the impression that these notions are ...
0
votes
0answers
23 views

Matrix inversion in the smoothing splines [duplicate]

The question is about the matrix inversion in the smoothing splines. Given observations (y1, x1), ..., (yn, xn) and a choice of $\lambda \ge 0$, the smoothing spline estimator, $\hat{f}_{\lambda}$ is ...
2
votes
1answer
105 views
1
vote
1answer
49 views

Why do cubic splines need to be continuous at the first and second derivative, but discontinuous at the third?

I'm working through Introduction to Statistical Learning and came upon this: One can show that adding a term of the form $ \beta_4h(x,\xi)$ to the model (7.8) $$y_i = \beta_0 + \beta_1x_i + \...
4
votes
0answers
48 views

When to choose regression splines over smoothing splines? [duplicate]

I am currently studying how to model covariates beyond linearity in order to use them with GAMs for regression / classification purposes. Talking about splines, two types were presented: regression ...
0
votes
0answers
10 views

Determine confidence in estimate from past estimates

I have a population on the order of 10,000 samples. These samples represent individual estimates of a variable, and for each estimate I also have the actual value of the variable. For each sample I ...
0
votes
0answers
69 views

contrast in plotHR for spline HR plot

I am using plotHR to plot spline with hazard ratio - I would like to set my reference point using 'cntrst'. In R: plotHR(mfit, term="td_macce30d_map", plot.bty="o", xlim=c(50, 110), xlab="MAP (mm Hg)...
10
votes
1answer
433 views

How different are restricted cubic splines and penalized splines?

I am reading a lot about using splines in various regression problems. Some books (e.g. Hodges Richly Parrameterized Linear Models) recommend penalized splines. Others (e.g. Harrell Regression ...
3
votes
1answer
48 views

How does one intuitively interpret significance of splines/GAM term?

Consider the data dput here. I can predict y from x using a cubic spline: ...
0
votes
1answer
117 views

splinefun build in function in R-programming

> t<-seq(0,1,len=5) > x<-matrix(c(1.3,2.3,21,2.4,3.8,9,4.5,11.3,4.2,7.8),2) > s1 <- splinefun(t, colMeans(x), method = "monoH.FC") > plot(s1) ...
1
vote
1answer
40 views

Censoring linearly splined predictor in regression

I'm developing a logistic regression where one of the independent variables has a non-linear relationship to the probability of the event occurring. I have created linear splines based on this ...
2
votes
3answers
729 views

Problems interpreting GAM output

I have been advised to run General Additive Models to be able to describe trends in my data, my data being animal harvest numbers by year. I have done so, but have a problem with interpreting the ...
4
votes
1answer
291 views

Thin Plate Regression Splines mgcv?

I am struggling on the understanding of thin plate regression splines. I already found a very helpful answer here in cross-validated: smoothing methods for gam in mgcv package but I still have some ...
3
votes
1answer
35 views

understanding derivatives of a regression spline

I am trying to understand why regression splines are continuous at their knots Suppose I am fitting a regression spline $$ E[Y|X] = \alpha + \beta_1 x + \beta_2 (x - t)^+ $$ where $(x - t)^+ = \...
1
vote
0answers
29 views

How to measure the amount of confounding in tensor interaction in GAMs?

I am interested in fitting an additive model with tensor interaction terms. This construction is described in Wood (2006) and used in the mgcv ...
1
vote
0answers
117 views

Interpretation of cox.zph Output with Smoothing Splines in R

In Luke Keele's paper, "Covariate Functional Form in Cox Models", Dr. Keele carries out two Grambsch and Therneau non-proportionality tests, that is, one for a model without splines and one for a ...
1
vote
0answers
23 views

Knots in restricted cubic splines as free parameters or pre-assigned?

On p. 26 of Regression Modelling Strategies (2nd ed.) Frank Harrell argues against letting the knots in a RCS be free parameters and for setting them in advance, at various quintiles. He cites ...
1
vote
0answers
127 views

Smoothing splines as basis expansion

I am following the discussion on chapter 5 of Elements of statistical learning which discusses basis expansion using splines. The data set I used is the Ozone data which can be found at :http://web....
0
votes
1answer
220 views

Natural spline term in GAM

Is it advisable to use natural regression spline basis? I learned that in R the supported smoothers in gam are the lo, ...