carlopacioni / vortexR

an R package for post Vortex simulation analysis
8 stars 3 forks source link

pairwise contrasts #51

Closed Dejan1983 closed 3 years ago

Dejan1983 commented 3 years ago

Hello Carlo and Florian! Thanks very much for making vortexR - it's been very interesting working my way through it. I have a question that i was hoping you could help me with. I have 4 paired scenarios from vortex run over 50y - the pairs are designed to test variation in one parameter (a state variable, which affects only one of each pair), across four scenarios where mortality rates and LEs are varied. I am hoping to contrast the impact of the state variable on N, GeneDiv etc over different levels of mortality and inbreeding depression. I've looked through the vortexR documentation on analysis and reckon that the best way to contrast the models is using 'pairwise'. I have been able to get pairwise to work on the full data set (i.e. all 8 models at once). I've then tried to subset the data frame to separate out the related pairs. But if the data frame contains only one pair of models, i get this error: 'Error in ratings.rank[, i] : incorrect number of dimensions' the dimensions of the reduced data frame (i.e. containing only the pairs) are 102 35, compared to the full data frame of 510 35. It does not return the same error if there is a third model in the scenario (making the df dimensions 153 * 35). i guess my question is two fold: 1) is 'pairwise' the best way to contrast 2 ordinary vortex models to one another in vortexR? 2) if yes, then how do i subset the data frame correctly to get around this error in dimensions? thank you! D

carlopacioni commented 3 years ago

Thanks Dejan for touching base. Unfortunately, this is a known problem that I didn't get around to fix yet. I'll make it a priority. The problem stems from the Kendall statistic that tries to rank scenarios, but because there is only one scenario in addition to the base scenario in your case, it fails.

You can use SSMD_matrix, which should give what you want except for the CV. Let me know if this works for you please.

carlo

Dejan1983 commented 3 years ago

Hi Carlo! Thank you for the very fast reply! I manage to get that working thanks! So that's a matrix where the SSMD is below the diagonal and p is above it? Is this the best way to contrast two models to one another in your opinion? Thanks again. D

carlopacioni commented 3 years ago

yes, I think. This will provide you with the extent of the difference and a statistical test (that is suitable for your large sample size). The CV is the only thing missing, but you can calculate them in R if you need them (but I think you can probably do without)