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   "Florian Christian Esser" <[email protected]>
To   [email protected]
Subject   Re: st: CR and AVE for factor analysis with 2 factors
Date   Tue, 29 Oct 2013 10:49:53 +0100

Hi Nick,

thank you so much! I will try the Mata approach, you suggested, but I have
to admit that I am not firm in it. In the meantime, would a workaround be
to set
gen nvar = e(df_m)
to
gen nvar = min(e(df_m),6)

Thank you very much again!

> That explains it then. Your loop goes 1 to 15. You are looking for
> entries rows 7 to 15 in the matrix, but they don't exist. As soon as
> you ask for -communalities[7,1]- Stata just overwrites your sum with
> missing as it evaluates -communalities[7,1]-  as missing. Either your
> loop must go 1 to 6, in this case, or (if you used the Mata approach I
> suggested earlier) you need not loop at all.
> Nick
> [email protected]
>
>
> On 29 October 2013 09:33, Florian Christian Esser
> <[email protected]> wrote:
>> It's 15
>>
>>> What's e(df_m) in your case?
>>> Nick
>>> [email protected]
>>>
>>>
>>> On 29 October 2013 09:07, Florian Christian Esser
>>> <[email protected]> wrote:
>>>> Here we go (I included the uniqueness and the loadings as well).
>>>> Communalities are on the bottom:
>>>> _____________________________________________________________
>>>>
>>>>
>>>> . matrix list e(Psi)
>>>>
>>>> e(Psi)[1,6]
>>>>             zwmdiff_1  zwpdiff_1  zwpdiff_2   zwcost_1   zwcost_2
>>>> zwcost_3
>>>> Uniqueness  .14721836  .16061008  .12541414  .01425274  .01366305
>>>> .02630422
>>>>
>>>> . matrix list e(L)
>>>>
>>>> e(L)[6,3]
>>>>               Factor1     Factor2     Factor3
>>>> zwmdiff_1   .81629684     .233233   .36337787
>>>> zwpdiff_1   .82275816   .39938175  -.05434294
>>>> zwpdiff_2    .8671496   .34761446   .04244559
>>>>  zwcost_1  -.52875169   .83417333   .10160593
>>>>  zwcost_2  -.51348298   .84223386   .11538764
>>>>  zwcost_3  -.18959666  -.28021389    .9269461
>>>>
>>>> . matrix psi = e(Psi)'
>>>>
>>>> . matrix communalities = J(rowsof(psi),1,1)
>>>>
>>>> . matrix communalities = communalities - psi
>>>>
>>>> . matrix colnames communalities = communalities
>>>>
>>>> . matrix list communalities
>>>>
>>>> communalities[6,1]
>>>>            communalit~s
>>>> zwmdiff_1     .85278164
>>>> zwpdiff_1     .83938992
>>>> zwpdiff_2     .87458586
>>>>  zwcost_1     .98574726
>>>>  zwcost_2     .98633695
>>>>  zwcost_3     .97369578
>>>> _____________________________________________________
>>>>
>>>>> What is implied by your log is that
>>>>>
>>>>> replace sum_factors = sum_factors + sqrt(communalities[3,1])
>>>>>
>>>>> has the effect of replacing -sum_factors- with missing. So, please
>>>>> show us that -communalities- matrix,
>>>>> namely the result of your line
>>>>>
>>>>> matrix list communalities
>>>>>
>>>>> (I see on closer examination that the -communalities- matrix is not
>>>>> the communalaties as first reported, but modified.)
>>>>>
>>>>> No idea, sorry, about your general factor analysis question. I'm
>>>>> firmly a PCA person.
>>>>> Nick
>>>>> [email protected]
>>>>>
>>>>>
>>>>> On 29 October 2013 07:14, Florian Christian Esser
>>>>> <[email protected]> wrote:
>>>>>> Hi Nick, thanks a lot for your advice.
>>>>>> Unfortunately, all my communalities are positive.
>>>>>> Does anyone have any ideas, what else could cause the issue?
>>>>>>
>>>>>> Is the general approach correct, to calculate CR and AVE for both
>>>>>> factors
>>>>>> at the same time, or would I have to do it individually. I.e. I do
>>>>>> the
>>>>>> factor analysis, identify, that the indicators load on two factors
>>>>>> and
>>>>>> then calculate CR and AVE for each factor individually?
>>>>>>
>>>>>>> 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/
>>>>>>>
>>>>>>
>>>>>>
>>>>>> *
>>>>>> *   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/
>>>>>
>>>>
>>>>
>>>> *
>>>> *   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/
>>>
>>
>>
>> *
>> *   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/
>


*
*   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