Announcement

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

  • average weighted scores

    Dear Statalists,

    I have a survey data that contains categorical variables in the Likert scale (typically 5 categories between strongly agree- strongly disagree). I would like to calculate a kind of average weighted scores by assigning values for each response categories, then, dividing it by a total number of observations. The values assigned as follows:
    Category The value that will be assigned
    1 - Strongly disagree -2
    2 – Disagree -1
    3 – Neither disagree nor agree 0
    4 – Agree +1
    5 – Disagree +2
    Now I want to calculate an average weighted score for each variable like this:
    Average weighted score = (All Strongly disagrees * -2) +(All Disagrees * -1)+ (All NDNAs * 0)+ (All Agrees * +1)+ (All Strongly agrees * +2) / Total number of frequency

    I could not figure out how to do that easily in Stata.

    I will be grateful for any help and advice.
    Best regards,
    Savas

  • #2
    You didn't get a quick response. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    Without knowing what your data look like, it is hard to figure out how to code something. If you're doing this for a bunch of variables, you'll want to loop over the variables. So, you want to sum of 1's, sum of 2's, etc.? I don't see how it would make sense to subtract 2 from a total.

    I suspect you want something like this:
    clear
    set obs 100

    g cat=1 in 1/50
    replace cat=2 in 51/100

    g altcat=4 if cat==1
    replace altcat=2 if cat==2


    foreach var in altcat {
    egen cat1`var'=sum(`var'==4)
    egen cat2`var'=sum(`var'==2)
    egen obs`var'=count(`var')
    g awc`var'=(cat1`var' + cat2`var')/obs`var'
    }

    Comment


    • #3
      Dear Phil Bromiley

      I am sorry for the inconvenience. I'll try to explain myself more clearly.

      I have variables like s15b, which obtained Likert-survey and take values ranging from 1 to 5.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int id float s15b
       1 5
       2 4
       3 1
       4 4
       5 2
       6 5
       7 2
       8 2
       9 2
      10 3
      11 3
      12 2
      13 3
      14 3
      15 3
      16 4
      17 4
      18 3
      19 4
      20 3
      end
      label values s15b likertenglish
      label def likertenglish 1 "Disagree Strongly", modify
      label def likertenglish 2 "Disagree", modify
      label def likertenglish 3 "Neither Agree Nor Disagree", modify
      label def likertenglish 4 "Agree", modify
      label def likertenglish 5 "Agree Strongly", modify
      For each variable (I have more than 50 variables like s15b), I need to calculate the average weighted views of respondents by assigning values -2 for 1 (disagree strongly), -1 for 2 (disagree), 0 for 3 (Neither Agree Nor Disgree), +1 for 4 (agree) and +2 (agree strongly). For s15b, I would likte to calculate this:

      weighteds1b = (Frequency of 1s * -2) + (Frequency 2s * -1) + (Frequency 3s * 0) + (Frequency 4s * +1) + (Frequency 5s * +2) / Total number of observation

      I need to do that for each of my variables separately. I use Stata 14.

      Thank you for any advice.
      Kind regards,
      Savas

      Comment

      Working...
      X