View source: R/rscaleusage_rcpp.r
rscaleUsage | R Documentation |
rscaleUsage
implements an MCMC algorithm for multivariate ordinal data with scale usage heterogeniety.
rscaleUsage(Data, Prior, Mcmc)
Data |
list(x, k) |
Prior |
list(nu, V, mubar, Am, gs, Lambdanu, LambdaV) |
Mcmc |
list(R, keep, nprint, ndghk, e, y, mu, Sigma, sigma, tau, Lambda) |
n
= nrow(x)
individuals respond to p
= ncol(x)
questions;
all questions are on a scale 1, \ldots, k
for respondent i
and question j
,
x_{ij} = d
if c_{d-1} \le y_{ij} \le c_d
where d = 1, \ldots, k
and c_d = a + bd + ed^2
y_i = mu + tau_i*iota + sigma_i*z_i
with z_i
\sim
N(0, Sigma)
(tau_i, ln(sigma_i))
\sim
N(\phi, Lamda)
\phi = (0, lambda_{22})
mu
\sim
N(mubar, Am^{-1})
Sigma
\sim
IW(nu, V)
Lambda
\sim
IW(Lambdanu, LambdaV)
e
\sim
unif on a grid
It is highly recommended that the user choose the default prior settings. If you wish to change prior settings and/or the grids used, please carefully read the case study listed in the reference below.
Data = list(x, k)
x: | n x p matrix of discrete responses |
k: | number of discrete rating scale options |
Prior = list(nu, V, mubar, Am, gs, Lambdanu, LambdaV)
[optional]
nu: | d.f. parameter for Sigma prior (def: p + 3) |
V: | scale location matrix for Sigma prior (def: nu*I) |
mubar: | p x 1 vector of prior means (def: rep(k/2,p) ) |
Am: | p x p prior precision matrix (def: 0.01*I) |
gs: | grid size for sigma (def: 100) |
Lambdanu: | d.f. parameter for Lambda prior (def: 20) |
LambdaV: | scale location matrix for Lambda prior (def: (Lambdanu - 3)*Lambda) |
Mcmc = list(R, keep, nprint, ndghk, e, y, mu, Sigma, sigma, tau, Lambda)
[only R
required]
R: | number of MCMC draws (def: 1000) |
keep: | MCMC thinning parameter -- keep every keep th draw (def: 1) |
nprint: | print the estimated time remaining for every nprint 'th draw (def: 100, set to 0 for no print) |
ndghk: | number of draws for a GHK integration (def: 100) |
e: | initial value (def: 0) |
y: | initial values (def: x) |
mu: | initial values (def: apply(y,2,mean) , a p-length vector) |
Sigma: | initial value (def: var(y) ) |
sigma: | initial values (def: rep(1,n) ) |
tau: | initial values (def: rep(0,n) ) |
Lambda: | initial values (def: matrix(c(4,0,0,.5),ncol=2) )
|
A list containing:
Sigmadraw |
|
mudraw |
|
taudraw |
|
sigmadraw |
|
Lambdadraw |
|
edraw |
|
tau_i
, sigma_i
are identified from the scale usage patterns in the p
questions asked per respondent (# cols of x
). Do not attempt to use this on datasets with only a small number of total questions.
Rob McCulloch (Arizona State University) and Peter Rossi (Anderson School, UCLA), perossichi@gmail.com.
For further discussion, see Case Study 3 on Overcoming Scale Usage Heterogeneity, Bayesian Statistics and Marketing by Rossi, Allenby, and McCulloch.
if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=1000} else {R=5}
set.seed(66)
data(customerSat)
surveydat = list(k=10, x=as.matrix(customerSat))
out = rscaleUsage(Data=surveydat, Mcmc=list(R=R))
summary(out$mudraw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.