Announcement

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

  • Matrix results, ESEM, SEM, EFA, CFA

    Hi Statalist members,

    When I try to recreate the results on example 2 from the dataset https://essedunet.nsd.no/cms/data/st...lice_stata.zip on Stata, I get the following error on the output: equation cov(Effective,Procfair) not found.

    This is the command/code:

    // Fitting the same 2-factor CFA model for 6 items separately for
    // each country, and collecting some of the results in a table.
    levelsof cntry, clean local(countries)
    local n_c: word count `countries'
    matrix results = J(`n_c',5,.)
    matrix rownames results = `countries'
    matrix colnames results = Fcorr pGlob pvEFA RMSEA CFI
    // Loop over the countries, and collect results:
    local i = 0
    foreach c of local countries {
    local ++i
    display "Country: " "`c'"
    // 2-factor CFA model
    sem (Effective -> plcpvcr plccbrg plcarcr) ///
    (ProcFair -> plcrspc plcfrdc plcexdc) if cntry=="`c'", ///
    var(Effective@1 ProcFair@1) method(mlmv) iter(100) ///
    nolog satopts(nolog) baseopts(nolog)
    matrix b=e(b)
    estimates store cfa_mod
    estat gof, stats(all)
    local converged=e(converged)
    if(`converged'==1){
    matrix results[`i',1] = _b[cov(Effective,ProcFair):_cons]
    matrix results[`i',2] = r(p_ms)
    matrix results[`i',4] = r(rmsea)
    matrix results[`i',5] = r(cfi)
    }
    // 2-factor EFA model, for comparison
    quietly: sem (Effective -> plcpvcr plccbrg plcarcr ///
    (plcrspc,init(0)) (plcfrdc,init(0))) ///
    (ProcFair -> (plccbrg,init(0)) (plcarcr,init(0)) ///
    plcrspc plcfrdc plcexdc) if cntry=="`c'", ///
    var(Effective@1 ProcFair@1) method(mlmv) from(b) iter(100)
    local converged=e(converged)
    if(`converged'==1){
    lrtest cfa_mod .
    matrix results[`i',3] = r(p)
    }
    }
    //
    matlist results, format(%4.3f)


    The problem appears to be the way the "matrix results[`i',1] = _b[cov(Effective,ProcFair):_cons]" and the way the matrix is saved: matrix b = e(b). Everything is fine if I drop the option, "matrix results[`i',1] = _b[cov(Effective,ProcFair):_cons]".

    Can someone help me with what could be wrong and how I can save the covariance results in my matrix?

    Thank you,
    Paul
Working...
X