Announcement

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

  • Generating confidence intervals for a new variable.

    Hi, I have a dataset of outcome measures at difference time points and an anchor score. I want to calculate the 95% CI for difference in means between two groups who score a certain value on an external anchor criterion. the code I am using is below, but the ci command just brings up an error message. Can soemone please assist. PS. I'm a stata novice.




    quietly sum pem_change_3mths if groc_3mths==1 | groc_3mths<0
    local mean_change = r(mean)
    dis `mean_change'

    quietly sum pem_change_3mths if groc_3mths==0
    local mean_unchanged = r(mean)
    dis `mean_unchanged'

    local betweenp = `mean_change' - `mean_unchanged'
    dis `betweenp'
    ci means `betweenp'

  • #2
    Code:
    gen group = 1 if groc_3mths == 1 | groc_3mths < 0
    replace group = 2 if groc_3mths == 0
    ttest pem_change_3mths, by(group)
    The last row of the output table from -ttest- will show you the mean and confidence interval for pem_change_3_mths.

    Comment


    • #3
      Thanks so much, that works perfectly! Very much appreciated :-)

      Comment

      Working...
      X