Statalist


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

st: RE: RE: RE: Re: sum across observations until a certaincutpoint


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Re: sum across observations until a certaincutpoint
Date   Sun, 9 Nov 2008 18:28:33 -0000

Not so. If you can analyse the data, you can also restructure them!

Sorry, but your answer is still ambiguous to me as you didn't answer my
question. I offered a choice of two wordings. You wrote your own. 

This may be what you want: 

Say items go -item1- to -item200-. 

gen within60 = 0 
qui forval i = 1/200 { 
	replace within60 = within60 + 1 if time`i' > 0 & time`i' <= 60 
} 

Nick 
[email protected] 

Amanda Botticello

I want to calculate how many items each subject completed within 60
seconds. And I can't do anything about the data structure,
unfortunately.

>>> "Nick Cox" <[email protected]> 11/9/2008 1:14 PM >>>
You've lost me. I don't understand how your data structure copes with
time spent on failed tasks. 

Please be clear: Do you want to cumulate times and see how many tasks in
total were completed within a total of 60 seconds, as implied by your
original question, or do you just want to count how many tasks were
individually completed within 60 seconds? 

Incidentally, I think you would be better off reshaping this to long. 

Nick 
[email protected] 

Amanda Botticello

The data is more like this:

id  item1  time1    item2  time2  itmem3 time3
1    1         2           1         3        1          2
2    1         5           0         0        0          0 
3    1         3           1         3        1          5

The variable "item" is coded 0,1, where 1 indicates the item was
completed
Time is recorded in number of seconds to complete.  If they didn't
complete an item, the time is 0

>>> "Nick Cox" <[email protected]> 11/9/2008 12:59 PM >>>
Still not very clear to me, but I guess something like this 

task1 task2 task3  task4  task5 
20      10    20    5       10 
5       10    15    30      2 
100     2      3    3       4 

So that the three individuals above had completed 4, 4, 0 tasks in the
first 60 seconds. 

How many within 60 seconds?  

gen cumul = 0 
gen within60 = 0 

qui forval i = 1/5 { 
	replace cumul = cumul + task`i' 
	replace within60 = `i' if cumul <= 60 
} 

Nick 
[email protected] 

Amanda Botticello PhD, MPH

IT's a "wide" dataset...subjects completed up to 200 items in a task,
and we recorded the number of seconds it took to complete each item.  I
can create a sum of the total number of items completed and total time;
now I want to find out how many items each individual completed in 60,
90, and 120 seconds.  Does that help?

>>> "Martin Weiss" <[email protected]> 11/9/2008 11:00 AM >>>

Well, if you want the running sum, look at -help sum()-. But maybe you
could 
give us a peek at your data structure, that would assist in answering
your 
question...

"Amanda Botticello" <[email protected]>

>I have a dataset of test items and the time (in seconds)to complete
each 
>item.  I need to create a variable that sums the time variables up to a

>certain number -- i.e., 60, 90, 120 seconds.  Is there a way I can use
the 
>egen newvar = rowtot (time*) command to count up to 60 seconds, etc?

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index