nof1.data: Make an N of 1 object containing data, priors, and a jags...

Description Usage Arguments Value Examples

View source: R/nof1.data.R

Description

Make an N of 1 object containing data, priors, and a jags model file for individual analysis

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
nof1.data(
  Y,
  Treat,
  ord.baseline.Treat = NULL,
  ord.model = NULL,
  response = NULL,
  ncat = NULL,
  bs.trend = F,
  y.time = NULL,
  knots.bt.block = NULL,
  block.no = NULL,
  bs.df = NULL,
  corr.y = F,
  alpha.prior = NULL,
  beta.prior = NULL,
  eta.prior = NULL,
  dc.prior = NULL,
  c1.prior = NULL,
  rho.prior = NULL,
  hy.prior = NULL,
  ...
)

Arguments

Y

Outcome of the study. This should be a vector with NA's included in time order.

Treat

Treatment indicator vector with same length as the outcome. Can be character or numeric.

ord.baseline.Treat

Used for ordinal outcome to define a reference treatment level.

ord.model

Used for ordinal outcome to pick the model. Can be "cumulative" for proportional odds model or "acat" for restricted adjacent category model.

response

Type of outcome. Can be "normal" for continuous outcome, "binomial" for binary outcome, "poisson" for count outcome, or "ordinal" for ordinal or nominal outcome.

ncat

Number of categories. Used in ordinal models.

bs.trend

Indicator for whether the model should adjust for trend using splines. The default is F.

y.time

Parameter used for modeling splines. Time when the outcome is measured.

knots.bt.block

parameter used for modeling splines. Indicator for whether or not knots should be set at the end of each block except for the last block. If TRUE, user should then specify block.no; if FALSE, user should then specify bs.df.

block.no

Block number used for modeling splines for the setting where the knots are set at the end of each block. Block number with the same length as the outcome.

bs.df

Degrees of freedom for modeling splines when knots are not set at the end of each block.

corr.y

Indicator for whether the correlation among measurements shoule be modeled. The default is F.

alpha.prior

Prior for the intercept of the model. Not needed now since we are using treatment-specific intercept model.

beta.prior

Prior for the treatment-specific intercept.

eta.prior

Prior for modelling spline terms.

dc.prior

Prior for the length between cutpoints. Used only for ordinal logistic models.

c1.prior

Prior for the first cutpoint. Used only for ordinal logistic models.

rho.prior

Prior for the correlated error model.

hy.prior

Prior for the heterogeneity parameter. Supports uniform, gamma, and half normal for normal and binomial response and wishart for multinomial response. It should be a list of length 3, where first element should be the distribution (one of dunif, dgamma, dhnorm, dwish) and the next two are the parameters associated with the distribution. For example, list("dunif", 0, 5) give uniform prior with lower bound 0 and upper bound 5 for the heterogeneity parameter. For wishart distribution, the last two parameter would be the scale matrix and the degrees of freedom.

...

Arguments to be passed to bs().

Value

An object of class "nof1.data" that is used to run the model using nof1.run is a list containing

Y

Outcome

Treat

Treatment

ncat

Number of categories for ordinal response

nobs

Total number of observations in a study

Treat.name

Treatment name

response

Type of outcome

Treat_Treat.name

Vector in the model matrix for Treat.name

bs.trend

Indicator for whether the model should adjust for trend using splines

corr.y

Indicator for whether the correlation among measurements shoule be modeled

priors

Priors that the code will be using. Default priors are used if prior was not specified

code

Rjags model file code that is generated using information provided by the user. To view model file inside R, use cat(nof1$code).

Examples

1
2
3
4
5
6
7
###Blocker data example
laughter
Y <- laughter$Y
Treat <- laughter$Treat
nof1 <- nof1.data(Y, Treat, ncat = 11, response = "ordinal")
str(nof1)
cat(nof1$code)

jiabei-yang/nof1ins documentation built on Sept. 7, 2021, 1:10 p.m.