circacompare_mixed: circacompare_mixed

Description Usage Arguments Value Examples

View source: R/circacompare_mixed.R

Description

circacompare_mixed is similar to circacompare but allows for some simple, user-specified random-effects on the rhythmic parameters of choice.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
circacompare_mixed(
  x,
  col_time,
  col_group,
  col_outcome,
  col_id,
  randomeffects = c(),
  period = 24,
  alpha_threshold = 0.05,
  nlme_control = list(),
  nlme_method = "REML",
  verbose = FALSE,
  timeout_n = 10000,
  control = list()
)

Arguments

x

data.frame. This is the data.frame which contains the rhythmic data for two groups in a tidy format.

col_time

The name of the column within the data.frame, x, which contains time in hours at which the data were collected.

col_group

The name of the column within the data.frame, x, which contains the grouping variable. This should only have two levels.

col_outcome

The name of the column within the data.frame, x, which contains outcome measure of interest.

col_id

The name of the column within the data.frame, x, which contains the identifying values for the random effect, such as subject_id.

randomeffects

which rhythmic parameters to allow random effects. The default is to include no rhythmic parameters.

period

The period of the rhythm. For circadian rhythms, leave this as the default value, 24.

alpha_threshold

The level of alpha for which the presence of rhythmicity is considered. Default is to 0.05.

nlme_control

A list of control values for the estimation algorithm to replace the default values returned by the function nlme::nlmeControl. Defaults to an empty list.

nlme_method

A character string. If "REML" the model is fit by maximizing the restricted log-likelihood. If "ML" the log-likelihood is maximized. Defaults to "REML".

verbose

An optional logical value. If TRUE information on the evolution of the iterative algorithm is printed. Default is FALSE.

timeout_n

The upper limit for the model fitting attempts. Default is 10000.

control

list. Used to control the parameterization of the model.

Value

list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Generate some data with within-id correlation for phase-shift (phi1)
set.seed(99)
phi1_in <- 3.15

mixed_data <- function(n){
  counter <- 1
  for(i in 1:n){
    x <- make_data(k1=0, alpha1=0, phi1=rnorm(1, phi1_in, 0.5), hours=72, noise_sd = 1)
    x$id <- counter
    counter <- counter + 1
    if(i==1){res <- x}else{res <- rbind(res, x)}
  }
  return(res)
}
df <- mixed_data(20)
out <- circacompare_mixed(
  x = df,
  col_time = "time",
  col_group = "group",
  col_outcome = "measure",
  col_id = "id",
  control=list(grouped_params=c("phi"), random_params=c("phi1"))
)
out

circacompare documentation built on April 20, 2021, 5:09 p.m.