Announcement

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

  • Generating a new variable with standardized values compared to a healthy control group mean and SD (z scores)

    I'm working with crossectional test data with a selection of test results (all continuous variables) in both a patient and healthy control (HC) group. I have made separate variables for the two groups' test results e.g. test1_controls, test1_patients, test2_controls, test2_patients etc. There are 95 patients and 48 healthy controls. I've attached the data for test 1.
    In order to compare the patient group to the healthy control group I want to make a new variable for each test with z-scores; generating a new value for each patient comparing them to the mean of the HC group so I can see how far above or below the "normal" data they fall. So if the test 1 z-score for patient number 1 was -2.3 that would mean they were 2.3 standard deviations below the mean of the healthy control group data for that test. What code would you use for this?
    I can do a generate a standardized value using egen test1_patients_z = std(test1_patients)
    but these standardized values are only based on the mean and SD of the patient group and I haven't been able to find any options that give me the result I need comparing to the healthy control mean.
    I tried egen test1_patients_z = std(test1_patients), mean(#) std(#)
    with # being manually entered mean and SD of test1_controls (which I got by codebook) but that did not work (it just shifted the whole scale upwards by the HC mean rather than the normal z score mean of 0).
    Thanks for your help!
    Attached Files

  • #2
    Welcome to Stata list. You did not get a quick answer. You will increase your chances of useful answer by following the FAQ on asking questions-provide Stata code in code delimiters, readable Stata output, and sample data using dataex. It is not recommended to attach files since many of us will not open files from strangers due to virus concerns.

    First you standardize the variables. Then you use test or ttest (not egen) to do the tests. There have been many discussions on this listserv about the wisdom of standardizing – you might check them out.

    Comment

    Working...
    X