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

meta() support #130

Open
chfleming opened this issue Oct 30, 2020 · 19 comments
Open

meta() support #130

chfleming opened this issue Oct 30, 2020 · 19 comments

Comments

@chfleming
Copy link
Contributor

chfleming commented Oct 30, 2020

Newer versions of ctmm have the meta() command for UD objects (see ?meta). It would be nice to have it supported in ctmmweb. There are two basic ways to use this function. You can either run meta() on a list of all of the individuals, like meta(list(...)), or you can run it on a list of lists, where each sub-list is a group like males or females to compare, like meta(list(male=list(...),female=list(...)).

@xhdong-umd
Copy link
Contributor

xhdong-umd commented Feb 27, 2021

Several questions about meta

  • The help said only home range is supported now, but it looked like I can also feed with model objects. What's the target for this function in ctmmweb? models or home ranges?
    • Even if it's not supported now, models will be supported in future, right? Do you want meta on models to be implemented in ctmmweb? If this is the case, I need to think on a design that can work on both model and home range pages.
  • On home range, there are some reports in console and a plot. I assume both should be put in ctmmweb.
    • With a list of lists, is there some column name missing in the last 3 tables?
> sub_list <- list(a = hrange_list_same_grid[1:3], b = hrange_list_same_grid[4:6])
> meta(sub_list)
* Sub-population a
                 ΔAICc
Dirac-\u03b4         0
inverse-Gaussian   Inf
* Sub-population b
                 ΔAICc
Dirac-\u03b4         0
inverse-Gaussian   Inf
* Joint population
                     ΔAICc
inverse-Gaussian 0.0000000
Dirac-\u03b4     0.9497466
* Joint population versus sub-populations (best models)
                    ΔAICc
Joint population 0.000000
Sub-population   2.634796
, , low

          /a        /b
a/ 1.0000000 0.6384834
b/ 0.7848531 1.0000000

, , est

         /a        /b
a/ 1.000000 0.9124752
b/ 1.112321 1.0000000

, , high

         /a       /b
a/ 1.000000 1.256063
b/ 1.541884 1.000000
  • Do you think ctmmweb need to have an interface to let user arrange individuals into groups to use the list of list feature?
  • any parameter of meta need to put in the interface to let user control them?

@chfleming
Copy link
Contributor Author

There's no need to worry about meta() on models for the time being. For the moment that's just implementing meta-analysis of the Gaussian home-range areas when applied to model fit objects It's not really important for anyone but me. Other features for model fit objects would go into a very different kind of analysis.

There are two usages of meta() on the home-range UD objects.

  1. Running meta() on a list of UD objects representing the sample of some population, to summarize that population. Often times, this will be every individual in the study. The output is a table of summary statistics for that population. The plot is a forest plot of the individuals in the population, and is potentially useful for users. Also the colors of the individuals can be carried over to that plot consistently with the rest of ctmmweb analysis.
  2. Running meta() on a list of named lists of UD objects, with each named list of UD objects representing a sub-population that will be compared. Users will need to be able to group individuals into named groups for this kind of analysis in ctmmweb. The output is a table of ratio estimates—the mean home-range area of population a / the mean home-range area of population b, where the rows are the numerator and the columns are the denominator, as per the initially strange looking row and column names. The plot is also a kind of forest plot for the sub-populations, and users will often what mean=FALSE in cases where grouping the sub-populations together doesn't make any sense.

@xhdong-umd
Copy link
Contributor

OK. for 2nd mode, do you want to always use mean = FALSE, or make it an option and default to false?
And what does the table header of ,, low mean? Are there 3 columns, first 2 columns have no name, but last column have a name low? The table below looks to be a 2x2 matrix and don't need more column names to me. If the matrix is just for low, should ,,low be just low?

, , low

          /a        /b
a/ 1.0000000 0.6384834
b/ 0.7848531 1.0000000

@chfleming
Copy link
Contributor Author

I would make mean an option. It sometimes makes sense and sometimes doesn't.

c(low,est,high) is what I label the lower point of the confidence interval, the point estimate, and the upper point of the confidence interval. There is a confidence interval for the estimate of each ratio. So b/a has a point estimate of 1.11 and a confidence interval of 0.78—1.54. This is the estimated mean home-range area of population b divided by the mean home-range area of population a. These ratios could potentially put into a second plot, as was done with the overlap page.

@xhdong-umd
Copy link
Contributor

xhdong-umd commented Mar 27, 2021

I'm seeing Dirac-\u03b4 in meta print out, with Chinese windows. I switched my local to English and still seeing it. Is that supposed to be some unicode symbol?

                        ΔAICc
inverse-Gaussian    0.0000000
Dirac-\u03b4        0.9497467

In ctmm code it seemed to be just "Dirac-d" but I don't know why it print out as this.

@chfleming
Copy link
Contributor Author

Did you upgrade to R 4.0.4? There is a known bug that is supposed to be addressed in the next release.

https://bugs.r-project.org/bugzilla/show_bug.cgi?id=18059

@xhdong-umd
Copy link
Contributor

xhdong-umd commented Mar 27, 2021

Yes I'm on R 4.0.4. That seemed to be the cause.

                     ΔAICc
inverse-Gaussian 0.0000000
Dirac-\u03b4     0.9497455
                     low          est        high
mean (km2)  2.753858e+02 380.21059001 507.2465737
CoV2 (RVAR) 3.124238e-03   0.08161385   0.2835524
CoV  (RSTD) 6.166569e-02   0.31517625   0.5874734

For the meta output, originally I plan to convert to a data.frame and show in a table, just like the model selection table. Though the first 2 lines and the other parts seemed to be different things, not easy to organize in same table. A simple and brutal method is just print the output in a text box in app as is, not using a html table.

Or maybe I can create 2 tables side by side as html table. I'll need some name/description on each table.

The advantage of just print the text vs make html table is that if there is change in meta output I don't need to change my side of code. With html table I need to assume something about output structure and names etc, which could change with ctmm updates.

@chfleming
Copy link
Contributor Author

I think the first table is just printed to the console and is just there for information purposes—mainly to see if variance estimation failed. The second table is the returned object and contains the important outputs.

@xhdong-umd
Copy link
Contributor

So I can ignore the first table in the app?

Besides, there was a warning in calculating home range, should I add some parameter to avoid the warning? I didn't see DOP in help page of akde.

[2021-03-27 17:25:05.591] Calculating Home Range in Same Grid ...  
   user  system elapsed 
   0.01    0.00    0.01 
DOP values missing. Assuming DOP=1.

@chfleming
Copy link
Contributor Author

I think the first table is fine to leave in the console. It's more for advanced users to tweak the IC argument and see how bad the variance estimate is.

The DOP values missing warning there is new from my recent re-coding, but shouldn't come up unless you have location error turned on? Is that the case?

@xhdong-umd
Copy link
Contributor

I imported buffalo like before, didn't turn on error specifically. How to check if location error is on? The data was imported and recognized as not calibrated.

@chfleming
Copy link
Contributor Author

I'm not getting this message with the most recent version of the package, if not having location error turned on... and it isn't turned on by default.

@xhdong-umd
Copy link
Contributor

More specifically, how to turn on location error? So that I can check my code and session to see if it was turned on.

On meta of sub-population, the sub-population cannot have single individual, otherwise there will be error. Is this expected? If it's expected, I can set some condition to prevent it happen but will need to explain to user each sub-population need to have at least 2 individuals.

@chfleming
Copy link
Contributor Author

If the GUESS object has a non-zero error slot (in any component), then error is turned on.

Normal users would not assign only 1 member to a population, but I can fix this error to not occur.

@xhdong-umd
Copy link
Contributor

It took me quite some time to track down the warning was generated in plotting telemetry data, not home range (my home range plot plot location together).

> library(ctmm)
> data("buffalo")
> plot(buffalo)
DOP values missing. Assuming DOP=1.
DOP values missing. Assuming DOP=1.
DOP values missing. Assuming DOP=1.
DOP values missing. Assuming DOP=1.
DOP values missing. Assuming DOP=1.
DOP values missing. Assuming DOP=1.

Looks like buffalo data have some UERE value. Is this the reason?

$identity
[1] "Toni"

$timezone
[1] "UTC"

$projection
[1] "+proj=tpeqd +lon_1=31.7775407470691 +lat_1=-24.2850983757726 +lon_2=31.8880063438124 +lat_2=-25.024736901024 +datum=WGS84"


Slot "UERE":
An object of class "UERE"
[[1]]
    horizontal
all         10

@xhdong-umd
Copy link
Contributor

Now I have the features mentioned implemented. I'm still not satisfied with the UI, but I don't want to spend further time to change it before we can discuss it in next meeting.

@chfleming
Copy link
Contributor Author

This is expected now. Location error is now turned on by default in plot() and a default UERE object is now assigned on import, but with DOF=0, which makes it do nothing but assign a guess value (which plot and outlie use before calibration). Previously, users were not realizing that they could plot the location errors and users with e-obs (or similar) data were plotting or assessing outliers with inappropriate guess values.

@xhdong-umd
Copy link
Contributor

The app allows user to select multiple models of same individual for home range, then we need to identify them in the meta plot. Previously I used individual name + model name in this case, but this will make the meta plot axis label too small.
2021-04-03_103800

2021-04-03_103607

@chfleming Can you make the axis label with fixed font or adjust the margin so it can take longer individual names? I think sometimes the user data also may have long name so this is needed anyway. You can test the plot by just making some long names.

I can also remove the "home range" part in the name above to make it shorter, but the model name is needed so in total we need at least 22-25 characters in name.

@chfleming
Copy link
Contributor Author

If you increase the margin, then the font size should increase up unto the default size. I coded it to only shrink the font when the margin is too narrow and fill the margin. Also, with ~50 individuals, I find it nice to have the font a bit smaller.

I pushed an update so that (1) meta() won't crash with one individual and (2) there is a verbose option when comparing populations, so that the analysis of each sub-population is returned in a list, in addition to the overall comparison. Some users might appreciate having the individual results in a big table like you do with the model fit results.

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

2 participants