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]

st: Advice on content of a do file


From   Peter King <[email protected]>
To   [email protected]
Subject   st: Advice on content of a do file
Date   Fri, 26 Jul 2013 18:12:38 +1200

Hi All,

I'm preparing to analyse survey responses to the ICECAP-A questionnaire. The ICECAP-A developers have provided code to substitute into a Stata do file to allow the calculation of values or tariffs for each respondent.

The code is as follows:

matrix UTILS=(-0.001,0.101,0.191,0.222\/*

*/-0.024,0.096,0.189,0.228\/*

*/0.006, 0.084, 0.156, 0.188\/*

*/0.021, 0.091, 0.159, 0.181\ /*

*/ -0.003, 0.069, 0.154, 0.181)

gen sta_index=UTILS[1,stability[_n]]

gen att_index=UTILS[2,attachment[_n]]

gen aut_index=UTILS[3,autonomy[_n]]

gen ach_index=UTILS[4,achievement[_n]]

gen enj_index=UTILS[5,enjoyment[_n]]

gen tariff=sta_index+att_index+aut_index+ach_index+enj_index


I have formatted my data as specified below:

"This code, when substituted into a Stata do file, will allow calculation of ICECAP-A tariffs for each respondent in a study, based on their answers to the five classification questions. Statistical analyses can then be conducted on these tariffs. Indeed they can be conducted on the five index values also, to ascertain sensitivity of these to differences in factors.


"Data should be set up with one study participant per row. As specified on the ICECAP-A questionnaire, coding should be such that the 'top' level (full capability for an attribute) should take the value '4', down to the bottom level (no capability) which should take the value '1'. NB this coding is the opposite of that used in instruments such as the EQ-5D (where 1 is top level). The five variables, containing a respondent's five ICECAP-A responses should be named stability, attachment, autonomy, achievement, enjoyment."

When I run the do file with the specified content I get the following reply/output:

. do "C:\Documents and Settings\User\My Documents\FCSPRU Files\Current projects\BIS 2006\Surve
> ys\Postal survey\Wave 2 2012\ICECAP Tariff.do"

. matrix UTILS=(-0.001,0.101,0.191,0.222\/*
> */-0.024,0.096,0.189,0.228\/*
> */0.006, 0.084, 0.156, 0.188\/*
> */0.021, 0.091, 0.159, 0.181\ /*
> */ -0.003, 0.069, 0.154, 0.181)

. gen sta_index=UTILS[1,stability[_n]]
matrix operators that return matrices not allowed in this context
r(509);

end of do-file

r(509);

.
I am new to using do files and wonder whether I should be including other information in the do file? Or is something else wrong in the code?

Any suggestions from more experienced users will be greatlt appreciated.


Many thanks,

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


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