Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graphing a cumulative frequency function

    Dear Statalist,

    I'm working with a panel data set consisting of 1.134.384 individuals tracked over different periods of time between 1970 and 2002 among different nations (ex. France, Germany Belgium and so on). I have a variable (6 values) about i's church attendence. I generated a variable which for each year and for each nations, records the percentage of individuals that declare to attend church functions several times in a week (value 1 of variable) once a week (value 2 of variable) and so on. So, considering two year, one nation (ex. France) my data set looks like that:

    year nation2 churchat pc_churchat
    1970 france SEV TIME 3.763441
    1970 france SEV TIME 3.763441
    1970 france SEV TIME 3.763441
    1970 france SEV TIME 3.763441
    1970 france SEV TIME 3.763441
    .
    .
    .
    1970 france ONCE A W 19.25709
    1970 france ONCE A W 19.25709
    1970 france ONCE A W 19.25709
    1970 france ONCE A W 19.25709
    1970 france ONCE A W 19.25709
    .
    .
    .
    1971 france SEV TIME 1.24105
    1971 france SEV TIME 1.24105
    1971 france SEV TIME 1.24105
    1971 france SEV TIME 1.24105
    1971 france SEV TIME 1.24105
    .
    .
    .
    1971 france ONCE A W 18.47255
    1971 france ONCE A W 18.47255
    1971 france ONCE A W 18.47255
    1971 france ONCE A W 18.47255
    1971 france ONCE A W 18.47255


    I have two problems:

    1) I want to creare a table that for each year (row imput) and for each nation (column imput) represents the cumulative probability of variable churchat for the only first two values (several time and once a w.). In the example,

    year France

    1970 3.763441+19.25709= 23.02
    1971 1.24105 +18.47255= 19.71
    .
    .
    .


    2) For each nation, I want to graph the cumulative probability function of the only first two values of variable (several time and once a w.) over year. In the other terms, I want to graph the column of the previous table.

    Thank for the attention.
    Last edited by Ivan Nardini; 17 Jul 2016, 08:11.

  • #2
    Please read the FAQ for how to post questions. Your description is too vague and your data example are not something that someone can work with. However, I think you are looking for something along the lines of:
    Code:
    clear*
    input year nation2 churchat pc_churchat
    1970 1 1 3.763441
    1970 1 1 3.763441
    1970 1 1 3.763441
    1970 1 1 3.763441
    1970 1 1 3.763441
    1970 1 2 19.25709
    1970 1 2 19.25709
    1970 1 2 19.25709
    1970 1 2 19.25709
    1970 1 2 19.25709
    1971 1 1 1.24105
    1971 1 1 1.24105
    1971 1 1 1.24105
    1971 1 1 1.24105
    1971 1 1 1.24105
    1971 1 2 18.47255
    1971 1 2 18.47255
    1971 1 2 18.47255
    1971 1 2 18.47255
    1971 1 2 18.47255
    end
    la de nation2 1 "france"
    la val nation2 nation2
    
    la de churchat 1 "SEV TIME" 2 "ONCE A W"
    la val churchat churchat
    
    egen tag=tag(year nation2 churchat)
    bys year nation2: egen sum_pc=total(pc_churchat) if churchat<3 & tag==1
    
    //TABLE FOR QUESTION 1
    table year nation2 if tag, c(mean sum_pc)
    
    //GRAPH FOR QUESTION 2
    graph bar sum_pc if tag, over(year) over(nation2)
    If this is not what you are looking for, use dataex to sample example of your data.

    Comment


    • #3
      Hi Oded, thanks you for your advice. It works perfectly. To the next question.

      Comment

      Working...
      X