hmflatlogit | R Documentation |
Under the assumption that the posterior distribution is well-defined, this Metropolis-Hastings algorithm produces a sample from the posterior distribution on the logit model coefficient beta under a flat prior.
hmflatlogit(niter, y, X, scale)
niter |
number of iterations |
y |
binary response variable |
X |
matrix of covariates with the same number of rows as |
scale |
scale of the Metropolis-Hastings random walk |
The function produces a sample of beta's as a matrix of size niter
x p
,
where p
is the number of covariates.
hmflatprobit
data(bank) bank=as.matrix(bank) y=bank[,5] X=bank[,1:4] flatlogit=hmflatlogit(1000,y,X,1) par(mfrow=c(1,3),mar=1+c(1.5,1.5,1.5,1.5)) plot(flatlogit[,1],type="l",xlab="Iterations",ylab=expression(beta[1])) hist(flatlogit[101:1000,1],nclass=50,prob=TRUE,main="",xlab=expression(beta[1])) acf(flatlogit[101:1000,1],lag=10,main="",ylab="Autocorrelation",ci=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.