Interpolation using LogNormal distributions in R I want to interpolate the dataset below using lognormal distribution in R. As you can see from the data below, I have different land size classes (ha) and I would like to interpolate the data using the standard land size classes I will use for all countries.
This is the original land size classes




Size classes (ha)
Area of holdings




Under 0.8 ha
18012


0.8 - 1.6
66155


1.6 - 2.4
80224


2.4 - 3.2
61555


3.2 - 4.0
47754


4.0 - 6.0
56234


6.0 ha and over
38257


Total holdings
368191




And the standard land sizes which I want to interpolate their data using the data above (area of holdings) are given as:




size classes (ha)




0 - 1


1 - 2


2 - 3


3 - 4


4 - 5


5 - 10




I have performed this calculation in Excel and I would like to create an R function to do this.
The code below is the function I am trying to create.
install.packages("assertthat")
library(assertthat)
interpolation <- function(x, x1, y1,x2, y2) 
{
assert_that(is.numeric(x), 
isTRUE(all(is.finite(x))),
                       is.scalar(x1),
                      is.scalar(y1),
                      is.scalar(x2),
                     is.scalar(y2),
                    x1< x2)
meanlog <- mean(log(y2)
SDlog <- sd(log(y2)
output <- rep(NA_real_, length(x))
output[x <= x1] <- y1
output[x >= x2] <- y2
btwpoints <- which(is.na(output))
output[btwpoints] <- stats::approx(
    x = plnorm(c(x1, x2)),
   y = c(y1, y2),
  xoutput = plnorm(x[btwpoints]), method = 
"linear")$y
return(output)
}

I have succeeded in setting up the four coordinates (x1,x2,y1, y2) which represent the lower and upper size classes. I am stuck in setting up the lognormal distribution in the function.
 A: The comments give you an approach to estimate a fit in the shape of a log normal cumulative distribution function.  However, if that approach does not produce an adequate fit (which I suspect might be in the eye of the beholder), then you might consider using cubic splines where you can restrict the fit to be non-decreasing.  Here is one such approach using R.
# Set the size class boundaries and the associated areas
sizeClass <- c(0, 0.8, 1.6, 2.4, 3.2, 4, 6, 10)
area <- c(0, 18012, 66155, 80224, 61555, 47754, 56234, 38257)

# Fit the cumulative area with a cubic spline (restricted to be nondecreasing)
cumulativeArea <- cumsum(area)
splinefit <- spline(sizeClass, cumulativeArea, n=100, method="hyman")

# Plot the data and fit
par(mai=c(1,1,0.5,0.5))
plot(sizeClass, cumulativeArea, xlab="Land size (ha)", ylim=c(0,400000),
  ylab="Cumulative area of total holdings (ha)", font.lab=2, cex.lab=1.5, pch=16, axes=FALSE)
axis(1)
axis(2, c(0:4)*100000, c("0", "100,000", "200,000", "300,000", "400,000"))
box()
par(xpd=TRUE)
lines(splinefit)


Now construct the desired classes through interpolation:
standardClasses = c(1,2,3,4,5,10)  # Upper class boundaries
standardArea <- data.frame(UpperClassBoundary = standardClasses,
  Area = diff(spline(sizeClass, cumulativeArea, xout=c(0, standardClasses),
  method="hyman")$y))
stdClasses = c("0-1 ha", "1-2 ha", "2-3 ha", "3-4 ha", "4-5 ha", "5-10 ha")
rownames(standardArea) = stdClasses
standardArea

        UpperClassBoundary     Area
0-1 ha                   1 31294.37
1-2 ha                   2 93815.97
2-3 ha                   3 87095.09
3-4 ha                   4 61494.56
4-5 ha                   5 37803.50
5-10 ha                 10 56687.50

