Title: | Box-Cox-Type Transformations for Linear and Logistic Models with Random Effects |
---|---|
Description: | Box-Cox-type transformations for linear and logistic models with random effects using non-parametric profile maximum likelihood estimation, as introduced in Almohaimeed (2018) <http://etheses.dur.ac.uk/12831/> and Almohaimeed and Einbeck (2022) <doi:10.1177/1471082X20966919>. The main functions are 'optim.boxcox()' for linear models with random effects and 'boxcoxtype()' for logistic models with random effects. |
Authors: | Iago Giné-Vázquez [cre] , Amani Almohaimeed [aut] , Jochen Einbeck [aut] |
Maintainer: | Iago Giné-Vázquez <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.46 |
Built: | 2024-10-31 19:46:30 UTC |
Source: | https://gitlab.com/iagogv/boxcoxmix |
Box-Cox-type transformations for linear and logistic models with
random effects using non-parametric profile maximum likelihood
estimation. The main functions are optim.boxcox()
for linear models with
random effects and boxcoxtype()
for logistic models with
random effects.
Package: | boxcoxmix |
Type: | Package |
Version: | 0.28 |
Date: | 2020-09-17 |
License: | GPL (>=3) |
Maintainer: Iago Giné-Vázquez [email protected] (ORCID)
Authors:
Amani Almohaimeed [email protected] (ORCID)
Jochen Einbeck [email protected] (ORCID)
Box G. and Cox D. (1964). An analysis of transformations. Journal of the Royal Statistical Society. Series B (Methodological), pages 211-252.
Aitkin, M. A., Francis, B., Hinde, J., and Darnell, R. (2009). Statistical modelling in R. Oxford University Press Oxford.
Jochen Einbeck, Ross Darnell and John Hinde (2014). npmlreg: Nonparametric maximum likelihood estimation for random effect models. R package version 0.46-1.
R Core Team (2016). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
Useful links:
The boxcoxtype()
performs a grid search over the parameter Lambda
for logistic mixed-effects models and then optimizes over this grid,
to calculate the maximum likelihood estimator of the transformation.
boxcoxtype( formula, random = ~1, k = 3, trials = 1, data, find.in.range = c(-2, 2), s = 20, plot.opt = 1, random.distribution = "np", ... ) boxcoxpower(Lambda = 0) binomial(link = boxcoxpower(0))
boxcoxtype( formula, random = ~1, k = 3, trials = 1, data, find.in.range = c(-2, 2), s = 20, plot.opt = 1, random.distribution = "np", ... ) boxcoxpower(Lambda = 0) binomial(link = boxcoxpower(0))
formula |
a formula describing the transformed response and the fixed effect model (e.g. y ~ x). |
random |
a formula defining the random model. Set |
k |
the number of mass points. |
trials |
optional prior weights for the data. For Bernoulli distribution, set trials=1. |
data |
a data frame containing variables used in the fixed and random effect models. |
find.in.range |
search in a range of |
s |
number of points in the grid search of |
plot.opt |
Set |
random.distribution |
the mixing distribution, Gaussian Quadrature (gq) or NPML (np) can be set. |
... |
extra arguments will be ignored. |
Lambda |
the power of the transformation |
link |
the link function to be used. |
The Box-Cox transformation (Box & Cox, 1964) is applied to the
logistic mixed-effects models with an unspecified
mixing distribution. The NPML estimate of the mixing distribution is known
to be a discrete distribution involving a finite number of mass-points and corresponding
masses (Aitkin et al., 2009). An Expectation-Maximization (EM) algorithm is
used for fitting the finite mixture distribution, one needs to specify the
number of components k
of the finite mixture in advance.
This algorithm can be implemented using the npmlreg function alldist
for the logistic-type overdispersion model and the npmlreg function allvc
for the
two-level logistic-type model, setting family = binomial(link = boxcoxpower(Lambda))
where
Lambda
is the value of the power transformation. When k
=1, the npmlreg function alldist()
fits the logistic regression model without random effects.
boxcoxtype()
performs a grid search over the parameter Lambda
and then
optimizes over this grid, to calculate the maximum likelihood estimator of the transformation.
It produces a plot of the profile likelihood function that summarises information
concerning Lambda
, including a vertical line indicating the best value of Lambda
that maximizes the profile log-likelihood.
List with class boxcoxmix
containing:
Maximum |
the best estimate of |
objective |
the value of the profile log-likelihood corresponding to Maximum. |
coef |
the vector of coefficients. |
profile.loglik |
the profile log-likelihood of the fitted regression model. |
fit |
the fitted alldist object from the last EM iteration. |
aic |
the Akaike information criterion of the fitted regression model. |
bic |
the Bayesian information criterion of the fitted regression model. |
The other outcomes are not relevant to users and they are intended for internal use only.
Amani Almohaimeed and Jochen Einbeck
Box G. and Cox D. (1964). An analysis of transformations. Journal of the Royal Statistical Society. Series B (Methodological), pages 211-252.
Aitkin, M. A., Francis, B., Hinde, J., and Darnell, R. (2009). Statistical modelling in R. Oxford University Press Oxford.
Jochen Einbeck, Ross Darnell and John Hinde (2014). npmlreg: Nonparametric maximum likelihood estimation for random effect models. R package version 0.46-1.
np.boxcoxmix
, optim.boxcox
,
tolfind.boxcox
, Kfind.boxcox
.
#Beta blockers data data("betablocker", package = "flexmix") library(npmlreg) betavc <-allvc(cbind(Deaths, Total - Deaths) ~ Treatment, data = betablocker,random=~1|Center, k=3,random.distribution='np',family = binomial(link = boxcoxpower(0))) betavc$disparity #[1] 318.7211 betavc3 <-boxcoxtype(cbind(Deaths, Total - Deaths) ~ Treatment,random=~1|Center, data = betablocker, find.in.range = c(-2,0.4),s=40,k=3,random.distribution='np') #Maximum Profile Log-likelihood: -158.6025 at lambda= -0.56 betavc3$fit$disparity #[1] 317.2049 betavc3$aic #[1] 331.2049 betavc3$bic #[1] 343.6942
#Beta blockers data data("betablocker", package = "flexmix") library(npmlreg) betavc <-allvc(cbind(Deaths, Total - Deaths) ~ Treatment, data = betablocker,random=~1|Center, k=3,random.distribution='np',family = binomial(link = boxcoxpower(0))) betavc$disparity #[1] 318.7211 betavc3 <-boxcoxtype(cbind(Deaths, Total - Deaths) ~ Treatment,random=~1|Center, data = betablocker, find.in.range = c(-2,0.4),s=40,k=3,random.distribution='np') #Maximum Profile Log-likelihood: -158.6025 at lambda= -0.56 betavc3$fit$disparity #[1] 317.2049 betavc3$aic #[1] 331.2049 betavc3$bic #[1] 343.6942
A grid search over the parameter K
, to set the best number of
mass-points.
Kfind.boxcox( formula, groups = 1, data, lambda = 1, EMdev.change = 1e-04, steps = 500, find.k = c(2, 10), model.selection = "aic", start = "gq", find.tol = c(0, 1.5), steps.tol = 15, ... )
Kfind.boxcox( formula, groups = 1, data, lambda = 1, EMdev.change = 1e-04, steps = 500, find.k = c(2, 10), model.selection = "aic", start = "gq", find.tol = c(0, 1.5), steps.tol = 15, ... )
formula |
a formula describing the transformed response and the fixed effect model (e.g. y ~ x). |
groups |
the random effects. To fit overdispersion models , set |
data |
a data frame containing variables used in the fixed and random effect models. |
lambda |
a transformation parameter, setting |
EMdev.change |
a small scalar, with default 0.0001, used to determine when to stop EM algorithm. |
steps |
maximum number of iterations for the EM algorithm. |
find.k |
search in a range of |
model.selection |
Set |
start |
a description of the initial values to be used in the fitted model, Quantile-based version "quantile" or Gaussian Quadrature "gq" can be set. |
find.tol |
search in a range of |
steps.tol |
number of points in the grid search of |
... |
extra arguments will be ignored. |
Not only the shape of the distribution causes the skewness it may due to the use of an
insufficient number of classes, K
. For this, the Kfind.boxcox()
function
was created to search over a selected range of K
and find the best. For each number
of classes, a grid search over tol
is performed and the tol
with the lowest
aic
or bic
value is considered as the optimal. Having the minimal aic
or bic
values for a whole range of
K
that have been specified beforehand, the Kfind.boxcox()
function can find
the best number of the component as the one with the smallest value. It also plots the aic
or bic
values against
the selected range of K
, including a vertical line indicating the best value of K
that minimizes the model selection criteria. The full range of
classes and their corresponding optimal tol
can be printed off from the Kfind.boxcox()
's
output and used with other boxcoxmix functions as starting points.
List with class boxcoxmix
containing:
MinDisparity |
the minimum disparity found. |
Best.K |
the
value of |
AllMinDisparities |
a vector containing all minimum disparities calculated on the grid. |
AllMintol |
list of |
All.K |
list of |
All.aic |
the Akaike information criterion of all fitted regression models. |
All.bic |
the Bayesian information criterion of all fitted regression models. |
Amani Almohaimeed and Jochen Einbeck
# Fabric data data(fabric, package = "npmlreg") teststr<-Kfind.boxcox(y ~ x, data = fabric, start = "gq", groups=1, find.k = c(2, 3), model.selection = "aic", steps.tol=5) # Minimal AIC: 202.2114 at K= 2
# Fabric data data(fabric, package = "npmlreg") teststr<-Kfind.boxcox(y ~ x, data = fabric, start = "gq", groups=1, find.k = c(2, 3), model.selection = "aic", steps.tol=5) # Minimal AIC: 202.2114 at K= 2
The function np.boxcoxmix()
fits an overdispersed generalized linear model
and variance component models using nonparametric profile maximum likelihood.
np.boxcoxmix( formula, groups = 1, data, K = 3, tol = 0.5, lambda = 1, steps = 500, EMdev.change = 1e-04, plot.opt = 1, verbose = TRUE, start = "gq", ... )
np.boxcoxmix( formula, groups = 1, data, K = 3, tol = 0.5, lambda = 1, steps = 500, EMdev.change = 1e-04, plot.opt = 1, verbose = TRUE, start = "gq", ... )
formula |
a formula describing the transformed response and the fixed effect model (e.g. y ~ x). |
groups |
the random effects. To fit overdispersion models , set |
data |
a data frame containing variables used in the fixed and random effect models. |
K |
the number of mass points. |
tol |
a positive scalar (usually, 0< |
lambda |
a transformation parameter, setting |
steps |
maximum number of iterations for the EM algorithm. |
EMdev.change |
a small scalar, with default 0.0001, used to determine when to stop EM algorithm. |
plot.opt |
Set |
verbose |
If set to FALSE, no printed output on progress. |
start |
a description of the initial values to be used in the fitted model, Quantile-based version "quantile" or Gaussian Quadrature "gq" can be set. |
... |
extra arguments will be ignored. |
The Box-Cox transformation (Box & Cox, 1964) is applied to the overdispersed
generalized linear models and variance component models with an unspecified
mixing distribution. The NPML estimate of the mixing distribution is known
to be a discrete distribution involving a finite number of mass-points and corresponding
masses (Aitkin et al., 2009). An Expectation-Maximization (EM) algorithm is
used for fitting the finite mixture distribution, one needs to specify the
number of components K
of the finite mixture in advance. To stop the EM-algorithm
when it reached its convergence point, we need to defined the convergence criteria that is
the absolute change in the successive log-likelihood function values being less than an arbitrary
parameter such as EMdev.change
= 0.0001 (Einbeck et at., 2014). This algorithm can be
implemented using the function np.boxcoxmix()
, which is designed to account for
overdispersed generalized linear models and variance component models using the non-parametric
profile maximum likelihood (NPPML) estimation.
The ability of the EM algorithm to locate the global maximum in fewer iterations
can be affected by the choice of initial values, the function np.boxcoxmix()
allows us to choose from two different methods to set the initial value of the mass
points. When option "gq" is set, then Gauss-Hermite masses and mass points are used
as starting points in the EM algorithm, while setting start= "quantile" uses the
Quantile-based version to select the starting points.
List with class being either boxcoxmix
or boxcoxmixpure
containing:
mass.point |
the fitted mass points. |
p |
the masses corresponding to the mixing proportions. |
beta |
the vector of coefficients. |
sigma |
the standard deviation of the mixing distribution (the square root of the variance). |
se |
the standard error of the estimate. |
w |
a matrix of posterior probabilities that element i comes from cluster k. |
loglik |
the log-likelihood of the fitted regression model. |
complete.loglik |
the complete log-likelihood of the fitted regression model. |
disparity |
the disparity of the fitted regression model. |
EMiteration |
provides the number of iterations of the EM algorithm. |
EMconverged |
TRUE means the EM algorithm converged. |
call |
the matched call. |
formula |
the formula provided. |
data |
the data argument. |
aic |
the Akaike information criterion of the fitted regression model. |
bic |
the Bayesian information criterion of the fitted regression model. |
fitted |
the fitted values for the individual observations. |
fitted.transformed |
the fitted values for the individual transformed observations. |
residuals |
the difference between the observed values and the fitted values. |
residuals.transformed |
the difference between the transformed observed values and the transformed fitted values. |
predicted.re |
a vector of predicted residuals. |
The other outcomes are not relevant to users and they are intended for internal use only.
Amani Almohaimeed and Jochen Einbeck
Box G. and Cox D. (1964). An analysis of transformations. Journal of the Royal Statistical Society. Series B (Methodological), pages 211-252.
Aitkin, M. A., Francis, B., Hinde, J., and Darnell, R. (2009). Statistical modelling in R. Oxford University Press Oxford.
Jochen Einbeck, Ross Darnell and John Hinde (2014). npmlreg: Nonparametric maximum likelihood estimation for random effect models. R package version 0.46-1.
#Pennsylvanian Hospital Stay Data data(hosp, package = "npmlreg") test1 <- np.boxcoxmix(duration ~ age + wbc1, data = hosp, K = 2, tol = 1, start = "quantile", lambda = 1) round(summary(test1)$w, digits = 3) # [1,] 1.000 0.000 # Refinery yield of gasoline Data data(Gasoline, package = "nlme") test2.vc <- np.boxcoxmix(yield ~ endpoint + vapor, groups = Gasoline$Sample, data = Gasoline, K = 3, tol = 1.7, start = "quantile", lambda = 0) test2.vc$disparity # [1] 176.9827
#Pennsylvanian Hospital Stay Data data(hosp, package = "npmlreg") test1 <- np.boxcoxmix(duration ~ age + wbc1, data = hosp, K = 2, tol = 1, start = "quantile", lambda = 1) round(summary(test1)$w, digits = 3) # [1,] 1.000 0.000 # Refinery yield of gasoline Data data(Gasoline, package = "nlme") test2.vc <- np.boxcoxmix(yield ~ endpoint + vapor, groups = Gasoline$Sample, data = Gasoline, K = 3, tol = 1.7, start = "quantile", lambda = 0) test2.vc$disparity # [1] 176.9827
The optim.boxcox()
performs a grid search over the parameter lambda
for overdispersed generalized linear models and variance component models and
then optimizes over this grid, to calculate the maximum likelihood estimator of
the transformation.
optim.boxcox( formula, groups = 1, data, K = 3, steps = 500, tol = 0.5, start = "gq", EMdev.change = 1e-04, find.in.range = c(-3, 3), s = 60, plot.opt = 3, verbose = FALSE, noformat = FALSE, ... )
optim.boxcox( formula, groups = 1, data, K = 3, steps = 500, tol = 0.5, start = "gq", EMdev.change = 1e-04, find.in.range = c(-3, 3), s = 60, plot.opt = 3, verbose = FALSE, noformat = FALSE, ... )
formula |
a formula describing the transformed response and the fixed effect model (e.g. y ~ x). |
groups |
the random effects. To fit overdispersion models, set |
data |
a data frame containing variables used in the fixed and random effect models. |
K |
the number of mass points. |
steps |
maximum number of iterations for the EM algorithm. |
tol |
a positive scalar (usually, 0< |
start |
a description of the initial values to be used in the fitted model, Quantile-based version "quantile" or Gaussian Quadrature "gq" can be set. |
EMdev.change |
a small scalar, with default 0.0001, used to determine when to stop EM algorithm. |
find.in.range |
search in a range of |
s |
number of points in the grid search of |
plot.opt |
Set |
verbose |
If set to FALSE, no printed output on progress. |
noformat |
Set |
... |
extra arguments will be ignored. |
The Box-Cox transformation (Box & Cox, 1964) is applied to the overdispersed
generalized linear models and variance component models with an unspecified
mixing distribution. The NPML estimate of the mixing distribution is known
to be a discrete distribution involving a finite number of mass-points and corresponding
masses (Aitkin et al., 2009). An Expectation-Maximization (EM) algorithm is
used for fitting the finite mixture distribution, one needs to specify the
number of components K
of the finite mixture in advance. To stop the EM-algorithm when it reached its convergence point,
we need to defined the convergence criteria that is the absolute change in
the successive log-likelihood function values being less than an arbitrary
parameter such as EMdev.change
= 0.0001 (Einbeck et
at., 2014). This algorithm can be implemented using
the function np.boxcoxmix()
, which is designed to account for overdispersed generalized
linear models and variance component models using the non-parametric
profile maximum likelihood (NPPML) estimation.
The ability of the EM algorithm to locate the global maximum in fewer iterations
can be affected by the choice of initial values, the function optim.boxcox()
allows us to choose from two different methods to set the initial value of the mass
points. When option "gq" is set, then Gauss-Hermite masses and mass points are used
as starting points in the EM algorithm, while setting start= "quantile" uses the
Quantile-based version to select the starting points.
optim.boxcox()
performs a grid search over the parameter lambda
and then
optimizes over this grid, to calculate the maximum likelihood estimator of the transformation.
It produces a plot of the non-parametric profile likelihood function that summarises information
concerning lambda
, including a vertical line indicating the best value of lambda
that maximizes the non-parametric profile log-likelihood.
List with class boxcoxmix
containing:
All.lambda |
list of |
Maximum |
the best estimate of |
objective |
the value of the profile log-likelihood corresponding to Maximum. |
EMconverged |
1 is TRUE, means the EM algorithm converged. |
EMiteration |
provides the number of iterations of the EM algorithm. |
mass.point |
the fitted mass points. |
p |
the masses corresponding to the mixing proportions. |
beta |
the vector of coefficients. |
sigma |
the standard deviation of the mixing distribution (the square root of the variance). |
se |
the standard error of the estimate. |
w |
a matrix of posterior probabilities that element i comes from cluster k. |
loglik |
the profile log-likelihood of the fitted regression model. |
profile.loglik |
the profile complete log-likelihood of the fitted regression model. |
disparity |
the disparity of the fitted regression model. |
call |
the matched call. |
formula |
the formula provided. |
data |
the data argument. |
aic |
the Akaike information criterion of the fitted regression model. |
fitted |
the fitted values for the individual observations. |
fitted.transformed |
the fitted values for the individual transformed observations. |
residuals |
the difference between the observed values and the fitted values. |
residuals.transformed |
the difference between the transformed observed values and the transformed fitted values. |
predicted.re |
a vector of predicted residuals. |
The other outcomes are not relevant to users and they are intended for internal use only.
Amani Almohaimeed and Jochen Einbeck
Box G. and Cox D. (1964). An analysis of transformations. Journal of the Royal Statistical Society. Series B (Methodological), pages 211-252.
Aitkin, M. A., Francis, B., Hinde, J., and Darnell, R. (2009). Statistical modelling in R. Oxford University Press Oxford.
Jochen Einbeck, Ross Darnell and John Hinde (2014). npmlreg: Nonparametric maximum likelihood estimation for random effect models. R package version 0.46-1.
# The strength Data data(strength, package = "mdscore") maxlam <- optim.boxcox(y ~ cut*lot, data = strength, K = 3, start = "gq" , find.in.range = c(-2, 2), s = 5) # Maximum profile log-likelihood: 33.6795 at lambda= -0.4 data(Oxboys, package = "nlme") Oxboys$boy <- gl(26,9) maxlamvc <- optim.boxcox(height ~ age, groups = Oxboys$boy, data = Oxboys, K = 2, start = "gq", find.in.range=c(-1.2,1), s=6, plot.opt = 0) maxlamvc$Maximum #[1] -0.8333333 plot(maxlamvc,8)
# The strength Data data(strength, package = "mdscore") maxlam <- optim.boxcox(y ~ cut*lot, data = strength, K = 3, start = "gq" , find.in.range = c(-2, 2), s = 5) # Maximum profile log-likelihood: 33.6795 at lambda= -0.4 data(Oxboys, package = "nlme") Oxboys$boy <- gl(26,9) maxlamvc <- optim.boxcox(height ~ age, groups = Oxboys$boy, data = Oxboys, K = 2, start = "gq", find.in.range=c(-1.2,1), s=6, plot.opt = 0) maxlamvc$Maximum #[1] -0.8333333 plot(maxlamvc,8)
plot()
is a generic function used to produce some useful diagnostic plotting of the functions:
np.boxcoxmix()
, optim.boxcox()
and tolfind.boxcox()
.
## S3 method for class 'boxcoxmix' plot(x, plot.opt = 1, ...)
## S3 method for class 'boxcoxmix' plot(x, plot.opt = 1, ...)
x |
an object for which a plot is desired. |
plot.opt |
an integer value between 1 and 8. |
... |
additional arguments. |
The plots to be printed depend on the number given in plot.opt
,
for the np.boxcoxmix()
, optim.boxcox()
and tolfind.boxcox()
functions:
1 |
the disparities with the iteration number against the mass points |
2 |
the fitted value against the response of the original and the transformed Data. |
3 |
probability plot of residuals of the original against the transformed data. |
4 |
individual posterior probabilities. |
5 |
control charts of residuals of the original against the transformed data. |
6 |
The histograms of residuals of the original against the transformed data. |
7 |
works only for the |
8 |
works only for the |
9 |
works only for the |
10 |
works only for the |
summary()
and print()
are generic functions used to produce the results of the functions:
np.boxcoxmix()
, optim.boxcox()
and tolfind.boxcox()
.
## S3 method for class 'boxcoxmix' print(x, digits = max(3, getOption("digits") - 3), na.print = "", ...) ## S3 method for class 'boxcoxmixpure' print(x, digits = max(3, getOption("digits") - 3), na.print = "", ...) ## S3 method for class 'boxcoxmix' summary(object, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'boxcoxmixpure' summary(object, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'boxcoxmix' print(x, digits = max(3, getOption("digits") - 3), na.print = "", ...) ## S3 method for class 'boxcoxmixpure' print(x, digits = max(3, getOption("digits") - 3), na.print = "", ...) ## S3 method for class 'boxcoxmix' summary(object, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'boxcoxmixpure' summary(object, digits = max(3, getOption("digits") - 3), ...)
x |
an object for which a summary is desired. |
digits |
an integer number format. |
na.print |
a character string which is used to indicate NA values output format. |
... |
additional arguments. |
object |
an object for which a summary is desired. |
Return invisibly the main object provided, while print a summary of its content.
A grid search over the parameter tol
, to set the initial values of
the EM algorithm.
tolfind.boxcox( formula, groups = 1, data, K = 3, lambda = 1, EMdev.change = 1e-04, plot.opt = 2, s = 15, steps = 500, find.in.range = c(0, 1.5), start = "gq", verbose = FALSE, noformat = FALSE, ... )
tolfind.boxcox( formula, groups = 1, data, K = 3, lambda = 1, EMdev.change = 1e-04, plot.opt = 2, s = 15, steps = 500, find.in.range = c(0, 1.5), start = "gq", verbose = FALSE, noformat = FALSE, ... )
formula |
a formula describing the transformed response and the fixed effect model (e.g. y ~ x). |
groups |
the random effects. To fit overdispersion models , set |
data |
a data frame containing variables used in the fixed and random effect models. |
K |
the number of mass points. |
lambda |
a transformation parameter, setting |
EMdev.change |
a small scalar, with default 0.0001, used to determine when to stop EM algorithm. |
plot.opt |
Set |
s |
number of points in the grid search of |
steps |
maximum number of iterations for the EM algorithm. |
find.in.range |
search in a range of |
start |
a description of the initial values to be used in the fitted model, Quantile-based version "quantile" or Gaussian Quadrature "gq" can be set. |
verbose |
If set to FALSE, no printed output on progress. |
noformat |
Set |
... |
extra arguments will be ignored. |
A grid search over tol
can be performed using tolfind.boxcox()
function, which works for np.boxcoxmix()
to find the
optimal solution.
List with class boxcoxmix
containing:
MinDisparity |
the minimum disparity found. |
Mintol |
the
value of |
AllDisparities |
a vector containing all disparities calculated on the grid. |
Alltol |
list of |
AllEMconverged |
1 is TRUE, means the EM algorithm converged. |
aic |
the Akaike information criterion of the fitted regression model. |
bic |
the Bayesian information criterion of the fitted regression model. |
Amani Almohaimeed and Jochen Einbeck
# The Pennsylvanian Hospital Stay Data data(hosp, package = "npmlreg") test1 <- tolfind.boxcox(duration ~ age , data = hosp, K = 2, lambda = 0, find.in.range = c(0, 2), s = 10, start = "gq") # Minimal Disparity: 137.8368 at tol= 2 # Minimal Disparity with EM converged: 137.8368 at tol= 2 # Effect of Phenylbiguanide on Blood Pressure data(PBG, package = "nlme") test2 <- tolfind.boxcox(deltaBP ~ dose , groups = PBG$Rabbit, find.in.range = c(0, 2), data = PBG, K = 2, lambda = -1, s = 15, start = "quantile", plot.opt = 0) test2$Mintol # [1] 1.6 test2$MinDisparity # [1] 449.5876
# The Pennsylvanian Hospital Stay Data data(hosp, package = "npmlreg") test1 <- tolfind.boxcox(duration ~ age , data = hosp, K = 2, lambda = 0, find.in.range = c(0, 2), s = 10, start = "gq") # Minimal Disparity: 137.8368 at tol= 2 # Minimal Disparity with EM converged: 137.8368 at tol= 2 # Effect of Phenylbiguanide on Blood Pressure data(PBG, package = "nlme") test2 <- tolfind.boxcox(deltaBP ~ dose , groups = PBG$Rabbit, find.in.range = c(0, 2), data = PBG, K = 2, lambda = -1, s = 15, start = "quantile", plot.opt = 0) test2$Mintol # [1] 1.6 test2$MinDisparity # [1] 449.5876