vcov.species_mix | R Documentation |
Calculates variance-covariance matrix from a species_mix object
## S3 method for class 'species_mix'
vcov(
object,
object2 = NULL,
method = "BayesBoot",
nboot = 10,
mc.cores = 1,
...
)
object |
an object obtained from fitting a RCP (for region of common profile) mixture model. Such as that generated from a call to species_mix(qv). |
object2 |
an object of class |
method |
the method to calculate the variance-covariance matrix. Options are:'FiniteDifference' (default), |
nboot |
the number of bootstrap samples to take for the bootstrap estimation. Argument is ignored if !method %in% c( |
mc.cores |
the number of cores to distribute the calculations on. Default is 4. Set to 1 if the computer is running Windows (as it cannot handle forking – see mclapply(qv)). Ignored if method=='EmpiricalInfo'. |
\dots |
Ignored |
If method is FiniteDifference
, then the estimates variance matrix is based on a finite difference approximation to the observed information matrix.
If method is either "BayesBoot" or "SimpleBoot", then the estimated variance matrix is calculated from bootstrap samples of the parameter estimates. See Foster et al (in prep) for details of how the bootstrapping is actually done, and species_mix_boot(qv) for its implementation.
A square matrix of size equal to the number of parameters. It contains the variance matrix of the parameter estimates.
# Estimate the variance-covariance matrix.
# This will provide estimates of uncertainty for model parameters.
library(ecomix)
set.seed(42)
sam_form <- stats::as.formula(paste0('cbind(',paste(paste0('spp',1:20),
collapse = ','),")~x1+x2"))
sp_form <- ~ 1
beta <- matrix(c(-2.9,-3.6,-0.9,1,.9,1.9),3,2,byrow=TRUE)
dat <- data.frame(y=rep(1,100),x1=stats::runif(100,0,2.5),
x2=stats::rnorm(100,0,2.5))
dat[,-1] <- scale(dat[,-1])
simulated_data <- species_mix.simulate(archetype_formula = sam_form,species_formula = sp_form,
data = dat,beta=beta,family="bernoulli")
fm1 <- species_mix(archetype_formula = sam_form,species_formula = sp_form,
data = simulated_data, family = 'bernoulli', nArchetypes=3)
vcov(fm1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.