Conditional mean

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

kirill.serykh
Posts: 15
Joined: Wed Apr 16, 2014 6:09 am

Conditional mean

Postby kirill.serykh » Wed Apr 16, 2014 9:26 am

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?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Conditional mean

Postby EViews Gareth » Wed Apr 16, 2014 9:29 am

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.

kirill.serykh
Posts: 15
Joined: Wed Apr 16, 2014 6:09 am

Re: Conditional mean

Postby kirill.serykh » Wed Apr 16, 2014 10:23 am

2) We'd need to see the workfile to get an idea of how your data is structured.
Here is the file data.f1
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

Postby kirill.serykh » Wed Apr 16, 2014 10:24 am

1) Open a series, click on View->Descriptive Statistics->Stats By Classification, and enter "year country" as the series to classify by.
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 :(

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Conditional mean

Postby EViews Gareth » Wed Apr 16, 2014 10:26 am

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

Postby kirill.serykh » Wed Apr 16, 2014 12:08 pm

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

Postby EViews Gareth » Wed Apr 16, 2014 12:59 pm

1) Open a series, click on View->Descriptive Statistics->Stats By Classification, and enter "year country" as the series to classify by.
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 :(
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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Conditional mean

Postby EViews Gareth » Wed Apr 16, 2014 1:00 pm

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?
We'd need to see the workfile.

kirill.serykh
Posts: 15
Joined: Wed Apr 16, 2014 6:09 am

Re: Conditional mean

Postby kirill.serykh » Wed Apr 16, 2014 1:18 pm

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?
We'd need to see the workfile.
Here it is, I'm sorry.
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

Postby EViews Gareth » Wed Apr 16, 2014 1:27 pm

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

Postby kirill.serykh » Wed Apr 16, 2014 2:05 pm

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

Postby EViews Gareth » Wed Apr 16, 2014 2:09 pm

There is only one mean...

kirill.serykh
Posts: 15
Joined: Wed Apr 16, 2014 6:09 am

Re: Conditional mean

Postby kirill.serykh » Wed Apr 16, 2014 2:14 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Conditional mean

Postby EViews Gareth » Wed Apr 16, 2014 2:19 pm

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

Postby kirill.serykh » Wed Apr 16, 2014 2:31 pm

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.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests