Announcement

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

  • Item Exploratory Factor Analysis - results changing when code is rerun

    I have a sample of N = 401 individuals who completed a self-report measure on mobile-use dependency. In an effort to validate the survey I plan on first running an exploratory factor analysis (EFA) followed by a confirmatory factor analysis (CFA). The questionnaire consisting of 18 binary items so I am using item factor analysis.

    I have randomly split the sample into two to carry out EFA on one sample and CFA on the other using the following code:

    Code:
    set seed 12345
    generate random = uniform()
    sort random
    generate group= .
    replace grp = 1 in 1/200
    replace grp = 2 in 201/401
    Then to run the item exploratory factor analysis (iEFA), I run the following code:

    Code:
    preserve
    drop if grp == 2
    tetrachoric i1-i18, posdef
    matrix mysigma = r(Rho)    // saving the tetrachoric correlation matrix
    
    factormat mysigma, n(401) mineigen(1) blanks(0.2) // factor analysis
    screeplot
    rotate, promax(3) oblique kaiser blanks(0.3)  
    restore
    Every time I rerun the the above chunks of code, I obtain different loadings and sometimes a different number of factors.
    What am I missing here?


  • #2
    Are you re-opening the data file when you rerun your code (to get back to the same initial state)?

    Also, why are you specifying n(401) on your factormat command when you are using only 200 observations?

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

    Comment


    • #3
      Hi Bruce, yes every time I reopen the file or rerun the code within the same session this happens.

      *The n = 401 is a mistake that should say 200 - thanks for pointing out.

      Comment


      • #4
        When I modify your code to use the data from this UCLA webpage, I get the same result every time. What do you get when you run my modified code?

        Code:
        cls
        forvalues i = 1/2 {
        
        use "https://stats.idre.ucla.edu/stat/stata/faq/tetra", clear
        set seed 12345
        generate random = uniform()
        sort random
        generate grp= .
        replace grp = 1 in 1/100
        replace grp = 2 in 101/200
        
        preserve
        drop if grp == 2
        tetrachoric female-sci, posdef
        matrix mysigma = r(Rho)    // saving the tetrachoric correlation matrix
        
        factormat mysigma, n(100) mineigen(1) blanks(0.2) // factor analysis
        screeplot
        rotate, promax(3) oblique kaiser blanks(0.3)  
        restore
        
        }
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment


        • #5
          Originally posted by Sam Honer View Post
          Every time I rerun the the above chunks of code, I obtain different loadings and sometimes a different number of factors.
          What am I missing here?
          You've sorted it.

          When you -restore- the dataset, it's not the same dataset as what you had at first: it's sorted differently, and so when you go to sort it again, you start from a different sort order.

          Comment

          Working...
          X