Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "meanF" function #6

Closed
jonesor opened this issue Dec 5, 2017 · 3 comments
Closed

Create "meanF" function #6

jonesor opened this issue Dec 5, 2017 · 3 comments
Assignees

Comments

@jonesor
Copy link
Owner

jonesor commented Dec 5, 2017

Function to produce mean fecundity matrices from individual matrices.

@patrickbarks
Copy link
Collaborator

@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)

@patrickbarks
Copy link
Collaborator

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).

@patrickbarks
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants