R: Bayesian thresholds mixed-effects models for categorical data
Bayesthresh
R Documentation
Bayesian thresholds mixed-effects models for categorical data
Description
This package fits a linear mixed model for ordinal categorical responses using
Bayesian inference via Monte Carlo Markov Chains. Default is Nandran & Chen algorithm
using Gaussian link function and saving just the summaries of the chains.
Among the options, package allow for two other options of algorithms, for using
Student's "t" link function and for saving the full chains.
a two-sided linear formula object describing the fixed-effects part of the model,
with the response on the left of a ~ operator and the terms, separated by +
operators, on the right. The vertical bar character "|" separates an expression for
a model matrix and a grouping factor.
data
an optional data frame containing the variables named in formula. By default
the variables are taken from the environment from which Bayesthres is called.
subset, na.action
further model specification arguments as in lm; see
there for details.
A
Matrix of variance-covariance of random effects.
algor
is a list that contains the name of the algorithm to be used. By default the algorithm
is the NC with function link Gaussian
Write
the Write is a function that by default is FALSE. If TRUE, the function save the
iterations of the sampling processin the matrix
priors
priors is a list that contains the parameters of the priors used to estimate the
variance components of random effects
burn, jump, ef.iter
are of the arguments of iteraction. By default the burn, jump and ef.iter
(effective iteractions) are 50, 2 e 4000 respectively
model
logical scalar. If FALSE the model frame in slot frame is truncated to zero rows.
Details
subset
an optional expression indicating the subset of the rows of
data that should be used in the fit. This can be a logical
vector, or a numeric vector indicating which observation numbers are
to be included, or a character vector of the row names to be
included. All observations are included by default.
na.action
a function that indicates what should happen when the
data contain NAs. The default action (na.fail) prints
an error message and terminate if there are any incomplete
observations.
algor
the are three options algorithms, AC, MC and NC, with link function Gaussian and
t-Student distribution. The object algort, by default is list(algorithm="NC", link="Gaussian").
Write
if Write=TRUE, the chain of iteractions is saved in the file output.txt.
The convergence process can be analyzed by the library coda
priors
The object defines the priors for the variance components of the AC and MC algorithms.
For the NC algorithm can be also defined a prior of residual variance. Objects ru (shape parameter)
and su (scale parameter) are the parameters of inverse gamma for the variance components. The NC
algorithm allows to change parameters of the residual variance. dre (shape parameter) and dse
(scale parameter) define the prior of the residual variance. By default, algorithms AC and MC have
a residual variance equal to 1.
Examples
# Not run
data(sensory)
Consumer <- factor(sensory$consumer) # Random effect
Sacarose <- factor(sensory$sacarose) # Fixed effect
#### Model
# Not run
dex1 <- Bayesthresh(cor ~ (1|Consumer) + Sacarose,
burn = 0, jump = 1, ef.iter = 10, data=sensory)
summary(dex1)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Bayesthresh)
Loading required package: lme4
Loading required package: Matrix
Loading required package: MASS
Loading required package: VGAM
Loading required package: stats4
Loading required package: splines
Loading required package: mvtnorm
Loading required package: matrixcalc
Loading required package: coda
Attaching package: 'coda'
The following object is masked from 'package:VGAM':
nvar
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Bayesthresh/Bayesthresh.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Bayesthresh
> ### Title: Bayesian thresholds mixed-effects models for categorical data
> ### Aliases: Bayesthresh
>
> ### ** Examples
>
>
> # Not run
> data(sensory)
>
> Consumer <- factor(sensory$consumer) # Random effect
> Sacarose <- factor(sensory$sacarose) # Fixed effect
>
> #### Model
> # Not run
> dex1 <- Bayesthresh(cor ~ (1|Consumer) + Sacarose,
+ burn = 0, jump = 1, ef.iter = 10, data=sensory)
> summary(dex1)
Threshold model with algorithm NC and link Gaussian
Formula: cor ~ (1 | Consumer) + Sacarose
Deviance: 315.4771
Marginal Log-likelihood:
Post. mean Post.std.dev
-157.7385 6.25876
Random effects:
Post.variance Post.std.dev
Consumer 0.4091697 0.5417228
Residuals 0.4604665 0.1448065
Fixed effects:
Estimate Std. Dev
(Intercept) 1.2613906 0.44822540
Sacarose40 -0.3156220 0.14221982
Sacarose50 -0.1570404 0.08740482
Iteraction Control:
Burn = 0 , Jump = 1 , Iteraction = 10
Time elapsed 0.029 seconds
>
>
>
>
>
>
> dev.off()
null device
1
>