Markdown not converging while R Studio does

164 views
Skip to first unread message

Zayra Lpz

unread,
Apr 2, 2019, 12:24:54 PM4/2/19
to lavaan
Hello!!

I have a problem running a piece of code in markdown. My code is:

m2= 'lnmath ~ G*gender + B31*lang + B32*enjoy
      enjoy ~ V21*gender
      lang~ V11*gender
      ind:= V21*B31 + V11*B32'
set.seed(2324)
fit_m2<- sem(m2, data=obsvar, se="bootstrap")

And while in R-Studio I get:

lavaan 0.6-3 ended normally after 24 iterations

  Optimization method                           NLMINB
  Number of free parameters                          8

                                                  Used       Total
  Number of observations                          7184        7377

  Estimator                                         ML
  Model Fit Test Statistic                       2.825
  Degrees of freedom                                 1
  P-value (Chi-square)                           0.093


Markdown reports:

lavaan WARNING: the optimizer warns that a solution has NOT been found!lavaan WARNING: the optimizer warns that a solution has NOT been found!lavaan WARNING: only 998 bootstrap draws were successfullavaan 0.6-3 ended normally after 24 iterations

  Optimization method                           NLMINB
  Number of free parameters                          8

                                                  Used       Total
  Number of observations                          7184        7377

  Estimator                                         ML
  Model Fit Test Statistic                       2.825
  Degrees of freedom                                 1
  P-value (Chi-square)                           0.093

Model test baseline model:

  Minimum Function Test Statistic              354.749
  Degrees of freedom                                 6
  P-value                                        0.000

As you can see, both outputs are equal, but in Markdown it seems that there is no convergent solution. Can someone help me figure out what the issue is? What response can I trust? I noticed that deleting the bootstrapping from the code in markdown eliminates the Warning. However, for my model the bootstrapping is important because I want to contrast indirect and direct effects. 

Thanks!

Stas Kolenikov

unread,
Apr 2, 2019, 9:25:38 PM4/2/19
to lav...@googlegroups.com
I would reasonably assume you tried "Restart R session and rerun all chunks"?

-- Stas Kolenikov, PhD, PStat (ASA, SSC)  @StatStas
-- Principal Scientist, Abt Associates @AbtDataScience
-- Opinions stated in this email are mine only, and do not reflect the position of my employer
-- http://stas.kolenikov.name
 


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Zayra Lpz

unread,
Apr 2, 2019, 9:56:10 PM4/2/19
to lavaan
Hi,

I did and still it generates the same output. Here I am attaching my data. 

Thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to lav...@googlegroups.com.
obsvar.Rdata

PD

unread,
Apr 3, 2019, 6:10:47 AM4/3/19
to lavaan
I dont use markdown, but looking at the output it would seem that for two bootstrap samples no solution was found (hence it says that 998 draws were successful). Rerun the analysis until all bootstrap samples return a solution. 

Zayra Lpz

unread,
Apr 4, 2019, 4:15:13 PM4/4/19
to lavaan
Hi, thank you! How should I give Markdown this instruction? 

Stas Kolenikov

unread,
Apr 4, 2019, 9:42:56 PM4/4/19
to lav...@googlegroups.com
Change the seed and see if that works out.

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.

To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.
--

Zayra Lpz

unread,
Apr 9, 2019, 12:45:49 PM4/9/19
to lav...@googlegroups.com
When changing to 2748590606, markdown reports: 
NAs introduced by coercion to integer rangeError in set.seed(2748590606) : supplied seed is not a valid integer

When changing to 27485:
lavaan WARNING: the optimizer warns that a solution has NOT been found!lavaan WARNING: only 999 bootstrap draws were successfullavaan 0.6-3 ended normally after 24 iterations

Similar results appear with other seeds.

Terrence Jorgensen

unread,
Apr 10, 2019, 8:57:48 AM4/10/19
to lavaan
When changing to 2748590606, markdown reports: 
NAs introduced by coercion to integer rangeError in set.seed(2748590606) : supplied seed is not a valid integer


When changing to 27485:
lavaan WARNING: the optimizer warns that a solution has NOT been found! 
lavaan WARNING: only 999 bootstrap draws were successful

You should try running your syntax outside the context of compiling a document, so you can resolve issues interactively.

If bootstrapping continues to fail so spectacularly, you could just use the default SEs using the delta method for the indirect effects.  Your N > 7000, so you are way past the point of the delta method not working well in small samples; bootstrapping is just an unnecessary headache in this situation.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
http://www.uva.nl/profile/t.d.jorgensen

Zayra Lpz

unread,
Apr 23, 2019, 5:00:36 PM4/23/19
to lavaan
Thank you very much! this helps!
Reply all
Reply to author
Forward
0 new messages