ecmerkle / blavaan

An R package for Bayesian structural equation modeling
https://ecmerkle.github.io/blavaan
86 stars 23 forks source link

blavaan upgrade to 0.5-5 fails in R 4.4.0 under windows 11 Pro #80

Closed lghunsicker closed 3 weeks ago

lghunsicker commented 3 months ago

Upgrade of package blavaan from 0.5-4 to 0.5-5 under R version 4.4.0 (2024-04-24 ucrt) fails consistently as noted below. Package V8 is installed and up-to-date. This seems to be due to a rstan::stanc command problem in the config file. Running either native R or RStudio on a Windows 11-Pro system. Rtools 4.4. RStan 2.32.6 StanHeaders 2.32.9 Interestingly, this update worked perfectly on my university Windows 11 desktop and R 4.3.3. (And Rtools 4.3, of course, and same versions of RStan and StanHeaders.) Is this an R version incompatibilty? Thanks in advance any help or suggestions. Larry Hunsicker

    installing source package 'blavaan' ...
    ** package 'blavaan' successfully unpacked and MD5 sums checked
    ** using staged installation
    Error in rstan::stanc(file_name, allow_undefined = TRUE, obfuscate_model_name = FALSE, :
    parser failed badly; maybe try installing the V8 package
    Calls: -> sapply -> lapply -> FUN ->
    Execution halted
    ERROR: configuration failed for package 'blavaan'
ecmerkle commented 3 months ago

@andrjohns could this be related to the rstan issue with hashtags in Stan files? In blavaan, inst/stan/stanmarg.stan has three hashtags that are in urls, as opposed to starting comments.


From: lghunsicker @.> Sent: Wednesday, June 12, 2024 3:16 PM To: ecmerkle/blavaan @.> Cc: Subscribed @.***> Subject: [ecmerkle/blavaan] blavaan upgrade to 0.5-5 fails in R 4.4.0 under windows 11 Pro (Issue #80)

WARNING: This message has originated from an External Source. This may be a phishing expedition that can result in unauthorized access to our IT System. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

Upgrade of package blavaan from 0.5-4 to 0.5-5 under R version 4.4.0 (2024-04-24 ucrt) fails consistently as noted below. Package V8 is installed and up-to-date. This seems to be due to a rstan::stanc command problem in the config file. Running either native R or RStudio on a Windows 11-Pro system. Rtools 4.4. RStan 2.32.6 StanHeaders 2.32.9 Interestingly, this update worked perfectly on my university Windows 11 desktop and R 4.3.3. (And Rtools 4.3, of course, and same versions of RStan and StanHeaders.) Is this an R version incompatibilty? Thanks in advance any help or suggestions. Larry Hunsicker

installing source package 'blavaan' ...
** package 'blavaan' successfully unpacked and MD5 sums checked
** using staged installation
Error in rstan::stanc(file_name, allow_undefined = TRUE, obfuscate_model_name = FALSE, :
parser failed badly; maybe try installing the V8 package
Calls: -> sapply -> lapply -> FUN ->
Execution halted
ERROR: configuration failed for package 'blavaan'

— Reply to this email directly, view it on GitHubhttps://github.com/ecmerkle/blavaan/issues/80, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABEYNQUNZDHPK3OYX2QZSDLZHCUCNAVCNFSM6AAAAABJHBR52SVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DSNRQHA4TGMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

andrjohns commented 3 months ago

Hmm most likely, there aren't any other parser bugs with 2.32 that I'm aware of. Let me know if removing the # doesn't fix things - then there could be a new bug to fix!

ecmerkle commented 3 months ago

@lghunsicker I just pushed a change that removes hashtags from the Stan file. If you are able to install from github, it would be great to know whether this fixes the problem. Instructions for installing from github are at the bottom of: https://github.com/ecmerkle/blavaan

lghunsicker commented 3 months ago

Bingo!! Installed without any problem, and executed the example from the blavaan function apparently correctly.

summary(fit)blavaan 0.5.5.1289 ended normally after 1000 iterations

Estimator BAYES Optimization method MCMC Number of model parameters 21

Number of observations 301

Statistic MargLogLik PPP Value -3805.681 0.000

Parameter Estimates:

Latent Variables: Estimate Post.SD pi.lower pi.upper Rhat Prior visual =~ x1 1.000 x2 0.576 0.117 0.371 0.828 1.000 normal(0,10) x3 0.759 0.129 0.541 1.055 1.000 normal(0,10) textual =~ x4 1.000 x5 1.123 0.067 0.998 1.262 1.001 normal(0,10) x6 0.933 0.059 0.820 1.057 0.999 normal(0,10) speed =~ x7 1.000 x8 1.231 0.173 0.943 1.625 1.002 normal(0,10) x9 1.169 0.241 0.814 1.754 1.001 normal(0,10)

Covariances: Estimate Post.SD pi.lower pi.upper Rhat Prior visual ~~ textual 0.389 0.080 0.238 0.549 0.999 lkj_corr(1) speed 0.244 0.054 0.147 0.361 1.001 lkj_corr(1) textual ~~ speed 0.163 0.047 0.078 0.264 1.001 lkj_corr(1)

Variances: Estimate Post.SD pi.lower pi.upper Rhat Prior .x1 0.578 0.123 0.334 0.820 1.001 gamma(1,.5)[sd] .x2 1.140 0.102 0.948 1.349 0.999 gamma(1,.5)[sd] .x3 0.845 0.101 0.659 1.050 1.000 gamma(1,.5)[sd] .x4 0.381 0.048 0.292 0.481 0.999 gamma(1,.5)[sd] .x5 0.451 0.061 0.338 0.578 1.000 gamma(1,.5)[sd] .x6 0.361 0.045 0.279 0.456 1.000 gamma(1,.5)[sd] .x7 0.829 0.093 0.660 1.017 1.000 gamma(1,.5)[sd] .x8 0.503 0.097 0.309 0.689 1.000 gamma(1,.5)[sd] .x9 0.559 0.097 0.352 0.736 1.001 gamma(1,.5)[sd] visual 0.788 0.154 0.497 1.107 1.000 gamma(1,.5)[sd] textual 0.979 0.114 0.774 1.222 1.000 gamma(1,.5)[sd] speed 0.362 0.094 0.195 0.567 1.003 gamma(1,.5)[sd]

coef(fit) visual=~x2 visual=~x3 textual=~x5 textual=~x6 speed=~x8 0.576 0.759 1.123 0.933 1.231 speed=~x9 x1x1 x2x2 x3~~x3 x4~~x4 1.169 0.578 1.140 0.845 0.381 x5x5 x6x6 x7x7 x8x8 x9~~x9 0.451 0.361 0.829 0.503 0.559 visualvisual textualtextual speedspeed visualtextual visual~~speed 0.788 0.979 0.362 0.389 0.244 textual~~speed 0.163

Thanks!! Larry Hunsicker

On Wed, Jun 12, 2024 at 6:02 PM Ed Merkle @.***> wrote:

@lghunsicker https://github.com/lghunsicker I just pushed a change that removes hashtags from the Stan file. If you are able to install from github, it would be great to know whether this fixes the problem. Instructions for installing from github are at the bottom of: https://github.com/ecmerkle/blavaan

— Reply to this email directly, view it on GitHub https://github.com/ecmerkle/blavaan/issues/80#issuecomment-2164033901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV4AP75RH46I4ERMUXZYBG3ZHDHRBAVCNFSM6AAAAABJHBR52SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRUGAZTGOJQGE . You are receiving this because you were mentioned.Message ID: @.***>

-- Larry Hunsicker

lghunsicker commented 3 months ago

I also posted a query yesterday on Posit Community. I could respond how to use your fix. But I assume that you will issue a new version with the correction. I could then just indicate that the problem was fixed with your updated version.

Thanks for the prompt response and the fix!

Larry Hunsicker

On Wed, Jun 12, 2024 at 6:02 PM Ed Merkle @.***> wrote:

@lghunsicker https://github.com/lghunsicker I just pushed a change that removes hashtags from the Stan file. If you are able to install from github, it would be great to know whether this fixes the problem. Instructions for installing from github are at the bottom of: https://github.com/ecmerkle/blavaan

— Reply to this email directly, view it on GitHub https://github.com/ecmerkle/blavaan/issues/80#issuecomment-2164033901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV4AP75RH46I4ERMUXZYBG3ZHDHRBAVCNFSM6AAAAABJHBR52SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRUGAZTGOJQGE . You are receiving this because you were mentioned.Message ID: @.***>

-- Larry Hunsicker

ecmerkle commented 3 months ago

Yes, I will send a new version to CRAN, though it might be next week before I get to it. So you might mention that installing from github will also solve the problem.


From: lghunsicker @.> Sent: Wednesday, June 12, 2024 8:31 PM To: ecmerkle/blavaan @.> Cc: Merkle, Edgar C. @.>; Comment @.> Subject: Re: [ecmerkle/blavaan] blavaan upgrade to 0.5-5 fails in R 4.4.0 under windows 11 Pro (Issue #80)

WARNING: This message has originated from an External Source. This may be a phishing expedition that can result in unauthorized access to our IT System. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

I also posted a query yesterday on Posit Community. I could respond how to use your fix. But I assume that you will issue a new version with the correction. I could then just indicate that the problem was fixed with your updated version.

Thanks for the prompt response and the fix!

Larry Hunsicker

On Wed, Jun 12, 2024 at 6:02 PM Ed Merkle @.***> wrote:

@lghunsicker https://github.com/lghunsicker I just pushed a change that removes hashtags from the Stan file. If you are able to install from github, it would be great to know whether this fixes the problem. Instructions for installing from github are at the bottom of: https://github.com/ecmerkle/blavaan

— Reply to this email directly, view it on GitHub https://github.com/ecmerkle/blavaan/issues/80#issuecomment-2164033901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV4AP75RH46I4ERMUXZYBG3ZHDHRBAVCNFSM6AAAAABJHBR52SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRUGAZTGOJQGE . You are receiving this because you were mentioned.Message ID: @.***>

-- Larry Hunsicker

— Reply to this email directly, view it on GitHubhttps://github.com/ecmerkle/blavaan/issues/80#issuecomment-2164184717, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABEYNQUANBJJYVXSPUN7TULZHDY63AVCNFSM6AAAAABJHBR52SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRUGE4DINZRG4. You are receiving this because you commented.Message ID: @.***>

sreedta8 commented 4 weeks ago

I have experienced the same issue on an Ubuntu machine and installing from GitHub using the remotes command worked. When examining the console output I noticed the following ("variable tracking size limit exceeded") which might help in troubleshooting the new version of "blavaan". In addition, even the GitNub version is taking a long time to compile and install the package. Please see the relevant portion of the console output mentioned above, below:

In file included from stanExports_stanmarg.cc:5:
stanExports_stanmarg.h: In constructor ‘model_stanmarg_namespace::model_stanmarg::model_stanmarg(stan::io::var_context&, unsigned int, std::ostream*)’:
stanExports_stanmarg.h:5799:3: note: **variable tracking size limit exceeded with** ‘-fvar-tracking-assignments’, retrying without
 5799 |   model_stanmarg(stan::io::var_context& context__, unsigned int
      |   ^~~~~~~~~~~~~~
g++ -std=gnu++17 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o blavaan.so RcppExports.o stanExports_stanmarg.o -L/home/sreedta/R/x86_64-pc-linux-gnu-library/4.4/RcppParallel/lib/ -Wl,-rpath,/home/sreedta/R/x86_64-pc-linux-gnu-library/4.4/RcppParallel/lib/ -ltbb -ltbbmalloc -L/usr/lib/R/lib -lR
installing to /home/sreedta/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-blavaan/00new/blavaan/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (blavaan)

Thanks @lghunsicker for highlighting the issue and thanks @ecmerkle for this awesome package

ecmerkle commented 4 weeks ago

Thanks for the report! I have not quite figured out why some people have this issue and others do not. It may be related to your rstan version. Regardless, I never got around to sending the fix to CRAN, partly because I never heard that anyone else had the problem. But I will endeavor to send it to CRAN in the next week.

About package compilation: it is expected that the compilation will take a long time because the underlying Stan file has become pretty large. On Ubuntu, it is possible to install a binary of the CRAN version from r2u and avoid compilation: https://eddelbuettel.github.io/r2u/

ecmerkle commented 3 weeks ago

These changes have now gone to CRAN, so the problem should now be fully addressed.

sreedta8 commented 3 weeks ago

Thanks a lot @ecmerkle for the update. I will test blavaan from CRAN and report back here.