
Calculate Variance-Covariance Matrix for a fitted PLN() model object
Source: R/PLNfit-S3methods.R
vcov.PLNfit.RdReturns the variance-covariance matrix of the main parameters of a fitted PLN() model object. The main parameters of the model correspond to $$B$$, as returned by coef.PLNfit(). The function can also be used to return the variance-covariance matrix of the residuals. The latter matrix can also be accessed via sigma.PLNfit()
Arguments
- object
an R6 object with class
PLNfit- type
type of parameter that should be extracted. Either "main" (default) for $$B$$ or "covariance" for $$\Sigma$$
- ...
additional parameters for S3 compatibility. Not used
Value
A matrix of variance/covariance extracted from the PLNfit model. If type="main" and \(B\) is a matrix of size d * p, the result is a block-diagonal matrix with p (number of species) blocks of size d (number of covariates). if type="main", it is a symmetric matrix of size p. .
Examples
data(trichoptera)
trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
myPLN <- PLN(Abundance ~ 1 + offset(log(Offset)), data = trichoptera)
#>
#> Initialization...
#> Adjusting a full covariance PLN model with nlopt optimizer
#> Post-treatments...
#> DONE!
vcov(myPLN, type = "covariance") ## Sigma
#> Che Hyc Hym Hys Psy Aga
#> Che 2.36804857 0.014013088 0.36612411 0.4451115 -0.0198837954 0.3061236614
#> Hyc 0.01401309 1.580813366 0.13147604 0.2705507 -0.1340690292 -0.0929797028
#> Hym 0.36612411 0.131476043 1.24566525 0.8648820 -0.1170859022 0.5163379584
#> Hys 0.44511147 0.270550686 0.86488204 2.6460381 -0.1444842034 0.4300489422
#> Psy -0.01988380 -0.134069029 -0.11708590 -0.1444842 0.0758107519 0.0003211362
#> Aga 0.30612366 -0.092979703 0.51633796 0.4300489 0.0003211362 1.0973553206
#> Glo 0.08950328 0.154949944 0.20870045 0.3374170 -0.0484852372 -0.0591492494
#> Ath 0.34493128 0.111887561 0.38762764 0.6046159 -0.0467929919 0.2012992803
#> Cea -0.01205897 0.005931994 -0.02811402 -0.0206879 0.0001707632 -0.0295319798
#> Ced 0.33492799 0.218449496 0.50843134 0.6788942 -0.0974754780 0.2208134826
#> Set -0.06108954 0.417109999 -0.18899155 0.1302355 -0.0912668144 -0.3011296629
#> All 0.27282591 -0.205269381 0.68370474 0.3753873 -0.0053424457 0.5905162466
#> Han -0.17283312 0.569988621 0.19848312 0.1240314 -0.2911688799 -0.1762937291
#> Hfo -0.36740890 0.488666100 -0.41635026 -0.2047491 -0.1477703021 -0.8269164653
#> Hsp -0.44455379 0.589170172 -0.35966329 -0.2048463 -0.1927077692 -0.7899092457
#> Hve 0.29901919 -0.102724682 0.16909662 0.2475257 0.0431935721 0.1868857926
#> Sta 0.35948933 0.253710635 0.47783317 0.6129222 -0.1215606803 0.4396261604
#> Glo Ath Cea Ced Set
#> Che 0.089503285 0.344931280 -0.0120589661 0.334927993 -0.06108954
#> Hyc 0.154949944 0.111887561 0.0059319938 0.218449496 0.41711000
#> Hym 0.208700447 0.387627642 -0.0281140229 0.508431344 -0.18899155
#> Hys 0.337416996 0.604615892 -0.0206878996 0.678894228 0.13023551
#> Psy -0.048485237 -0.046792992 0.0001707632 -0.097475478 -0.09126681
#> Aga -0.059149249 0.201299280 -0.0295319798 0.220813483 -0.30112966
#> Glo 1.105300765 0.220980713 0.0024434926 0.224027293 0.28786050
#> Ath 0.220980713 1.362283900 -0.0084650710 0.441271692 0.09075435
#> Cea 0.002443493 -0.008465071 0.0622123749 -0.009231921 0.02113566
#> Ced 0.224027293 0.441271692 -0.0092319211 0.957145677 0.19252015
#> Set 0.287860498 0.090754347 0.0211356565 0.192520153 1.60305596
#> All -0.072092305 0.093776351 -0.0333106689 0.082521331 -0.68465018
#> Han -0.196735972 -0.206101015 0.0064506257 0.052338847 -0.04113283
#> Hfo 0.296715339 -0.174487100 0.0371327987 -0.143505858 0.83187823
#> Hsp 0.243917152 -0.238276471 0.0343092592 -0.127999302 0.78413116
#> Hve 0.089725045 0.242321353 -0.0091671536 0.206707729 -0.04114175
#> Sta 0.017238180 0.307915170 -0.0174519514 0.434617948 0.05554091
#> All Han Hfo Hsp Hve Sta
#> Che 0.272825907 -0.172833115 -0.3674089 -0.44455379 0.299019194 0.35948933
#> Hyc -0.205269381 0.569988621 0.4886661 0.58917017 -0.102724682 0.25371063
#> Hym 0.683704737 0.198483121 -0.4163503 -0.35966329 0.169096618 0.47783317
#> Hys 0.375387293 0.124031354 -0.2047491 -0.20484635 0.247525732 0.61292225
#> Psy -0.005342446 -0.291168880 -0.1477703 -0.19270777 0.043193572 -0.12156068
#> Aga 0.590516247 -0.176293729 -0.8269165 -0.78990925 0.186885793 0.43962616
#> Glo -0.072092305 -0.196735972 0.2967153 0.24391715 0.089725045 0.01723818
#> Ath 0.093776351 -0.206101015 -0.1744871 -0.23827647 0.242321353 0.30791517
#> Cea -0.033310669 0.006450626 0.0371328 0.03430926 -0.009167154 -0.01745195
#> Ced 0.082521331 0.052338847 -0.1435059 -0.12799930 0.206707729 0.43461795
#> Set -0.684650182 -0.041132825 0.8318782 0.78413116 -0.041141751 0.05554091
#> All 1.801734384 0.023265637 -0.7564163 -0.66906861 0.148819919 0.19968045
#> Han 0.023265637 3.764723559 0.6459366 1.01640027 -0.595625597 0.47095381
#> Hfo -0.756416341 0.645936567 2.8772068 1.70052437 -0.348862797 -0.26049293
#> Hsp -0.669068606 1.016400275 1.7005244 2.62260703 -0.486664378 -0.19841880
#> Hve 0.148819919 -0.595625597 -0.3488628 -0.48666438 1.316443760 0.14608600
#> Sta 0.199680450 0.470953813 -0.2604929 -0.19841880 0.146086002 1.03037302