Open lizzieinvancouver opened 2 years ago
Above code with 180 species and 20 ind:
> summary(testme)$summary[names(param), c("2.5%", "25%", "mean", "75%", "97.5%")]
2.5% 25% mean 75% 97.5%
a_z 25.6356160 31.0807784 33.6526045 36.2896353 41.31497921
lam_interceptsa 0.2136373 0.3280266 0.3951826 0.4622820 0.58097259
sigma_interceptsa 14.6138985 15.8084821 16.5755666 17.2753153 18.96086368
b_zf -7.4069107 -5.1098833 -3.9471401 -2.7631003 -0.43034857
lam_interceptsbf 0.5259026 0.6312682 0.6775191 0.7290883 0.80322904
sigma_interceptsbf 4.7166738 5.1446615 5.4179780 5.6687920 6.20620375
b_zc -8.5517207 -6.0484456 -4.7931694 -3.4787639 -1.15332992
lam_interceptsbc 0.2128007 0.3252506 0.3888928 0.4500825 0.57154220
sigma_interceptsbc 6.3172444 6.8138248 7.1657860 7.4803275 8.18800558
b_zp -2.1562684 -1.4609121 -1.1190482 -0.7877977 -0.09188855
lam_interceptsbp 0.2556062 0.3775644 0.4443258 0.5099231 0.63283385
sigma_interceptsbp 1.6375313 1.7953956 1.8921524 1.9803540 2.19612227
sigma_y 12.7356985 12.9369959 13.0556637 13.1692029 13.41790472
> t(param)
a_z lam_interceptsa sigma_interceptsa b_zf lam_interceptsbf sigma_interceptsbf b_zc lam_interceptsbc sigma_interceptsbc b_zp lam_interceptsbp
[1,] 30 0.4 16 -6 0.7 6 -7 0.5 7 -1.4 0.3
sigma_interceptsbp sigma_y
[1,] 2
> fitContinuous(spetree, intercepts, model="lambda")
GEIGER-fitted comparative model of continuous data
fitted ‘lambda’ model parameters:
lambda = 0.280980
> fitContinuous(spetree, slopes_bf, model="lambda")
GEIGER-fitted comparative model of continuous data
fitted ‘lambda’ model parameters:
lambda = 0.713862
> fitContinuous(spetree, slopes_bc, model="lambda")
GEIGER-fitted comparative model of continuous data
fitted ‘lambda’ model parameters:
lambda = 0.277327
> fitContinuous(spetree, slopes_bp, model="lambda")
GEIGER-fitted comparative model of continuous data
fitted ‘lambda’ model parameters:
lambda = 0.264521
@MoralesCastilla Gave me some Stan code so I tried to guess at the priors, I will push that code. I presume they are not the current priors as they are a bit too informative ... here's the output you get with them for 40 species and 10 reps:
> summary(testme)$summary[names(param), c("2.5%", "25%", "mean", "75%", "97.5%")]
2.5% 25% mean 75% 97.5%
a_z 19.51776127 25.0751158 28.0261827 30.7739547 37.6448647
lam_interceptsa 0.01764048 0.1868317 0.3739923 0.5461470 0.8193567
sigma_interceptsa 10.41653533 12.9021608 14.7569487 16.2593202 21.0160887
b_zf -6.64033604 -4.6751918 -3.7827552 -2.9707643 -0.7419553
lam_interceptsbf 0.01560908 0.1341071 0.2924646 0.4259815 0.7032562
sigma_interceptsbf 3.44549992 4.0623032 4.5736742 4.9805250 6.1986628
b_zc -6.32305088 -3.2747549 -2.0883295 -0.7854263 1.4240409
lam_interceptsbc 0.02652788 0.2382849 0.4283001 0.6133275 0.8476398
sigma_interceptsbc 4.31036003 5.1008849 5.7993734 6.3609889 8.0261278
b_zp -3.30534305 -2.1783033 -1.6632799 -1.1726396 0.1043179
lam_interceptsbp 0.03463622 0.2526582 0.4587370 0.6565015 0.9139612
sigma_interceptsbp 1.50638397 1.9452331 2.2650324 2.5389862 3.2943143
sigma_y 15.04382998 15.8405956 16.3121778 16.7664784 17.7234642
> t(param)
a_z lam_interceptsa sigma_interceptsa b_zf lam_interceptsbf sigma_interceptsbf b_zc lam_interceptsbc
[1,] 30 0.4 16 -6 0.7 6 -7 0.5
sigma_interceptsbc b_zp lam_interceptsbp sigma_interceptsbp sigma_y
[1,] 7 -1.4 0.3 2 13
And with 180 spp and 20 reps (on quick glance I think it looks better, but need to look more closely):
> summary(testme)$summary[names(param), c("2.5%", "25%", "mean", "75%", "97.5%")]
2.5% 25% mean 75% 97.5%
a_z 26.16788397 31.3460049 33.6749868 35.9931946 40.9447214
lam_interceptsa 0.09471524 0.2387768 0.3275394 0.4136576 0.5765438
sigma_interceptsa 14.28478736 15.4613583 16.3121416 17.0517536 18.9718984
b_zf -7.47987922 -5.1066596 -3.9563395 -2.8043435 -0.4454207
lam_interceptsbf 0.56754361 0.6819431 0.7276882 0.7810711 0.8506121
sigma_interceptsbf 4.85441833 5.3100113 5.6109722 5.8874111 6.5047324
b_zc -8.43974922 -6.2264660 -5.1973400 -4.1534252 -2.1338918
lam_interceptsbc 0.12708536 0.2383223 0.3194505 0.3941891 0.5463607
sigma_interceptsbc 6.15913589 6.6442033 6.9841236 7.2589029 8.0955819
b_zp -2.12458174 -1.4542851 -1.1306831 -0.8014007 -0.1530833
lam_interceptsbp 0.15850374 0.3158795 0.4061253 0.4972156 0.6585695
sigma_interceptsbp 1.61490859 1.7654698 1.8723188 1.9613890 2.2091046
sigma_y 12.92811206 13.1500490 13.2643711 13.3785709 13.6069277
> t(param)
a_z lam_interceptsa sigma_interceptsa b_zf lam_interceptsbf sigma_interceptsbf b_zc lam_interceptsbc
[1,] 30 0.4 16 -6 0.7 6 -7 0.5
sigma_interceptsbc b_zp lam_interceptsbp sigma_interceptsbp sigma_y
[1,] 7 -1.4 0.3 2 13
I ran into this issue about 6 weeks ago when trying to check we can recover the parameters in @MoralesCastilla OSPREE results, which TJ Davies asked about. I was editing a version of simulate_fit_uber_threeslopeintercept.R and found issues with negative slopes. @FaithJones and @willpearse asked if it was a priors issue.
Here's where I have gotten:
fitContinuous(spetree, intercepts, model="lambda")
to try to check what the lamba might be and often it is more similar to the model output, but I am not sure how good to feel about using different model output to check my model output.Below is the general code I have been running:
The output is not bad (run yourself to check, it does not take long) but the 'bz_f' is around -3, instead of -6 at the mean.
A few later and adding the output to show (this is using the above priors):