R/species_mix_s3-class.R
vcov.species_mix.Rd
Calculates variance-covariance matrix from a species_mix object
# S3 method for 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 |
A square matrix of size equal to the number of parameters. It contains the variance matrix of the parameter estimates.
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.
# Estimate the variance-covariance matrix. # This will provide estimates of uncertainty for model parameters. # \donttest{ 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)#>#>#>#>#>#>#>#>#>#>#>#>#>#>#> initial value 819.837658 #> iter 10 value 819.706575 #> final value 819.703416 #> converged#> ..........#> spp1 spp2 spp3 spp4 #> spp1 1.479054e-03 -0.0036288098 -2.238456e-05 1.706005e-03 #> spp2 -3.628810e-03 0.1290588302 -9.138796e-04 -3.216081e-03 #> spp3 -2.238456e-05 -0.0009138796 1.115070e-03 1.021110e-04 #> spp4 1.706005e-03 -0.0032160809 1.021110e-04 2.735869e-03 #> spp5 -2.008618e-03 0.0402145338 7.561347e-03 -2.416954e-03 #> spp6 -2.318914e-03 0.0977104066 -1.138946e-03 -1.735680e-03 #> spp7 -1.310811e-05 0.0045339497 3.157129e-04 2.837014e-04 #> spp8 1.368845e-03 -0.0069285176 4.870846e-05 2.444858e-03 #> spp9 8.044533e-05 0.0189223903 1.010740e-03 6.634078e-04 #> spp10 -3.778817e-05 0.0010637312 5.861215e-06 2.771258e-05 #> spp11 1.268586e-03 -0.0020535450 9.561731e-05 1.909232e-03 #> spp12 2.183028e-03 -0.0035539059 2.159930e-04 3.508742e-03 #> spp13 -2.279269e-03 0.0543518880 -2.172558e-03 -2.349510e-03 #> spp14 -1.083880e-03 0.0654240045 -1.237169e-03 -3.844096e-04 #> spp15 1.460730e-04 0.0022671201 4.831802e-06 4.952563e-04 #> spp16 7.559622e-04 -0.0012427896 4.837884e-05 1.206662e-03 #> spp17 -9.317876e-05 0.0055313466 -3.024852e-04 1.879483e-04 #> spp18 -7.120777e-04 0.0154856245 2.140288e-04 -6.123161e-04 #> spp19 1.871369e-03 -0.0035041040 1.148707e-04 2.999241e-03 #> spp20 8.454284e-04 -0.0024370413 -1.855341e-05 1.150212e-03 #> x1.Archetype1 -8.687603e-03 0.1662504098 1.844111e-03 -1.091633e-02 #> x1.Archetype2 3.678123e-03 -0.0057722698 4.509085e-04 5.953548e-03 #> x1.Archetype3 1.255422e-03 -0.0173297809 4.215040e-04 2.501608e-04 #> x2.Archetype1 -5.091656e-03 0.2909788633 -4.324444e-03 -2.212212e-03 #> x2.Archetype2 -3.910601e-03 0.0070469656 3.673486e-05 -6.184998e-03 #> x2.Archetype3 -9.239140e-04 -0.0127532339 -1.554752e-03 -1.767368e-03 #> eta1 4.624360e-05 0.0021605293 -1.396076e-03 -7.059815e-04 #> eta2 -5.582388e-04 -0.0114785258 5.561645e-04 -2.563862e-03 #> spp5 spp6 spp7 spp8 #> spp1 -0.0020086181 -0.0023189137 -1.310811e-05 1.368845e-03 #> spp2 0.0402145338 0.0977104066 4.533950e-03 -6.928518e-03 #> spp3 0.0075613474 -0.0011389460 3.157129e-04 4.870846e-05 #> spp4 -0.0024169544 -0.0017356799 2.837014e-04 2.444858e-03 #> spp5 0.0765586108 0.0270535064 2.866762e-03 -3.939390e-03 #> spp6 0.0270535064 0.0744343005 3.366347e-03 -4.561082e-03 #> spp7 0.0028667624 0.0033663471 4.018405e-04 1.072040e-04 #> spp8 -0.0039393896 -0.0045610823 1.072040e-04 2.620848e-03 #> spp9 0.0084576850 0.0140653052 1.599971e-03 -3.143385e-04 #> spp10 0.0001189736 0.0007990035 7.672605e-05 1.944246e-06 #> spp11 -0.0011664066 -0.0010636634 1.730777e-04 1.577957e-03 #> spp12 -0.0022743193 -0.0017907880 4.234193e-04 3.138032e-03 #> spp13 0.0022307587 0.0414865476 1.582161e-03 -3.960115e-03 #> spp14 0.0140997172 0.0502837655 2.231347e-03 -2.300978e-03 #> spp15 -0.0002185977 0.0019268955 2.369262e-04 3.559819e-04 #> spp16 -0.0009296109 -0.0006236818 1.256096e-04 1.079660e-03 #> spp17 -0.0001253665 0.0046924937 1.616905e-04 9.201543e-05 #> spp18 0.0075515767 0.0116156520 6.249017e-04 -8.332242e-04 #> spp19 -0.0026181554 -0.0018860500 3.130662e-04 2.680530e-03 #> spp20 -0.0014022883 -0.0015381057 8.632498e-06 1.019708e-03 #> x1.Archetype1 0.0779902337 0.1224944224 5.791216e-03 -1.510588e-02 #> x1.Archetype2 -0.0019035557 -0.0030044857 6.484705e-04 5.255015e-03 #> x1.Archetype3 0.0031986947 -0.0128761808 -1.160681e-03 4.720891e-04 #> x2.Archetype1 0.0727531953 0.2229924175 1.008287e-02 -1.090084e-02 #> x2.Archetype2 0.0085907172 0.0036020009 -6.621205e-04 -5.509228e-03 #> x2.Archetype3 -0.0149543176 -0.0097124239 -1.215135e-03 -9.424566e-04 #> eta1 -0.0069636644 0.0024600816 -6.489304e-04 -6.838493e-04 #> eta2 0.0060994988 -0.0091086370 -1.130863e-03 -2.185118e-03 #> spp9 spp10 spp11 spp12 #> spp1 8.044533e-05 -3.778817e-05 1.268586e-03 2.183028e-03 #> spp2 1.892239e-02 1.063731e-03 -2.053545e-03 -3.553906e-03 #> spp3 1.010740e-03 5.861215e-06 9.561731e-05 2.159930e-04 #> spp4 6.634078e-04 2.771258e-05 1.909232e-03 3.508742e-03 #> spp5 8.457685e-03 1.189736e-04 -1.166407e-03 -2.274319e-03 #> spp6 1.406531e-02 7.990035e-04 -1.063663e-03 -1.790788e-03 #> spp7 1.599971e-03 7.672605e-05 1.730777e-04 4.234193e-04 #> spp8 -3.143385e-04 1.944246e-06 1.577957e-03 3.138032e-03 #> spp9 9.463397e-03 3.282355e-04 4.979592e-04 1.103085e-03 #> spp10 3.282355e-04 2.335887e-05 7.221910e-06 2.802847e-05 #> spp11 4.979592e-04 7.221910e-06 1.408107e-03 2.447036e-03 #> spp12 1.103085e-03 2.802847e-05 2.447036e-03 4.633885e-03 #> spp13 6.916422e-03 4.679101e-04 -1.579421e-03 -2.456747e-03 #> spp14 9.299077e-03 5.453371e-04 -1.945017e-04 -1.934153e-04 #> spp15 1.320439e-03 4.025029e-05 3.647373e-04 7.219768e-04 #> spp16 3.391420e-04 1.205152e-05 8.447895e-04 1.542437e-03 #> spp17 1.326156e-03 -1.995004e-05 1.792345e-04 5.033828e-04 #> spp18 2.245943e-03 8.817383e-05 -5.169915e-04 -5.751979e-04 #> spp19 7.362725e-04 2.982925e-05 2.092759e-03 3.853147e-03 #> spp20 -2.258820e-04 -1.673093e-05 8.203609e-04 1.467446e-03 #> x1.Archetype1 2.529084e-02 1.285485e-03 -7.371688e-03 -1.339409e-02 #> x1.Archetype2 -6.647563e-05 2.328880e-05 4.121578e-03 7.687343e-03 #> x1.Archetype3 -5.638797e-03 -4.884334e-04 4.626352e-04 8.188458e-04 #> x2.Archetype1 4.118547e-02 2.380148e-03 -1.100020e-03 -1.438256e-03 #> x2.Archetype2 -3.121064e-03 -1.063455e-04 -4.347545e-03 -7.909826e-03 #> x2.Archetype3 -4.257967e-03 -5.062838e-05 -1.319246e-03 -2.935075e-03 #> eta1 -2.520578e-04 -1.563721e-04 -3.186135e-04 -7.839209e-04 #> eta2 -2.161156e-03 -4.357832e-04 -1.427461e-03 -2.880883e-03 #> spp13 spp14 spp15 spp16 #> spp1 -0.0022792695 -1.083880e-03 1.460730e-04 7.559622e-04 #> spp2 0.0543518880 6.542400e-02 2.267120e-03 -1.242790e-03 #> spp3 -0.0021725580 -1.237169e-03 4.831802e-06 4.837884e-05 #> spp4 -0.0023495104 -3.844096e-04 4.952563e-04 1.206662e-03 #> spp5 0.0022307587 1.409972e-02 -2.185977e-04 -9.296109e-04 #> spp6 0.0414865476 5.028377e-02 1.926896e-03 -6.236818e-04 #> spp7 0.0015821610 2.231347e-03 2.369262e-04 1.256096e-04 #> spp8 -0.0039601154 -2.300978e-03 3.559819e-04 1.079660e-03 #> spp9 0.0069164218 9.299077e-03 1.320439e-03 3.391420e-04 #> spp10 0.0004679101 5.453371e-04 4.025029e-05 1.205152e-05 #> spp11 -0.0015794213 -1.945017e-04 3.647373e-04 8.447895e-04 #> spp12 -0.0024567472 -1.934153e-04 7.219768e-04 1.542437e-03 #> spp13 0.0309805779 2.838857e-02 1.212596e-03 -1.084900e-03 #> spp14 0.0283885715 3.444477e-02 1.496814e-03 -7.491137e-05 #> spp15 0.0012125955 1.496814e-03 4.240594e-04 2.247225e-04 #> spp16 -0.0010849002 -7.491137e-05 2.247225e-04 5.361388e-04 #> spp17 0.0030691952 3.493049e-03 7.629365e-04 1.122901e-04 #> spp18 0.0061107082 7.617722e-03 3.605643e-04 -2.480922e-04 #> spp19 -0.0025498565 -4.093810e-04 5.461708e-04 1.322542e-03 #> spp20 -0.0014443234 -6.953999e-04 1.057677e-04 5.055395e-04 #> x1.Archetype1 0.0657072821 7.840062e-02 1.217329e-03 -4.565646e-03 #> x1.Archetype2 -0.0044812872 -4.539968e-04 8.277271e-04 2.590298e-03 #> x1.Archetype3 -0.0079505513 -8.733228e-03 -4.303075e-04 1.056352e-04 #> x2.Archetype1 0.1245437402 1.520277e-01 6.384612e-03 -5.610314e-04 #> x2.Archetype2 0.0050429756 5.007622e-04 -1.383715e-03 -2.756114e-03 #> x2.Archetype3 -0.0038187057 -6.528625e-03 -1.039817e-03 -7.808706e-04 #> eta1 0.0020192692 2.165237e-03 4.681860e-04 -2.339102e-04 #> eta2 -0.0061848197 -7.081741e-03 -2.401725e-04 -1.053966e-03 #> spp17 spp18 spp19 spp20 #> spp1 -9.317876e-05 -7.120777e-04 1.871369e-03 8.454284e-04 #> spp2 5.531347e-03 1.548562e-02 -3.504104e-03 -2.437041e-03 #> spp3 -3.024852e-04 2.140288e-04 1.148707e-04 -1.855341e-05 #> spp4 1.879483e-04 -6.123161e-04 2.999241e-03 1.150212e-03 #> spp5 -1.253665e-04 7.551577e-03 -2.618155e-03 -1.402288e-03 #> spp6 4.692494e-03 1.161565e-02 -1.886050e-03 -1.538106e-03 #> spp7 1.616905e-04 6.249017e-04 3.130662e-04 8.632498e-06 #> spp8 9.201543e-05 -8.332242e-04 2.680530e-03 1.019708e-03 #> spp9 1.326156e-03 2.245943e-03 7.362725e-04 -2.258820e-04 #> spp10 -1.995004e-05 8.817383e-05 2.982925e-05 -1.673093e-05 #> spp11 1.792345e-04 -5.169915e-04 2.092759e-03 8.203609e-04 #> spp12 5.033828e-04 -5.751979e-04 3.853147e-03 1.467446e-03 #> spp13 3.069195e-03 6.110708e-03 -2.549857e-03 -1.444323e-03 #> spp14 3.493049e-03 7.617722e-03 -4.093810e-04 -6.953999e-04 #> spp15 7.629365e-04 3.605643e-04 5.461708e-04 1.057677e-04 #> spp16 1.122901e-04 -2.480922e-04 1.322542e-03 5.055395e-04 #> spp17 2.536504e-03 1.505856e-03 2.175650e-04 -4.047001e-05 #> spp18 1.505856e-03 2.871135e-03 -6.617777e-04 -4.167357e-04 #> spp19 2.175650e-04 -6.617777e-04 3.288304e-03 1.261121e-03 #> spp20 -4.047001e-05 -4.167357e-04 1.261121e-03 5.424138e-04 #> x1.Archetype1 4.763017e-03 2.155656e-02 -1.194748e-02 -6.038813e-03 #> x1.Archetype2 2.328991e-04 -7.022292e-04 6.529809e-03 2.592364e-03 #> x1.Archetype3 1.426819e-03 -6.415330e-04 3.021381e-04 6.666651e-04 #> x2.Archetype1 1.504320e-02 3.426223e-02 -2.369429e-03 -3.273314e-03 #> x2.Archetype2 -6.702719e-04 1.784774e-03 -6.778942e-03 -2.518040e-03 #> x2.Archetype3 -2.276370e-03 -2.955094e-03 -1.968528e-03 -5.777809e-04 #> eta1 2.893906e-03 7.580128e-04 -7.668850e-04 -1.934875e-04 #> eta2 2.472024e-03 3.293092e-04 -2.789600e-03 -7.643254e-04 #> x1.Archetype1 x1.Archetype2 x1.Archetype3 x2.Archetype1 #> spp1 -0.0086876030 3.678123e-03 0.0012554222 -0.0050916558 #> spp2 0.1662504098 -5.772270e-03 -0.0173297809 0.2909788633 #> spp3 0.0018441112 4.509085e-04 0.0004215040 -0.0043244439 #> spp4 -0.0109163259 5.953548e-03 0.0002501608 -0.0022122119 #> spp5 0.0779902337 -1.903556e-03 0.0031986947 0.0727531953 #> spp6 0.1224944224 -3.004486e-03 -0.0128761808 0.2229924175 #> spp7 0.0057912161 6.484705e-04 -0.0011606808 0.0100828685 #> spp8 -0.0151058772 5.255015e-03 0.0004720891 -0.0109008437 #> spp9 0.0252908447 -6.647563e-05 -0.0056387969 0.0411854741 #> spp10 0.0012854847 2.328880e-05 -0.0004884334 0.0023801481 #> spp11 -0.0073716876 4.121578e-03 0.0004626352 -0.0011000205 #> spp12 -0.0133940912 7.687343e-03 0.0008188458 -0.0014382556 #> spp13 0.0657072821 -4.481287e-03 -0.0079505513 0.1245437402 #> spp14 0.0784006160 -4.539968e-04 -0.0087332278 0.1520277093 #> spp15 0.0012173287 8.277271e-04 -0.0004303075 0.0063846118 #> spp16 -0.0045656462 2.590298e-03 0.0001056352 -0.0005610314 #> spp17 0.0047630171 2.328991e-04 0.0014268188 0.0150432050 #> spp18 0.0215565556 -7.022292e-04 -0.0006415330 0.0342622295 #> spp19 -0.0119474759 6.529809e-03 0.0003021381 -0.0023694294 #> spp20 -0.0060388126 2.592364e-03 0.0006666651 -0.0032733144 #> x1.Archetype1 0.2430573867 -2.159108e-02 -0.0220294776 0.3534280576 #> x1.Archetype2 -0.0215910849 1.423751e-02 0.0019650064 -0.0023218414 #> x1.Archetype3 -0.0220294776 1.965006e-03 0.0118337103 -0.0373091273 #> x2.Archetype1 0.3534280576 -2.321841e-03 -0.0373091273 0.6727607769 #> x2.Archetype2 0.0251290191 -1.234308e-02 0.0008315698 0.0041349120 #> x2.Archetype3 -0.0148446981 -4.968032e-03 -0.0024345972 -0.0305305856 #> eta1 0.0003432089 -2.591263e-03 0.0031783043 0.0081527975 #> eta2 -0.0061863153 -5.954178e-03 0.0094891856 -0.0300459197 #> x2.Archetype2 x2.Archetype3 eta1 eta2 #> spp1 -3.910601e-03 -9.239140e-04 0.0000462436 -0.0005582388 #> spp2 7.046966e-03 -1.275323e-02 0.0021605293 -0.0114785258 #> spp3 3.673486e-05 -1.554752e-03 -0.0013960761 0.0005561645 #> spp4 -6.184998e-03 -1.767368e-03 -0.0007059815 -0.0025638619 #> spp5 8.590717e-03 -1.495432e-02 -0.0069636644 0.0060994988 #> spp6 3.602001e-03 -9.712424e-03 0.0024600816 -0.0091086370 #> spp7 -6.621205e-04 -1.215135e-03 -0.0006489304 -0.0011308635 #> spp8 -5.509228e-03 -9.424566e-04 -0.0006838493 -0.0021851178 #> spp9 -3.121064e-03 -4.257967e-03 -0.0002520578 -0.0021611559 #> spp10 -1.063455e-04 -5.062838e-05 -0.0001563721 -0.0004357832 #> spp11 -4.347545e-03 -1.319246e-03 -0.0003186135 -0.0014274612 #> spp12 -7.909826e-03 -2.935075e-03 -0.0007839209 -0.0028808832 #> spp13 5.042976e-03 -3.818706e-03 0.0020192692 -0.0061848197 #> spp14 5.007622e-04 -6.528625e-03 0.0021652371 -0.0070817411 #> spp15 -1.383715e-03 -1.039817e-03 0.0004681860 -0.0002401725 #> spp16 -2.756114e-03 -7.808706e-04 -0.0002339102 -0.0010539660 #> spp17 -6.702719e-04 -2.276370e-03 0.0028939057 0.0024720239 #> spp18 1.784774e-03 -2.955094e-03 0.0007580128 0.0003293092 #> spp19 -6.778942e-03 -1.968528e-03 -0.0007668850 -0.0027895996 #> spp20 -2.518040e-03 -5.777809e-04 -0.0001934875 -0.0007643254 #> x1.Archetype1 2.512902e-02 -1.484470e-02 0.0003432089 -0.0061863153 #> x1.Archetype2 -1.234308e-02 -4.968032e-03 -0.0025912630 -0.0059541776 #> x1.Archetype3 8.315698e-04 -2.434597e-03 0.0031783043 0.0094891856 #> x2.Archetype1 4.134912e-03 -3.053059e-02 0.0081527975 -0.0300459197 #> x2.Archetype2 1.498892e-02 3.197817e-03 0.0005792110 0.0056046715 #> x2.Archetype3 3.197817e-03 8.023681e-03 0.0003470483 -0.0008508639 #> eta1 5.792110e-04 3.470483e-04 0.0062765902 0.0060355288 #> eta2 5.604671e-03 -8.508639e-04 0.0060355288 0.0140332463