Spline interpolation with R

I want to do (cubic) spline interpolation for population data to "convert" annual data to quarterly data. I know that there are many shortcomings, but I need to do this.

Here is an example of my code (using common input):

#--------------spline interpolation x = c(1973:2014) population = seq(500000, 600000, length.out = 42) list = spline(x, population, n = 4*length(x), method = "fmm", xmin = min(x), xmax = max(x), ties = mean) x_spline = list$x pop_spline = list$y 

How can I determine that splines are calculated β€œquarterly”, in other words, in 1973.25, 1973.5, 1973.75, 1974, etc.? Sorry for not being an expert in statistics: what would be the best method for "converting" annual data to quarterly data: "fmm", "natural", "periodic", "monoH.FC" or "hyman"? It was assumed that population growth is evenly distributed throughout the year.

Best wishes and great success!

+5
source share
1 answer

Why not use splinefun :

 func = splinefun(x=x, y=population, method="fmm", ties = mean) 

Then you determine the point you want to predict:

 func(seq(1973, 2014, 0.25)) 
+6
source

Source: https://habr.com/ru/post/1212191/


All Articles