Community Server

The platform that enables you to build rich, interactive communities
Welcome to Community Server Sign in | Join | Help
in Search

The CI of ratio of two samples, independent, dependent or correlated

Last post 07-30-2006, 10:37 AM by Random Walker. 1 replies.
Sort Posts: Previous Next
  •  07-20-2006, 12:39 AM 22

    The CI of ratio of two samples, independent, dependent or correlated

    Dear users,

    The CI of a ratio of two samples is often difficult to calculate even so Fieller has published a method that applies mostly to large normal samples. I have write a small piece of code to calculate it.

    'Two samples data'
      COPY (16 14 13 17 15) numerator
      COPY (32 28 29 30 31) denominator
    'For information'
      MEAN numerator Mnumerator
      MEAN denominator Mdenominator
      DIVIDE Mnumerator Mdenominator Ratio
      PRINT Mnumerator Mdenominator Ratio
    'Bootstrap'
      COPY 10000 rptCount
      REPEAT rptCount
        SAMPLE 5 numerator numBootstrap
        SAMPLE 5 denominator denBootstrap
        MEAN numBootstrap MnumBS
        MEAN denBootstrap MdenBS
        DIVIDE MnumBS MdenBS ratios
        SCORE ratios ratio
        SCORE MnumBS Mnum
        SCORE MdenBS Mden
      END
    'results'
      MEAN Mnum MBSnum
      MEAN Mden MBSden
      MEAN ratio Mratio
      STDEV ratio SDratio
      PERCENTILE ratio (2.5 97.5) CIratio
      PRINT MBSnum MBSden Mratio SDratio CIratio
      HISTOGRAM ratio

    You can easily adapt this code to dependent samples modifying the Sample syntax :
        SAMPLE 5 1,5 chooser
        TAKE numerator chooser numBootstrap
        TAKE denominator chooser denBootstrap

    Take care to verify these codes. I am not a specialist.

    I am also interested to complete these two examples with the CI of correlated samples... This is the case when a trend exists into each sample i.e. (17 16 15 14 13) / (32 31 30 29 28).
    In such case, the trend adds variability to the samples, and increases artificially the CI of the ratio. Taking into accound the previous data, there is in fact none variability other than the linear trend.

    Currently I am unable to build the code to directly calculate the CI with Statistics101. I suppose that a basic approach is to remove the trend before the calculation of the bootstrap ratio :
    - determine the pivot point of the sample (the mean?)
    - Calculate the parameters of the trend Y = ax + b
    - rotate horizontally the regression line, so that the variability of the sample is reduced (practically, it means Y' = Y - (Ymean - Ypredicted).
    - calculate the CI of the ratio as the ratio of two normal independant samples.

    I will be pleased to received advices or commentaries from specialists.
    Sincerely.
  •  07-30-2006, 10:37 AM 25 in reply to 22

    Re: The CI of ratio of two samples, independent, dependent or correlated

    I'm not a statistician and I'm not sure exactly what you are trying to do, but if you haven't done so already, you might look into these chapters of Julian Simon's book, where he gives examples of confidence intervals and correlated data:
    http://www.resample.com/content/text/24-Chap-20.pdf
    http://www.resample.com/content/text/25-Chap-21.pdf
    http://www.resample.com/content/text/27-Chap-23.pdf

    Given your example of correlated data, it might be enough to simply compute the ratios and bootstrap from there.
    For example:

    'Since the two vectors are correlated, all we really have
    'for samples is five ratios. They happen to be in order in the beginning,
    'but when we SAMPLE them, the new samples will not be in order,
    'and may have duplicates.
    DIVIDE (17 16 15 14 13) (32 31 30 29 28) ratios
    PRINT ratios

    COPY 1000 rptCount
    REPEAT rptCount
       SAMPLE 5 ratios sample
       MEAN sample meanSample
       SCORE meanSample meanSamples
    END
    PERCENTILE meanSamples (2.5 97.5) CIRatio
    PRINT CIRatio
    HISTOGRAM meanSamples

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems