Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: compare a variable within groups of observations

From   Giancarlo Musto <>
Subject   st: compare a variable within groups of observations
Date   Mon, 3 May 2010 19:51:40 +0200

Hi everybody,

I have a dataset on children's daily arrival time at school over a
period of 4 years. To be more precise for each kid ("child") I have
1460 observations - one for each day - of the variable "arrival_time"
that tells me the arrival time at school in each given day and takes
value "." if the child did not go to school in a specific day.
Moreover, the dataset contains for each kid its 9-digit zip code

What I would like to do is to create peer groups on the basis of the
arrival times and of the zip codes. To be precise, I would like to do
what it follows:

1) define a time period from "$starting_date" to "$end_date"

2) look within the groups of kids with the same 9-digit zip code

3) count the number of days in which the kids in each groups arrive in
the same time interval (for istance, "arrival_time" of one of them
plus or minus a minute)

4) define kids as belonging to the peer group if they arrived at
school in the same interval for a given for a given numbers of days,
say a threshold ("$threshold") that can be thought as a certain
percentage of the number of school days of the kids that went less
days to school.

Clearly, if there were only two children in each zip code group it
would be quite easy to do this. Nevertheless, this is not the case and
I don't know how to deal with several comparisons within the same zip
code group. Indeed, I need to compare kids within the groups in

I hope you can solve my problem, or at least give me some good advices.

Giancarlo Musto
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index