- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How do I determine difference in medians and confidence interval for this difference
I have been asked to report the difference and 95% confidence intervals around the difference for means and medians in a study. It is easy to get these values for means, but I’ve found it difficult to figure out how to do this for medians and non-parametric data.
I am working with two groups of subjects, non-paired integer data.
Any help is appreciated. I am running JMP 12.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I determine difference in medians and confidence interval for this difference
Hi @strickerp,
Determining the standard error of the median as an estimator has complications, so exact confidence intervals aren't typically defined (though there are approximate formulae around that work well for large samples). The best way to form a confidence interval for such a statistic is by bootstrapping it. Are you using JMP Pro 12 by chance? If so, you can generate bootstrapped confidence intervals about the median difference by using JMP Pro's Right-click bootstrapping:
Using JMP Pro:
- Launch Fit Y by X with your variable
- Go to the Red Triangle > Quantiles.
- Right-click on top of the reported medians and select "Bootstrap." Enter the number of bootstrap samples you want (I would suggest 5000, which will take some time). You will get a table with one row per bootstrap sample, and columns for the median that was found on each iteration for each level of your X variable.
- Since you're interested in forming a confidence interval about the difference of medians, select both columns in the table, right click on the row header > New Formula Column > Combine > Difference.
- To get your bootstrapped confidence interval, go to Analyze > Distribution, place your new difference score column in for Y and click okay.
- JMP knows this is a bootstrapped table, so it will return a section titled "Bootstrap Confidence Limits." For 95% intervals, look at the .95 rows of coverage.
Here's a quick video showing those steps:
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
I hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I determine difference in medians and confidence interval for this difference
Hi @strickerp,
Determining the standard error of the median as an estimator has complications, so exact confidence intervals aren't typically defined (though there are approximate formulae around that work well for large samples). The best way to form a confidence interval for such a statistic is by bootstrapping it. Are you using JMP Pro 12 by chance? If so, you can generate bootstrapped confidence intervals about the median difference by using JMP Pro's Right-click bootstrapping:
Using JMP Pro:
- Launch Fit Y by X with your variable
- Go to the Red Triangle > Quantiles.
- Right-click on top of the reported medians and select "Bootstrap." Enter the number of bootstrap samples you want (I would suggest 5000, which will take some time). You will get a table with one row per bootstrap sample, and columns for the median that was found on each iteration for each level of your X variable.
- Since you're interested in forming a confidence interval about the difference of medians, select both columns in the table, right click on the row header > New Formula Column > Combine > Difference.
- To get your bootstrapped confidence interval, go to Analyze > Distribution, place your new difference score column in for Y and click okay.
- JMP knows this is a bootstrapped table, so it will return a section titled "Bootstrap Confidence Limits." For 95% intervals, look at the .95 rows of coverage.
Here's a quick video showing those steps:
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
I hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I determine difference in medians and confidence interval for this difference
If you don't have JMP Pro, you can produce the bootstrap yourself, but it requires the extra steps of sampling your table with replacement so you can compute the median for each group at each iteration. You could this via scripting, but here's how you could go about this interactively by using my Sample With Replacement Add-In (download this first).
- Launch the Sample with Replacement Add In (Add-In Menu > Sample With Replacement > Sample Now)
- Select the columns you need for the particular comparison of medians (your Y, and your X factor)
- Specify at least 5000 for the number of samples, and click OK (leave sample size alone, this is only for over- or -under sampling). You will have a new table that is as many rows as your original table times the number of samples you drew. For a large initial table this could be huge.
- Launch Tables > Summary
- Group by Sample Number
- Subgroup by your Factor
- Select your Y, then click "Statistics" and select "Median." Click OK. You will now have the same summary table we got from the Right-Click bootstrap, so the steps now are the same
- Select the two median columns, right-click in the header > New Formula Column > Combine > Difference
- Launch Analyze > Distribution, place the difference column in for Y, and click OK
- There will not be a Bootstrap limits section, but you can use the Quantiles to find your coverage limits. For 95% confidence, read off the values for the 2.5% and 97.5% quantiles.
Here's another video showing this quickly:
- Chapters
- descriptions off, selected
- captions settings, opens captions settings dialog
- captions off, selected
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
This is a modal window. This modal can be closed by pressing the Escape key or activating the close button.
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I determine difference in medians and confidence interval for this difference
This is wonderful- thank you so much!