Learn R Programming

spaMM (version 3.3.0)

confint.HLfit: Confidence intervals

Description

This computes confidence intervals for a given parameter, based either on parametric bootstrap or, for fixed-effect parameters, on the p_v-based approximation of the profile likelihood ratio for this parameter. The profiling is over all other fitted parameters: other fixed effects, as well as variances of random effects and spatial correlations if these were fitted. The bootstrap is performed if the parm argument is a function or a quoted expression or if the boot_args argument is a list. The profile confidence interval is computed if neither of these conditions is true; in that case parm must be the name of a fixed-effect coefficient.

Usage

# S3 method for HLfit
confint(object, parm, level=0.95, verbose=TRUE, 
                          boot_args=NULL, ...)

Arguments

object

An object of class HLfit, as returned by the fitting functions in spaMM.

parm

character, or function, or a quoted expression. If character, The name of a parameter to be fitted, or its position in the the object's $fixef vector. Valid names are those of the object's $fixef. If a function, it must return the focal parameter estimate from a fit object. If a quoted expression, it must likewise extract a parameter estimate from a fit object; this expression must refer to the fitted object as ‘hlfit’ (see Examples).

level

The coverage of the interval.

verbose

whether to print the interval or not. As the function returns its more extensive results invisibly, this printing is the only visible output.

boot_args

NULL or a list of arguments passed to functions spaMM_boot and boot.ci. It must contain element nsim (for spaMM_boot). The type argument of boot.ci can only be given as element ci_type, to avoid conflict with the type argument of spaMM_boot.

Additional arguments (maybe not used, but conforming to the generic definition of confint).

Value

If a bootstrap was performed, the result of the boot.ci call is returned, with basic and percentile intervals, and modified call element. Otherwise, a list including the confidence interval for the target parameter, and the fits lowerfit and upperfit giving the profile fits at the confidence bounds. This is returned invisibly.

Examples

Run this code
# NOT RUN {
<!-- % checked in test-confint.R -->
# }
# NOT RUN {
data("wafers")
wfit <- HLfit(y ~X1+(1|batch),family=Gamma(log),data=wafers,method="ML")
confint(wfit,"X1")  # profile CI
if (spaMM.getOption("example_maxtime")>30) {
   confint(wfit,"X1", boot_args=list(nsim=99)) # bootstrap CI induced by 'boot_args'
   # bootstrap CI induced by 'parm' being a function:
   confint(wfit,parm=function(v) fixef(v)[["X1"]], 
           boot_args=list(nb_cores=10, nsim=199))
   # Same effect if 'parm' is a quoted expression in terms of 'hlfit':
   confint(wfit,parm=quote(fixef(hlfit)[["X1"]]), 
           boot_args=list(nb_cores=10, nsim=199))
}
# }

Run the code above in your browser using DataLab