Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread William R Revelle
Hi all.

I am taking a brief vacation and will look at this next week.

Bill


> On Aug 29, 2019, at 2:53 PM, William Dunlap  wrote:
> 
> Element #2 of that output,  the empty fomula " F1=~  ", triggers the bug in 
> omegaSem.
> omegaSem needs to ignore such entries in omega's output.  psych's author 
> should be able to fix things up.
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> 
> 
> On Thu, Aug 29, 2019 at 12:31 PM Danilo Esteban Rodriguez Zapata 
>  wrote:
> well the output with the code that you refer is the following:
> 
> > psych::omega(my.data)$model$lavaan
> [1] g =~ 
> +AUT_10_04+AUN_07_01+AUN_07_02+AUN_09_01+AUN_10_01+AUT_11_01+AUT_17_01+AUT_20_03+CRE_05_02+CRE_07_04+CRE_10_01+CRE_16_02+EFEC_03_07+EFEC_05+EFEC_09_02+EFEC_16_03+EVA_02_01+EVA_07_01+EVA_12_02+EVA_15_06+FLX_04_01+FLX_04_05+FLX_08_02+FLX_10_03+IDO_01_06+IDO_05_02+IDO_09_03+IDO_17_01+IE_01_03+IE_10_03+IE_13_03+IE_15_01+LC_07_03+LC_08_02+LC_11_03+LC_11_05+ME_02_03+ME_07_06+ME_09_01+ME_09_06+NEG_01_03+NEG_05_04+NEG_07_03+NEG_08_01+OP_03_05+OP_12_01+OP_14_01+OP_14_02+ORL_01_03+ORL_03_01+ORL_03_05+ORL_10_05+PER_08_02+PER_16_01+PER_19_06+PER_22_06+PLA_01_03+PLA_05_01+PLA_07_02+PLA_10_01+PLA_12_02+PLA_18_01+PR_06_02+PR_15_03+PR_25_01+PR_25_06+REL_09_05+REL_14_03+REL_14_06+REL_16_04+RS_02_03+RS_07_05+RS_08_05+RS_13_03+TF_03_01+TF_04_01+TF_10_03+TF_12_01+TRE_09_05+TRE_09_06+TRE_26_04+TRE_26_05
> [2] F1=~  
>   
>   
>   
>   
>   
>   
>   
>   
>   
>   
> [3] F2=~  + AUN_07_02 + CRE_05_02 + CRE_07_04 + CRE_16_02 + EFEC_09_02 + 
> EVA_12_02 + FLX_08_02 + IDO_01_06 + IDO_05_02 + LC_08_02 + LC_11_03 + 
> LC_11_05 + ME_02_03 + ME_07_06 + ME_09_06 + NEG_07_03 + OP_03_05 + OP_14_01 + 
> OP_14_02 + ORL_01_03 + ORL_03_01 + PER_08_02 + PER_19_06 + PLA_05_01 + 
> PLA_07_02 + PLA_10_01 + PLA_12_02 + PLA_18_01 + PR_06_02 + PR_15_03 + 
> PR_25_01 + PR_25_06 + REL_14_06 + REL_16_04 + TF_04_01 + TF_10_03 + TRE_26_04 
> + TRE_26_05   
>   
>   
>   
>   
> [4] F3=~  + AUT_10_04 + AUN_07_01 + AUN_09_01 + AUN_10_01 + AUT_11_01 + 
> AUT_17_01 + AUT_20_03 + CRE_10_01 + EFEC_03_07 + EFEC_05 + EFEC_16_03 + 
> EVA_02_01 + EVA_07_01 + EVA_15_06 + FLX_04_01 + FLX_04_05 + FLX_10_03 + 
> IDO_09_03 + IDO_17_01 + IE_01_03 + IE_10_03 + IE_13_03 + IE_15_01 + LC_07_03 
> + ME_09_01 + NEG_01_03 + NEG_05_04 + NEG_08_01 + OP_12_01 + ORL_03_05 + 
> ORL_10_05 + PER_16_01 + PER_22_06 + PLA_01_03 + REL_09_05 + REL_14_03 + 
> RS_02_03 + RS_07_05 + RS_08_05 + RS_13_03 + TF_03_01 + TF_12_01 + TRE_09_05 + 
> TRE_09_06 
>   
>   
>  
> > 
> 
> El jue., 29 ago. 2019 a las 14:29, Danilo Esteban Rodriguez Zapata 
> () escribió:
> Dear William,
> 
> Thank you for your answer, I would like to add some information that I just 
> obtained looking in different sites and forums. Someone there ask me to 
> create a fake data file, so I did that from my original data file. What I did 
> was open the .csv file with notepad and replace all the 4 for 5 and the 2 for 
> 1, then I saved the file again with no other changes. I also searched for the 
> "~" in the file and I found nothing.  Now with that file I did the omegaSem() 
> function and it worked succesfully, so the weird thing here is that the 
> omegaSem() function works with the fake data file, wich is exactly the same 
> as the original file, but recoding some answers as I said. 
> 
> It seems to be an issue with the file. When I replace, lets say, the 5 for 6 
> and make the omegaSem() again, it works. Then I replace back again the 6 for 
> 5 in all the data and the function doesn't works anymore.
> 
> 
> El jue., 29 ago. 2019 a las 12:33, William Dunlap () 
> escribió:

Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread Danilo Esteban Rodriguez Zapata via R-help
Thank you so much, I'll wait until then. The good thing is that we can make
sure now what is the actual problem.  I wish you have a good rest.

El jue., 29 ago. 2019 a las 14:55, William R Revelle (<
reve...@northwestern.edu>) escribió:

> Hi all.
>
> I am taking a brief vacation and will look at this next week.
>
> Bill
>
>
> > On Aug 29, 2019, at 2:53 PM, William Dunlap  wrote:
> >
> > Element #2 of that output,  the empty fomula " F1=~  ", triggers the bug
> in omegaSem.
> > omegaSem needs to ignore such entries in omega's output.  psych's author
> should be able to fix things up.
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> >
> > On Thu, Aug 29, 2019 at 12:31 PM Danilo Esteban Rodriguez Zapata <
> danilo_rodrig...@cun.edu.co> wrote:
> > well the output with the code that you refer is the following:
> >
> > > psych::omega(my.data)$model$lavaan
> > [1] g =~
> +AUT_10_04+AUN_07_01+AUN_07_02+AUN_09_01+AUN_10_01+AUT_11_01+AUT_17_01+AUT_20_03+CRE_05_02+CRE_07_04+CRE_10_01+CRE_16_02+EFEC_03_07+EFEC_05+EFEC_09_02+EFEC_16_03+EVA_02_01+EVA_07_01+EVA_12_02+EVA_15_06+FLX_04_01+FLX_04_05+FLX_08_02+FLX_10_03+IDO_01_06+IDO_05_02+IDO_09_03+IDO_17_01+IE_01_03+IE_10_03+IE_13_03+IE_15_01+LC_07_03+LC_08_02+LC_11_03+LC_11_05+ME_02_03+ME_07_06+ME_09_01+ME_09_06+NEG_01_03+NEG_05_04+NEG_07_03+NEG_08_01+OP_03_05+OP_12_01+OP_14_01+OP_14_02+ORL_01_03+ORL_03_01+ORL_03_05+ORL_10_05+PER_08_02+PER_16_01+PER_19_06+PER_22_06+PLA_01_03+PLA_05_01+PLA_07_02+PLA_10_01+PLA_12_02+PLA_18_01+PR_06_02+PR_15_03+PR_25_01+PR_25_06+REL_09_05+REL_14_03+REL_14_06+REL_16_04+RS_02_03+RS_07_05+RS_08_05+RS_13_03+TF_03_01+TF_04_01+TF_10_03+TF_12_01+TRE_09_05+TRE_09_06+TRE_26_04+TRE_26_05
> > [2] F1=~
>
>
>
>
>
>
>
>
>
>
> > [3] F2=~  + AUN_07_02 + CRE_05_02 + CRE_07_04 + CRE_16_02 + EFEC_09_02 +
> EVA_12_02 + FLX_08_02 + IDO_01_06 + IDO_05_02 + LC_08_02 + LC_11_03 +
> LC_11_05 + ME_02_03 + ME_07_06 + ME_09_06 + NEG_07_03 + OP_03_05 + OP_14_01
> + OP_14_02 + ORL_01_03 + ORL_03_01 + PER_08_02 + PER_19_06 + PLA_05_01 +
> PLA_07_02 + PLA_10_01 + PLA_12_02 + PLA_18_01 + PR_06_02 + PR_15_03 +
> PR_25_01 + PR_25_06 + REL_14_06 + REL_16_04 + TF_04_01 + TF_10_03 +
> TRE_26_04 + TRE_26_05
>
>
>
>
> > [4] F3=~  + AUT_10_04 + AUN_07_01 + AUN_09_01 + AUN_10_01 + AUT_11_01 +
> AUT_17_01 + AUT_20_03 + CRE_10_01 + EFEC_03_07 + EFEC_05 + EFEC_16_03 +
> EVA_02_01 + EVA_07_01 + EVA_15_06 + FLX_04_01 + FLX_04_05 + FLX_10_03 +
> IDO_09_03 + IDO_17_01 + IE_01_03 + IE_10_03 + IE_13_03 + IE_15_01 +
> LC_07_03 + ME_09_01 + NEG_01_03 + NEG_05_04 + NEG_08_01 + OP_12_01 +
> ORL_03_05 + ORL_10_05 + PER_16_01 + PER_22_06 + PLA_01_03 + REL_09_05 +
> REL_14_03 + RS_02_03 + RS_07_05 + RS_08_05 + RS_13_03 + TF_03_01 + TF_12_01
> + TRE_09_05 + TRE_09_06
>
>
>
> > >
> >
> > El jue., 29 ago. 2019 a las 14:29, Danilo Esteban Rodriguez Zapata (<
> danilo_rodrig...@cun.edu.co>) escribió:
> > Dear William,
> >
> > Thank you for your answer, I would like to add some information that I
> just obtained looking in different sites and forums. Someone there ask me
> to create a fake data file, so I did that from my original data file. What
> I did was open the .csv file with notepad and replace all the 4 for 5 and
> the 2 for 1, then I saved the file again with no other changes. I also
> searched for the "~" in the file and I found nothing.  Now with that file I
> did the omegaSem() function and it worked succesfully, so the weird thing
> here is that the omegaSem() function works with the fake data file, wich is
> exactly the same as the original file, but recoding some answers as I said.
> >
> > It seems to be an issue with the file. When I replace, lets say, the 5
> for 6 and make the omegaSem() again, it works. Then I replace back again
> the 6 for 5 in all the data and the function doesn't works anymore.
> >
> >
> > El jue., 29 ago. 2019 a las 12:33, William Dunlap ()
> escribió:
> > > omegaSem(r9,n.obs=198)
> > Error in parse(text = x, keep.source = FALSE) :
> >   :2:0: unexpected end of input
> >
> > This error probably comes from calling factor("~") and
> psych::omegaSem(data) will do that if  all the columns in data are very
> highly correlated with one another.   In that case omega(data, nfactor=n)
> will not be able to find n factors in the data but it returns "~" in place
> of the factors that it could not find.  E.g.,
> > > fakeData <- data.frame(A=1/(1:40), B=1/(2:41), C=1/(3:42), D=1/(4:43),
> E=1/(5:44))
> > > cor(fakeData)
> >   A B C D E
> > A 1.000 0.9782320 0.9481293 0.9215071 0.8988962
> > B 0.9782320 1.000 0.9932037 0.9811287 0.9684658
> > C 0.9481293 0.9932037 1.000 0.9969157 0.9906838
> > D 0.9215071 0.9811287 0.9969157 1.000 0.9983014
> > E 0.8988962 0.9684658 0.9906838 0.9983014 1.000
> > > psych::omegaSem(fakeData)
> > Loading required namespace: lavaan
> > Loading required namespace: GPArotation
> > In factor.stats, I could not find the RMSEA upper bound . Sorry about
> that
> > 

Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread Danilo Esteban Rodriguez Zapata via R-help
well the output with the code that you refer is the following:

> psych::omega(my.data)$model$lavaan
[1] g =~
+AUT_10_04+AUN_07_01+AUN_07_02+AUN_09_01+AUN_10_01+AUT_11_01+AUT_17_01+AUT_20_03+CRE_05_02+CRE_07_04+CRE_10_01+CRE_16_02+EFEC_03_07+EFEC_05+EFEC_09_02+EFEC_16_03+EVA_02_01+EVA_07_01+EVA_12_02+EVA_15_06+FLX_04_01+FLX_04_05+FLX_08_02+FLX_10_03+IDO_01_06+IDO_05_02+IDO_09_03+IDO_17_01+IE_01_03+IE_10_03+IE_13_03+IE_15_01+LC_07_03+LC_08_02+LC_11_03+LC_11_05+ME_02_03+ME_07_06+ME_09_01+ME_09_06+NEG_01_03+NEG_05_04+NEG_07_03+NEG_08_01+OP_03_05+OP_12_01+OP_14_01+OP_14_02+ORL_01_03+ORL_03_01+ORL_03_05+ORL_10_05+PER_08_02+PER_16_01+PER_19_06+PER_22_06+PLA_01_03+PLA_05_01+PLA_07_02+PLA_10_01+PLA_12_02+PLA_18_01+PR_06_02+PR_15_03+PR_25_01+PR_25_06+REL_09_05+REL_14_03+REL_14_06+REL_16_04+RS_02_03+RS_07_05+RS_08_05+RS_13_03+TF_03_01+TF_04_01+TF_10_03+TF_12_01+TRE_09_05+TRE_09_06+TRE_26_04+TRE_26_05
[2] F1=~










[3] F2=~  + AUN_07_02 + CRE_05_02 + CRE_07_04 + CRE_16_02 + EFEC_09_02 +
EVA_12_02 + FLX_08_02 + IDO_01_06 + IDO_05_02 + LC_08_02 + LC_11_03 +
LC_11_05 + ME_02_03 + ME_07_06 + ME_09_06 + NEG_07_03 + OP_03_05 + OP_14_01
+ OP_14_02 + ORL_01_03 + ORL_03_01 + PER_08_02 + PER_19_06 + PLA_05_01 +
PLA_07_02 + PLA_10_01 + PLA_12_02 + PLA_18_01 + PR_06_02 + PR_15_03 +
PR_25_01 + PR_25_06 + REL_14_06 + REL_16_04 + TF_04_01 + TF_10_03 +
TRE_26_04 + TRE_26_05




[4] F3=~  + AUT_10_04 + AUN_07_01 + AUN_09_01 + AUN_10_01 + AUT_11_01 +
AUT_17_01 + AUT_20_03 + CRE_10_01 + EFEC_03_07 + EFEC_05 + EFEC_16_03 +
EVA_02_01 + EVA_07_01 + EVA_15_06 + FLX_04_01 + FLX_04_05 + FLX_10_03 +
IDO_09_03 + IDO_17_01 + IE_01_03 + IE_10_03 + IE_13_03 + IE_15_01 +
LC_07_03 + ME_09_01 + NEG_01_03 + NEG_05_04 + NEG_08_01 + OP_12_01 +
ORL_03_05 + ORL_10_05 + PER_16_01 + PER_22_06 + PLA_01_03 + REL_09_05 +
REL_14_03 + RS_02_03 + RS_07_05 + RS_08_05 + RS_13_03 + TF_03_01 + TF_12_01
+ TRE_09_05 + TRE_09_06



>

El jue., 29 ago. 2019 a las 14:29, Danilo Esteban Rodriguez Zapata (<
danilo_rodrig...@cun.edu.co>) escribió:

> Dear William,
>
> Thank you for your answer, I would like to add some information that I
> just obtained looking in different sites and forums. Someone there ask me
> to create a fake data file, so I did that from my original data file. What
> I did was open the .csv file with notepad and replace all the 4 for 5 and
> the 2 for 1, then I saved the file again with no other changes. I also
> searched for the "~" in the file and I found nothing.  Now with that file I
> did the omegaSem() function and it worked succesfully, so the weird thing
> here is that the omegaSem() function works with the fake data file, wich is
> exactly the same as the original file, but recoding some answers as I said.
>
> It seems to be an issue with the file. When I replace, lets say, the 5 for
> 6 and make the omegaSem() again, it works. Then I replace back again the 6
> for 5 in all the data and the function doesn't works anymore.
>
> El jue., 29 ago. 2019 a las 12:33, William Dunlap ()
> escribió:
>
>> > omegaSem(r9,n.obs=198)
>> Error in parse(text = x, keep.source = FALSE) :
>>   :2:0: unexpected end of input
>>
>> This error probably comes from calling factor("~") and
>> psych::omegaSem(data) will do that if  all the columns in data are very
>> highly correlated with one another.   In that case omega(data, nfactor=n)
>> will not be able to find n factors in the data but it returns "~" in place
>> of the factors that it could not find.  E.g.,
>> > fakeData <- data.frame(A=1/(1:40), B=1/(2:41), C=1/(3:42), D=1/(4:43),
>> E=1/(5:44))
>> > cor(fakeData)
>>   A B C D E
>> A 1.000 0.9782320 0.9481293 0.9215071 0.8988962
>> B 0.9782320 1.000 0.9932037 0.9811287 0.9684658
>> C 0.9481293 0.9932037 1.000 0.9969157 0.9906838
>> D 0.9215071 0.9811287 0.9969157 1.000 0.9983014
>> E 0.8988962 0.9684658 0.9906838 0.9983014 1.000
>> > psych::omegaSem(fakeData)
>> Loading required namespace: lavaan
>> Loading required namespace: GPArotation
>> In factor.stats, I could not find the RMSEA upper bound . Sorry about that
>> Error in parse(text = x, keep.source = FALSE) :
>>   :2:0: unexpected end of input
>> 1: ~
>>^
>> In addition: Warning message:
>> In cov2cor(t(w) %*% r %*% w) :
>>   diag(.) had 0 or NA entries; non-finite result is doubtful
>> > psych::omega(fakeData)$model$lavaan
>> In factor.stats, I could not find the RMSEA upper bound . Sorry about that
>> [1] g =~ +A+B+C+D+E   F1=~  + B + C + D + E F2=~  + A
>> [4] F3=~
>> Warning message:
>> In cov2cor(t(w) %*% r %*% w) :
>>   diag(.) had 0 or NA entries; non-finite result is doubtful
>>
>> You can get a result if you use nfactors=n where n is the number of the
>> good F entries in psych::omega()$model$lavaan:
>> > psych::omegaSem(fakeData, nfactors=2)
>> ...
>>
>> Measures of factor score adequacy
>>gF1*  F2*
>> Correlation of scores with factors 

Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread Danilo Esteban Rodriguez Zapata via R-help
Dear William,

Thank you for your answer, I would like to add some information that I just
obtained looking in different sites and forums. Someone there ask me to
create a fake data file, so I did that from my original data file. What I
did was open the .csv file with notepad and replace all the 4 for 5 and the
2 for 1, then I saved the file again with no other changes. I also searched
for the "~" in the file and I found nothing.  Now with that file I did the
omegaSem() function and it worked succesfully, so the weird thing here is
that the omegaSem() function works with the fake data file, wich is exactly
the same as the original file, but recoding some answers as I said.

It seems to be an issue with the file. When I replace, lets say, the 5 for
6 and make the omegaSem() again, it works. Then I replace back again the 6
for 5 in all the data and the function doesn't works anymore.

El jue., 29 ago. 2019 a las 12:33, William Dunlap ()
escribió:

> > omegaSem(r9,n.obs=198)
> Error in parse(text = x, keep.source = FALSE) :
>   :2:0: unexpected end of input
>
> This error probably comes from calling factor("~") and
> psych::omegaSem(data) will do that if  all the columns in data are very
> highly correlated with one another.   In that case omega(data, nfactor=n)
> will not be able to find n factors in the data but it returns "~" in place
> of the factors that it could not find.  E.g.,
> > fakeData <- data.frame(A=1/(1:40), B=1/(2:41), C=1/(3:42), D=1/(4:43),
> E=1/(5:44))
> > cor(fakeData)
>   A B C D E
> A 1.000 0.9782320 0.9481293 0.9215071 0.8988962
> B 0.9782320 1.000 0.9932037 0.9811287 0.9684658
> C 0.9481293 0.9932037 1.000 0.9969157 0.9906838
> D 0.9215071 0.9811287 0.9969157 1.000 0.9983014
> E 0.8988962 0.9684658 0.9906838 0.9983014 1.000
> > psych::omegaSem(fakeData)
> Loading required namespace: lavaan
> Loading required namespace: GPArotation
> In factor.stats, I could not find the RMSEA upper bound . Sorry about that
> Error in parse(text = x, keep.source = FALSE) :
>   :2:0: unexpected end of input
> 1: ~
>^
> In addition: Warning message:
> In cov2cor(t(w) %*% r %*% w) :
>   diag(.) had 0 or NA entries; non-finite result is doubtful
> > psych::omega(fakeData)$model$lavaan
> In factor.stats, I could not find the RMSEA upper bound . Sorry about that
> [1] g =~ +A+B+C+D+E   F1=~  + B + C + D + E F2=~  + A
> [4] F3=~
> Warning message:
> In cov2cor(t(w) %*% r %*% w) :
>   diag(.) had 0 or NA entries; non-finite result is doubtful
>
> You can get a result if you use nfactors=n where n is the number of the
> good F entries in psych::omega()$model$lavaan:
> > psych::omegaSem(fakeData, nfactors=2)
> ...
>
> Measures of factor score adequacy
>gF1*  F2*
> Correlation of scores with factors 11.35  12.4284.45
> Multiple R square of scores with factors  128.93 154.32  7131.98
> Minimum correlation of factor score estimates 256.86 307.64 14262.96
> ...
> Does that work with your data?
>
> This is a problem that the maintainer of psych,
> >   maintainer("psych")
> [1] "William Revelle "
> would like to know about.
>
>
>
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Thu, Aug 29, 2019 at 9:03 AM Danilo Esteban Rodriguez Zapata via R-help
>  wrote:
>
>> This is a problem related to my last question referred to the omegaSem()
>> function in the psych package (that is already solved because I realized
>> that I was missing a variable assignment and because of that I had an
>> 'object not found' error:
>>
>>
>> https://stackoverflow.com/questions/57661750/one-of-the-omegasem-function-arguments-is-an-object-not-found
>>
>> I was trying to use that function following the guide to find McDonald's
>> hierarchical Omega by Dr William Revelle:
>>
>> http://personality-project.org/r/psych/HowTo/omega.pdf
>>
>> So now, with the variable error corrected, I'm having a different error
>> that does not occur when I use the same function with the example database
>> (Thurstone) provided in the tutorial that comes with the psych package. I
>> mean, I'm able to use the function succesfully using the Thurstone data
>> (with no other action, I have the expected result) but the function
>> doesn't
>> work when I use my own data.
>>
>> I searched over other posted questions, and the actions that they perform
>> are not even similar to what I'm trying to do. I have almost two weeks
>> using R, so I'm not able to identify yet how can I extrapolate the
>> solutions for that error message to my procedure (because it seems to be
>> frequent), although I have basic code knowledge. However related questions
>> give no anwer by now.
>>
>> Additionally, I decided to look over more documentation about the package,
>> and when I was testing other functions, I was able to use the omegaSem()
>> function with another example database, BUT after and only after I did the

Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread William Dunlap via R-help
Element #2 of that output,  the empty fomula " F1=~  ", triggers the bug in
omegaSem.
omegaSem needs to ignore such entries in omega's output.  psych's author
should be able to fix things up.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Aug 29, 2019 at 12:31 PM Danilo Esteban Rodriguez Zapata <
danilo_rodrig...@cun.edu.co> wrote:

> well the output with the code that you refer is the following:
>
> > psych::omega(my.data)$model$lavaan
> [1] g =~
> +AUT_10_04+AUN_07_01+AUN_07_02+AUN_09_01+AUN_10_01+AUT_11_01+AUT_17_01+AUT_20_03+CRE_05_02+CRE_07_04+CRE_10_01+CRE_16_02+EFEC_03_07+EFEC_05+EFEC_09_02+EFEC_16_03+EVA_02_01+EVA_07_01+EVA_12_02+EVA_15_06+FLX_04_01+FLX_04_05+FLX_08_02+FLX_10_03+IDO_01_06+IDO_05_02+IDO_09_03+IDO_17_01+IE_01_03+IE_10_03+IE_13_03+IE_15_01+LC_07_03+LC_08_02+LC_11_03+LC_11_05+ME_02_03+ME_07_06+ME_09_01+ME_09_06+NEG_01_03+NEG_05_04+NEG_07_03+NEG_08_01+OP_03_05+OP_12_01+OP_14_01+OP_14_02+ORL_01_03+ORL_03_01+ORL_03_05+ORL_10_05+PER_08_02+PER_16_01+PER_19_06+PER_22_06+PLA_01_03+PLA_05_01+PLA_07_02+PLA_10_01+PLA_12_02+PLA_18_01+PR_06_02+PR_15_03+PR_25_01+PR_25_06+REL_09_05+REL_14_03+REL_14_06+REL_16_04+RS_02_03+RS_07_05+RS_08_05+RS_13_03+TF_03_01+TF_04_01+TF_10_03+TF_12_01+TRE_09_05+TRE_09_06+TRE_26_04+TRE_26_05
> [2] F1=~
>
>
>
>
>
>
>
>
>
>
> [3] F2=~  + AUN_07_02 + CRE_05_02 + CRE_07_04 + CRE_16_02 + EFEC_09_02 +
> EVA_12_02 + FLX_08_02 + IDO_01_06 + IDO_05_02 + LC_08_02 + LC_11_03 +
> LC_11_05 + ME_02_03 + ME_07_06 + ME_09_06 + NEG_07_03 + OP_03_05 + OP_14_01
> + OP_14_02 + ORL_01_03 + ORL_03_01 + PER_08_02 + PER_19_06 + PLA_05_01 +
> PLA_07_02 + PLA_10_01 + PLA_12_02 + PLA_18_01 + PR_06_02 + PR_15_03 +
> PR_25_01 + PR_25_06 + REL_14_06 + REL_16_04 + TF_04_01 + TF_10_03 +
> TRE_26_04 + TRE_26_05
>
>
>
>
> [4] F3=~  + AUT_10_04 + AUN_07_01 + AUN_09_01 + AUN_10_01 + AUT_11_01 +
> AUT_17_01 + AUT_20_03 + CRE_10_01 + EFEC_03_07 + EFEC_05 + EFEC_16_03 +
> EVA_02_01 + EVA_07_01 + EVA_15_06 + FLX_04_01 + FLX_04_05 + FLX_10_03 +
> IDO_09_03 + IDO_17_01 + IE_01_03 + IE_10_03 + IE_13_03 + IE_15_01 +
> LC_07_03 + ME_09_01 + NEG_01_03 + NEG_05_04 + NEG_08_01 + OP_12_01 +
> ORL_03_05 + ORL_10_05 + PER_16_01 + PER_22_06 + PLA_01_03 + REL_09_05 +
> REL_14_03 + RS_02_03 + RS_07_05 + RS_08_05 + RS_13_03 + TF_03_01 + TF_12_01
> + TRE_09_05 + TRE_09_06
>
>
>
> >
>
> El jue., 29 ago. 2019 a las 14:29, Danilo Esteban Rodriguez Zapata (<
> danilo_rodrig...@cun.edu.co>) escribió:
>
>> Dear William,
>>
>> Thank you for your answer, I would like to add some information that I
>> just obtained looking in different sites and forums. Someone there ask me
>> to create a fake data file, so I did that from my original data file. What
>> I did was open the .csv file with notepad and replace all the 4 for 5 and
>> the 2 for 1, then I saved the file again with no other changes. I also
>> searched for the "~" in the file and I found nothing.  Now with that file I
>> did the omegaSem() function and it worked succesfully, so the weird thing
>> here is that the omegaSem() function works with the fake data file, wich is
>> exactly the same as the original file, but recoding some answers as I said.
>>
>> It seems to be an issue with the file. When I replace, lets say, the 5
>> for 6 and make the omegaSem() again, it works. Then I replace back again
>> the 6 for 5 in all the data and the function doesn't works anymore.
>>
>> El jue., 29 ago. 2019 a las 12:33, William Dunlap ()
>> escribió:
>>
>>> > omegaSem(r9,n.obs=198)
>>> Error in parse(text = x, keep.source = FALSE) :
>>>   :2:0: unexpected end of input
>>>
>>> This error probably comes from calling factor("~") and
>>> psych::omegaSem(data) will do that if  all the columns in data are very
>>> highly correlated with one another.   In that case omega(data, nfactor=n)
>>> will not be able to find n factors in the data but it returns "~" in place
>>> of the factors that it could not find.  E.g.,
>>> > fakeData <- data.frame(A=1/(1:40), B=1/(2:41), C=1/(3:42), D=1/(4:43),
>>> E=1/(5:44))
>>> > cor(fakeData)
>>>   A B C D E
>>> A 1.000 0.9782320 0.9481293 0.9215071 0.8988962
>>> B 0.9782320 1.000 0.9932037 0.9811287 0.9684658
>>> C 0.9481293 0.9932037 1.000 0.9969157 0.9906838
>>> D 0.9215071 0.9811287 0.9969157 1.000 0.9983014
>>> E 0.8988962 0.9684658 0.9906838 0.9983014 1.000
>>> > psych::omegaSem(fakeData)
>>> Loading required namespace: lavaan
>>> Loading required namespace: GPArotation
>>> In factor.stats, I could not find the RMSEA upper bound . Sorry about
>>> that
>>> Error in parse(text = x, keep.source = FALSE) :
>>>   :2:0: unexpected end of input
>>> 1: ~
>>>^
>>> In addition: Warning message:
>>> In cov2cor(t(w) %*% r %*% w) :
>>>   diag(.) had 0 or NA entries; non-finite result is doubtful
>>> > psych::omega(fakeData)$model$lavaan
>>> In factor.stats, I could not find the RMSEA upper bound . Sorry about
>>> that
>>> [1] g =~ +A+B+C+D+E   F1=~  + B + C + D + E F2=~  + A
>>> 

Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread William Dunlap via R-help
Please use 'reply to all' for responses to R-help reponses.

What do you get with your original data for
   psych::omega(my.data)$model$lavaan
?  Any entries like "F3=~"?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Aug 29, 2019 at 12:05 PM Danilo Esteban Rodriguez Zapata <
danilo_rodrig...@cun.edu.co> wrote:

> Dear William,
>
> Thank you for your answer, I would like to add some information that I
> just obtained looking in different sites and forums. Someone there ask me
> to create a fake data file, so I did that from my original data file. What
> I did was open the .csv file with notepad and replace all the 4 for 5 and
> the 2 for 1, then I saved the file again with no other changes. I also
> searched for the "~" in the file and I found nothing.  Now with that file I
> did the omegaSem() function and it worked succesfully, so the weird thing
> here is that the omegaSem() function works with the fake data file, wich is
> exactly the same as the original file, but recoding some answers as I said.
>
> It seems to be an issue with the file. When I replace, lets say, the 5 for
> 6 and make the omegaSem() again, it works. Then I replace back again the 6
> for 5 in all the data and the function doesn't works anymore.
>
> El jue., 29 ago. 2019 a las 12:33, William Dunlap ()
> escribió:
>
>> > omegaSem(r9,n.obs=198)
>> Error in parse(text = x, keep.source = FALSE) :
>>   :2:0: unexpected end of input
>>
>> This error probably comes from calling factor("~") and
>> psych::omegaSem(data) will do that if  all the columns in data are very
>> highly correlated with one another.   In that case omega(data, nfactor=n)
>> will not be able to find n factors in the data but it returns "~" in place
>> of the factors that it could not find.  E.g.,
>> > fakeData <- data.frame(A=1/(1:40), B=1/(2:41), C=1/(3:42), D=1/(4:43),
>> E=1/(5:44))
>> > cor(fakeData)
>>   A B C D E
>> A 1.000 0.9782320 0.9481293 0.9215071 0.8988962
>> B 0.9782320 1.000 0.9932037 0.9811287 0.9684658
>> C 0.9481293 0.9932037 1.000 0.9969157 0.9906838
>> D 0.9215071 0.9811287 0.9969157 1.000 0.9983014
>> E 0.8988962 0.9684658 0.9906838 0.9983014 1.000
>> > psych::omegaSem(fakeData)
>> Loading required namespace: lavaan
>> Loading required namespace: GPArotation
>> In factor.stats, I could not find the RMSEA upper bound . Sorry about that
>> Error in parse(text = x, keep.source = FALSE) :
>>   :2:0: unexpected end of input
>> 1: ~
>>^
>> In addition: Warning message:
>> In cov2cor(t(w) %*% r %*% w) :
>>   diag(.) had 0 or NA entries; non-finite result is doubtful
>> > psych::omega(fakeData)$model$lavaan
>> In factor.stats, I could not find the RMSEA upper bound . Sorry about that
>> [1] g =~ +A+B+C+D+E   F1=~  + B + C + D + E F2=~  + A
>> [4] F3=~
>> Warning message:
>> In cov2cor(t(w) %*% r %*% w) :
>>   diag(.) had 0 or NA entries; non-finite result is doubtful
>>
>> You can get a result if you use nfactors=n where n is the number of the
>> good F entries in psych::omega()$model$lavaan:
>> > psych::omegaSem(fakeData, nfactors=2)
>> ...
>>
>> Measures of factor score adequacy
>>gF1*  F2*
>> Correlation of scores with factors 11.35  12.4284.45
>> Multiple R square of scores with factors  128.93 154.32  7131.98
>> Minimum correlation of factor score estimates 256.86 307.64 14262.96
>> ...
>> Does that work with your data?
>>
>> This is a problem that the maintainer of psych,
>> >   maintainer("psych")
>> [1] "William Revelle "
>> would like to know about.
>>
>>
>>
>>
>>
>>
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>>
>> On Thu, Aug 29, 2019 at 9:03 AM Danilo Esteban Rodriguez Zapata via
>> R-help  wrote:
>>
>>> This is a problem related to my last question referred to the omegaSem()
>>> function in the psych package (that is already solved because I realized
>>> that I was missing a variable assignment and because of that I had an
>>> 'object not found' error:
>>>
>>>
>>> https://stackoverflow.com/questions/57661750/one-of-the-omegasem-function-arguments-is-an-object-not-found
>>>
>>> I was trying to use that function following the guide to find McDonald's
>>> hierarchical Omega by Dr William Revelle:
>>>
>>> http://personality-project.org/r/psych/HowTo/omega.pdf
>>>
>>> So now, with the variable error corrected, I'm having a different error
>>> that does not occur when I use the same function with the example
>>> database
>>> (Thurstone) provided in the tutorial that comes with the psych package. I
>>> mean, I'm able to use the function succesfully using the Thurstone data
>>> (with no other action, I have the expected result) but the function
>>> doesn't
>>> work when I use my own data.
>>>
>>> I searched over other posted questions, and the actions that they perform
>>> are not even similar to what I'm trying to do. I have almost two weeks
>>> using R, so I'm not able to 

Re: [R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread William Dunlap via R-help
> omegaSem(r9,n.obs=198)
Error in parse(text = x, keep.source = FALSE) :
  :2:0: unexpected end of input

This error probably comes from calling factor("~") and
psych::omegaSem(data) will do that if  all the columns in data are very
highly correlated with one another.   In that case omega(data, nfactor=n)
will not be able to find n factors in the data but it returns "~" in place
of the factors that it could not find.  E.g.,
> fakeData <- data.frame(A=1/(1:40), B=1/(2:41), C=1/(3:42), D=1/(4:43),
E=1/(5:44))
> cor(fakeData)
  A B C D E
A 1.000 0.9782320 0.9481293 0.9215071 0.8988962
B 0.9782320 1.000 0.9932037 0.9811287 0.9684658
C 0.9481293 0.9932037 1.000 0.9969157 0.9906838
D 0.9215071 0.9811287 0.9969157 1.000 0.9983014
E 0.8988962 0.9684658 0.9906838 0.9983014 1.000
> psych::omegaSem(fakeData)
Loading required namespace: lavaan
Loading required namespace: GPArotation
In factor.stats, I could not find the RMSEA upper bound . Sorry about that
Error in parse(text = x, keep.source = FALSE) :
  :2:0: unexpected end of input
1: ~
   ^
In addition: Warning message:
In cov2cor(t(w) %*% r %*% w) :
  diag(.) had 0 or NA entries; non-finite result is doubtful
> psych::omega(fakeData)$model$lavaan
In factor.stats, I could not find the RMSEA upper bound . Sorry about that
[1] g =~ +A+B+C+D+E   F1=~  + B + C + D + E F2=~  + A
[4] F3=~
Warning message:
In cov2cor(t(w) %*% r %*% w) :
  diag(.) had 0 or NA entries; non-finite result is doubtful

You can get a result if you use nfactors=n where n is the number of the
good F entries in psych::omega()$model$lavaan:
> psych::omegaSem(fakeData, nfactors=2)
...

Measures of factor score adequacy
   gF1*  F2*
Correlation of scores with factors 11.35  12.4284.45
Multiple R square of scores with factors  128.93 154.32  7131.98
Minimum correlation of factor score estimates 256.86 307.64 14262.96
...
Does that work with your data?

This is a problem that the maintainer of psych,
>   maintainer("psych")
[1] "William Revelle "
would like to know about.






Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Aug 29, 2019 at 9:03 AM Danilo Esteban Rodriguez Zapata via R-help <
r-help@r-project.org> wrote:

> This is a problem related to my last question referred to the omegaSem()
> function in the psych package (that is already solved because I realized
> that I was missing a variable assignment and because of that I had an
> 'object not found' error:
>
>
> https://stackoverflow.com/questions/57661750/one-of-the-omegasem-function-arguments-is-an-object-not-found
>
> I was trying to use that function following the guide to find McDonald's
> hierarchical Omega by Dr William Revelle:
>
> http://personality-project.org/r/psych/HowTo/omega.pdf
>
> So now, with the variable error corrected, I'm having a different error
> that does not occur when I use the same function with the example database
> (Thurstone) provided in the tutorial that comes with the psych package. I
> mean, I'm able to use the function succesfully using the Thurstone data
> (with no other action, I have the expected result) but the function doesn't
> work when I use my own data.
>
> I searched over other posted questions, and the actions that they perform
> are not even similar to what I'm trying to do. I have almost two weeks
> using R, so I'm not able to identify yet how can I extrapolate the
> solutions for that error message to my procedure (because it seems to be
> frequent), although I have basic code knowledge. However related questions
> give no anwer by now.
>
> Additionally, I decided to look over more documentation about the package,
> and when I was testing other functions, I was able to use the omegaSem()
> function with another example database, BUT after and only after I did the
> schmid transformation. So with that, I discovered that when I tried to use
> the omegaSem() function before the schmid tranformation I had the same
> error message, but not after that tranformation with this second example
> database.
>
> This make sense with the actual procedure of the omegaSem() procedure, but
> I'm suposing that it must be done completely and automatically by the
> omegaSem() function as it is explained in the guide and I have understood
> until now, as it follows:
>
> 1. omegaSem() applies factor analysis
> 2. omegaSem() rotate factors obliquely
> 3. omegaSem() transform data with Schmid Leiman (schmid)
>
> ---necessary steps to print output---
>
> 4. omegaSem() print McDonald's hierarchical Omega
>
> So here, another questions appears:  - Why the omegaSem() function works
> with the Thurstone database without any other action and only works for the
> second example database after performing the schmid transformation? -  Why
> with other databases I dont have the same output applying the omegaSem()
> function directly? - How is this 

[R] R code: How to correct "Error in parse(text = x, keep.source = FALSE)" output in psych package using own dataset

2019-08-29 Thread Danilo Esteban Rodriguez Zapata via R-help
This is a problem related to my last question referred to the omegaSem()
function in the psych package (that is already solved because I realized
that I was missing a variable assignment and because of that I had an
'object not found' error:

https://stackoverflow.com/questions/57661750/one-of-the-omegasem-function-arguments-is-an-object-not-found

I was trying to use that function following the guide to find McDonald's
hierarchical Omega by Dr William Revelle:

http://personality-project.org/r/psych/HowTo/omega.pdf

So now, with the variable error corrected, I'm having a different error
that does not occur when I use the same function with the example database
(Thurstone) provided in the tutorial that comes with the psych package. I
mean, I'm able to use the function succesfully using the Thurstone data
(with no other action, I have the expected result) but the function doesn't
work when I use my own data.

I searched over other posted questions, and the actions that they perform
are not even similar to what I'm trying to do. I have almost two weeks
using R, so I'm not able to identify yet how can I extrapolate the
solutions for that error message to my procedure (because it seems to be
frequent), although I have basic code knowledge. However related questions
give no anwer by now.

Additionally, I decided to look over more documentation about the package,
and when I was testing other functions, I was able to use the omegaSem()
function with another example database, BUT after and only after I did the
schmid transformation. So with that, I discovered that when I tried to use
the omegaSem() function before the schmid tranformation I had the same
error message, but not after that tranformation with this second example
database.

This make sense with the actual procedure of the omegaSem() procedure, but
I'm suposing that it must be done completely and automatically by the
omegaSem() function as it is explained in the guide and I have understood
until now, as it follows:

1. omegaSem() applies factor analysis
2. omegaSem() rotate factors obliquely
3. omegaSem() transform data with Schmid Leiman (schmid)

---necessary steps to print output---

4. omegaSem() print McDonald's hierarchical Omega

So here, another questions appears:  - Why the omegaSem() function works
with the Thurstone database without any other action and only works for the
second example database after performing the schmid transformation? -  Why
with other databases I dont have the same output applying the omegaSem()
function directly? - How is this related to the error message that the
compiler shows when I try to apply the function directly to the database?


This is the code that I'm using now: (example of the succesfull omegaSem()
done after schmid tranformation not included)

```
> library(psych)
> library(ctv, lavaan)
> library(GPArotation)
> my.data <- read.file()
Data from the .csv file
D:\Users\Admon\Documents\prueba_export_1563806208742.csv has been loaded.
> describe(my.data)
   vars   n mean   sd median trimmed  mad min max range  skew
kurtosis
AUT_10_04 1 195 4.11 0.90  44.23 1.48   1   5 4 -0.92
0.33
AUN_07_01 2 195 3.79 1.14  43.90 1.48   1   5 4 -0.59
 -0.71
AUN_07_02 3 195 3.58 1.08  43.65 1.48   1   5 4 -0.39
 -0.56
AUN_09_01 4 195 4.15 0.80  44.23 1.48   1   5 4 -0.76
0.51
AUN_10_01 5 195 4.25 0.79  44.34 1.48   1   5 4 -0.91
0.74
AUT_11_01 6 195 4.43 0.77  54.56 0.00   1   5 4 -1.69
3.77
AUT_17_01 7 195 4.46 0.67  54.55 0.00   1   5 4 -1.34
2.96
AUT_20_03 8 195 4.44 0.65  54.53 0.00   2   5 3 -0.84
0.12
CRE_05_02 9 195 2.47 1.01  22.43 1.48   1   5 4  0.35
 -0.46
CRE_07_0410 195 2.42 1.08  22.34 1.48   1   5 4  0.51
 -0.43
CRE_10_0111 195 4.41 0.68  54.51 0.00   2   5 3 -0.79
 -0.12
CRE_16_0212 195 2.75 1.23  32.69 1.48   1   5 4  0.29
 -0.96
EFEC_03_07   13 195 4.35 0.69  44.45 1.48   1   5 4 -0.95
1.59
EFEC_05  14 195 4.53 0.59  54.60 0.00   3   5 2 -0.82
 -0.34
EFEC_09_02   15 195 2.19 0.91  22.11 1.48   1   5 4  0.57
 -0.03
EFEC_16_03   16 195 4.21 0.77  44.29 1.48   2   5 3 -0.71
 -0.04
EVA_02_0117 195 4.47 0.61  54.54 0.00   3   5 2 -0.70
 -0.50
EVA_07_0118 195 4.38 0.60  44.43 1.48   3   5 2 -0.40
 -0.70
EVA_12_0219 195 2.64 1.22  22.59 1.48   1   5 4  0.30
 -1.00
EVA_15_0620 195 4.19 0.74  44.26 1.48   2   5 3 -0.55
 -0.29
FLX_04_0121 195 4.32 0.69  44.41 1.48   2   5 3 -0.71
0.05
FLX_04_0522 195 4.23 0.74  44.32 0.00   1   5 4 -0.99
1.69
FLX_08_0223 195 2.87 1.19  32.86 1.48   1   5 4  0.07
 -1.05
FLX_10_0324 195 4.30 0.71  44.39 1.48   2   5 3 -0.84
0.66
IDO_01_0625 195 3.10 1.26  33.13 1.48   1   5 4