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
5 votes
3 answers
90 views

Introductory material on splines

I am looking for a basic, step-by-step introduction into modelling with splines. (I have encountered splines while teaching another topic. The textbook I am using does not cover splines in sufficient ...
0 votes
0 answers
18 views

Restricted Cubic Splines with 3 knots

I have started studying cubic splines and I am confused. If I have 3 knots according to the theory I should have K-2 = 3-2 =1 polynomial. When I use the rms package in R there is indeed one polynomial....
  • 79
0 votes
0 answers
16 views

Understanding the estimated variance in the GAMM function

I have a small code snippet that I am providing below and I do not understand how the GAMM function from the mgcv package calculates the estimated variance. Here's the code snippet below, ...
1 vote
1 answer
39 views

Robust standard errors with splines

I realize that large changes in model results between using robust and non-robust standard errors can suggest a misspecified model. My case refers to using a Cox regression and I have experimented ...
  • 335
0 votes
0 answers
15 views

Hat matrix for penalized spline

Suppose the penalized spline given by equation $$ \hat{x}=(W+\lambda_{1}D^{T}D+2\lambda_{2})^{-1}\left[Wy+\lambda_{2}(A+B)\right], $$ where $\lambda_{1},\lambda_{2}$ are positive constants and $A,B$ ...
  • 101
1 vote
0 answers
11 views

Penalty Matrix in P-Splines with correlated data

Good evening, I'm having some trouble understanding how the penalty matrix in penalized splines is set up if the error term has a stationary process. Say I have $y=X\beta+ \epsilon$ with $\epsilon \...
1 vote
1 answer
54 views

natural splines in R with ns( )

I'm struggling with specifying the right R syntax for natural and (cubic) B-splines, using ns() and bs() of package "...
  • 83
0 votes
0 answers
13 views

Interpretation of psplines in Cox model output

I have used psplines() to account for nonlinearity and to help with cox.zph violations in my Cox model. I'm aware that the ...
  • 335
5 votes
2 answers
596 views

Smoothing spline seems to fit too precisely?

I am trying to fit some time series data to a smoothing spline in R. However, it seems like the spline is fitting the data too perfectly, meaning overfitting. I was trying to figure out what settings ...
  • 1,242
3 votes
1 answer
54 views

P-Splines with dependent data

I'm working through the generalized additive models book by Simon Wood and I've had a discussion with a friend of mine over how P-Splines estimation would work for dependent data. For independent data ...
0 votes
0 answers
9 views

Proportional hazards violation after restrcited cubic spline application, Cox

I am using Cox for the purposes of assessing the effect of a treatment on mortality. I have 50 covariates with 120df and n = 100k. I have read in various locations about the utility of using ...
  • 335
1 vote
0 answers
33 views

Should I standardize b-splines in a regression model?

I am fitting a non-linear regression model with 3 covariates $(x_1,x_2,x_3)$. The covariates $x_1$ and $x_2$ have linear effects, and $x_3$ covariate has a non-linear effect using a b-spline with 5 ...
  • 11
1 vote
1 answer
43 views

Whether to use an intercept for spline regression

I'm using the function ns() and bs() in the R package spline. By default, there is no intercept. I know using an intercept will ...
  • 11
2 votes
1 answer
66 views

Longitudinal Binary Logistic Model vs. Cox Model

Longitudinal logistic regression can be used to approximate the hazard ratios from a Cox model: https://hbiostat.org/stat/binarySurv.html In the first paragraph, Frank Harrell states: In the special ...
0 votes
0 answers
27 views

"System is computationally singular" error after using restricted cubic splines

To permit appropriate specification of functional form, I am using restricted cubic splines (rcs() from rms) in my Cox model. I'...
  • 335
1 vote
1 answer
48 views

Schoenfeld plots after restricted cubic spline

I'm using a Cox model with 100k subjects and 1624 events to model the effects of a treatment with respect to 49 covariates, 127df. Due to proportional hazard violation of some continuous variables, I'...
  • 335
0 votes
1 answer
67 views

Visualization after restricted cubic splines in Cox

I've used pspline to add restricted cubic splines to certain continuous covariates that violated the PH assumption upon first analysis. I identified these covarites ...
  • 335
0 votes
0 answers
21 views

In mgcv, why can't a model fit large coefficients for each of the basis functions to play the role of an intercept?

Let $$X \sim Unif(0,1000) \\ Y \sim N(1000, 1)$$ $X$ has no effect on $Y$, but for some reason, we decide to predict $y_i = f(x_i) + \epsilon_i$ using a penalised B-spline (note the lack of intercept ...
0 votes
1 answer
40 views

How can I calculate the odds of exposure for >1 outcome group, combined, using the rms::lrm function. Predict? Contrast?

I have been using a logistic model from rms::lrm to estimate the odds ratio of a binary exposure on an outcome, using splines [time] as Frank Harrell recommended. I ...
  • 1
0 votes
1 answer
31 views

What transformation can I apply to a random vector to make its cumulative sum strictly negative (or positive)?

$X$ is a random vector of real numbers. What is a good $f(X)$ such that $Y = f(X)$ satisfies $\displaystyle\sum_{i <k} Y_i < 0$ for all values of $Y$, where $Y$ has $k$ elements indexed with $i$?...
  • 12.4k
2 votes
1 answer
50 views

Advice on computing contrasts of categorical predictor across range of interacting continuous predictor fitted with a restricted cubic spline #rms

Background After fitting a logistic regression model, I am trying to produce a series contrasts between levels of a categorical variable, x1, across the values of an interacting continuous variable, ...
0 votes
1 answer
35 views

Incorporating seasonality in regression #gTrans #rms

I have been looking into incorporating seasonal effects using the gTrans function in the rms R package. However, I am having some difficulty interpreting the statistical explanation in the document. ...
0 votes
0 answers
28 views

How to get from cubic spline to natural cubic spline?

I am following a video lecture on spline regression where this formula is presented to design a cubic spline regression. The teacher continues to explain that one would usually prefer the usage of &...
0 votes
0 answers
28 views

Extracting the trend from the Gamm function in mgcv with a AR(2) correlation

I'm referencing a paper, "Filtering Time Series with Penalized Splines" from 2011 where the authors provide some code to show how a time series can be detrended by expressing penalized ...
3 votes
1 answer
66 views

Calculation of degrees of freedom for B-splines

I am confused about how the degrees of freedom in a B-spline are calculated in the package splines. The documentation for the B-spline function can be found here: https://www.rdocumentation.org/...
1 vote
0 answers
30 views

How to do a hypothesis testing for smoothing spline at x=certain value?

I have a dataset with response variable y (e.g Starch content) and independent variable x (e.g. Size of Load) and used smoothing cubic splines to fit the data. The data is binned by a categorical ...
1 vote
1 answer
37 views

Approach for Trend comparison in a Time Series

I'm a bit confused on how to properly compare a known trend to an estimated one. I've got two sets of data which are of the following format, $$y_{t_1}=x_{t_1}+WN$$ $$y_{t_2}=x_{t_1}+MA(2)$$ Where $WN ...
0 votes
0 answers
14 views

How to numerically or manually compute bayesian confidence intervals for cubic spline?

I've been looking for ways to add 95% confidence interval to smoothing splines. There's a lot of packages from R that adds this (mostly based from G. Wahba's work which suggested Bayesian confidence ...
0 votes
0 answers
26 views

Does using bs() to fit splines work with as.factor with geeglm?

I am running analyses of longitudinal health data. Each subject has two health measurements—one at age 60, and one at age 80. Subjects are marked as either "healthy" or "sick" at ...
0 votes
0 answers
66 views

Logistic regression with GAM smoothing

I'm working through an example of using cubic spline regression for logistic regression classification from Elements of Statistical Learning [1] (Phoneme classification - Example 5.2.3 on page 148). ...
  • 274
0 votes
1 answer
69 views

Interpreting results of likelihood test in cox model comparison

I am utilizing a cox model for time to event analysis. I have a continuous predictor, that appeared to violate the linearity assumption. I then re-did my model with a spline function, and compared my ...
4 votes
3 answers
96 views

Comparing AIC of Tensor Product Smooths versus Thin Plate Splines

I'm comparing the AIC of these two models. Tensor Product Smooth vs. Thin Plate Spline both fit using REML ...
  • 540
1 vote
1 answer
64 views

How to extract the penalty term from the GAMM function in R and what is used to estimate the penalty terms

I'm working on some log GDP data and I am testing out a Generalized Additive Mixed Model for it with a penalized cubic regression spline. I am using the GAMM function from the mgcv package in R and I ...
1 vote
1 answer
107 views

Confirming cubic spline was done on imputed datasets (imputed by mice Package) and the estimate is the pooled based on Rubin's rule

I am performing restricted cubic spline (Cox proportional hazard ratio) after imputing 10 datasets using mice package. My variables as follow: Outcome: DM Exposure: BMI time to events: time Covariates:...
  • 35
0 votes
0 answers
57 views

Lspline and bs produce very different coefficients for linear splines - which is preferred?

In the vignette for the lspline package in R it says that the package computes Linear splines with convenient parametrisations ...
5 votes
1 answer
360 views

Motivating use of Bayesian splines in excess mortality estimation

I'm reading this paper estimating excess deaths induced by the pandemic. That is, roughly, it constructs a model to estimate how many deaths (from all causes) would have occurred if the pandemic had ...
1 vote
1 answer
159 views

How to fit piecewise linear splines or natural cubic splines in mgcv

How do GAMs generate forecasts that are outside the range of the training data? I often need to use regression models for extrapolated forecasts, where the values of the predictors are outside their ...
4 votes
2 answers
72 views

Determining spline basis dimension using Wood's statistical test

In Simon Wood's book Generalized Additive Models (2nd ed.) on page 243, he describes the following procedure for checking that the basis dimension is too small: Fortunately informal checking that the ...
  • 1,173
0 votes
0 answers
263 views

How to set the number of knots in a regression spline

I want to fit fit a cubic regression spline and select the optimal number of knots via grid search. In other words, I want to find the optimal number of knots that minimizes the average test Mean ...
1 vote
1 answer
196 views

How to create a B-spline basis without intercept and linear trend included?

I want to fit the following model using splines: \begin{align} Y(t) = \beta_0 + \beta_1t + \sum_{j=2}^{d} \beta_jB(t)_j \end{align} where $B_j$ are the basis functions. However, when I run the ...
0 votes
0 answers
30 views

Selecting characteristics for prediction of stock returns (Adaptive Group Lasso in R)

In attempt to find out what drives the predictive power and not the explanatory power of cross sections of expected return. We attempt to split the characteristics of stocks in quadratic splines, ...
  • 1
1 vote
0 answers
56 views

Advice on use of survival vs logistic model

I have a longitudinal dataset from a medical registry where every subject has a certain medical condition. Periodically, each subject is checked for a specific outcome (yes, no) of interest. I have ...
1 vote
1 answer
61 views

Interpretion natural spline function ov IV in ordinal regression

I know that this question was already posed several times but I am not sure If I really got the interpretation for spline functions right. I have an ordered model that is regressed on an index ranging ...
  • 19
0 votes
1 answer
37 views

GAM - setting K-values before or after testing the different models

I'm working with GAM and I'm testing different models with and without certain variables, and I need to set k-values for the different smoothers. Do I need to use the exact same k-values prior to ...
  • 1
2 votes
1 answer
97 views

Should you include time as a continuous predictor when estimating incidence or prevalence?

Suppose one has a time series of disease counts and populations (at risk, total etc.) or, equivalently, binary events of disease status. Then suppose one wanted to present estimates of incidence or ...
1 vote
1 answer
135 views

What is a GAM; question about sklearn's SplineTransformer

From my understanding, using basis-spline feature expansion/transformation with fixed parameters (number and placement of knots, etc.), then feeding that into a linear/logistic regression is ...
1 vote
1 answer
40 views

Missing Data with Splines

I am modeling data with a gamma response. Two continuous variables in my data set are nonlinear and have a large number of nulls. One option I see is to bin/discretize the variables where the nulls ...
  • 225
0 votes
2 answers
82 views

Combining quantile regression with binning

I'm trying to employ a framework where I uncover the marginal effects of the quantiles of one continuous variable on another continuous variable - something analogous to the Quantile-on-quantile (QQR) ...
4 votes
2 answers
114 views

Splines feature selection

I remember reading that for a certain kind of splines, all basis functions have to be included when using feature selection methods such as stepwise regression or shrinkage. The argument for that was ...
  • 43
0 votes
0 answers
12 views

How to understand the center constraint in spline regression?

Assume that I have a basic understanding of the basis spline functions, basis spline regression, natural spline regression. Then, how should I understand the center constraint in the natural spline?

1
2 3 4 5
11