Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: CR and AVE for factor analysis with 2 factors


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: CR and AVE for factor analysis with 2 factors
Date   Mon, 28 Oct 2013 16:36:34 +0000

Your missing value is presumably the result of taking the square root
of a negative number. Is at least one of your communalities reported
as negative?

That aside you have segments like

gen nvar = e(df_m)
gen sum_factors=0
local i=1
while `i' <= nvar {
replace sum_factors = sum_factors + sqrt(communalities[`i',1])
local i=`i'+1
}

You can simplify this. First, to hold constants, use locals or
scalars, not variables. Second, use -forval- to loop here:

local nvar = e(df_m)
local sum_factors = 0
forval i = 1/`nvar' {
     local sum_factors = `sum_factors'  + sqrt(communalities[`i',1]
}

Third, use Mata instead. Here is a self-contained example:

. matrix foo = (1,2,3,4)

. mata : st_numscalar("sum_factors", sum(sqrt(st_matrix("foo"))))

. scalar li
sum_factors =  6.1462644

However, none of these tricks can get round what appears to be your problem.


Nick
[email protected]


On 28 October 2013 14:11, Florian Christian Esser
<[email protected]> wrote:
> Hi everyone,
>
> I am trying to do factor analysis in order to measure two strategy
> constructs. I have 6 indicators that load on these two constructs. Now I
> want to calculate composite reliability (CR) and average variance
> extracted(AVE).
> I use the following code (here for CR):
> ___________________________________________________________________
> factor zwmdiff_1 zwpdiff_1 zwpdiff_2 zwcost_1 zwcost_2 zwcost_3, pcf
> matrix list e(Psi)
> matrix list e(L)
> matrix psi = e(Psi)'
> matrix communalities = J(rowsof(psi),1,1)
> matrix communalities = communalities - psi
> matrix colnames communalities = communalities
> matrix list communalities
> gen nvar = e(df_m)
> gen sum_factors=0
> local i=1
> while `i' <= nvar {
> replace sum_factors = sum_factors + sqrt(communalities[`i',1])
> local i=`i'+1
> }
> generate sum_psi=0
> local i=1
> while `i' <= nvar {
> replace sum_psi = sum_psi + psi[`i',1]
> local i=`i'+1
> }
> gen cr=(sum_factors*sum_factors)/((sum_factors*sum_factors)+sum_psi)
> drop nvar
> drop sum_factors
> drop sum_psi
> list cr in 1
> _________________________________________________________________
>
> The problem is that once the local macro starts running it tells me:
> _____________________________
> [...]
> (534 real changes made)
> (534 real changes made)
> (534 real changes made, 534 to missing)
> (0 real changes made)
> (0 real changes made)
> (0 real changes made)
> [...]
> ___________________________
>
> and accordingly there is an empty result for CR.
> If I add "factors(1)" in the command line above, I get a result, but I
> since I have two factors, I think it is not correct to do this.
>
> Does anyone know what to do here?
>
> Thanks a lot in advance.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index