Learn R Programming

ltable (version 2.0.2)

MCLogLin: Function MCLogLin

Description

Performs log-linear analyses for constructed tabulated data based on Gibbs sampler with NB2 posterior marginal distribution for counts

Usage

MCLogLin(formula, data, contrasts=NULL, XLB=-100, XUB=100, a=0.1, b=0.1,
DIC=FALSE, pcov=FALSE, draw=10000, burnin=3000 )

Value

returns a matrix with columns of chains of sampled values of model parameters (expected counts, regression coefficients, inverce dispersion parameter) to be studied by MCMC facilitating packages (e.g., coda, mcmc, mcmcplot, etc.)

Arguments

formula

a symbolic description of the model to be fit.

data

name of the data set; object of data.frame class

contrasts

serves to choose types of contrasts to study effects of factors, the same with glm{stats}), orthogonal polynomials by default

XLB

the vector of smallest possible values of regression effects betas; can be number if pertains to all betas.

XUB

the vector of largest possible values of regression effects betas; can be number if pertains to all betas.

a

the value of shape parameter of gamma distributed inverce dispersion parameter (phi), i.e., phi~Ga(a,b), so that mean(phi)=a/b and var(phi)=a/b^2

b

the value of rate (1/scale) parameter of gamma distributed inverce dispersion parameter (phi), i.e., phi~Ga(a,b), so that mean(phi)=a/b and var(phi)=a/b^2

DIC

requests print of deviance information criteria and its components

pcov

requests print of covariance and correlation matricies of the model parameters

draw

indicates requested number of samples

burnin

indicates requested number of initial samples to discard

Author

Ocheredko Oleksandr Ocheredko@yahoo.com

Details

  • Performs log-linear modelling with supplied data by using Gibbs sampler.

  • Printing output includes standard table of parameters estimates, goodness of fit indicators, analysis of residuals. On the prompt it prints the deviance information criteria with its components as well as covariance and correlation matricies of the model parameters

See Also

glm MCMCglmm

Examples

Run this code
require(ltable)
data(tdata, package="ltable")
## For better illustration You should increase draw and burnin pars
res1<-MCLogLin(Counts~smoker +contraceptive +tromb +
contraceptive*tromb, data=tdata, draw=1500, burnin=500)


data(iris)
iriscut<-with(iris, data.frame(PL=cut(Petal.Length,3),
                               PW=cut(Petal.Width,3)))
irist<-table_f(iriscut,"PL,PW")
irisd<-tableToData(irist, ordered="PL,PW")
res2<-ltable::MCLogLin(Counts~PW+PL+PW*PL, DIC=TRUE, data=irisd,
draw=1500, burnin=500)



Run the code above in your browser using DataLab