The DHS Program User Forum - RDF feed
https://userforum.dhsprogram.com/index.php
Multilevel modeling in DHS-Sri Lanka
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=16598&th=7735#msg_16598
I need to make a community poverty variable for my multilevel analysis. Hence I generated following command using some tutorials. However when I used bys QACLUST: egen tot_in_clus3=count(QACLUST) command , it comes with the error saying "type mismatch". I need to make community poverty variable with 0 for "low"=percentage who are belongs to middle and above and 1as hight for who are belong to lowest and secondary (all five categories)
QAcluster =Is my cluster ID and QHWEALTH is my wealth index quintiles (five categories)..
gen poverty=0
replace poverty=1 if QHWLTHI<=2
*collapse poverty, by(QACLUST)
bys QACLUST: egen tot_in_clus3=count(QACLUST)
bys QACLUST : egen tot_poverty=total(poverty)
bys QACLUST: gen poverty_percent=tot_poverty*100/tot_in_clus3
]]>dga1n@soton.ac.uk2019-02-05T13:15:20-00:00Re: Multilevel modeling in DHS-Sri Lanka
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=16614&th=7735#msg_16614
"Type" refers to whether the variable is stored as a number or as a string (that is, as characters). In general, you get this error when you accidentally mix numeric and string variables within a command or ask for an operation with a string variable that can only be done with a numeric variable. My guess is that your QACLUST is coded with numbers such as 1, 2, 3, etc., but you have somehow specified those numbers to be read as characters.
The data files already contain a variable that is the cluster id code. It's v001 in the IR and BR and KR files, hv001 in the HR and PR files, and mv001 in the MR file. It's a numeric variable, and your code will work fine if you use it in place of QACLUST.
To repeat, I believe that your QACLUST has been constructed as a string variable and that's the problem. To find out how QACLUST is being interpreted by Stata, enter "describe QACLUST". Good luck.
]]>Bridgette-DHS2019-02-06T15:09:01-00:00Re: Multilevel modeling in DHS-Sri Lanka
https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=16625&th=7735#msg_16625
I am grateful for your response. I converted my variables successfully. Thanks]]>dga1n@soton.ac.uk2019-02-07T16:50:21-00:00