| hist2dsm {JOPS} | R Documentation | 
Smooth a 2D histogram
Description
Fit a 2D smooth P-spline surface to a matrix of counts, assuming Poisson distributed observations.
Usage
hist2dsm(
  Y,
  nsegx = 10,
  nsegy = nsegx,
  bdeg = 3,
  lambdax = 10,
  lambday = lambdax,
  dx = 3,
  dy = dx,
  Mu = Y + 0.01,
  kappa = 1e-04,
  tol = 1e-05
)
Arguments
| Y | a matrix of counts. | 
| nsegx | the number of knots along  | 
| nsegy | the number of evenly spaced knots along  | 
| bdeg | the degree of the basis, default is 3. | 
| lambdax | the positive number for the tuning parameter along  | 
| lambday | the positive number for the tuning parameter along  | 
| dx | the order of the difference penalty along  | 
| dy | the order of the difference penalty along  | 
| Mu | the initialization of the mean (default  | 
| kappa | a (small, positive) number for ridge tuning parameter to stabilize estimation (default  | 
| tol | the convergence criterion (default  | 
Value
A list with elements:
| ed | the effective dimension of the smooth 2D surface. | 
| Mu | a matrix with the smooth estimates, with dimensions of  | 
| pen | the numerical value of the penalty. | 
Author(s)
Paul Eilers
References
Eilers, P.H.C., Marx, B.D., and Durban, M. (2015). Twenty years of P-splines, SORT, 39(2): 149-186.
Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.
Examples
x = faithful$eruptions
y = faithful$waiting
h = hist2d(x, y, c(100, 100))
sm = hist2dsm(h$H, nsegx = 25, nsegy = 25, bdeg = 3, lambdax = 10, lambday = 10)
image(h$xgrid, h$ygrid, sm$Mu, xlab = 'Eruption length (min)',
      ylab = 'Waiting time (min)', main = 'Old Faithful')