Giter Site home page Giter Site logo

Create "meanF" function about rcompadre HOT 3 CLOSED

jonesor avatar jonesor commented on July 30, 2024
Create "meanF" function

from rcompadre.

Comments (3)

patrickbarks avatar patrickbarks commented on July 30, 2024

@DannyLBuss I started editing this function, and perhaps got carried away. I hope it's a bit simpler now, but let me know what you think.

I changed the functionality to return a mean of mean matFs instead of a random matF, and I also changed it to return a meanMatF for every single row of the database that gets passed, rather than for only a subset of "Individual" matrices. I figure the user can subset to "Individual" at a later point, if they so wish. Let me know what you think, and/or if you prefer the original function.

(Also, I changed the name to appendMeanMatF)

from rcompadre.

patrickbarks avatar patrickbarks commented on July 30, 2024

I propose dropping the meanMatF function in favour of a more general function that takes a list of matrices (of equal dimension) and returns the element-wise mean matrix (e.g. averageMats).

The problem I see with meanMatF is that there are many different grouping levels at which a user might want to calculate a mean matrix, depending on the analysis, e.g.

  • SpeciesAuthor x MatrixPopulation
  • SpeciesAuthor x MatrixPopulation x MatrixTreatment
  • SpeciesAuthor x MatrixStartYear
  • SpeciesAuthor x MatrixStartYear x <user-derived column>

There's also the complication of how to deal with matrix dimension mismatch, if it pops up at the desired level. I think making meanMatF sufficiently flexible would also make it overly complicated.

With the tidy version of db (#27) and a function like averageMats, it would be easier for a user to average any type of matrix at any given group level with their own 'split-apply-combine' operation, e.g.

db %>% 
  group_by(SpeciesAuthor, MatrixDimension) %>% 
  mutate(matF_mean = averageMats(matF)) %>% 
  ungroup()

I suggest we replace meanMatF with averageMats, and add an example like this to the vignette (or website, etc.).

(Side note: popbio has a mean.list S3 method that does the same thing as averageMats, but I think it would be preferable to have a separate standalone function).

from rcompadre.

patrickbarks avatar patrickbarks commented on July 30, 2024

cdb_mean_matF and mpm_mean can be used to produce mean fecundity matrices. My issues from the previous comment are resolved by #48, so closing this.

from rcompadre.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.