Session Ready
Exercise

Confidence bands using the segplot() function

It is common to have statistical estimates in the form of confidence intervals in addition to point estimates. Such data can be displayed using segment plots via the segplot() function in the latticeExtra package.

Calls to segplot() should be in the following form.

segplot(
  categories ~ lower_limit + upper_limit,
  data    = some_data,
  centers = point_estimates
)

Notice that the categories are displayed on the y-axis, and the confidence intervals are displayed on the x-axis. The point estimates, usually a mean or median value for that category, are specified using the centers argument, not the formula. An optional argument, draw.bands, let's you choose between confidence bands and confidence intervals. This argument is passed to the default panel function panel.segplot().

The estimated county-wise death rates in the USCancerRates dataset also have associated 95% confidence bounds, in the variables LCL95.male and UCL95.male for males, and similarly LCL95.female and UCL95.female for females. Plotting the confidence bounds for all counties is not useful because there are too many counties. For this exercise, your goal is to plot the county-wise confidence intervals for males for the state of Louisiana.

Instructions
100 XP
  • Create a subset of the USCancerRates dataset containing data for only the state of "Louisiana". Assign this subset to LACancerRates1.

  • Reorder the levels of the county variable by the value of rate.male. Assign the updated dataset to LACancerRates2.

  • Draw a segment plot of 95% confidence intervals for county-wise death rates for males in Louisiana.

    • The categories are the counties, given by the county variable.
    • LCL95.male and UCL95.male contain the confidence limits.
    • The points estimates are given by rate.male.
    • Set draw.bands to FALSE to draw confidence intervals (rather than bands).