Thank you for your answer... Here are the complete code and the data.
pregnancystate<-c("pregnancystate_nomales.csv")
data<-read.csv(file = "pregnancystate_nomales.csv", dec = ".",sep = ",", header =
TRUE)
cat(file = "preg.bug", "
#Likelihood:
model {
for(i in 1: 69){
pregnancy[i] ~ dbern(p[i])
logit(p[i]) <- b0+ b1 * (log(pdgng[i])) + b2 * (log(ec[i]))
}
#priors:
b0 ~ dunif(0,1)
b1 ~ dnorm(0, 0.0001)
b2 ~ dnorm(0, 0.0001)
}"
)
pdg<-data$pdgng
ec<-data$ec
obs<-69 #number of observations
inits <- function() {
list(b0=runif(0,0.05),b1 = rnorm(1,0,1), b2 = rnorm(1,0,1))
}
parameters <- c( "b0", "b1", "b2")
ni <- 100000
nt <- 1
nb <- 50000
nc <- 3
library(jagsUI)
pregn <- jags(data=data, parameters.to.save = parameters, model.file
="preg.bug" , n.chains = nc, n.thin = nt,
n.iter = ni, n.burnin = nb)
print(pregn)
###Logistic curve
pdgng<-data$pdgng
ec<-data$ec
logitp <- 0.497-1.699 * (log(pdgng)) +3.829 * (log(ec))
logistic<-exp(logitp)/(1+exp(logitp))
op5<-par(cex.lab=0.9,font.lab=2,cex.axis=1,bty="n")
plot(logitp,logistic,ylab="Probability",xlab="logitp")
abline(h=0.5, col="blue",lwd=1,lty=2)
My data:
pregnancy,pdgng,ec ,logit(p),probability
0,143997.3937,746.5102301,2.736380058,0.939139522
1,45109.3079,1418.995961,4.659342216,0.990616199
0,52683.58472,56.85769855,-0.802104453,0.309575536
1,138659.7743,852.4850646,2.984848323,0.951884912
0,52689.26541,47.78030436,-1.091276892,0.251377908
0,35554.31237,54.64659066,-0.578210329,0.359344501
1,44957.50427,881.71069,3.870957685,0.979586972
0,17346.58536,34.3035689,-0.82320263,0.305084254
1,87056.00603,959.375944,3.524232772,0.971369456
0,65611.00906,75.41128029,-0.494460715,0.378843302
0,40403.69619,50.41093373,-0.806534415,0.308629482
1,70574.46512,201.8534225,1.088218252,0.748046058
0,42819.85124,63.11200154,-0.47587338,0.383227039
0,24432.8854,55.57544032,-0.273726259,0.431992534
0,40603.1634,66.64685283,-0.346121395,0.414323288
0,42019.87914,52.39963524,-0.771133528,0.316233952
0,31035.0976,74.1115375,0.028378308,0.507094101
1,72415.54675,245.6925039,1.395895237,0.801531717
1,84035.46785,125.7413611,0.172889837,0.543115117
0,54189.70386,72.94486225,-0.408776022,0.399205644
1,27718.06513,59.68819086,-0.248043693,0.438305071
0,34963.48171,61.44647007,-0.370936316,0.408314794
0,107577.8631,100.9496181,-0.374125172,0.407544612
0,45300.54732,74.97611356,-0.23107752,0.442486313
1,87096.67182,967.8444156,3.538495187,0.97176345
0,51185.37663,139.2228995,0.707560153,0.669861819
0,55756.69828,54.10187088,-0.926462682,0.28364291
0,62001.79489,72.06355191,-0.528232186,0.370929297
1,90068.53164,1229.299153,3.911209047,0.980376504
1,49585.43419,167.4432442,1.037725477,0.738410897
1,49404.23826,89.63236934,0.001765223,0.500441306
1,61502.94127,665.0569165,3.171324365,0.959740787
1,67251.66979,233.6405586,1.366821986,0.796866212
1,92243.7537,327.5783641,1.695613274,0.844960934
0,54199.09589,49.26495746,-1.06124114,0.257072343
1,123323.012,1444.722047,3.94799264,0.981071798
0,53346.41158,41.17624229,-1.347644582,0.206255721
0,29770.49904,54.5633406,-0.449895094,0.389385709
1,109766.4443,780.8332001,3.011143597,0.953075026
1,98604.30654,172.0454198,0.576164889,0.640184471
1,312081.4201,215.5575672,0.101773998,0.52542156
0,57012.73092,55.32276656,-0.905791033,0.287861894
1,60997.32874,384.736727,2.267748818,0.906170555
1,97002.76256,214.6832766,0.956219147,0.722364177
1,153642.8724,1119.772165,3.362507665,0.966512036
0,38540.42815,53.2720665,-0.679986605,0.336264292
1,26926.33036,154.1974377,1.350760623,0.794253953
0,40106.0074,73.12316073,-0.182908088,0.454400038
1,231120.767,555.4809947,1.896414313,0.869485158
1,69794.21866,192.9932648,1.021808213,0.735324668
1,38155.6105,155.9863581,1.113037873,0.752695031
0,23854.68994,43.47440207,-0.664222643,0.339791692
1,34365.31734,204.2199999,1.637949837,0.837255778
1,81997.44506,602.4558705,2.795054752,0.942408006
0,51168.54791,54.91864886,-0.838270405,0.301899182
1,45249.61128,277.0660431,1.942187893,0.87459231
1,19571.31501,33.21986659,-0.96548945,0.275780463
1,102338.8059,986.4792596,3.451336152,0.969270963
0,36239.49787,24.65023113,-1.915433194,0.128371691
0,19273.67035,18.41201813,-1.935041598,0.126193601
0,33700.59761,31.68973854,-1.444385314,0.190867176
0,27424.33371,33.6980347,-1.190374235,0.233192011
0,30118.85279,31.41423431,-1.376085775,0.201638377
0,24570.3708,34.2774031,-1.081053394,0.253306723
0,24154.21332,36.994861,-0.94166181,0.280564787
1,92503.08903,310.94613,1.60693896,0.832985967
1,47316.63823,165.8834488,1.056687739,0.742057059
1,16917.84884,260.5582078,2.565165807,0.928585784
1,36961.88734,338.2647117,2.422986594,0.918563435
1s are pregnant females and 0s are not pregnant females. I intend to logitp vs probability and use different a colour to the dots which belong to pregnant females and another colour to those that belong to not pregnant.
I hope this clarify my question.
Regards,
Antonela