Conditional mean
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Conditional mean
Hello, guys. I have 2 problems, can you please help me to solve them?
First of all, I have a data set from PISA which contains results of mathematical tests of different puupils from different schools from different countries. This list contains 34 countries, 5 periods of time, huge number of schools from every country and more huge numberof pupils. There are 2 separate variables for country and year: - CNT (where there is a 3-digit text code for the country, for example, AUS, USA, RUS...) and YEAR - where is a year (2000, 2003, 2006, 2009, 2012). So, here are my 2 problems:
1) I have 30 other variables for which I want to calculate a mean value for each country in each year.
2) Also I have a school ID variable and a couple of school data variables that are repeated for each pupil that belongs to the current school. I need to calculate the conditional mean data for each year and country, but due to the fact that for pupils from one school data are the same, I need to delete all data for that school except one.
How can I do this in Eviews?
First of all, I have a data set from PISA which contains results of mathematical tests of different puupils from different schools from different countries. This list contains 34 countries, 5 periods of time, huge number of schools from every country and more huge numberof pupils. There are 2 separate variables for country and year: - CNT (where there is a 3-digit text code for the country, for example, AUS, USA, RUS...) and YEAR - where is a year (2000, 2003, 2006, 2009, 2012). So, here are my 2 problems:
1) I have 30 other variables for which I want to calculate a mean value for each country in each year.
2) Also I have a school ID variable and a couple of school data variables that are repeated for each pupil that belongs to the current school. I need to calculate the conditional mean data for each year and country, but due to the fact that for pupils from one school data are the same, I need to delete all data for that school except one.
How can I do this in Eviews?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
1) Open a series, click on View->Descriptive Statistics->Stats By Classification, and enter "year country" as the series to classify by.
2) We'd need to see the workfile to get an idea of how your data is structured.
2) We'd need to see the workfile to get an idea of how your data is structured.
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
Here is the file data.f12) We'd need to see the workfile to get an idea of how your data is structured.
For instance, there is only one year, but 34 countries. I need an average value of pvscie1 for every school in every country, but there is a problem: sometimes schoolid data are the same for different schools in different countries ( for example, schoolid has a value 6 for AUT and for LVA, but these schools are different.
- Attachments
-
- data.rar
- (923.06 KiB) Downloaded 670 times
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
And is it possible to do such operation for the group of variables? Of course, it's possible to repeat this operation for 30 times, but it's a little bit time-wasting :(1) Open a series, click on View->Descriptive Statistics->Stats By Classification, and enter "year country" as the series to classify by.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
Same procedure, but enter "schoolid cnt" as the series to classify by.
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
Thank you so much. And I have one more question: what if need an average value by all schools in the country? The problem is that actually, I need only one observation of variables PCGIRLS and COMPWEB for each school of each country, because values of these variables are repeated for every observation (pupil) in every school. How is possible to leave only one value for each school and to delete others?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
Write a for loop that loops through the elements of the group and uses the @meansby function, or the series.statsby command. More details can be found in the Command and Programming Reference, and the Object Reference.And is it possible to do such operation for the group of variables? Of course, it's possible to repeat this operation for 30 times, but it's a little bit time-wasting :(1) Open a series, click on View->Descriptive Statistics->Stats By Classification, and enter "year country" as the series to classify by.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
We'd need to see the workfile.Thank you so much. And I have one more question: what if need an average value by all schools in the country? The problem is that actually, I need only one observation of variables PCGIRLS and COMPWEB for each school of each country, because values of these variables are repeated for every observation (pupil) in every school. How is possible to leave only one value for each school and to delete others?
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
Here it is, I'm sorry.We'd need to see the workfile.Thank you so much. And I have one more question: what if need an average value by all schools in the country? The problem is that actually, I need only one observation of variables PCGIRLS and COMPWEB for each school of each country, because values of these variables are repeated for every observation (pupil) in every school. How is possible to leave only one value for each school and to delete others?
- Attachments
-
- zfsd.rar
- (246.45 KiB) Downloaded 574 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
Something like:
Code: Select all
smpl if @trend=0 or (schoolid<>schoolid(-1))
show @mean(pcgirls)
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
It shows only one value for all observations.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
There is only one mean...
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
Oh, I'm sorry, maybe I said not very correctly.
I meant that I need 34 means, where 34 is the number of countries. The problem is that data are available for every pupil, but pupils that are studying in one school have the same data (like, PCGIRLS = percentage of girls, and the percentage of girls is the same in each school for every pupil). The problem is that I need to leave only one row for every school (because they are repeated) and then to calculate mean for every country.
I meant that I need 34 means, where 34 is the number of countries. The problem is that data are available for every pupil, but pupils that are studying in one school have the same data (like, PCGIRLS = percentage of girls, and the percentage of girls is the same in each school for every pupil). The problem is that I need to leave only one row for every school (because they are repeated) and then to calculate mean for every country.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Conditional mean
ok, so set the sample like I said, then do the @meansby, or View->Descp Stats->Stats by Classification
-
kirill.serykh
- Posts: 15
- Joined: Wed Apr 16, 2014 6:09 am
Re: Conditional mean
But it's still shows me only one value for all of the schools in all countries - 260.5809
I meant that I need to delete all the repeated values, for instance, first 16 values are 0.510, but I need to leave only one (because this is the value for school, not for the pupil), and then to calculate average value for the country.
I meant that I need to delete all the repeated values, for instance, first 16 values are 0.510, but I need to leave only one (because this is the value for school, not for the pupil), and then to calculate average value for the country.
Who is online
Users browsing this forum: No registered users and 2 guests
