Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bootstrapping test statistic for two paired ratios

    Hi,

    I am trying to bootstrap a paired t test statistic for two paired ratio estimates (ifr0 and ifr1). I am getting the error 'variable ifr0 not found' when I run the below syntax. Can anyone advise on what I am doing wrong?

    Thanks,
    Kate

    capture program drop meandiff
    program meandiff, rclass

    ratio (ifr0: q309/Q214) if r1==1, vce(bootstrap, cluster(id))
    scalar define ifr0 = _b[ifr0]
    summarize ifr0 if r1==1
    scalar define mean_ifr0=r(mean)

    ratio (ifr1: r309/Q214) if r1==1, vce(bootstrap, cluster(id))
    scalar define ifr1 = _b[ifr1]
    summarize ifr1 if r1==1
    scalar define mean_ifr1=r(mean)

    return scalar meandiff = mean_ifr0-mean_ifr1
    end

    bootstrap t=r(t), reps(100): meandiff ttest mean_ifr0 mean_ifr1

  • #2
    Kate.
    welcome to the list.
    A temptative answer would consider that the -if- condition is the same (-if r==1-) for both ratios.
    Was it intentional or not?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thanks for your response. Yes, the (if r1==1) condition is intentional for both ratios to select a sub-sample of the data included in round 1. The idea is to compare the ratio of participant reporting at time 1 (q309) and time two (r309) to an observer report (Q214 at baseline).

      To test if the two paired ratio estimates are significantly different from each other, I first tried the below syntax. However, I was unsure if using the 'test' command after the ratio estimations was appropriate for paired data, which is why I tried the approach listed in my first post. Also I wanted to use bootstrapping given these are ratios and the distribution is not normal. Any help would be greatly appreciated!

      Syntax:

      ratio (ifr0: q309/Q214) (ifr1: r309/Q214) if r1==1, vce(bootstrap)
      test _b[ifr0] = _b[ifr1]

      Output:
      Ratio estimation Number of obs = 506
      Replications = 50

      ifr0: q309/Q214
      ifr1: r309/Q214

      --------------------------------------------------------------
      | Observed Bootstrap Normal-based
      | Ratio Std. Err. [95% Conf. Interval]
      -------------+------------------------------------------------
      ifr0 | .9356223 .0095552 .9168944 .9543502
      ifr1 | .8681904 .0099048 .8487773 .8876034
      --------------------------------------------------------------


      ( 1) ifr0 - ifr1 = 0

      chi2( 1) =37207.41
      Prob > chi2 = 0.0000

      Comment


      • #4
        Hi everyone,

        Does anyone know if it is possible to perform a paired t test (using bootstrapping) of ratio estimation results? I've tried various approaches to saving ratio estimates in a scalar or matrix and then to bootstrap the test statistic, but to no avail after a great deal of time. Any guidance on the syntax posted in my Post 1 would be hugely helpful.

        Thanks!
        Kate

        Comment


        • #5
          Kate:
          what if you change:
          Code:
          summarize ifr0 if r1==1
          in:

          Code:
          summarize ifr0 if r1==1, meanonly
          and do the same variation for -ifr1-?
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            You cannot use summarize ifr0 when ifr0 is a scalar and not a dataset variable, and that's what your error message ('variable ifr0 not found') is all about.

            I'm not sure what you're dataset is like. You keep talking about paired t-test of ratios, but the Stata command ratio is for unpaired data. Are the observations paired? If so then something like that below would give you a bootstrapped paired t-statistic of the ratios.
            Code:
            generate double q_Q = q309 / Q214
            generate double r_Q = r309 / Q214
            
            bootstrap t=r(t), rep(1000) nodots nowarn: ttest q_Q = r_Q
            estat bootstrap, all
            But if the observations are paired, why not just to a paired t-test of q309 to r309?

            I suppose there's an easy explanation, but I'm not seeing it at the moment, how the observations are not paired (hence the use of ratio), but the ratios formed are paired.

            Comment

            Working...
            X