Print a species_mix model object.
# S3 method for species_mix
print(x, ...)A model object.
Ignored
#Print information about a species_mix model
# \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")
#> Random alpha from normal (-1,0.5) distribution
fm1 <- species_mix(archetype_formula = sam_form,species_formula = sp_form,
data = simulated_data, family = 'bernoulli', nArchetypes=3)
#> SAM modelling
#> There are 3 archetypes
#> There are 100 site observations for 20 species
#> The model for the archetype (grouping) is ~x1 + x2
#> The model for the species is ~1
#> You are implementing a bernoulli Species Archetype Model.
#> This model uses a logit link function.
#> Using ECM algorithm to find starting values; using 1 refits
#> ECM restart 1 of 1
#> Initialising starting values
#> Initial groups parameter estimates by K-means clustering
#> Iteration: 1 | New loglik -950.728 | Ratio loglik 0
#> Iteration: 2 | New loglik -829.843 | Ratio loglik 0.8728
#> Iteration: 3 | New loglik -820.246 | Ratio loglik 0.9884
#> Iteration: 4 | New loglik -819.839 | Ratio loglik 0.9995
#> initial value 819.837517
#> iter 10 value 819.706573
#> final value 819.703416
#> converged
print(fm1)# }
#> bernoulli species_mix model
#>
#> Pi
#> Archetype1 Archetype2 Archetype3
#> 0.25 0.40 0.35
#>
#> Coefficients
#> $alpha
#> spp1 spp2 spp3 spp4 spp5 spp6 spp7
#> -0.8017228 -1.6402022 -0.5752349 -1.0844095 -1.0206820 -1.1776678 -0.7334905
#> spp8 spp9 spp10 spp11 spp12 spp13 spp14
#> -1.2036923 -1.6417827 -0.1856826 -0.8567274 -1.3909619 -0.7040062 -0.7040062
#> spp15 spp16 spp17 spp18 spp19 spp20
#> -0.8934080 -0.3780058 -1.3858328 -1.0552210 -1.2036923 -0.4298860
#>
#> $beta
#> x1 x2
#> Archetype1 -2.9107152 -3.5524871
#> Archetype2 -0.8299324 0.9551631
#> Archetype3 0.9916068 1.9873572
#>