skiptoniam / ecomix

ecomix is a package to implement model based species level (Species Archetype Models) or site level (Regions of Common Profile) grouping of community data.
https://skiptoniam.github.io/ecomix/
7 stars 2 forks source link

Reintoduce Tweedie for both SAMs & RCPs #27

Open skiptoniam opened 1 year ago

skiptoniam commented 1 year ago

Reintoduce Tweedie for both SAMs & RCPs

fhui28 commented 3 months ago

There is currently a bug in species_mix for tweedie? When I try to run a modified example in your help file, I guess the below.

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="tweedie")
#> Random alpha from normal (-1,0.5) distribution
#> Random values for species' dispersion parameters
#> Power parameter assigned to 1.6 for each species
fm1 <- species_mix(archetype_formula = sam_form,species_formula = sp_form,
                   data = simulated_data, family = 'tweedie',  nArchetypes=3)
#> SAM modelling
#> There are 3 archetypes to group the species into
#> 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 tweedie Species Archetype Model.
#> Using ECM algorithm to find starting values; using 1 refits
#> ECM restart 1 of 1
#> Initialising starting values
#> Error in many.fit(y, X, W, U, site_spp_weights, offset, y_is_na, G, S, : argument "powers" is missing, with no default

Created on 2024-08-21 with reprex v2.1.1

Thanks!

skiptoniam commented 3 months ago

Hi Francis, I've been meaning to get back to these bugs. There is also an issues with dispersion parameter in the negbin (which I need to fix). Skip

fhui28 commented 3 months ago

[like] Francis Hui reacted to your message:


From: Skip Woolley @.> Sent: Wednesday, August 21, 2024 12:23:15 AM To: skiptoniam/ecomix @.> Cc: Francis KC Hui @.>; Comment @.> Subject: Re: [skiptoniam/ecomix] Reintoduce Tweedie for both SAMs & RCPs (Issue #27)

Hi Francis, I've been meaning to get back to these bugs. There is also an issues with dispersion parameter in the negbin (which I need to fix). Skip

— Reply to this email directly, view it on GitHubhttps://github.com/skiptoniam/ecomix/issues/27#issuecomment-2299982336, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABH6DBEC2NVPADGF47JBMCDZSPMXHAVCNFSM6AAAAABM2DUI4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJZHE4DEMZTGY. You are receiving this because you commented.Message ID: @.***>