I have a set of measured values that I'd liked to interpolate in R using cubic splines. Since these are just piecewise polynomials I'd subsequently like to integrate the interpolation function algebraically. Therefore I need the coefficients. Is there a way to obtain these?
Calling splines::interpSpline(foo, bar)$coef doesn't seem to return the actual polynomial coefficients.
Get polynomial coefficients from interpolation splines in R
1.4k views Asked by Thomas Neitmann At
1
There are 1 answers
Related Questions in R
- How to make an R Shiny app with big data?
- How do I keep only specific rows based on whether a column has a specific value?
- Likert scale study - ordinal regression model
- Extract a table/matrix from R into Excel with same colors and stle
- How can I solve non-conformable arguments in R netmeta::discomb (Error in B.matrix %*% C.matrix)?
- Can raw means and estimated marginal means be the same ? And when?
- Understanding accumulate function when .dir is set to "backwards"
- Error in if (nrow(peaks) > 0) { : argument is of length zero Calls: CopywriteR ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution ha
- How to increase quality of mathjax output?
- Convert the time intervals to equal hours and fill in the value column
- How to run an R function getpoints() from IPDfromKM package in an R shiny app which in R pops up a plot that utilizes clicks to capture coordinates?
- Replace NA in list of dfs in certain columns and under certain conditions
- R and text on Cyrillic
- The ts() function in R is returning the correct start and frequency but not end value which is 1 and not 179
- TROUBLING with the "DROP_NA" Function
Related Questions in INTERPOLATION
- How can I apply scipy.interpolate.RBFInterpolator on an image / ndarray?
- Is there a way to affect the interpolation between translucent colours in WPF?
- Interpolating 3D volumetric data with scipy's RegularGridInterpolator
- Getting interpolation out of nested for loops in python
- Coefficient for pandas.series.interpolate
- Scipy 2D interpolation not accomodating every point
- `pandas` datetime - correct way to do linear interpolation
- Terra::interpolate problem with quantiles prediction (R)
- Is there any c++ function similar to smoothbivariatespline from scipy.interpolate
- Interpolation from reanimated doesn't work on scroll indicator from inside flatlist
- Interpolation raster to a given point in R but controlling the interpolation area of influence
- The interpolate method in pandas.DataFrame.interpolate() doesn't interpolate or extrapolate time-series data correctly
- Interpolate array along first axis with scipy
- Using SciPy ndimage.zoom on an array with nan values
- How to interpolate missing values given a SpatRaster object in R Terra package?
Related Questions in INTEGRAL
- Integrals of multiple variables with some of the limits depending on variables (Julia)
- Monte Carlo 4D integral with variable limit
- How to optimise an objective function with a summation of integrals in Matlab?
- Problem with assigning one last value to an integral in Fortran
- Problem with conditions and integrals in Fortran
- Issues with reproducing equation using the integral function in R
- R: Trouble subsetting a vector for use with trapz function (pracma package)
- Float overflow in scipy quadrature
- Could someone explain this error on fprintf() in Octave?
- Integrating a symbolic expression with differentials in the equation
- Error in EM algorithm: Non-finite Function Value in Likelihood Estimation with Integrals
- More efficient way? other than using for loop with np.trapz() to generate an integral curve over large pandas dataframe
- compute a specific integral image from sprite sheet's integral image?
- scipy "The integral is probably divergent, or slowly convergent"
- maple, expansion of definite integral to series
Related Questions in SPLINES
- is there a way to know the knots used by spline()?
- Spline Normal Calculation
- setting smoothing parameters in d3 js smoothing splines
- mgcv: Extract Knot Locations for `tp` smooth from a GAM model
- Emulating Excel's "scatter with smooth curve" spline function in Matplotlib for 3 points
- How can I make a B spline with specific values of 1st derivative at breakpoints (not only ends) using MATLAB?
- Contour lines drawing in Java with a given Delaunay triangulation
- NA/NaN/Inf error when fitting LQMM
- B-spline for non-polynomial splines in r
- evaluate (i.e., predict) a smoothing spline outside R
- Get polynomial coefficients from interpolation splines in R
- Tensor smooths in gamm4
- How to add a spline to rjags model
- Errors Plotting a Restricted Cubic Spline with ggplot2
- non-conformable arguments error from lmer when trying to extract information from the model matrix
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The output of
splines::interpSpline(x,y)$coefgives polynomial coefficients of the part between x(i) and x(i+1) in terms of the powers of (x-x(i)), not of powers of x. This makes sense because the resulting coefficients are of reasonable size and are easier to interpret: for example, each constant term is just y(i), the quadratic coefficient gives the concavity at x(i), and so on.For example, this output
means that
3 - 1.54054054*(x-1) + 0.13513514*(x-1)^31 + 0.08108108*(x-3) + 0.8108108*(x-3)^2 - 0.16816817*(x-3)^34 + 0.40540541*(x-6) - 0.7027027*(x-6)^2 + 0.07807808*(x-6)^3I don't see much use of the last line, which describes linear continuation of the spline beyond x=9, the right endpoint of the data.
To integrate these is no more difficult than to integrate powers of x, but of course one needs to choose the constants of integration if the goal is to get a continuous antiderivative. The choice of the form of polynomials makes dealing with constants of integration easier. Assuming we pick the antiderivative that has value 0 at the left endpoint, the rest is as follows:
3*(x-1) - 1.54054054*(x-1)^2/2 + 0.13513514*(x-1)^4/4C1 + 1*(x-3) + 0.08108108*(x-3)^2/2 + 0.8108108*(x-3)^3/3 - 0.16816817*(x-3)^4/4. Here C1 is the value of the previous antiderivative at x=3.C2 + 4*(x-6) + 0.40540541*(x-6)^2/2 - 0.7027027*(x-6)^3/3 + 0.07807808*(x-6)^4/4. Here C2 is the value of the previous antiderivative at x=6.