Announcement

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

  • TTest Problem

    I am having problem where i want want to compare six social preferences (Patience, trust, altruism etc) against 30 sample countries (Compare each to the overall mean) but i am getting errors kindly help. The main aim is check whether the mean value for each social preference differs significantly in your selected sample compared to the overall mean and this is the error

    ttest patience if country == "Afghanistan", by(country)
    1 group found, 2 required
    r(420);


  • #2
    Create the country indicators and use these as the by variables. The 0 category is all other countries and the 1 category is the indicated country.

    Code:
    gen Afghanistan= country=="Afghanistan"
    ttest patience, by(Afghanistan)

    Comment


    • #3
      Hello Caspar Njoroge. You said you want to "[c]ompare each to the overall mean". To do that, use -contrast- with the g. operator after -regress- or -anova-. Here's an example using the auto.dta data file that comes with Stata.

      Code:
      clear
      sysuse auto
      
      // Example using -regress-
      regress price i.rep78
      contrast g.rep78
      
      // Example using -anova-
      anova price rep78
      contrast g.rep78
      Replace price with your DV and rep78 with your country variable.

      Given the number of countries you have, you should think about how to handle the obvious multiplicity problem.

      HTH.
      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 18.5 (Windows)

      Comment

      Working...
      X