Webjags >> Main page Recent changes History

Built-in models:Logistic regression

Difference between revisions from 2014/11/11 16:44 and 2025/12/07 00:45.

!Model
The logistic regression model with binary dependent variable \(y\) and independent variables \(\mathbf{x}=(x_{1},\ldots,x_{p})\) using a logit link,
{{%%
\[y_{i}  \sim Bernoulli(p_{i})\]
\[logit(p_{i})=\log\left(\frac{p_{i} }{1-p_{i} }\right)  =  \beta_{0}+\beta_{1}x_{1i}+\ldots+\beta_{p}x_{pi}\]
%%}}
In this model, the dependent variable can only take two values, 1 and 0. For example, in an experiment, 1 can represent success and 0 can represent failure. \(p_{i}\) is the probability that \(y_{i}=1\). Thus, \(p_{i}/(1-p_{i})\) is the odds that \(y_{i}=1\). Essentially, the predictors are predicting the log-odds.

!Code

{{
model{
for (i in 1:N){
y[i]~dbern(p[i])
logit(p[i])<-beta0+beta1*(x1[i]-mean(x1[]))+beta2*(x2[i]-mean(x2[]))
}
beta0~dnorm(0,1.0E-6)
beta1~dnorm(0,1.0E-6)
beta2~dnorm(0,1.0E-6)
exp1<-exp(beta1)
exp2<-exp(beta2)
}
}}


Powered by LionWiki. Last changed: 2024/12/10 23:04 Erase cookies History