CoryMcCartan / birdie

Bayesian Instrumental Regression for Disparity Estimation
http://corymccartan.com/birdie/
GNU General Public License v3.0
5 stars 3 forks source link

Installation Issue - Eigen.hpp missing #16

Closed maxwellpalmer closed 9 months ago

maxwellpalmer commented 9 months ago

I am trying to install birdie, and getting the following error:

In file included from stanExports_multinom.cc:5:
In file included from ./stanExports_multinom.h:6:
../inst/include/rstan/rstaninc.hpp:4:10: fatal error: 'stan/math/prim/mat/fun/Eigen.hpp' file not found
#include <stan/math/prim/mat/fun/Eigen.hpp>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [stanExports_multinom.o] Error 1
ERROR: compilation failed for package ‘birdie’
* removing ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/birdie’

R version 4.3.2 on a mac (aarch64-apple-darwin20). I tried a fresh install of rstan and also tried using a new renv environment.

CoryMcCartan commented 9 months ago

Sorry about this! Looks like there's an issue with finding Stan libraries. Just to check, does rstan::stan_demo("eight_schools") run successfully? If not, then it's likely a Makevars configuration issue that the Stan forums might have some guidance on.

I can also try to pre-compile the package on my end for mac and send you the binary for installation

maxwellpalmer commented 9 months ago

rstan::stan_demo("eight_schools") runs without issues. Output below. I looked into Makevars on the stan forums, but as far as I can tell things are working properly.

> rstan::stan_demo("eight_schools")

> J <- 8

> y <- c(28,  8, -3,  7, -1,  1, 18, 12)

> sigma <- c(15, 10, 16, 11,  9, 11, 10, 18)

> tau <- 25

SAMPLING FOR MODEL 'eight_schools' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 2.3e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.23 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 1: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 1: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 1: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 1: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 0.121 seconds (Warm-up)
Chain 1:                0.082 seconds (Sampling)
Chain 1:                0.203 seconds (Total)
Chain 1: 

SAMPLING FOR MODEL 'eight_schools' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 5e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 2: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 2: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 2: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 2: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 0.104 seconds (Warm-up)
Chain 2:                0.038 seconds (Sampling)
Chain 2:                0.142 seconds (Total)
Chain 2: 

SAMPLING FOR MODEL 'eight_schools' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 6e-06 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 
Chain 3: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 3: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 3: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 3: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 3: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 3: 
Chain 3:  Elapsed Time: 0.09 seconds (Warm-up)
Chain 3:                0.048 seconds (Sampling)
Chain 3:                0.138 seconds (Total)
Chain 3: 

SAMPLING FOR MODEL 'eight_schools' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 5e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.05 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 4: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 4: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 4: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 4: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 4: 
Chain 4:  Elapsed Time: 0.088 seconds (Warm-up)
Chain 4:                0.053 seconds (Sampling)
Chain 4:                0.141 seconds (Total)
Chain 4: 
Inference for Stan model: eight_schools.
4 chains, each with iter=2000; warmup=1000; thin=1; 
post-warmup draws per chain=1000, total post-warmup draws=4000.

           mean se_mean   sd   2.5%    25%    50%    75% 97.5% n_eff Rhat
mu         7.71    0.21 5.33  -2.30   4.26   7.93  10.97 17.92   618 1.00
theta[1]  11.51    0.33 8.84  -3.09   5.78  10.49  15.81 32.30   718 1.00
theta[2]   7.61    0.21 6.52  -4.80   3.22   7.71  11.63 20.84   933 1.00
theta[3]   5.73    0.24 7.64 -10.79   1.36   6.23  10.48 19.71  1026 1.00
theta[4]   7.60    0.21 6.86  -6.37   3.25   7.77  11.77 21.18  1050 1.00
theta[5]   4.77    0.22 6.37  -8.57   0.84   5.16   9.00 15.94   803 1.00
theta[6]   5.98    0.23 6.67  -8.12   1.89   6.48  10.40 18.40   821 1.00
theta[7]  10.53    0.25 7.10  -1.52   5.74   9.99  14.54 26.70   825 1.00
theta[8]   8.14    0.25 8.41  -8.17   3.18   7.91  12.91 25.61  1147 1.00
tau        7.04    0.27 5.42   1.35   3.21   5.66   9.11 20.69   390 1.01
lp__     -18.16    0.36 5.12 -27.86 -21.79 -18.28 -14.59 -7.53   207 1.02

Samples were drawn using NUTS(diag_e) at Tue Jan 23 07:45:01 2024.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at 
convergence, Rhat=1).
Warning messages:
1: There were 81 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them. 
2: Examine the pairs() plot to diagnose sampling problems

3: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess 
4: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
CoryMcCartan commented 9 months ago

Thanks for this. The problem ended up being related to rstan's recent updates.

Everything should be working now. You can also try downloading the attached tarball and installing with remotes::install_local("<path/to/birdie_0.5.0.tgz"), which should let you skip the compilation step completely

birdie_0.5.0.tgz

maxwellpalmer commented 9 months ago

That worked perfectly. I was able to build from source. Thank you!