Restricted (Natural) cubic spline - wrong equation?

In summary, the speaker is sharing their struggle with fitting a restricted cubic spline to their data, following a specific book and using R-code. They have set knots and are using the NLS() function, but are unable to achieve the desired S-shape of the data. They are questioning if their equation is wrong or if their approach is incorrect, and is seeking suggestions or a better forum for their question.
  • #1
shockedMonkey
2
0
My Restricted (Natural) Cubic Spline Equation is Wrong ?

I am trying to fit a restricted cubic spline (natural cubic spline) to toy data, attempting to follow
Hastie, Tibshirani, Friedman 2nd ed. 5.2.1 p.144-146, Eqs 5.4 and 5.5.
Data: Is basically a transposed ‘S’ shape. R-code is:
n <© 100
x <- (1:n)/n
true <- ((exp(1.2*x)+1.5*sin(7*x))-1)/3
noise <- rnorm(n, 0, 0.15)
y <- true + noise
plot(x,y)

I set knots at: {.2, .4, .6, .8} and am fitting using the non-linear NLS() function in R, but I can’t get the S-shape of the data no matter what I try.

My equations is wrong ? Or I am completely off-base in my approach? Any suggestions?
(Book-excerpt, my equation, and data-plot posted below)
 

Attachments

  • book1.JPG
    book1.JPG
    16 KB · Views: 426
  • book2.JPG
    book2.JPG
    8.2 KB · Views: 450
  • splineEq.JPG
    splineEq.JPG
    8.7 KB · Views: 470
  • data.JPG
    data.JPG
    17.3 KB · Views: 406
Mathematics news on Phys.org
  • #2
Q: Is my problem unclear? Or - is anyone aware of a better forum for my question? Thank you.
 

1. What is a restricted (natural) cubic spline?

A restricted (natural) cubic spline is a type of interpolation technique used to fit a smooth curve through a set of data points. It involves dividing the data into smaller segments and fitting a cubic polynomial function to each segment. The term "restricted" means that the spline is constrained to be linear at the beginning and end points of the data. This helps to prevent overfitting and ensures a more stable and accurate curve.

2. What is the wrong equation for a restricted (natural) cubic spline?

The wrong equation for a restricted (natural) cubic spline is one that violates the linear constraints at the beginning and end points. This could be due to an error in the calculation or implementation of the spline, or by using an incorrect mathematical formula.

3. How does using the wrong equation affect the results of a restricted (natural) cubic spline?

Using the wrong equation for a restricted (natural) cubic spline can significantly impact the accuracy of the fitted curve. It may result in a curve that does not fit the data well and may even lead to incorrect conclusions. Additionally, using the wrong equation can introduce errors and inconsistencies in further analysis or predictions based on the spline.

4. How can one identify if the wrong equation was used for a restricted (natural) cubic spline?

One way to identify if the wrong equation was used for a restricted (natural) cubic spline is by visually inspecting the fitted curve. If the curve appears to be noticeably incorrect or does not fit the data well, it could be an indication of an incorrect equation being used. Additionally, comparing the results to those obtained using a correct equation or performing sensitivity analyses can also help identify any discrepancies.

5. How can errors in the equation for a restricted (natural) cubic spline be corrected?

If errors in the equation for a restricted (natural) cubic spline are identified, they can be corrected by identifying and fixing the mistake in the equation or by using a correct equation. It is important to carefully check all calculations and double-check the formula being used. If the errors are due to incorrect data, it may be necessary to re-examine the data or collect new data.

Similar threads

Replies
1
Views
2K
Replies
2
Views
851
Replies
4
Views
4K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
  • Topology and Analysis
Replies
2
Views
1K
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • General Math
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
Back
Top