CRSU-Apps / MetaInsight

An interactive web-based tool for analyzing, interrogating, and visualizing network meta-analyses using R-shiny
https://crsu.shinyapps.io/MetaInsight/
GNU General Public License v3.0
9 stars 9 forks source link

MR-43 contribution matrix #154

Closed JanionNevill closed 5 months ago

JanionNevill commented 6 months ago

I haven't been able to test this in the app with a data set with more than 2 arms, as the base contribution matrix function throws an error with the 4-arm data set provided. Unit tests do use a data set with 3 arms though.

tommorris168 commented 6 months ago

Sorry, one more change. When the outcome is binary, the y-axis labels should be on the odds ratio scale, rather than the log-odds ratio-scale. Naomi did this in her graph using ggplot2::scale_y_continuous.

JanionNevill commented 6 months ago

Sorry, one more change. When the outcome is binary, the y-axis labels should be on the odds ratio scale, rather than the log-odds ratio-scale. Naomi did this in her graph using ggplot2::scale_y_continuous.

It already does this: image

JanionNevill commented 6 months ago

Currently it only allows treatment effect parameters. There are also covariate parameters to be added. I was thinking there could be two drop-down lists, each with its own "add all" button. If they were all in the same list it might get too crowded when you add all.

I'm afraid that I have no idea what you're talking about here 😳 That's my lack of statistical knowledge showing through...

tommorris168 commented 6 months ago

I'm afraid that I have no idea what you're talking about here 😳 That's my lack of statistical knowledge showing through...

:laughing: Actually I was getting confused, and what I wrote didn't make sense! I was thinking there were two lines per treatment, but actually there are two contributions per study per treatment. One of them is the circle that is there now, which is for the d parameter (treatment effect), and the other isn't there which is for the beta parameter (treatment-by-covariate interaction). If you look at figure 8 of the Donegan paper (attached to the Jira task) where we got the graph from, there are two circles per study. The red one is the d and the blue one is the beta. They have one treatment effect per graph, so it makes sense for them to have both circles. We have multiple treatment effects in the same graph, so I don't think we should put both circles in as it will become too busy.

So, forget what I said about there being two drop down lists. What we actually need is where the "show contributions" tick box is, there need to be three options: show treatment effect contributions, show covariate effect contributions, or nothing.

You got the treatment effect contributions from the columns ending in _d in the contribution matrix. The covariate contributions come from the columns ending in _beta (except for the shared covariate parameters, where there is only one column called B, and this column applies to all treatments).

Clear as mud?

JanionNevill commented 6 months ago

Clear as mud?

As mud indeed 😅

What we actually need is where the "show contributions" tick box is, there need to be three options: show treatment effect contributions, show covariate effect contributions, or nothing.

Is this different to the selection of "contribution" vs. "weight"?

JanionNevill commented 6 months ago

There should be a warning displayed on the screen, something like this: "Contributions cannot be determined. This possibly indicates a poorly fitting model. Please check model diagnostics in the Result Details and Deviance Report tabs".

It already does show a warning when the contribution matrix is uncalculatable. I will make the message more clear though.

tommorris168 commented 6 months ago

Sorry, one more change. When the outcome is binary, the y-axis labels should be on the odds ratio scale, rather than the log-odds ratio-scale. Naomi did this in her graph using ggplot2::scale_y_continuous.

It already does this: image

It isn't working. You can tell by comparing the forest plot, which is on the odds-ratio scale, to the graph which is still on the log-odds-ratio scale.

tommorris168 commented 6 months ago

Clear as mud?

As mud indeed 😅

What we actually need is where the "show contributions" tick box is, there need to be three options: show treatment effect contributions, show covariate effect contributions, or nothing.

Is this different to the selection of "contribution" vs. "weight"?

Yes, the two sets of parameters are always included in the output, regardless of which options are selected.

JanionNevill commented 5 months ago

Sorry, one more change. When the outcome is binary, the y-axis labels should be on the odds ratio scale, rather than the log-odds ratio-scale. Naomi did this in her graph using ggplot2::scale_y_continuous.

It already does this: image

It isn't working. You can tell by comparing the forest plot, which is on the odds-ratio scale, to the graph which is still on the log-odds-ratio scale.

I'd passed the wrong object to the function, that's why it wasn't working. I've fixed that now, but it's not displaying correctly, possibly due to the centring/normalising of the covariate value.

image

I will try to fix this, but if you have any insights which would be useful, please let me know.

JanionNevill commented 5 months ago

So, forget what I said about there being two drop down lists. What we actually need is where the "show contributions" tick box is, there need to be three options: show treatment effect contributions, show covariate effect contributions, or nothing.

You got the treatment effect contributions from the columns ending in _d in the contribution matrix. The covariate contributions come from the columns ending in _beta (except for the shared covariate parameters, where there is only one column called B, and this column applies to all treatments).

I've implemented this now, but it'll need thorough checking, because I'm not 100% sure that I've understood the concept fully. When using "Shared" regression, every study contributes to every regression, regardless of the shape of the network.

tommorris168 commented 5 months ago

I'd passed the wrong object to the function, that's why it wasn't working. I've fixed that now, but it's not displaying correctly, possibly due to the centring/normalising of the covariate value. image

I will try to fix this, but if you have any insights which would be useful, please let me know.

I think the trans parameter is transforming the y-axis itself, whereas we only want the y-axis labels to change. So it should be exactly as Naomi has it, using the labels parameter but with plogis replaced by exp in the function definition.

JanionNevill commented 5 months ago

I think I've addressed everything now...

tommorris168 commented 5 months ago

I've implemented this now, but it'll need thorough checking, because I'm not 100% sure that I've understood the concept fully. When using "Shared" regression, every study contributes to every regression, regardless of the shape of the network.

In shared regression there is one covariate parameter, and the studies that contribute to this parameter are precisely those that have the reference treatment. So what you've programmed is correct.

JanionNevill commented 5 months ago

In shared regression there is one covariate parameter, and the studies that contribute to this parameter are precisely those that have the reference treatment. So what you've programmed is correct.

Just to check, are the direct and indirect contributions done correctly?

tommorris168 commented 5 months ago

Just to check, are the direct and indirect contributions done correctly?

I believe so.

tommorris168 commented 5 months ago

Actually, as I was checking that I have found two issues.

  1. In regression_plot_panel.R there is test code on line 349.
  2. The axes don't always react appropriately to the input changing. Run the attached data set with "shared" then change the options on the graph to Show contributions = "Covariate Effect" and Study circle sized by = "Absolute contribution". Then compare Contribution type between "weight" and "contribution". You'll see that the y-axis changes and drops off one of the circles when the contribution type is "weight". Cert_four_arms.csv
JanionNevill commented 5 months ago
  • In regression_plot_panel.R there is test code on line 349.
  • The axes don't always react appropriately to the input changing. Run the attached data set with "shared" then change the options on the graph to Show contributions = "Covariate Effect" and Study circle sized by = "Absolute contribution". Then compare Contribution type between "weight" and "contribution". You'll see that the y-axis changes and drops off one of the circles when the contribution type is "weight".
  1. I've removed the test code now.
  2. I've debugged into the code when making those contributions matrices, and it's doing what it's supposed to. The value in the contribution matrix is zero, so it doesn't plot it.