# NOT RUN {
# Respiratory Data Example
data(indon)
attach(indon)
baseage2 <- baseage**2
follow <- age-baseage
follow2 <- follow**2
# Prior information
prior <- list(alpha=1,
M=4,
frstlprob=FALSE,
nu0=4,
tinv=diag(1,1),
mub=rep(0,1),
Sb=diag(1000,1),
beta0=rep(0,9),
Sbeta0=diag(10000,9))
# Initial state
state <- NULL
# MCMC parameters
nburn <- 5000
nsave <- 5000
nskip <- 20
ndisplay <- 100
mcmc <- list(nburn=nburn,
nsave=nsave,
nskip=nskip,
ndisplay=ndisplay,
tune1=0.5,tune2=0.5,
samplef=1)
# Fitting the Logit model
fit1 <- PTglmm(fixed=infect~gender+height+cosv+sinv+xero+baseage+baseage2+
follow+follow2,random=~1|id,family=binomial(logit),
prior=prior,mcmc=mcmc,state=state,status=TRUE)
fit1
plot(PTrandom(fit1,predictive=TRUE))
# Plot model parameters (to see the plots gradually set ask=TRUE)
plot(fit1,ask=FALSE)
plot(fit1,ask=FALSE,nfigr=2,nfigc=2)
# Extract random effects
PTrandom(fit1)
PTrandom(fit1,centered=TRUE)
# Extract predictive information of random effects
PTrandom(fit1,predictive=TRUE)
# Predictive marginal and joint distributions
plot(PTrandom(fit1,predictive=TRUE))
# Fitting the Probit model
fit2 <- PTglmm(fixed=infect~gender+height+cosv+sinv+xero+baseage+baseage2+
follow+follow2,random=~1|id,family=binomial(probit),
prior=prior,mcmc=mcmc,state=state,status=TRUE)
fit2
# Plot model parameters (to see the plots gradually set ask=TRUE)
plot(fit2,ask=FALSE)
plot(fit2,ask=FALSE,nfigr=2,nfigc=2)
# Extract random effects
PTrandom(fit2)
# Extract predictive information of random effects
PTrandom(fit2,predictive=TRUE)
# Predictive marginal and joint distributions
plot(PTrandom(fit2,predictive=TRUE))
# }
Run the code above in your browser using DataLab