confint.gnm {gnm} | R Documentation |
Computes confidence intervals for one or more parameters in a generalized nonlinear model, based on the profiled deviance.
## S3 method for class 'gnm': confint(object, parm = ofInterest(object), level = 0.95, trace = FALSE, ...) ## S3 method for class 'profile.gnm': confint(object, parm = names(object), level = 0.95, ...)
object |
an object of class "gnm" or "profile.gnm" |
parm |
(optional) either a numeric vector of indices or a
character vector of names, specifying the parameters for which
confidence intervals are to be estimated. If parm is missing,
confidence intervals are found for all parameters. |
level |
the confidence level required. |
trace |
a logical value indicating whether profiling should be traced. |
... |
arguments passed to or from other methods |
These are methods for the generic function confint
in the
base
package.
For "gnm"
objects, profile.gnm
is first called to
profile the deviance over each parameter specified by parm
, or
over all parameters in the model if parm
is missing.
The method for "profile.gnm"
objects is then called, which
interpolates the deviance profiles to estimate the limits of the
confidence interval for each parameter, see profile.gnm
for more details.
If a "profile.gnm"
object is passed directly to confint
,
parametrs specified by parm
must be a subset of the profiled
parameters.
For unidentified parameters a confidence interval cannot be calculated
and the limits will be returned as NA
. If the deviance curve
has an asymptote and a limit of the confidence interval cannot be
reached, the limit will be returned as -Inf
or Inf
appropriately. If the range of the profile does not extend far enough
to estimate a limit of the confidence interval, the limit will be
returned as NA
. In such cases, it may be desirable create a
profile object directly, see profile.gnm
for more
details.
A matrix (or vector) with columns giving lower and upper confidence limits for each parameter. These will be labelled as (1-level)/2 and 1 - (1-level)/2 in % (by default 2.5% and 97.5%).
Heather Turner
### Example in which profiling doesn't take too long data(voting) count <- with(voting, percentage/100 * total) yvar <- cbind(count, voting$total - count) classMobility <- gnm(yvar ~ -1 + Dref(origin, destination), constrain = "delta1", family = binomial, data = voting) confint(classMobility, trace = TRUE) ## Not run: ### Profiling takes much longer here, but example more interesting! data(yaish) unidiff <- gnm(Freq ~ educ*orig + educ*dest + Mult(Exp(educ), orig:dest), ofInterest = "[.]educ", constrain = "[.]educ1", family = poisson, data = yaish, subset = (dest != 7)) ## Letting 'confint' compute profile confint(unidiff, trace = TRUE) ## 2.5 % 97.5 % ## Mult(Exp(.), orig:dest).educ1 NA NA ## Mult(Exp(.), orig:dest).educ2 -0.5978901 0.1022447 ## Mult(Exp(.), orig:dest).educ3 -1.4836854 -0.2362378 ## Mult(Exp(.), orig:dest).educ4 -2.5792398 -0.2953420 ## Mult(Exp(.), orig:dest).educ5 -Inf -0.7007616 ## Creating profile object first with user-specified stepsize prof <- profile(unidiff, trace = TRUE, stepsize = 0.1) confint(prof, ofInterest(unidiff)[2:5]) ## 2.5 % 97.5 % ## Mult(Exp(.), orig:dest).educ2 -0.5978324 0.1022441 ## Mult(Exp(.), orig:dest).educ3 -1.4834753 -0.2362138 ## Mult(Exp(.), orig:dest).educ4 NA -0.2950790 ## Mult(Exp(.), orig:dest).educ5 NA NA ## For 95% confidence interval, need to estimate parameters for which ## z = +/- 1.96. Profile has not gone far enough for last two parameters range(prof[[4]]$z) ## -1.566601 2.408650 range(prof[[5]]$z) ## -0.5751376 1.1989487 ## End(Not run)