Bootstrap computation of standard error for maxlogL
class objects.
Source: R/bootstrap_maxlogL.R
bootstrap_maxlogL.Rd
bootstrap_maxlogL
computes standard errors of
maxlogL
class objects by non-parametric bootstrap.
Arguments
- object
an object of
maxlogL
class whose standard errors are going to be computed by bootstrap.- R
numeric. It is the number of resamples performed with the dataset in bootstrap computation. Default value is 2000.
- silent
logical. If TRUE, notifications of
bootstrap_maxlogL
are suppressed.- ...
arguments passed to
boot
used in this routine for estimation of standard errors.
Details
The computation performed by this function may be
invoked when Hessian from optim
and
hessian
fail in maxlogL
or
in maxlogLreg
.
However, this function can be run even if Hessian matrix calculation
does not fails. In this case, standard errors in the maxlogL
class object is replaced.
Author
Jaime Mosquera Gutiérrez, jmosquerag@unal.edu.co
Examples
library(EstimationTools)
#--------------------------------------------------------------------------------
# First example: Comparison between standard error computation via Hessian matrix
# and standard error computation via bootstrap
N <- rbinom(n = 100, size = 10, prob = 0.3)
phat1 <- maxlogL(x = N, dist = 'dbinom', fixed = list(size = 10),
link = list(over = "prob", fun = "logit_link"))
## Standard error computation method and results
print(phat1$outputs$StdE_Method) # Hessian
#> [1] "Hessian from optim"
summary(phat1)
#> _______________________________________________________________
#> Optimization routine: nlminb
#> Standard Error calculation: Hessian from optim
#> _______________________________________________________________
#> AIC BIC
#> 337.521 337.521
#> _______________________________________________________________
#> Estimate Std. Error Z value Pr(>|z|)
#> prob 0.28200 0.01423 19.82 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> _______________________________________________________________
#> Note: p-values valid under asymptotic normality of estimators
#> ---
## 'bootstrap_maxlogL' implementation
phat2 <- phat1 # Copy the first 'maxlogL' object
bootstrap_maxlogL(phat2, R = 100)
#>
#> ...Bootstrap computation of Standard Error. Please, wait a few minutes...
#>
#>
#> --> Done <---
## Standard error computation method and results
print(phat2$outputs$StdE_Method) # Bootstrap
#> [1] "Bootstrap"
summary(phat2)
#> _______________________________________________________________
#> Optimization routine: nlminb
#> Standard Error calculation: Bootstrap
#> _______________________________________________________________
#> AIC BIC
#> 337.521 337.521
#> _______________________________________________________________
#> Estimate Std. Error Z value Pr(>|z|)
#> prob 0.28200 0.01354 20.82 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> _______________________________________________________________
#> Note: p-values valid under asymptotic normality of estimators
#> ---
#--------------------------------------------------------------------------------