Title: | Density Estimation with Semidefinite Programming |
---|---|
Description: | The models of probability density functions are Gaussian or exponential distributions with polynomial correction terms. Using a maximum likelihood method, 'dsdp' computes parameters of Gaussian or exponential distributions together with degrees of polynomials by a grid search, and coefficient of polynomials by a variant of semidefinite programming. It adopts Akaike Information Criterion for model selection. See a vignette for a tutorial and more on our 'Github' repository <https://github.com/tsuchiya-lab/dsdp/>. |
Authors: | Satoshi Kakihara [aut, cre], Takashi Tsuchiya [aut] |
Maintainer: | Satoshi Kakihara <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-24 06:46:54 UTC |
Source: | CRAN |
A cumulative distribution function(CDF) of Exponential-based
model.
To access parameters and coefficients in an object emodel
of a class expmodel
, use emodel$result[k, "lmd1"]
,
emodel$coeffs[[k]]
for some index k
.
This index appears in the leftmost column of estimation table generated by
summary(emodel)
.
cdf_expmodel(coeff, lmd, x)
cdf_expmodel(coeff, lmd, x)
coeff |
A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and last element is the largest degree of coefficients. |
lmd |
A rate parameter, which is positive. |
x |
A numeric vector of input. |
A numeric vector of CDF of an exponential-based model.
expmodel()
summary.expmodel()
estimate.expmodel()
func.expmodel()
cdf_expmodel()
## Create an object of `expmodel` emodel <- expmodel(mixexpgamma$n200) ## Estimate with degree 4 and rate parameter 2.0 emodel <- estimate(emodel, 4, 2.0) ## Input vector x <- seq(0, 12, 0.1) ## Output of PDF in above estimation yv <- cdf_expmodel(emodel$coeffs[[1]], emodel$result[1, "lmd1"], x)
## Create an object of `expmodel` emodel <- expmodel(mixexpgamma$n200) ## Estimate with degree 4 and rate parameter 2.0 emodel <- estimate(emodel, 4, 2.0) ## Input vector x <- seq(0, 12, 0.1) ## Output of PDF in above estimation yv <- cdf_expmodel(emodel$coeffs[[1]], emodel$result[1, "lmd1"], x)
A cumulative distribution function(CDF) of Gaussian-based model.
To access parameters and coefficients in an object gmodel
of a class gaussmodel
, use gmodel$result[k, "mu1"]
,
gmodel$result[k, "sig1"]
, gmodel$coeffs[[k]]
for some index k
.
This index appears in the leftmost column of estimation table generated by
summary(gmodel)
.
cdf_gaussmodel(coeff, mu, sig, x)
cdf_gaussmodel(coeff, mu, sig, x)
coeff |
A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and last element is the largest degree of coefficients. |
mu |
A mean of Gaussian distribution. |
sig |
A standard deviation of Gaussian distribution, which is positive. |
x |
A numeric input vector. |
A numeric vector of CDF of Gaussian-based model.
gaussmodel()
summary.gaussmodel()
estimate.gaussmodel()
func.gaussmodel()
pdf_gaussmodel()
## Create an object of `gaussmodel` gmodel <- gaussmodel(mix2gauss$n200) ## Estimate with a degree 6, a mean 0, and standard deviations 0.5 gmodel <- estimate(gmodel, 6, 0, 0.5) ## Input vector x <- seq(-3, 3, 0.1) ## Output of PDF in above estimation yv <- cdf_gaussmodel(gmodel$coeffs[[1]], gmodel$result[1, "mu1"], gmodel$result[1, "sig1"], x)
## Create an object of `gaussmodel` gmodel <- gaussmodel(mix2gauss$n200) ## Estimate with a degree 6, a mean 0, and standard deviations 0.5 gmodel <- estimate(gmodel, 6, 0, 0.5) ## Input vector x <- seq(-3, 3, 0.1) ## Output of PDF in above estimation yv <- cdf_gaussmodel(gmodel$coeffs[[1]], gmodel$result[1, "mu1"], gmodel$result[1, "sig1"], x)
Reduce a data set to a named list of 'values' and 'freq', which are representatives of bins and their frequencies, respectively.
databinning(data, bins = 40)
databinning(data, bins = 40)
data |
A numeric vector of a data set. |
bins |
A positive integer to represent the number of bins. |
A named list of values
and freq
whose length is bins
.
rlst <- databinning(mix2gauss$n200)
rlst <- databinning(mix2gauss$n200)
Compute the mean and the standard deviation of a data set
represented by the pair of the numeric vectors data
and optionally its
frequency vector freq
.
datastats(data, freq = NULL)
datastats(data, freq = NULL)
data |
A numeric vector of a data set. |
freq |
A frequency vector corresponding to the |
The mean and the standard deviation of a data set.
## Without a frequency data datastats(mix2gauss$n200) ## With a frequency data datastats(mix2gaussHist$n200p, mix2gaussHist$n200f)
## Without a frequency data datastats(mix2gauss$n200) ## With a frequency data datastats(mix2gaussHist$n200p, mix2gaussHist$n200f)
Density estimation with Semidefinite Programming. The models of probability density functions are Gaussian or exponential distributions with polynomial correction terms. Using a maximum likelihood method, it computes parameters of Gaussian or exponential distributions together with degrees of polynomials by a grid search, and coefficients of polynomials by a variant of semidefinite programming. It adopts Akaike Information Criterion for model selection. See vignettes for tutorials and more information.
This is a generic S3 method for estimation.
estimate(model, ...)
estimate(model, ...)
model |
An instance of a class model to be estimated. |
... |
additional arguments affecting the |
An instance of a model with estimated data.
expmodel
Estimates Exponential-based model expmodel
among
parameter vectors, deglist
, lmdlist
.
Then it sorts the results by AIC.
## S3 method for class 'expmodel' estimate( model, deglist = deglist, lmdlist = lmdlist, recompute = FALSE, stepsize = NULL, verbose = FALSE, ... )
## S3 method for class 'expmodel' estimate( model, deglist = deglist, lmdlist = lmdlist, recompute = FALSE, stepsize = NULL, verbose = FALSE, ... )
model |
An object of |
deglist |
A vector of degrees of polynomials. The element should be positive integers. |
lmdlist |
A vector of rate parameters of Exponential-based models. The element should be larger than 0. |
recompute |
If |
stepsize |
A vector in descending order whose values are between 0 and 1. If a small step size is supplied, it can attain successful estimates, but it might take more iterations. |
verbose |
If |
... |
Arguments to be passed to or from other methods. |
A expmodel
object including the estimates.
Those estimates are stored in model$result
with
data.frame
format and model$coeffs
in list
format.
expmodel()
summary.expmodel()
plot.expmodel()
## Create an expmodel object emodel <- expmodel(mixexpgamma$n200) ## Estimate a model with parameters emodel <- estimate(emodel, deglist=c(4,5), lmdlist=c(0.5, 1, 2))
## Create an expmodel object emodel <- expmodel(mixexpgamma$n200) ## Estimate a model with parameters emodel <- estimate(emodel, deglist=c(4,5), lmdlist=c(0.5, 1, 2))
gaussmodel
Estimates Gaussian-based model gaussmodel
among
parameter vectors, deglist
, mulist
, sdlist
.
Then it sorts the results by AIC.
## S3 method for class 'gaussmodel' estimate( model, deglist = deglist, mulist = mulist, sdlist = sdlist, scaling = FALSE, recompute = FALSE, stepsize = NULL, verbose = FALSE, ... )
## S3 method for class 'gaussmodel' estimate( model, deglist = deglist, mulist = mulist, sdlist = sdlist, scaling = FALSE, recompute = FALSE, stepsize = NULL, verbose = FALSE, ... )
model |
An object of a |
deglist |
A vector of degrees of polynomials. The element should be positive even numbers. |
mulist |
A vector of means for Gaussian-based models. |
sdlist |
A vector of standard deviations for Gaussian-based models. The element should be larger than 0. |
scaling |
A logical scalar, which indicates whether or not it scales
means and standard deviations in |
recompute |
If |
stepsize |
A vector in descending order whose values are between 0 and 1. If a small step size is supplied, it can attain successful estimates, but it might take more iterations. |
verbose |
If |
... |
Arguments to be passed to or from other methods. |
A gaussmodel
object including the estimates.
Those estimates are stored in model$result
with
data.frame
format and model$coeffs
in list
format.
gaussmodel()
summary.gaussmodel()
plot.gaussmodel()
## Create an `gaussmodel` object gmodel <- gaussmodel(mix2gauss$n200) ## Estimate a model with parameters gmodel <- estimate(gmodel, deglist=c(2, 4), mulist=c(0.0, 0.2), sdlist=c(0.75, 1.0))
## Create an `gaussmodel` object gmodel <- gaussmodel(mix2gauss$n200) ## Estimate a model with parameters gmodel <- estimate(gmodel, deglist=c(2, 4), mulist=c(0.0, 0.2), sdlist=c(0.75, 1.0))
Evaluate the polynomial whose coefficients are represented in
coeff
vector. The order of the coefficient is an increasing order, i.e.,
coeff[1]
is a constant term, and coeff[2]
is a coefficient of 1st degree
term, etc. Evaluation is done using Horner's method.
eval_poly(coeff, x)
eval_poly(coeff, x)
coeff |
A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and the last element is the largest degree of coefficients. |
x |
A numeric input vector. |
A vector of values of a polynomial whose coefficient is coeff
.
pdf_gaussmodel()
pdf_expmodel()
cdf_gaussmodel()
cdf_expmodel()
## Evaluate a polynomial x^2 - 2x + 2 with x = 1, 2, 3. ## 0th, 1st, 2nd degree of coefficients coeff <- c(2, -2, 1) x <- c(1, 2, 3) eval_poly(coeff, x)
## Evaluate a polynomial x^2 - 2x + 2 with x = 1, 2, 3. ## 0th, 1st, 2nd degree of coefficients coeff <- c(2, -2, 1) x <- c(1, 2, 3) eval_poly(coeff, x)
Estimate coefficients of a polynomial in Exponential-based model:
,
where is a coefficient vector,
is a rate
parameter of an exponential distribution:
.
Using data
and optionally its frequencies freq
,
and a degree of a polynomial,
a rate parameter lmd
of an exponential distribution,
it computes the coefficients of polynomial, along with
Akaike Information Criterion(AIC) and an accuracy information from
underlying SDP solver.
In general, the smaller the AIC is, the better the model is.
An accuracy
around 1e-7
is a good indication for a computational
result of coefficients estimation.
exp_est(deg, lmd, data, freq, verbose, stepvec)
exp_est(deg, lmd, data, freq, verbose, stepvec)
deg |
A degree of polynomial, which is positive even integer. |
lmd |
A rate parameter of an exponential distribution, which is positive. |
data |
A numeric vector of a data set to be estimated. |
freq |
A numeric vector of frequencies for a data set |
verbose |
If |
stepvec |
It designates the stepsize for SDP solver.
If the problem is easy, i.e., the number of a data set are small and a degree
of a polynomial is small, then, for example, |
A list
of deg, lmd, aic, accuracy, coefficient vector
rlst <- exp_est(3, 1.0, mixexpgamma$n200, NULL, FALSE, c(0.7, 0.4))
rlst <- exp_est(3, 1.0, mixexpgamma$n200, NULL, FALSE, c(0.7, 0.4))
expmodel
This function is a constructor for S3 class expmodel
,
which represents Exponential-based model.
It usually takes data
and optionally freq
as arguments and
also optionally stepsize
Members of interest in practice are result
and coeffs
, which maintain
the information of estimates and coefficients of polynomials, respectively.
expmodel(data = data, freq = NULL, stepsize = c(0.5, 0.3))
expmodel(data = data, freq = NULL, stepsize = c(0.5, 0.3))
data |
A nonnegative numeric vector of a data set to be estimated. |
freq |
A frequency vector corresponding to the |
stepsize |
A numeric vector whose element is larger than 0 and smaller
than 1, and decreasing order. The default value is |
An object of Exponential-based model expmodel
.
summary.expmodel()
plot.expmodel()
estimate.expmodel()
## Create `expmodel` object from a data set `mixexpgamma$n200`. emodel <- expmodel(mixexpgamma$n200) ## Create `expmodel` object from a data set `mixExpGammaHist$n800p` and ## its frequencies `mixExpGammaHist$n800f`. emodel <- expmodel(mixExpGammaHist$n800p, mixExpGammaHist$n800f)
## Create `expmodel` object from a data set `mixexpgamma$n200`. emodel <- expmodel(mixexpgamma$n200) ## Create `expmodel` object from a data set `mixExpGammaHist$n800p` and ## its frequencies `mixExpGammaHist$n800f`. emodel <- expmodel(mixExpGammaHist$n800p, mixExpGammaHist$n800f)
This is a generic S3 method for estimate.
func(model, x, ...)
func(model, x, ...)
model |
An instance of a class model to be evaluated. |
x |
A numeric vector for input. |
... |
additional arguments affecting the |
An evaluation of x
with model
.
Evaluate an input vector x
with Exponential-based model and
return its vector.
By default, it evaluate with the best model and its density, but
it can designate the model by index and also can evaluate with a cumulative
distribution.
## S3 method for class 'expmodel' func(model, x, cdf = FALSE, n = 1, ...)
## S3 method for class 'expmodel' func(model, x, cdf = FALSE, n = 1, ...)
model |
|
x |
A numeric vector to be evaluated with a distribution. |
cdf |
A logical scalar whether the evaluation is done with a cumulative
distribution or not. A default value is |
n |
The index indicates the estimates. 1, by default, is the best estimate, and 2 is the 2nd best, etc. |
... |
Arguments to be passed to or from other methods. |
A numeric vector of the evaluatio of input vector x
with a model.
expmodel()
summary.expmodel()
plot.expmodel()
estimate.expmodel()
pdf_expmodel()
cdf_expmodel()
## Create an `expmodel` object emodel <- expmodel(mixexpgamma$n200) ## Estimate an model with parameters emodel <- estimate(emodel, deglist=5, lmdlist=3.75) ## A vector for input x <- seq(0, 14, by=0.1) ## Density function y <- func(emodel, x) ## Cumulative distribution y <- func(emodel, x, cdf=TRUE)
## Create an `expmodel` object emodel <- expmodel(mixexpgamma$n200) ## Estimate an model with parameters emodel <- estimate(emodel, deglist=5, lmdlist=3.75) ## A vector for input x <- seq(0, 14, by=0.1) ## Density function y <- func(emodel, x) ## Cumulative distribution y <- func(emodel, x, cdf=TRUE)
Evaluate an input vector x
with Gaussian-based model and
return its vector.
By default, it evaluate with the best model and its density, but
it can designate the model by index and also can evaluate with a cumulative
distribution.
## S3 method for class 'gaussmodel' func(model, x, cdf = FALSE, n = 1, scaling = FALSE, ...)
## S3 method for class 'gaussmodel' func(model, x, cdf = FALSE, n = 1, scaling = FALSE, ...)
model |
|
x |
A numeric vector to be evaluated with a distribution. |
cdf |
A logical scalar whether the evaluation is done with a cumulative
distribution or not. A default value is |
n |
The index indicates the estimates. 1, by default, is the best estimate, and 2 is the 2nd best, etc. |
scaling |
A logical scalar, which indicates whether or not it scales
means and standard deviations in |
... |
Arguments to be passed to or from other methods. |
A numeric vector of the evaluatio of input vector x
with a model.
gaussmodel()
summary.gaussmodel()
plot.gaussmodel()
estimate.gaussmodel()
pdf_gaussmodel()
cdf_gaussmodel()
## Create an `gaussmodel` object gmodel <- gaussmodel(mix2gauss$n200) ## Estimate an model with parameters gmodel <- estimate(gmodel, deglist=4, mulist=0.15, sdlist=0.73) ## A vector for input x <- seq(-4, 4, by=0.1) ## Density function y <- func(gmodel, x) ## Cumulative distribution y <- func(gmodel, x, cdf=TRUE)
## Create an `gaussmodel` object gmodel <- gaussmodel(mix2gauss$n200) ## Estimate an model with parameters gmodel <- estimate(gmodel, deglist=4, mulist=0.15, sdlist=0.73) ## A vector for input x <- seq(-4, 4, by=0.1) ## Density function y <- func(gmodel, x) ## Cumulative distribution y <- func(gmodel, x, cdf=TRUE)
Estimate coefficients of a polynomial in Gaussian-based model:
,
where is a coefficient vector,
and
are a mean and a standard deviation of Gaussian distribution:
Using data
and optionally its frequencies freq
,
and a degree of a polynomial,
a mean mu
and a standard deviation sig
of Gausian distribution,
it computes the coefficients of a polynomial, along with
Akaike Information Criterion(AIC) and an accuracy information from
an underlying SDP solver.
In general, the smaller the AIC is, the better the model is.
An accuracy
around 1e-7
is a good indication for a computational
result of coefficients estimation.
gauss_est(deg, mu, sig, data, freq, verbose, stepsize)
gauss_est(deg, mu, sig, data, freq, verbose, stepsize)
deg |
A degree of polynomial, which is positive even integer. |
mu |
A mean of Gaussian distribution. |
sig |
A standard deviation of Gaussian distribution, which is positive. |
data |
A numeric vector of a data set to be estimated. |
freq |
A numeric vector of frequencies for a data set |
verbose |
If |
stepsize |
It designates the stepsize for SDP solver.
If the problem is easy, i.e., the number of a data set are small and a degree
of a polynomial is small, then, for example, |
A list
of deg
, mu
, sig
, aic
, accuracy
,
coefficient vector
.
rlst <- gauss_est(4, 0, 1, mix2gauss$n200, NULL, FALSE, c(0.7, 0.4))
rlst <- gauss_est(4, 0, 1, mix2gauss$n200, NULL, FALSE, c(0.7, 0.4))
gaussmodel
This function is a constructor for S3 class gaussmodel
,
which represents Gaussian-based model.
It usually takes data
and optionally freq
as arguments and
also optionally stepsize
.
Members of interest in practice are result
and coeffs
, which maintain
the information of estimates and coefficients of polynomials, respectively.
gaussmodel(data = data, freq = NULL, stepsize = c(0.5, 0.3))
gaussmodel(data = data, freq = NULL, stepsize = c(0.5, 0.3))
data |
A numeric vector of a data set to be estimated. |
freq |
A frequency vector corresponding to the |
stepsize |
A numeric vector whose element is larger than 0 and smaller
than 1, and decreasing order. The default value is |
An object of Gaussian-based model gaussmodel
.
summary.gaussmodel()
plot.gaussmodel()
estimate.gaussmodel()
## Create `gaussmodel` object from a data set `mix2gauss$n200`. gmodel <- gaussmodel(mix2gauss$n200) ## Create `gaussmodel` object from a data set `mix2gaussHist$n200p` and ## its frequencies `mix2gaussHist$n200f`. gmodel <- gaussmodel(mix2gaussHist$n200p, mix2gaussHist$n200f)
## Create `gaussmodel` object from a data set `mix2gauss$n200`. gmodel <- gaussmodel(mix2gauss$n200) ## Create `gaussmodel` object from a data set `mix2gaussHist$n200p` and ## its frequencies `mix2gaussHist$n200f`. gmodel <- gaussmodel(mix2gaussHist$n200p, mix2gaussHist$n200f)
Compute the mean of a data set
represented by the pair of the numeric vectors data
and optionally its
frequency vector freq
.
histmean(data, freq = NULL)
histmean(data, freq = NULL)
data |
A numeric vector of a data set. |
freq |
A frequency vector corresponding to the |
The mean of a data set.
## Without a frequency data histmean(mix2gauss$n200) ## With a frequency data histmean(mix2gaussHist$n200p, mix2gaussHist$n200f)
## Without a frequency data histmean(mix2gauss$n200) ## With a frequency data histmean(mix2gaussHist$n200p, mix2gaussHist$n200f)
Evaluate an incomplete gamma function:
using SLATEC dgami
in https://netlib.org/slatec/.
When ( and
) or (
and
),
compute the result, otherwise the value is
NaN
.
igamma(a, x)
igamma(a, x)
a |
A positive numeric vector. |
x |
A nonnegative numeric vector with same length as |
A vector of values of an incomplete gamma function.
igamma(1, 1)
igamma(1, 1)
Evaluate an complementary incomplete gamma function:
using SLATEC dgamic
in https://netlib.org/slatec/.
When ( and
) or (
and
),
compute the result, otherwise the value is
NaN
.
igammac(a, x)
igammac(a, x)
a |
A numeric vector. |
x |
A nonnegative numeric vector with same length as |
A vector of values of a complementary incomplete gamma function.
igammac(1, 1)
igammac(1, 1)
Dataset generated by mixture of 2 Gaussian Distributions whose density is:
.
mix2gauss
mix2gauss
A list of numeric vectors of Bimodal Gaussian Mixture Model.
A numeric vector with 200 elements.
A numeric vector with 400 elements.
A numeric vector with 600 elements.
A numeric vector with 800 elements.
A numeric vector with 1000 elements.
A numeric vector with 1200 elements.
A density function of mixed Gaussian distributions whose density is:
.
mix2gauss_fun(x)
mix2gauss_fun(x)
x |
A numeric vector for arguments of a density function. |
A numeric vector of probabilities for a given argument x
.
Generate mix gaussian random numbers whose density is:
.
mix2gauss_gen(n = 100, seed = NULL)
mix2gauss_gen(n = 100, seed = NULL)
n |
The number of random numbers. |
seed |
A seed for random number generator. |
A numeric vector of random numbers whose a density is described in Description.
Dataset of Mixture of 2 Gaussian Distributions, histogram version, whose density is:
.
mix2gaussHist
mix2gaussHist
A list of numeric vectors of Bimodal Gaussian Mixture Model.
A numeric vector with 200 elements.
Histogram sample data with 25 bins.
Histogram frequency data with 25 bins.
A numeric vector with 400 elements.
Histogram sample data with 50 bins.
Histogram frequency data with 50 bins.
A numeric vector with 800 elements.
Histogram sample data with 100 bins.
Histogram frequency data with 100 bins.
Datasets generated by Mixture of 3 Gaussian Distributions whose density is proportional to:
mix3gauss
mix3gauss
A list of numeric vectors of Unimodal Gaussian Asymmetric Mixture Model.
A numeric vector with 200 elements.
A numeric vector with 400 elements.
A numeric vector with 600 elements.
A numeric vector with 800 elements.
A numeric vector with 1000 elements.
A numeric vector with 1200 elements.
A density function proportional to:
mix3gauss_fun(x)
mix3gauss_fun(x)
x |
A numeric vector for arguments of a density function. |
A numeric vector of probabilities for a given argument x
.
A random number generator whose density function is proportional to:
mix3gauss_gen(n = 100, seed = NULL)
mix3gauss_gen(n = 100, seed = NULL)
n |
The number of random numbers. |
seed |
A seed for random number generator. |
A numeric vector of probabilities for a given argument x
.
Dataset of mixture of exponential distribution and gamma distribution whose density is:
mixexpgamma
mixexpgamma
A list of numeric vectors of Mixture of Exponential and Gamma distribution Model.
A numeric vector with 200 elements.
A numeric vector with 400 elements.
A numeric vector with 600 elements.
A numeric vector with 800 elements.
A numeric vector with 1000 elements.
A numeric vector with 1200 elements.
A density function of
mixexpgamma_fun(x)
mixexpgamma_fun(x)
x |
A numeric vector for arguments of a density function. |
A numeric vector of probabilities for a given argument x
.
Generate random numbers whose density function:
mixexpgamma_gen(n = 100, seed = NULL)
mixexpgamma_gen(n = 100, seed = NULL)
n |
The number of random numbers. |
seed |
A seed for random number generator. |
A numeric vector of probabilities for a given argument x
.
Dataset of mixture of exponential distribution and gamma distribution, histogram version, whose density is:
mixExpGammaHist
mixExpGammaHist
A list of numeric vectors of Mixture of Exponential and Gamma distribution Model.
A numeric vector with 200 elements.
Histogram sample data with 25 bins.
Histogram frequency data with 25 bins.
A numeric vector with 400 elements.
Histogram sample data with 50 bins.
Histogram frequency data with 50 bins.
A numeric vector with 800 elements.
Histogram sample data with 100 bins.
Histogram frequency data with 100 bins.
A probability density function(PDF) of Exponential-based
model.
It is an underlying routine for plot.expmodel
to compute the values
of PDF.
To access parameters and coefficients in an object emodel
of a class expmodel
, use emodel$result[k, "lmd1"]
,
emodel$coeffs[[k]]
for some index k
.
This index appears in the leftmost column of estimation table generated by
summary(emodel)
.
pdf_expmodel(coeff, lmd, x)
pdf_expmodel(coeff, lmd, x)
coeff |
A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and last element is the largest degree of coefficients. |
lmd |
A rate parameter of an exponential distribution, which is positive. |
x |
A numeric input vector. |
A numeric vector of PDF of an exponential-based model.
expmodel()
summary.expmodel()
estimate.expmodel()
func.expmodel()
plot.expmodel()
cdf_expmodel()
## Create an object of `expmodel` emodel <- expmodel(mixexpgamma$n200) ## Estimate with degree 4 and rate parameter 2.0 emodel <- estimate(emodel, 4, 2.0) ## Input vector x <- seq(0, 12, 0.1) ## Output of PDF in above estimation yv <- pdf_expmodel(emodel$coeffs[[1]], emodel$result[1, "lmd1"], x)
## Create an object of `expmodel` emodel <- expmodel(mixexpgamma$n200) ## Estimate with degree 4 and rate parameter 2.0 emodel <- estimate(emodel, 4, 2.0) ## Input vector x <- seq(0, 12, 0.1) ## Output of PDF in above estimation yv <- pdf_expmodel(emodel$coeffs[[1]], emodel$result[1, "lmd1"], x)
A probability density function(PDF) of a Gaussian model.
It is an underlying routine for plot.gaussmodel
to compute the values
of PDF.
To access parameters and coefficients in an object gmodel
of a class gaussmodel
, use gmodel$result[k, "mu1"]
,
gmodel$result[k, "sig1"]
, gmodel$coeffs[[k]]
for some index k
.
This index appears in the leftmost column of estimation table generated by
summary(gmodel)
.
pdf_gaussmodel(coeff, mu, sig, x)
pdf_gaussmodel(coeff, mu, sig, x)
coeff |
A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and last element is the largest degree of coefficients. |
mu |
A mean of Gaussian distribution. |
sig |
A standard deviation of Gaussian distribution, which is positive. |
x |
A numeric input vector. |
A numeric vector of PDF of Gaussian-based distribution.
gaussmodel()
summary.gaussmodel()
estimate.gaussmodel()
func.gaussmodel()
plot.gaussmodel()
cdf_gaussmodel()
## Create an object of `gaussmodel` gmodel <- gaussmodel(mix2gauss$n200) ## Estimate with a degree 6, a mean 0, and standard deviations 0.5 gmodel <- estimate(gmodel, 6, 0, 0.5) ## Input vector x <- seq(-3, 3, 0.1) ## Output of PDF in above estimation yv <- pdf_gaussmodel(gmodel$coeffs[[1]], gmodel$result[1, "mu1"], gmodel$result[1, "sig1"], x)
## Create an object of `gaussmodel` gmodel <- gaussmodel(mix2gauss$n200) ## Estimate with a degree 6, a mean 0, and standard deviations 0.5 gmodel <- estimate(gmodel, 6, 0, 0.5) ## Input vector x <- seq(-3, 3, 0.1) ## Output of PDF in above estimation yv <- pdf_gaussmodel(gmodel$coeffs[[1]], gmodel$result[1, "mu1"], gmodel$result[1, "sig1"], x)
Plot the histogram and, if available, estimated densities
or cumulative distributions of expmodel
object.
## S3 method for class 'expmodel' plot( x, cum = FALSE, nmax = 4, graphs = NULL, bins = 40, hist = TRUE, linesize = 1, ... )
## S3 method for class 'expmodel' plot( x, cum = FALSE, nmax = 4, graphs = NULL, bins = 40, hist = TRUE, linesize = 1, ... )
x |
|
cum |
A logical scalar, whether or not it plots cumulative
histogram/distributions instead of plain histogram/densities.
Default value is |
nmax |
A maximum number of estimates to be plotted in the graph. The default value is 4. |
graphs |
A vector of indices to be displayed in the graph.
These indices appear in the leftmost column of the table in
|
bins |
A number of bins of the histogram. |
hist |
A logical scalar. If |
linesize |
A positive numeric scalar, which indicates the thickness of
lines. The default value is |
... |
Arguments to be passed to or from other methods. |
A ggplot2
object.
expmodel()
summary.expmodel()
func.expmodel()
pdf_expmodel()
cdf_expmodel()
## Create `expmodel` object from a data set mixexpgamma$n200 emodel <- expmodel(mixexpgamma$n200) ## Plot it (histogram only) plot(emodel)
## Create `expmodel` object from a data set mixexpgamma$n200 emodel <- expmodel(mixexpgamma$n200) ## Plot it (histogram only) plot(emodel)
Plot the histogram and, if available, estimated densities
or cumulative distributions of gaussmodel
object.
## S3 method for class 'gaussmodel' plot( x, cum = FALSE, nmax = 4, graphs = NULL, bins = 40, hist = TRUE, scaling = FALSE, linesize = 1, ... )
## S3 method for class 'gaussmodel' plot( x, cum = FALSE, nmax = 4, graphs = NULL, bins = 40, hist = TRUE, scaling = FALSE, linesize = 1, ... )
x |
|
cum |
A logical scalar, whether or not it plots cumulative
histogram/distributions instead of plain histogram/densities.
Default value is |
nmax |
A maximum number of estimates to be plotted in the graph. The default value is 4. |
graphs |
A vector of indices to be displayed in the graph.
These indices appear in the leftmost column of the table in
|
bins |
A number of bins of the histogram. |
hist |
A logical scalar. If |
scaling |
A logical scalar, which indicates whether or not it scales
means and standard deviations in |
linesize |
A positive numeric scalar, which indicates the thickness of
lines. The default value is |
... |
Arguments to be passed to or from other methods. |
A ggplot2
object.
gaussmodel()
summary.gaussmodel()
func.gaussmodel()
pdf_gaussmodel()
cdf_gaussmodel()
## Create `gaussmodel` object from a data set mix2gauss$n200 gmodel <- gaussmodel(mix2gauss$n200) ## Plot it (histogram only) plot(gmodel)
## Create `gaussmodel` object from a data set mix2gauss$n200 gmodel <- gaussmodel(mix2gauss$n200) ## Plot it (histogram only) plot(gmodel)
Substitute a coefficient of a polynomial with
a*x + b
.
For a polynomial with a coefficient vector ,
compute the coefficient vector of
polyaxb(coeff, c, a, b)
polyaxb(coeff, c, a, b)
coeff |
A coefficient vector in increasing order of degrees; the first element is 0th degree, ..., and the last element is the largest degree of coefficients. |
c |
A multiple factor of constant to be applied to all coefficients. |
a |
A coefficient of 1st degree of |
b |
A coefficient of 0th degree of |
A substituted coefficient.
coeff <- c(2, -2, 1) a <- 1.1 b <- 1.2 coeff1 <- c(b, a) coeff2 <- polyaxb(coeff, 1, a, b) xv <- c(1, 2, 3) ## a*x + b yv1 <- eval_poly(coeff1, xv) ## polynomial(a*x + b, coeff) yv2 <- eval_poly(coeff, yv1) ## polynomial(x, coeff2) yv <- eval_poly(coeff2, xv) ## This value is nearly 0 in the presence of rounding errors yv - yv2
coeff <- c(2, -2, 1) a <- 1.1 b <- 1.2 coeff1 <- c(b, a) coeff2 <- polyaxb(coeff, 1, a, b) xv <- c(1, 2, 3) ## a*x + b yv1 <- eval_poly(coeff1, xv) ## polynomial(a*x + b, coeff) yv2 <- eval_poly(coeff, yv1) ## polynomial(x, coeff2) yv <- eval_poly(coeff2, xv) ## This value is nearly 0 in the presence of rounding errors yv - yv2
printf
printf(...)
printf(...)
... |
Any number of arguments to be printed. |
None.
expmodel
object.Summary of expmodel
object, including a mean and quantiles.
If some estimation has done, also print out estimates, up to nmax
number of them.
## S3 method for class 'expmodel' summary(object, nmax = 10, estonly = FALSE, ...)
## S3 method for class 'expmodel' summary(object, nmax = 10, estonly = FALSE, ...)
object |
|
nmax |
A number of estimates to show in the summary. The default is 10. |
estonly |
Show only the results of estimates. The default value
is |
... |
Arguments to be passed to or from other methods. |
None.
expmodel()
plot.expmodel()
estimate.expmodel()
## Create expmodel object from a data set mixexpgamma$n200 emodel <- expmodel(mixexpgamma$n200) ## Print a summary of an object summary(emodel)
## Create expmodel object from a data set mixexpgamma$n200 emodel <- expmodel(mixexpgamma$n200) ## Print a summary of an object summary(emodel)
gaussmodel
objectSummary of gaussmodel
object, including a mean and
a standard deviation and quantiles.
If some estimation has done, also print out estimates, up to nmax
number of them.
## S3 method for class 'gaussmodel' summary(object, nmax = 10, estonly = FALSE, ...)
## S3 method for class 'gaussmodel' summary(object, nmax = 10, estonly = FALSE, ...)
object |
|
nmax |
A number of estimates to show in the summary. The default is 10. |
estonly |
Show only the results of estimates. The default value
is |
... |
Arguments to be passed to or from other methods. |
None.
gaussmodel()
plot.gaussmodel()
estimate.gaussmodel()
## Create gaussmodel object from a data set mix2gauss$n200 gmodel <- gaussmodel(mix2gauss$n200) ## Print a summary of an object summary(gmodel)
## Create gaussmodel object from a data set mix2gauss$n200 gmodel <- gaussmodel(mix2gauss$n200) ## Print a summary of an object summary(gmodel)