gnlrem | R Documentation |
gnlrem
fits user-specified nonlinear regression equations to one or
both parameters of the common one and two parameter distributions. One
parameter of the location regression is random with some specified mixing
distribution.
gnlrem(
y = NULL,
distribution = "normal",
mixture = "normal-var",
random = NULL,
nest = NULL,
random2 = NULL,
nest2 = NULL,
mu = NULL,
shape = NULL,
linear = NULL,
pmu = NULL,
pshape = NULL,
pmix = NULL,
delta = 1,
common = FALSE,
envir = parent.frame(),
print.level = 0,
typsize = abs(p),
ndigit = 10,
gradtol = 1e-05,
stepmax = 10 * sqrt(p %*% p),
steptol = 1e-05,
iterlim = 100,
compute_hessian = TRUE,
compute_kkt = TRUE,
fscale = 1,
eps = 1e-04,
trace = 0,
maxfun.bobyqa = 10000,
npt.bobyqa = min(p * 2, p + 2),
abs.tol.nlminb = 1e-20,
xf.tol.nlminb = 2.2e-14,
x.tol.nlminb = 1.5e-08,
rel.tol.nlminb = 1e-10,
method = "nlminb",
ooo = FALSE,
p_lowb = -Inf,
p_uppb = Inf,
points = 5,
steps = 10,
int2dmethod = c("romberg_int2d", "cuba")[1],
tol.pcubature = 1e-05,
tol.hcubature = 0.001
)
y |
A response vector of uncensored data, a two column matrix for
binomial data, or an object of class, |
distribution |
The distribution for the response: binomial, beta
binomial,
(removed: double binomial, use |
mixture |
The mixing distribution for the random parameter: logit-bridge-var,
logit-bridge-phi, normal-var (default), normal-phi,
Cauchy-scl, Cauchy-phi, stabledist-subgauss-scl, stabledist-subgauss-phi,
libstable4u-subgauss-scl, libstable4u-subgauss-phi,
libstable4u-subgauss-scl-over-sqrt, libstable4u-subgauss-scl-over-sqrt-phi,
logistic, Laplace, inverse Gauss, gamma, inverse gamma, Weibull,
beta, simplex, or two-sided power. The first twelve have zero location
parameter, the next three have unit location parameter, and the last two
have location parameter set to 0.5. cloglog-bridge-delta-free estimates delta
(experimental). cloglog-bridge-0-mean makes delta whatever it needs to be
to maintain a mean-0 random intercept distribution (experimental).
cloglog-bridge-delta-eq-alpha sets delta = alpha for the classic
distribution (experimental). betaprime has mean (shp/(shp-1) for shp>1.
"beta-HGLM" is experimental and is the same as "beta" but
instead it is integrated with intb
instead of int1. |
random |
The name of the random parameter in the |
nest |
The variable classifying observations by the unit upon which
they were observed. Ignored if |
random2 |
The name of the 2nd random parameter in the |
nest2 |
The variable classifying observations by the unit corresponding to 'random2'. |
mu |
A user-specified formula containing named unknown parameters,
giving the regression equation for the location parameter. This may contain
the keyword, |
shape |
A user-specified formula containing named unknown parameters,
giving the regression equation for the shape parameter. This may contain
the keyword, |
linear |
A formula beginning with ~ in W&R notation, specifying the linear part of the regression function for the location parameter or list of two such expressions for the location and/or shape parameters. |
pmu |
Vector of initial estimates for the location parameters. These must be supplied in their order of appearance in the formula as a named list. |
pshape |
Vector of initial estimates for the shape parameters. These must be supplied either in their order of appearance in the expression or in a named list. |
pmix |
Initial estimate for the untransformed (not logarithm)
of the dispersion parameter of the mixing distribution. For
|
delta |
Scalar or vector giving the unit of measurement (always one
for discrete data) for each response value, set to unity by default. For
example, if a response is measured to two decimals, |
common |
If TRUE, the formulae with unknowns for the location and
shape have names in common. All parameter estimates must be supplied in
|
envir |
Environment in which model formulae are to be interpreted or a
data object of class, |
print.level |
Arguments for nlm. |
typsize |
Arguments for nlm. |
ndigit |
Arguments for nlm. |
gradtol |
Arguments for nlm. |
stepmax |
Arguments for nlm. |
steptol |
Arguments for nlm. |
iterlim |
Arguments for optimx (itnmax). |
compute_hessian |
Argument (logical) |
compute_kkt |
Argument (logical) |
fscale |
Arguments for nlm. |
eps |
Precision of the Romberg integration. |
trace |
Arguments for nlminb. |
maxfun.bobyqa |
Argument for bobyqa |
npt.bobyqa |
Argument for bobyqa |
abs.tol.nlminb |
Argument for nlminb. Default 1e-20 assumes known nonnegative function. Set to 0 if you don't know if function is nonnegative. |
xf.tol.nlminb |
Argument for nlminb. Default is 2.2e-14 |
x.tol.nlminb |
Argument for nlminb. Default is 1.5e-8 |
rel.tol.nlminb |
Argument for nlminb. Default is 1e-10 |
method |
Arguments for optimx – a string denoting which
optimization to use. Accommodate vector of strings, however
traditional |
ooo |
*o*ptimx *o*utput *o*nly. Default is FALSE, which
means that the traditional |
p_lowb |
Argument to nlminb / optimx for the |
p_uppb |
Argument to nlminb / optimx for the |
points |
For the Romberg integration, the number of extrapolation points so that 2*points is the order of integration, by default set to 5; points=2 is Simpson's rule. |
steps |
For the Romberg integration, the maximum number of steps, by default set to 10. |
int2dmethod |
EXPERIMENTAL. default "romberg_int2d". Can also be "cuba". |
tol.pcubature |
default value 1e-5.
For the case of |
tol.hcubature |
default value 0.001. This is the maximum tolerance passed
to hcubature which does the integral for the bivariate subgaussian for
|
It is recommended that initial estimates for pmu
and pshape
be obtained from gnlr
.
These nonlinear regression models must be supplied as formulae where
parameters are unknowns. (See finterp
.)
If ooo=TRUE
, A list of class gnlm
is
returned that contains all of the relevant information
calculated, including error codes. If ooo=FALSE
, then
just the optimx output.
Bruce Swihart and J.K. Lindsey
dose <- c(9,12,4,9,11,10,2,11,12,9,9,9,4,9,11,9,14,7,9,8)
y <- c(8.674419, 11.506066, 11.386742, 27.414532, 12.135699, 4.359469,
1.900681, 17.425948, 4.503345, 2.691792, 5.731100, 10.534971,
11.220260, 6.968932, 4.094357, 16.393806, 14.656584, 8.786133,
20.972267, 17.178012)
id <- rep(1:4, each=5)
gnlrem(y, mu=~a+b*dose+rand, random="rand", nest=id, pmu=c(a=8.7,b=0.25),
pshape=3.44, pmix=2.3)
## Not run:
## from repeated::gnlmix
dose <- c(9,12,4,9,11,10,2,11,12,9,9,9,4,9,11,9,14,7,9,8)
#y <- rgamma(20,shape=2+0.3*dose,scale=2)+rep(rnorm(4,0,4),rep(5,4))
y <- c(8.674419, 11.506066, 11.386742, 27.414532, 12.135699, 4.359469,
1.900681, 17.425948, 4.503345, 2.691792, 5.731100, 10.534971,
11.220260, 6.968932, 4.094357, 16.393806, 14.656584, 8.786133,
20.972267, 17.178012)
resp <- restovec(matrix(y, nrow=4, byrow=TRUE), name="y")
reps <- rmna(resp, tvcov=tvctomat(matrix(dose, nrow=4, byrow=TRUE), name="dose"))
# same linear normal model with random normal intercept fitted four ways
# compare with growth::elliptic(reps, model=~dose, preg=c(0,0.6), pre=4)
glmm(y~dose, nest=individuals, data=reps)
gnlmm(reps, mu=~dose, pmu=c(8.7,0.25), psh=3.5, psd=3)
gnlmix(reps, mu=~a+b*dose+rand, random="rand", pmu=c(8.7,0.25),
pshape=3.44, pmix=2.3)
# gamma model with log link and random normal intercept fitted three ways
glmm(y~dose, family=Gamma(link=log), nest=individuals, data=reps, points=8)
gnlmm(reps, distribution="gamma", mu=~exp(a+b*dose), pmu=c(2,0.03),
psh=1, psd=0.3)
gnlmix(reps, distribution="gamma", mu=~exp(a+b*dose+rand), random="rand",
pmu=c(2,0.04), pshape=1, pmix=-2)
# gamma model with log link and random gamma mixtures
gnlmix(reps, distribution="gamma", mixture="gamma",
mu=~exp(a*rand+b*dose), random="rand", pmu=c(2,0.04),
pshape=1.24, pmix=3.5)
gnlmix(reps, distribution="gamma", mixture="gamma",
mu=~exp(a+b*dose)*rand, random="rand", pmu=c(2,0.04),
pshape=1.24, pmix=2.5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.