compak_fitpmf: Fit compak smoother at values x using a sample of data

Description Usage Arguments Value Examples

View source: R/compak_fitpmf.R

Description

The function estimates the p.m.f. using the Conway-Maxwell-Poisson associated kernels (compak) smoother. Bandwidth can be specified as h or nu where nu= 1/h. If none is specified, one can be provided by using cross-validation or minimising Kullback-Leibler divergence.

Usage

1
2
3
4
5
6
7
8
9
compak_fitpmf(
  a.sample,
  x = NULL,
  h = NULL,
  nu = NULL,
  workers = 1L,
  bandwidth_optim = "KL",
  ...
)

Arguments

a.sample

numeric vector: the data sample from which estimate is to be computed.

x

Either NULL or a numeric vector: the points of the grid at which the density is to be estimated. If none is provided, the range of a.sample will be used.

h, nu

numeric: the bandwidth or smoothing parameter. Only one is needed and they are related by nu = 1/h. If neither h nor nu is provided, a bandwidth selection will be carried out.

workers

numeric; a positive integer to represent the number of cores used for parallel processing to evaluate the kde

bandwidth_optim

character; the type of bandwidth selection to be used. Possible values are "KL" (Kullback-Leibler divergence) and "CV" (cross-validation).

...

other arguments passed to bandwidth selection, such as interval.

Value

An object class 'compak' is a list containing the following components:

f.cmp

the estimated p.m.f. values

data

The data - same as input a.sample

h

The bandwidth used to compute the density estimate

nu

The dispersion used to compute the density estimate

x

The coordinates of the points where the density is estimated

bandwidth_optim

the type of bandwidth selection used - same as input

kernel.est

a list that contains the estimated kernel at each grid point

Examples

1
2
3
4
5
6
7
8
9
### Huang et, al (2020) Page 10
data(days)
fit.compak2 <- compak_fitpmf(days, 10:40, bandwidth_optim = "CV")
fit.compak2

### Huang et, al (2020) Page 9

data(somites)
fit.compak <- compak_fitpmf(somites, 60:180, bandwidth_optim = "CV")

thomas-fung/compak documentation built on Dec. 23, 2021, 9:57 a.m.