Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: programming question for instrument scoring with weights


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: programming question for instrument scoring with weights
Date   Thu, 9 Jun 2011 09:52:14 -0500

If you need it to work superfast, you can code this in Mata with
views. If not, you can code this with a fixed scoring system (kinda
ugly):

generate int total_score = item1 + item2 + item3 + [fill in the dots]
+ item19 + 4*item2 + 3*item3 + 2*item5 + 2*item7 + item9 - 3*item3a

I am assuming that your items are coded 1 for yes, 0 for no. Or you
can do this sequentially:

egen int total_score = total( item1 item2 [fill in the dots] item19 )
replace total_score = total_score + 4 if item2 == 1
...
replace total_score = total_score - 3 if item3a == 1

All of these ways are cumbersome, and the more lines of code you have,
the more likely it is you will have an error somewhere. The choice
between different ways of coding your problem is a matter of
aesthetics, and how readable the code will be to you and other users
of it.

On Thu, Jun 9, 2011 at 9:16 AM, Lucea, Marguerite <[email protected]> wrote:
> I'm working on creating a variable that is an instrument score. . . the only issue is that some of the questions are weighted differently than others. I'm not sure how to code for it in STATA.
>
> This is the way the scale is scored (19 questions). First, you total the score for 1-19. Then, if they answered "yes" to #2, you add 4pts. If yes to #3, add 3 pts. If yes to #4, add 3 pts. If yes to #5, add 2 pts. If yes to #6, add 2pts. If yes to #7, add 2 pts. If yes to #8, add 1 pt. If yes to 9, add 1 pt. If yes to #3a (not in the original totaling), subtract 3 pts. The final result after all these adjustments and weights is the total score.



-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index