Page 1 of 1

Calculating mean minus index observation

Posted: Tue May 06, 2014 7:04 am
by ww34
I am trying to calculate mean preschool enrolment in each class, excluding the index child. I am using the command

series meanenrol= @meansby(preschool, t2_id, "@all")

t2_id is the teacher id which identifies the class and this is working fine to give me the average for the class but I want the average for the class excluding the observation child. Does anybody have any idea how I can do this? Thanks in advance.

Re: Calculating mean minus index observation

Posted: Tue May 06, 2014 7:17 am
by startz

Code: Select all

series meanenrol= @meansby(preschool, t2_id, "@all") - preschool

Re: Calculating mean minus index observation

Posted: Tue May 06, 2014 7:30 am
by ww34
Thanks but that didn't work, gave me negative numbers. If it helps preschool is a dummy variable.

Re: Calculating mean minus index observation

Posted: Tue May 06, 2014 7:56 am
by startz
Oops, I misunderstood what you want. Maybe something like

Code: Select all

series meanenrol= (@sumsby(preschool, t2_id, "@all")-preschool)/(@obsby(preschool, t2_id, "@all")-1)

Re: Calculating mean minus index observation

Posted: Tue May 06, 2014 8:01 am
by ww34
Brilliant! That worked perfectly. Thank you so much!