Aims and content

The present document includes the analytical steps implemented to characterize and explore the antecedents of sleep patterns in a sample of older adolescents with (N = 47; 31 girls) and without (N = 46; 28 girls) DSM-5 insomnia.

The data processing pipeline is depicted at this page, whereas the first part of data analysis (data preparation, psychometrics, and descriptives) is depicted at this page. The former script resulted in the following long-form ema and wide-form demos datasets:

# removing all objets from the workspace
rm(list=ls())

# loading datasets exported at the end of the first Data Analysis script
load("emaFINAL.RData")
load("demosFINAL.RData")

# setting system time zone to GMT (for consistent temporal synchronization)
Sys.setenv(tz="GMT")


Here, we use generalized linear mixed-effects regression (GLMER) models to examine the direct and bidirectional relationships between sleep and psychological distress. In the following models, s.archit, s.timing, s.variab, and s.auton variables measured at day i are predicted by the predictors selected in step 1 in addition to the diary ratings (stress, worry, mood, PsyDist, and fs) measured at day i (M5), and diary ratings measured at day i+1 (M6), in order to evaluate the direct and bidirectional relationship between sleep and psychological distress. Finally, the interaction between diary ratings and insomnia is included in model M7.


The report also includes the final outputs reported in the main paper.


For each step and each outcome variable, models are specified by using alternative distribution families based on the nature of the outcome, inspected to evaluate model fit, compared in terms of likelihood and strength of evidence, and inspected to check the results of the selected model.

Note that all level-1 continuous predictors are centered to the individual mean (mean-centered, mc), whereas all level-2 continuous predictors are centered to the grand average (grand-mean-centered, gmc).

Finally, several robustness checks are performed to account for the arbitrariness of data processing and analytical choices, including (1) the consideration of insomnia.group instead of the insomnia variable, (2) the inclusion of covid19 as a further covariate, (3) the exclusion of participants with extreme missing data (marked with majMiss = 1), (4) the exclusion of the TotalSteps1000 variable from the analyses, (5) the use of alternative family distributions for those variables not showing optimal fit, and (6) the exclusion of diary ratings entered on the following day (marked with lateResp = 1).


The following R packages and functions are used.

# required packages
packages <- c("dplyr","Rmisc","lme4","ordinal","sjPlot","ggplot2","car","knitr","MuMIn","knitr","XML","sjPlot","reshape2")

# generate packages references
knitr::write_bib(c(.packages(), packages),"packagesAn.bib")

# # run to install missing packages
# xfun::pkg_attach2(packages, message = FALSE); rm(list=ls())

# loading mainly used packages
library(lme4); library(ordinal); library(reshape2); library(MuMIn); library(sjPlot); library(ggplot2); library(Rmisc)
glmerAn (from https://github.com/Luca-Menghini/LuMenPsy.Rfunctions )

#' @title Generalized linear (mixed-effects) regression analysis
#' @param modelType = type of model: GLM, mixed-effects (GLMER), or cumulative link mixedm odel (CLMM)
#' @param long = long-form dataset (data.frame) considered if modelType = GLMER or CLMM
#' @param wide = wide-form dataset (data.frame) 
#' @param resp = name of the response variable (character)
#' @param fix.eff = character vector of names of the predictor(s)
#' @param cluster.ID = name of the cluster variable considered if modelType = GLMER or CLMM (default: "ID")
#' @param timeVar = name of the variable indexing time, considered if modelType = GLMER (defult: "ActivityDate")
#' @param REML = argument from the lme4::lmer() function, see ?lmer
#' @param ran.eff = character string indicating the random effect by using the lme4 syntax (defult: "(1|ID)")
#' @param family = character string indicating the name of the GLM(ER) family to be used in the models (default: "normal")
#' @param link =character string indicating the name of the GLM(ER) link function to be used in the models (default: "identity")
#' @param nAGQ = argument from the lme4::glmer() function, see ?glmer
#' @param mc.predictors = character vector of names of the predictors to be mean-centered
#' @param gmc.predictors = character vector of names of the predictors to be grand-mean-centered
#' @param outputs = character vector of the desired outcomes: "fit" for model diagnostics, "mComp" for model comparison, "coeff" for the coefficient table, "plotEff" for the effect plot(s), and "key.res" for the key results
#' @param mComp.baseline = character string indicating the name of the last predictor included in the baseline model to be compared with the subsequent models. If equal to NA (defult), the null model is used as the baseline model for comparison
#' @param p.adjust.method = argument from the stats::p.adjust() function (see ?p.adjust) indicating which method should be used to correct the p-values obtained from the likelihood ratio test (default: NA, for no adjustment)
#' @param coeff.models = name of the predictor(s) whose corresponding model(s) should be considered for the "coeff" output
#' @param transform = argument from sjPlot::tab_model(), see ?tab_model
#' @param coeff.models = model(s) to be considered for the "coeff" output
#' @param plot.model = character string indicating the name of the predictor(s) whose model(s) should be considered for the "plotEff" output
#' @param plot.pred = character string indicating the name of the predictor(s) to be plotted
#' @param show.data = argument from sjPlot::plot_model(), see ?plot_model
#' @param dot.size = argument from sjPlot::plot_model(), see ?plot_model
#' @param dodge = argument from sjPlot::plot_model(), see ?plot_model
#' @param dot.size = argument from sjPlot::plot_model(), see ?plot_model
#' @param ci.lv = argument from sjPlot::plot_model(), see ?plot_model
#' @param y.lim = numeric vector of length 2 indicating the limits of the y-axis
#' @param return.plot = booean. Should the plot be returned by the function? (default: FALSE)
#' @param key.model = character string indicating the name of the predictor(s) whose model(s) should be considered for the "key.res" output
#' @param key.predictor = character string indicating the name of the predictor to be considered by the "key.res" output
#' @param digits = number of digits for all numeric ouputs
#' @param messages = boolean indicating whether a message should be printed for each operation (defult: FALSE)
glmerAn <- function(modelType=c("GLM","GLMER"),long,wide,resp,fix.eff,cluster.ID="ID",timeVar="ActivityDate",REML=FALSE,
                    ran.eff="(1|ID)",family="normal",link="identity",nAGQ=1,mc.predictors=NA,gmc.predictors=NA,
                    outputs=c("fit","mComp","coeff","plotEff","key.results"),mComp.baseline=NA,p.adjust.method=NA,
                    coeff.models=NA,transform=NULL,plot.model=NA,plot.pred="all",
                    show.data=FALSE,dot.size=1,dodge=0,ci.lv=.95,y.lim=NA,return.plot=FALSE,
                    key.model=NA,key.predictor=NA,digits=3,messages=TRUE){ 
  
  if(messages==TRUE){ cat("Running",modelType,"analysis of",resp,"...") }
  
  # data preparation ..................................................................................................................
  if(messages==TRUE){ cat("\n\nPreparing data...") }
  
  # participants' ID recoding as factor
  colnames(long)[which(colnames(long)==cluster.ID)] <- colnames(wide)[which(colnames(wide)==cluster.ID)] <- "ID"
  long$ID <- as.factor(as.character(long$ID))
  wide$ID <- as.factor(as.character(wide$ID))
  wide <- wide[order(wide$ID),] # sorting wide by ID
  colnames(long)[which(colnames(long)==timeVar)] <- "time" # time variable
  long <- long[order(long$ID,long$time),] # sorting long by ID and time
  if(nlevels(long$ID)!=nlevels(wide$ID)){ stop(message="Error: different No. of participants in long and wide datasets") }
  
  # listwise deletion
  if(modelType%in%c("GLMER","CLMM")){ memory <- long 
    for(Var in c(resp,fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)])){ colnames(long)[which(colnames(long)==Var)] <- "Var"
      long <- long[!is.na(long$Var),] # removing obs. with missing response in any resp or fix.eff variable
      colnames(long)[which(colnames(long)=="Var")] <- Var }
    long$ID <- as.factor(as.character(long$ID))
    wide <- wide[wide$ID%in%levels(long$ID),] # excluding wide IDs not included in long IDs
    if(messages==TRUE){ cat("\n - Excluding",nrow(memory)-nrow(long),"incomplete observations (",
                            round(100*(nrow(memory)-nrow(long))/nrow(memory),1),
                            "% ) in the response var. or in any of the predictors,\n   and",
                            nlevels(memory$ID)-nlevels(long$ID),"participants with no complete variables") }
  } else { memory <- wide
    for(Var in c(resp,fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)])){ colnames(wide)[which(colnames(wide)==Var)] <- "Var"
      wide <- wide[!is.na(wide$Var),]
      colnames(wide)[which(colnames(wide)=="Var")] <- Var }
    if(messages==TRUE){ cat("\n - Excluding",nrow(memory)-nrow(wide),"participants with no complete variables") }}
  
  # mean-centering predictors
  if(!is.na(gmc.predictors[1])){ if(messages==TRUE){ cat("\n - Grand-mean-centering",paste(gmc.predictors,collapse=" , ")) }
    for(Var in gmc.predictors){  colnames(wide)[which(colnames(wide)==Var)] <- "Var" 
      wide$Var.gmc <- wide$Var - mean(wide$Var,na.rm=TRUE) # computing gmc values
      colnames(wide) <- gsub("Var",Var,colnames(wide))
      long <- plyr::join(long,wide[,c("ID",paste(Var,"gmc",sep="."))],type="left",by="ID") # joining gmc to long dataset
      fix.eff <- gsub(Var,paste(Var,"gmc",sep="."),fix.eff) }} # updating labels in fix.eff (from Var to Var.gmc)
  if(!is.na(mc.predictors[1])){ if(messages==TRUE){ cat("\n - Mean-centering",paste(mc.predictors,collapse=" , ")) }
    suppressMessages(suppressWarnings(require(Rmisc))) 
    for(Var in mc.predictors){ colnames(long)[which(colnames(long)==Var)] <- "Var" 
      wide$Var.cm <- suppressWarnings(summarySE(long,measurevar="Var",groupvars="ID",na.rm=TRUE)[,3]) # cluster means
      long <- plyr::join(long,wide[,c("ID","Var.cm")],type="left",by="ID") # joining cm to long dataset
      long$Var.mc <- long$Var - long$Var.cm # computing mc values
      colnames(long) <- gsub("Var",Var,colnames(long)) 
      fix.eff <- gsub(Var,paste(Var,"mc",sep="."),fix.eff) }} # updating labels in fix.eff (from Var to Var.mc)
  long <- long[,!duplicated(colnames(long))] # removing duplicated columns (don't know why)

  # modeling .........................................................................................................................
  
  # creating model formulas
  formulas <- character()
  if(modelType=="GLM"){ ran.eff <- "1" }
  null.f <- paste(resp,"~",ran.eff) # creating null model formula
  for(i in 1:length(fix.eff)){ # creating other formulas
    if(i==1){ formulas[i] <- paste(resp,"~",fix.eff[1]) } else { formulas[i] <- paste(formulas[i-1],"+",fix.eff[i])  }}
  if(modelType%in%c("GLMER","CLMM")){ if(!is.na(ran.eff)){ formulas <- paste(formulas,"+",ran.eff)
      if(substr(ran.eff,2,2)!="1"){ ranSlope <- paste(fix.eff[which(grepl(ran.eff,fix.eff))])[1]
        null.f <- gsub(ranSlope,"1",null.f)  # removing random slope from models without the related predictor
        for(i in 1:length(formulas)){ 
          if(!(grepl(ranSlope,gsub(paste(ranSlope,"[|]",sep=""),"",formulas[i])))){ 
            formulas[i] <- gsub(paste(ranSlope,"[|]",sep=""),"1|",formulas[i]) }}}
    } else { stop(message="Error: GLMER model type without ran.eff specification") }}
  if(messages==TRUE){ cat("\n\nModel specification:\n - model M0 (null):",null.f)
    for(i in 1:length(formulas)){ cat("\n - model M",i,": ",formulas[i],sep="")}}
  
  # fitting models
  models <- list()
  if(modelType=="GLM"){ if(messages==TRUE){ cat("\n\nFitting GLM models of",resp,"on",nrow(wide),"participants \n   using the",
                                                family,"family with the",link,"link function...") }
    if(family=="normal" & link=="identity"){ null.m <- lm(as.formula(null.f),data=wide) # normal family
      for(i in 1:length(formulas)){ models[[i]] <- lm(formula=as.formula(formulas[i]),data=wide) }
      } else if (family=="gamma") { null.m <- glm(as.formula(null.f),data=wide,family=Gamma(link=link),nAGQ=nAGQ) # gamma family
        for(i in 1:length(formulas)){ models[[i]] <- glm(formula=as.formula(formulas[i]),data=wide,family=Gamma(link=link)) }
        } else if(family=="normal" & link!="identity"){  
          null.m <- glm(as.formula(null.f),data=wide,family=gaussian(link=link)) # normal with other link functions
          for(i in 1:length(formulas)){ models[[i]] <- glm(formula=as.formula(formulas[i]),data=wide,family=gaussian(link=link)) }
        } else if(family=="binomial"){ 
          null.m <- glm(as.formula(null.f),data=wide,family=binomial(link=link)) # logistic regression
          for(i in 1:length(formulas)){ models[[i]] <- glm(formula=as.formula(formulas[i]),data=wide,family=binomial(link=link))}
        } else { stop(message="Error: only normal, gamma, and binomial family are allowed, 
                      with identity, inverse, and log link functions") }
  } else if(modelType=="GLMER"){ suppressMessages(suppressWarnings(require(lme4)))
    if(messages==TRUE){ cat("\n\nFitting",modelType,"models of",resp,"on",nrow(long),"observations from",
                            nlevels(as.factor(as.character(long$ID))),"participants \n   using the",family,
                            "family with the",link,"link function using",ifelse(REML==FALSE,"ML","REML"),"estimator...") }
    if(family=="normal" & link=="identity"){ null.m <- lmer(as.formula(null.f),data=long,REML=REML) # normal  identity
      for(i in 1:length(formulas)){ models[[i]] <- lmer(formula=as.formula(formulas[i]),data=long,REML=REML) }
      } else if (family=="gamma") { null.m <- glmer(as.formula(null.f),data=long,family=Gamma(link=link),nAGQ=nAGQ) # gamma
        for(i in 1:length(formulas)){ models[[i]]<-glmer(formula=as.formula(formulas[i]),data=long,family=Gamma(link=link),nAGQ=nAGQ) }
        } else if(family=="normal" & link!="identity"){ 
          null.m <- glmer(as.formula(null.f),data=long,family=gaussian(link=link),nAGQ=nAGQ) # normal with other links
          for(i in 1:length(formulas)){ models[[i]] <- glmer(formula=as.formula(formulas[i]),data=long,
                                                             family=gaussian(link=link),nAGQ=nAGQ) }
        } else if(family=="binomial"){ null.m <- glmer(as.formula(null.f),data=long,family=binomial(link=link),nAGQ=nAGQ) # logistic
          for(i in 1:length(formulas)){ models[[i]] <- glmer(formula=as.formula(formulas[i]),data=long,
                                                             family=binomial(link=link),nAGQ=nAGQ)}
        } else { stop(message="Error: only normal, logistic, and gamma family are allowed, 
                               with identity, inverse, and log link functions") }
  } else if(modelType=="CLMM"){ suppressMessages(suppressWarnings(require(ordinal))) # cumulative link mixed models
    if(messages==TRUE){ cat("\n\nFitting",modelType,"models of",resp,"on",nrow(long),"observations from",
                            nlevels(as.factor(as.character(long$ID))),"participants \n   using Cumulative Link Mixed Models") }
    long[,resp] <- factor(long[,resp],ordered=TRUE) # response variable as ordered factor
    null.m <- suppressWarnings(clmm(as.formula(gsub("~","~ 1 +",null.f)),data=long)) # suppress formula warning (bugged)
    for(i in 1:length(formulas)){ models[[i]] <- suppressWarnings(clmm(formula=as.formula(formulas[i]),data=long,nAGQ=nAGQ)) }
  } else { stop(message="Error: modelType can only be 'GLM', 'GLMER', or 'CLMM'") }
  
  # outputs..........................................................................................................................
  if(messages==TRUE){ cat("\n\nGenerating models outputs...") }
  
  # model diagnostics
  if("fit"%in%outputs & modelType!="CLMM"){ if(messages==TRUE){ cat("\n\n - Plotting diagnostics of the most complex model:") }
    suppressMessages(suppressWarnings(require(sjPlot))); suppressMessages(suppressWarnings(require(ggplot2)))
    fit <- models[[length(models)]] # most complex model
    if(modelType=="GLMER"){ dat <- long } else { dat <- wide } # fitted dataset
    plots <- list()
    if(family=="normal" & link=="identity"){ p <- plot_model(fit,type="diag",dot.size=dot.size) # LM(ER) diagnostics (normal)
      if(modelType=="GLMER"){ p[[2]] <- p[[2]]$ID } 
      suppressMessages(plot_grid(p,tags=TRUE,margin=c(0,0,0,0)))
    } else { if(family=="binomial"){ # logistic regression
      dat$logit <- log(predict(fit,type="response")/(1-predict(fit,type="response"))) # computing logit
      for(Var in fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)]){ # plotting logit by each continuous predictor
        if(class(dat[,Var])=="numeric"){  plots[[length(plots)+1]] <- ggplot(dat,aes_string(x=Var,y="logit")) + 
          geom_point(size=dot.size) + suppressMessages(stat_smooth(method="loess")) + ggtitle("Logit by",Var) }}
      } else { plots[[length(plots)+1]] <- ggplot(data.frame(residuals=residuals(fit,type="deviance")), # deviance residuals QQ plot
                                                  aes(sample=residuals)) + stat_qq(size=dot.size) + stat_qq_line() +
        labs(x="Theoretical qualtiles (normal distr.)",y="Sample quantiles") + ggtitle("Deviance Residuals' normal QQ plot") 
      plots[[length(plots)+1]] <- ggplot(fortify.merMod(fit), aes(.fitted, resid(fit,type="deviance"))) + geom_point() +
        suppressMessages(stat_smooth(method="loess"))+geom_hline(yintercept=0, col="red", linetype="dashed") +
        labs(x="Fitted values",y="Residuals") + ggtitle("Deviance residuals vs. fitted values") }
      p <- plot_model(fit,type="diag",dot.size=dot.size) # random effects with GLMER
      if(modelType=="GLMER"){ p <- p$ID }
      plots[[length(plots)+1]] <- p + ggtitle("Random effects' normal QQ plot") }
    if(family!="binomial"){ type <- ifelse(family=="gamma","deviance","pearson") # deviance residuals with gamma
      for(Var in fix.eff[which(grepl(":",fix.eff,fixed=TRUE)==FALSE)]){ # homoscedasticity: residuals by levels of categorical pred.
      if(class(dat[,Var])=="factor"){ Dat <- cbind(dat,residuals=resid(fit,type=type),Var=dat[,Var],Resp=dat[,resp])
         plots[[length(plots)+1]] <- ggplot(Dat,aes_string(x="Var",y="residuals")) + 
           ggtitle(paste(type,"residuals by",Var,"\n mean =",paste(round(with(Dat, tapply(Resp, Var, mean)),1),collapse=", "),
                         ", SD =",paste(round(with(Dat, tapply(Resp, Var, sd)),1),collapse=", "))) + xlab(Var) +
           geom_point(size=dot.size,position=position_jitter(),color="gray") + geom_violin(alpha=0.3) }}}
    suppressMessages(plot_grid(plots,tags=TRUE,margin=rep(0,4))) 
    cat("\n  Printing Variance Inflation Factors (VIF):\n")
    suppressMessages(suppressWarnings(require(car))) # variance inflation factors
    print(vif(fit)) }
  
  # model comparison - likelihood ratio test & Akaike weight
  if("mComp"%in%outputs | "key.results"%in%outputs){ 
    # likelihood ratio test
    if(messages==TRUE){ cat("\n\n - Running likelihood ratio test:") } 
    suppressMessages(suppressWarnings(require(knitr))); suppressMessages(suppressWarnings(require(MuMIn))) 
    m.num <- 1
    if(is.na(mComp.baseline)){ bsl <- null.m  # selecting baseline model
      } else { m.num <- grep(mComp.baseline,fix.eff) + 1
         bsl <- models[[m.num - 1]] }
    if(modelType!="CLMM"){ lrt <- as.data.frame(anova(bsl,models[[m.num]]))
      if(length(models)>m.num){
        for(i in m.num:(length(models)-1)){ lrt <- rbind(lrt,as.data.frame(anova(models[[i]],models[[i+1]]))[2,]) }}
      } else { lrt <- as.data.frame(ordinal:::anova.clm(bsl,models[[m.num]])) # use anova.clm() to avoid env. issue
        if(length(models)>m.num){
          for(i in m.num:(length(models)-1)){ lrt <- rbind(lrt,as.data.frame(ordinal:::anova.clm(models[[i]],models[[i+1]]))[2,]) }}}
    rownames(lrt) <- c(ifelse(is.na(mComp.baseline),"Null model","Baseline"),
                       fix.eff[m.num:length(fix.eff)])
    if(!is.na(p.adjust.method)){ # p-value corrections for multiple comparison
      if(messages==TRUE){ cat(" (applying",p.adjust.method,"p-values correction)")}
      lrt[!is.na(lrt$`Pr(>Chisq)`),"Pr(>Chisq)"] <- p.adjust(lrt[!is.na(lrt$`Pr(>Chisq)`),"Pr(>Chisq)"],
                                                             method=p.adjust.method)  }
    if(messages==TRUE){ # printing selected model
      if(nrow(lrt[!is.na(lrt$`Pr(>Chisq)`) & lrt$`Pr(>Chisq)` < 0.05,])==0 ){ 
        cat("\n   Selected model:",ifelse(is.na(mComp.baseline),"Null model","Baseline"))
    } else { for(i in nrow(lrt):2){ if(lrt[i,ncol(lrt)] < .05){ if(messages==TRUE){ cat("\n   Selected model:",rownames(lrt)[i]) }
                                       break }}}}
    if("mComp"%in%outputs){ print(kable(round(lrt,digits))) } # printing LRT table
    # Akaike weights
    AICs <- lrt[1:2,"AIC"] # Akaike weight
    if(messages==TRUE | ("mComp"%in%outputs & !("key.results"%in%outputs))){ 
      cat("\n\n - Computing Aw coefficients for each model vs. all previous models:",
          "\n   -",ifelse(is.na(mComp.baseline),"Null model","Baseline"),"vs.",fix.eff[m.num],": =",round(Weights(AICs),digits)[1],
          "\n   -",fix.eff[m.num],"vs.",ifelse(is.na(mComp.baseline),"Null model","Baseline"),"model =",
          round(Weights(AICs),digits)[2]) }
    if(nrow(lrt)>2){ for(i in 3:nrow(lrt)){ AICs <- c(AICs,lrt[i,"AIC"])
      if(messages==TRUE | ("mComp"%in%outputs & !("key.results"%in%outputs))){ 
        cat("\n   -",row.names(lrt)[i],"=",round(Weights(AICs),digits)[length(AICs)]) }}}
    if(messages==TRUE | ("mComp"%in%outputs & !("key.results"%in%outputs))){ 
      cat("\n   Selected model based on Aw:",row.names(lrt[which(lrt$AIC==min(lrt$AIC)),])) }
    if("key.results"%in%outputs){ 
      key <- lrt[which(grepl(key.predictor,row.names(lrt))),] # key results
      if(nrow(key)>1){ key <- key[1,] }
      key.results <- data.frame(sig.LRT=key[,ncol(key)]<0.05, # sig.LRT
                                higher.Aw=key$AIC==min(AICs[1:which(AICs==key$AIC)])) }} # higher.Aw
  
  # estimated parameters from key.model
  if("key.results"%in%outputs){
    modSummary <- summary(models[[which(fix.eff==key.model)]])
    modSummary <- modSummary$coefficients
    if(modelType=="CLMM"){ modSummary <- modSummary[nlevels(long[,resp]):nrow(modSummary),] }
    key <- modSummary[which(grepl(key.predictor,row.names(modSummary))),3][1] # taking only first coeff for key.results
    key.results <- cbind(key.results,t.196=abs(key)>1.96,t=key) }
  if("coeff"%in%outputs){ if(messages==TRUE){ suppressMessages(suppressWarnings(require(knitr)))
    cat("\n\n - Printing estimated coefficients for models",paste(coeff.models,collapse=" , "))}
    suppressMessages(suppressWarnings(require(XML))); suppressMessages(suppressWarnings(require(sjPlot)))
    out <- data.frame(readHTMLTable(htmlParse(tab_model(models[which(fix.eff%in%coeff.models)],transform=transform,
                                                        show.icc=FALSE,show.p=FALSE,show.stat=TRUE,show.re.var=FALSE,
                                                        show.ci=FALSE,show.r2=FALSE,show.se=TRUE,collapse.se=TRUE,
                                                        string.est="B (SE)",string.stat="t")))[1])
    colnames(out) <- out[1,]
    out <- out[-1,] # sorting rows and columns
    out <- rbind(out[which(!substr(out$Predictors,1,3)%in%c("SD ","Cor")),],
                 out[which(substr(out$Predictors,1,3)=="SD "),],out[which(substr(out$Predictors,1,4)=="Cor "),])
    print(knitr::kable(out)) }
  
  # plotting effects
  if("plotEff"%in%outputs){ if(messages==TRUE){ cat("\n\n - Plotting effect(s) estimated by model",which(fix.eff==plot.model)) }
    suppressMessages(suppressWarnings(require(sjPlot))); suppressMessages(suppressWarnings(require(ggplot2)))
    if(plot.pred[1]=="all"){ fix.eff.plot <- fix.eff } else { fix.eff.plot <- plot.pred }
    if(length(fix.eff.plot)==1){ if(grepl(":",plot.pred)){ 
        terms <- c(strsplit(plot.pred,split=":")[[1]][1],strsplit(plot.pred,split=":")[[1]][2]) 
      } else { terms <- fix.eff[which(fix.eff==fix.eff.plot)] } 
      p <- plot_model(models[[which(fix.eff==fix.eff.plot)]],type="pred",terms=terms,ci.lv=ci.lv,dodge=dodge,
                      show.data=show.data,dot.size=dot.size,jitter=0.15) + ggtitle(paste(resp,"by",fix.eff.plot,fix.eff.plot))
      if(!is.na(y.lim[1])){ p <- p + ylim(y.lim) }
      if(return.plot==TRUE){ return(p) } else { print(p) } # returning or printing the plot 
    } else { plots <- list()
      for(i in 1:length(fix.eff.plot)){ if(grepl(":",fix.eff.plot[i],fixed=TRUE)==FALSE){ # predicted effects conditioned on ran.eff.
          p <- plot_model(models[[i]],type="pred",terms=fix.eff.plot[i],show.data=show.data,dot.size=dot.size,ci.lv=ci.lv,
                          colors="gray",jitter=0.15,dodge=dodge)
        } else { p <- plot_model(models[[i]],type="pred",terms=strsplit(fix.eff.plot[i],split=":")[[1]],ci.lv=ci.lv,dodge=dodge) }
                 plots[[i]] <- p + ggtitle(paste(resp,"by",fix.eff.plot[i])) }
      plot_grid(plots,tags=TRUE,margin=rep(0,4)) }}
  
  # returning key results (sig. LRT, Aw higher than previous model, t > 1.96)
  if("key.results"%in%outputs){ return(key.results) }}

Fits GLM(ER) models and prints the core numeric and graphical ouputs considered for the analyses.

key.resPlot (from https://github.com/Luca-Menghini/LuMenPsy.Rfunctions )

key.resPlot <- function(res=NA,robCheck=NA,levels=c(s.archit,s.timing,paste(s.variab,"c",sep=""),s.auton)){ 
  suppressMessages(suppressWarnings(require(ggplot2)))
  
  # setting color scale
  res[res$t.196==TRUE & res$sig.LRT==TRUE & res$higher.Aw==TRUE,"Value"] <- 10 # 10 = substantial effect
  res[res$t.196==TRUE & ((res$sig.LRT==FALSE & res$higher.Aw==TRUE) | 
                           res$sig.LRT==TRUE & res$higher.Aw==FALSE),"Value"] <- 7.5 # 7.5 = substantial but LRT n.s. OR lower Aw
  res[res$t.196==TRUE & res$sig.LRT==FALSE & res$higher.Aw==FALSE,"Value"] <- 5 # 5 = substantial but both LRT n.s. AND lower Aw
  res[res$t.196==FALSE & ((res$sig.LRT==TRUE & res$higher.Aw==TRUE) | (res$sig.LRT==TRUE & res$higher.Aw==FALSE) |
                            res$sig.LRT==FALSE & res$higher.Aw==TRUE),"Value"] <- 2.5 # 2.5 = unsubstantial and LRT n.s. OR lower Aw
  res[res$t.196==FALSE & res$sig.LRT==FALSE & res$higher.Aw==FALSE,"Value"] <- 1 # 1 = no evidence at all
  res$Measure <- factor(res$measure,levels=levels) # Measures as factor
  
  # plotting
  if(is.na(robCheck)){ # single set of analyses
    ggplot(res,aes(x=Measure,y=as.factor(1),fill=Value)) + geom_tile() + geom_text(aes(label=round(t,2))) +
      scale_fill_gradient2(low="red",high="lightgreen",mid="yellow",midpoint=5,limit = c(1,10), space = "Lab") + 
      labs(x="",y="") + theme(legend.position = "none",axis.text.y = element_blank(),axis.text.x=element_text(angle=45))
  } else { require(reshape2) # multiple robustness checks
    colnames(res)[which(colnames(res)==robCheck)] <- "robCheck"
    ggplot(res,aes(x=Measure, y=as.factor(robCheck), fill=Value)) + geom_tile() + geom_text(aes(label=round(t,2))) +
      scale_fill_gradient2(low="red",high="lightgreen",mid="yellow",midpoint=5,limit = c(1,10), space = "Lab") + 
      labs(x="",y="") + theme(legend.position = "none",axis.text.x=element_text(angle=45)) }}

Visualizes the key results (Aw, LRT, and t value) obtained with the glmerAn function.


1. Sleep by diary ratings

Here, s.archit, s.timing, s.variab, and s.auton variables are predicted by the predictors selected in step 1 in addition to (1) the diary ratings measured at day i, and (2) the diary ratings measured at day i+1, in order to evaluate the direct and bidirectional relationship between sleep and psychological distress, as well as (3) the interaction between prior-day diary ratings and insomnia.

Here, we code the next day diary ratings.

# selecting all diaryVars variables
diaryVars <- c("stress","worry","mood","PsyDist","fs.w")

# computing lead variables (i.e., next day, "nd")
library(dplyr)
for(i in 1:length(diaryVars)){
  colnames(ema)[colnames(ema)==diaryVars[i]] <- "variable"
  ema <- ema %>% group_by(ID) %>% mutate(variable.nd=dplyr::lead(variable,n=1,default=NA)) # computing lead var
  ema[ema$dayNr!=ema$partdayNr,"variable.nd"] <- NA # removing lagged values in cases when dayNr != partdayNr
  colnames(ema) <- gsub("variable",diaryVars[i],colnames(ema)) }
ema <- as.data.frame(ema)
detach("package:dplyr", unload=TRUE)

# correlation between PsyDist and PsyDist.nd: .34-.50 (quite high) -> risk for multicollinearity?
cor(ema$stress,ema$stress.nd,use="complete.obs")
## [1] 0.4163984
cor(ema$worry,ema$worry.nd,use="complete.obs")
## [1] 0.4611379
cor(ema$mood,ema$mood.nd,use="complete.obs")
## [1] 0.3458227
cor(ema$PsyDist,ema$PsyDist.nd,use="complete.obs")
## [1] 0.5100607
cor(ema$fs.w,ema$fs.w.nd,use="complete.obs")
## [1] 0.2734142
# printing info
cat(nrow(ema),"total cases\n",nrow(ema[!is.na(ema$TIB),]),"with sleep.timing\n",
    nrow(ema[!is.na(ema$TIB) & !is.na(ema$PsyDist),]),"with both sleep.timing and PsyDist\n",
    nrow(ema[!is.na(ema$TIB) & !is.na(ema$PsyDist) & !is.na(ema$PsyDist.nd),]),"with sleep.timing, PsyDist, and PsyDist.nd")
## 6219 total cases
##  5121 with sleep.timing
##  4333 with both sleep.timing and PsyDist
##  3798 with sleep.timing, PsyDist, and PsyDist.nd
# changing variable name for better compatibility with the function below
colnames(ema)[which(colnames(ema)%in%c("stress.nd","worry.nd","mood.nd","PsyDist.nd","fs.w.nd"))] <- 
  c("s.nd","w.nd","m.nd","P.nd","f.nd")


1.1. Sleep architecture

s.archit variables are modeled by considering the subset of complete s.archit and dailyDiary data, whereas dailyAct data are ignored since none of the s.archit variables was substantially predicted by TotalSteps1000. Sex is excluded as well, since it only predicted small differences in some s.archit, but not in diary ratings.

s.archit <- c("TIB","TST","WASO","SE","light.p","deep.p","rem.p")

TIB

In section 5.1, TIB was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (shorter TIB for later than usual SO) and weekday.sleep (longer TIB during weekend).

# selecting core predictors
res <- res.nd <- res.int <- list() # empty list of key results
for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TIB by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) } 
  
  # saving key results (considering M3 which showed higher Aw than M2 for all predictors)
  res[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors, # day i (M3)
                                          modelType=c("GLMER"),mc.predictors=mc.predictors,
                                          mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                          outputs="key.results",key.predictor=keys[1],key.model=keys[2],messages=FALSE))
  res.nd[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors, # day i+1 (M3)
                                             modelType=c("GLMER"),mc.predictors=mc.predictors,
                                             mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                             outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE))
  res.int[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors, # interaction (M4)
                                              modelType=c("GLMER"),mc.predictors=mc.predictors,
                                              mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                              outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
          mComp.baseline="weekday.sleep",p.adjust.method="BH", 
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing TIB by stress 
## ###########################################
## 
## Running GLMER analysis of TIB ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): TIB ~ (1|ID)
##  - model M1: TIB ~ SO.num.mc + (1|ID)
##  - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TIB ~ SO.num.mc + weekday.sleep + stress.mc + (1|ID)
##  - model M4: TIB ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (1|ID)
##  - model M5: TIB ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: TIB ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc      weekday.sleep          stress.mc            s.nd.mc 
##           1.037423           1.056067           2.306710           1.077631 
##           insomnia stress.mc:insomnia 
##           1.000034           2.259939 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: s.nd.mc
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline           |    5| 43035.46| 43066.67| -21512.73| 43025.46|     NA| NA|         NA|
## |stress.mc          |    6| 43005.85| 43043.31| -21496.93| 42993.85| 31.608|  1|      0.000|
## |s.nd.mc            |    7| 42974.21| 43017.90| -21480.10| 42960.21| 33.645|  1|      0.000|
## |insomnia           |    8| 42975.96| 43025.89| -21479.98| 42959.96|  0.251|  1|      0.617|
## |stress.mc:insomnia |    9| 42976.77| 43032.95| -21479.39| 42958.77|  1.186|  1|      0.368|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0 
##    - stress.mc vs. Baseline model = 1
##    - s.nd.mc = 1
##    - insomnia = 0.294
##    - stress.mc:insomnia = 0.164
##    Selected model based on Aw: s.nd.mc
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)              |451.51(4.52) |99.99  |451.96(4.52) |100.10 |449.73(6.35) |70.80  |
## |3  |SO.num.mc                |-37.08(0.99) |-37.47 |-37.24(0.99) |-37.79 |-37.23(0.99) |-37.79 |
## |4  |weekday.sleep [weekend]  |53.01(2.52)  |21.07  |51.31(2.52)  |20.35  |51.28(2.52)  |20.34  |
## |5  |stress.mc                |-6.78(1.20)  |-5.63  |-5.17(1.23)  |-4.21  |-6.62(1.81)  |-3.66  |
## |8  |s.nd.mc                  |             |       |-7.18(1.24)  |-5.81  |-7.22(1.24)  |-5.85  |
## |9  |insomnia [1]             |             |       |             |       |4.47(8.91)   |0.50   |
## |10 |stress.mc * insomnia [1] |             |       |             |       |2.61(2.40)   |1.09   |
## |11 |N                        |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations             |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)           |40.99(NA)    |       |41.00(NA)    |       |40.92(NA)    |       |
## |7  |SD (Observations)        |8.20(NA)     |       |8.18(NA)     |       |8.18(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB by worry 
## ###########################################
## 
## Running GLMER analysis of TIB ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): TIB ~ (1|ID)
##  - model M1: TIB ~ SO.num.mc + (1|ID)
##  - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TIB ~ SO.num.mc + weekday.sleep + worry.mc + (1|ID)
##  - model M4: TIB ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (1|ID)
##  - model M5: TIB ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: TIB ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: worry.mc
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline          |    5| 43035.46| 43066.67| -21512.73| 43025.46|     NA| NA|         NA|
## |worry.mc          |    6| 42986.93| 43024.38| -21487.46| 42974.93| 50.536|  1|      0.000|
## |w.nd.mc           |    7| 42988.42| 43032.12| -21487.21| 42974.42|  0.503|  1|      0.824|
## |insomnia          |    8| 42990.17| 43040.11| -21487.09| 42974.17|  0.249|  1|      0.824|
## |worry.mc:insomnia |    9| 42992.15| 43048.33| -21487.07| 42974.15|  0.025|  1|      0.874|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0 
##    - worry.mc vs. Baseline model = 1
##    - w.nd.mc = 0.321
##    - insomnia = 0.118
##    - worry.mc:insomnia = 0.042
##    Selected model based on Aw: worry.mc
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)             |451.69(4.52) |100.04 |451.68(4.52) |100.04 |449.45(6.35) |70.75  |
## |3  |SO.num.mc               |-37.13(0.99) |-37.63 |-37.11(0.99) |-37.60 |-37.11(0.99) |-37.60 |
## |4  |weekday.sleep [weekend] |52.32(2.51)  |20.81  |52.35(2.51)  |20.82  |52.34(2.52)  |20.80  |
## |5  |worry.mc                |-8.84(1.24)  |-7.13  |-9.03(1.27)  |-7.13  |-9.24(1.86)  |-4.98  |
## |8  |w.nd.mc                 |             |       |0.89(1.26)   |0.71   |0.89(1.26)   |0.70   |
## |9  |insomnia [1]            |             |       |             |       |4.45(8.91)   |0.50   |
## |10 |worry.mc * insomnia [1] |             |       |             |       |0.39(2.47)   |0.16   |
## |11 |N                       |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations            |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)          |40.99(NA)    |       |41.00(NA)    |       |40.92(NA)    |       |
## |7  |SD (Observations)       |8.19(NA)     |       |8.19(NA)     |       |8.19(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB by mood 
## ###########################################
## 
## Running GLMER analysis of TIB ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): TIB ~ (1|ID)
##  - model M1: TIB ~ SO.num.mc + (1|ID)
##  - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TIB ~ SO.num.mc + weekday.sleep + mood.mc + (1|ID)
##  - model M4: TIB ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (1|ID)
##  - model M5: TIB ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: TIB ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    5| 43035.46| 43066.67| -21512.73| 43025.46|    NA| NA|         NA|
## |mood.mc          |    6| 43033.49| 43070.94| -21510.74| 43021.49| 3.972|  1|      0.185|
## |m.nd.mc          |    7| 43035.32| 43079.02| -21510.66| 43021.32| 0.166|  1|      0.684|
## |insomnia         |    8| 43037.08| 43087.01| -21510.54| 43021.08| 0.246|  1|      0.684|
## |mood.mc:insomnia |    9| 43038.90| 43095.08| -21510.45| 43020.90| 0.179|  1|      0.684|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.272 
##    - mood.mc vs. Baseline model = 0.728
##    - m.nd.mc = 0.225
##    - insomnia = 0.086
##    - mood.mc:insomnia = 0.033
##    Selected model based on Aw: mood.mc
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)             |451.29(4.52) |99.94  |451.29(4.52) |99.94  |449.07(6.35) |70.69  |
## |3  |SO.num.mc               |-36.94(0.99) |-37.15 |-36.94(0.99) |-37.15 |-36.95(0.99) |-37.15 |
## |4  |weekday.sleep [weekend] |53.84(2.52)  |21.33  |53.81(2.52)  |21.31  |53.81(2.52)  |21.31  |
## |5  |mood.mc                 |-2.51(1.26)  |-1.99  |-2.46(1.27)  |-1.93  |-1.83(1.95)  |-0.94  |
## |8  |m.nd.mc                 |             |       |-0.51(1.26)  |-0.41  |-0.50(1.26)  |-0.40  |
## |9  |insomnia [1]            |             |       |             |       |4.43(8.91)   |0.50   |
## |10 |mood.mc * insomnia [1]  |             |       |             |       |-1.08(2.54)  |-0.42  |
## |11 |N                       |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations            |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)          |40.98(NA)    |       |40.98(NA)    |       |40.90(NA)    |       |
## |7  |SD (Observations)       |8.22(NA)     |       |8.22(NA)     |       |8.22(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB by PsyDist 
## ###########################################
## 
## Running GLMER analysis of TIB ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): TIB ~ (1|ID)
##  - model M1: TIB ~ SO.num.mc + (1|ID)
##  - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + (1|ID)
##  - model M4: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: TIB ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: PsyDist.mc
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline            |    5| 43035.46| 43066.67| -21512.73| 43025.46|     NA| NA|         NA|
## |PsyDist.mc          |    6| 42997.05| 43034.50| -21492.52| 42985.05| 40.414|  1|      0.000|
## |P.nd.mc             |    7| 42995.27| 43038.96| -21490.63| 42981.27|  3.782|  1|      0.104|
## |insomnia            |    8| 42997.02| 43046.96| -21490.51| 42981.02|  0.247|  1|      0.619|
## |PsyDist.mc:insomnia |    9| 42998.59| 43054.77| -21490.29| 42980.59|  0.432|  1|      0.619|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0 
##    - PsyDist.mc vs. Baseline model = 1
##    - P.nd.mc = 0.709
##    - insomnia = 0.228
##    - PsyDist.mc:insomnia = 0.094
##    Selected model based on Aw: P.nd.mc
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)               |451.80(4.52) |99.90  |451.87(4.52) |99.93  |449.67(6.36) |70.69  |
## |3  |SO.num.mc                 |-37.25(0.99) |-37.65 |-37.29(0.99) |-37.69 |-37.28(0.99) |-37.68 |
## |4  |weekday.sleep [weekend]   |52.34(2.52)  |20.76  |52.04(2.52)  |20.61  |52.00(2.52)  |20.59  |
## |5  |PsyDist.mc                |-10.18(1.60) |-6.37  |-9.29(1.66)  |-5.60  |-10.50(2.48) |-4.23  |
## |8  |P.nd.mc                   |             |       |-3.21(1.65)  |-1.95  |-3.24(1.65)  |-1.97  |
## |9  |insomnia [1]              |             |       |             |       |4.42(8.92)   |0.50   |
## |10 |PsyDist.mc * insomnia [1] |             |       |             |       |2.10(3.20)   |0.66   |
## |11 |N                         |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations              |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)            |41.06(NA)    |       |41.05(NA)    |       |40.98(NA)    |       |
## |7  |SD (Observations)         |8.20(NA)     |       |8.19(NA)     |       |8.19(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB by fs.w 
## ###########################################
## 
## Running GLMER analysis of TIB ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): TIB ~ (1|ID)
##  - model M1: TIB ~ SO.num.mc + (1|ID)
##  - model M2: TIB ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TIB ~ SO.num.mc + weekday.sleep + fs.w + (1|ID)
##  - model M4: TIB ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (1|ID)
##  - model M5: TIB ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: TIB ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: fs.w
## 
## |              | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline      |    5| 43035.46| 43066.67| -21512.73| 43025.46|     NA| NA|         NA|
## |fs.w          |    6| 42996.34| 43033.80| -21492.17| 42984.34| 41.118|  1|      0.000|
## |f.nd          |    7| 42996.87| 43040.57| -21491.44| 42982.87|  1.470|  1|      0.451|
## |insomnia      |    8| 42998.64| 43048.57| -21491.32| 42982.64|  0.238|  1|      0.626|
## |fs.w:insomnia |    9| 43000.36| 43056.54| -21491.18| 42982.36|  0.276|  1|      0.626|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0 
##    - fs.w vs. Baseline model = 1
##    - f.nd = 0.434
##    - insomnia = 0.152
##    - fs.w:insomnia = 0.06
##    Selected model based on Aw: fs.w
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)             |451.82(4.52) |99.97  |451.86(4.52) |100.01 |449.69(6.36) |70.74  |
## |3  |SO.num.mc               |-37.25(0.99) |-37.65 |-37.27(0.99) |-37.67 |-37.26(0.99) |-37.66 |
## |4  |weekday.sleep [weekend] |52.31(2.52)  |20.75  |52.16(2.52)  |20.67  |52.12(2.52)  |20.65  |
## |5  |fs.w                    |-8.76(1.36)  |-6.43  |-8.31(1.41)  |-5.89  |-9.14(2.11)  |-4.32  |
## |8  |f.nd                    |             |       |-1.70(1.40)  |-1.21  |-1.72(1.40)  |-1.23  |
## |9  |insomnia [1]            |             |       |             |       |4.33(8.92)   |0.49   |
## |10 |fs.w * insomnia [1]     |             |       |             |       |1.43(2.73)   |0.53   |
## |11 |N                       |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations            |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)          |41.03(NA)    |       |41.01(NA)    |       |40.94(NA)    |       |
## |7  |SD (Observations)       |8.20(NA)     |       |8.20(NA)     |       |8.19(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term

  • model M5 including prior-day stress, worry, PsyDist, and fs.w, and model M6 with next-day stress are associated with a significant LRT and stronger evidence in terms of Aw (also characterizing prior-day mood), compared to the baseline model

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for prior-day stress, worry, PsyDist, and fs.w, and for next-day stress, while mood did not show substantial direct or inverse effects


TST

In section 5.1, TST was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (shorter TST for later than usual SO) and weekday.sleep (longer TST during weekend).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TST by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  
  # saving key results (considering M3 which showed higher Aw than M2 for all predictors)
  res[[i]] <- rbind(res[[i]],cbind(measure="TST",glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors, #day i
                                                         modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                         mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                                         outputs="key.results",key.predictor=keys[1],key.model=keys[2],
                                                         messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="TST",glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors, #i+1
                                                               mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                                               modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                               outputs="key.results",key.predictor=keys[2],key.model=keys[2],
                                                               messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="TST",glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors,
                                                                 mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                                                 modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                 outputs="key.results",key.predictor=keys[3],
                                                                 key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="TST",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors, 
          mComp.baseline="weekday.sleep",p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing TST by stress 
## ###########################################
## 
## Running GLMER analysis of TST ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): TST ~ (1|ID)
##  - model M1: TST ~ SO.num.mc + (1|ID)
##  - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TST ~ SO.num.mc + weekday.sleep + stress.mc + (1|ID)
##  - model M4: TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (1|ID)
##  - model M5: TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: TST ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc      weekday.sleep          stress.mc            s.nd.mc 
##           1.037420           1.056063           2.306710           1.077630 
##           insomnia stress.mc:insomnia 
##           1.000036           2.259939 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: s.nd.mc
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline           |    5| 42192.10| 42223.31| -21091.05| 42182.10|     NA| NA|         NA|
## |stress.mc          |    6| 42162.07| 42199.52| -21075.03| 42150.07| 32.031|  1|      0.000|
## |s.nd.mc            |    7| 42132.02| 42175.72| -21059.01| 42118.02| 32.044|  1|      0.000|
## |insomnia           |    8| 42133.87| 42183.80| -21058.93| 42117.87|  0.154|  1|      0.694|
## |stress.mc:insomnia |    9| 42134.88| 42191.06| -21058.44| 42116.88|  0.984|  1|      0.428|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0 
##    - stress.mc vs. Baseline model = 1
##    - s.nd.mc = 1
##    - insomnia = 0.284
##    - stress.mc:insomnia = 0.146
##    Selected model based on Aw: s.nd.mc
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)              |399.06(3.82) |104.38 |399.46(3.82) |104.49 |397.98(5.38) |73.99  |
## |3  |SO.num.mc                |-31.94(0.89) |-36.02 |-32.08(0.88) |-36.32 |-32.07(0.88) |-36.31 |
## |4  |weekday.sleep [weekend]  |47.41(2.25)  |21.03  |45.92(2.26)  |20.32  |45.90(2.26)  |20.31  |
## |5  |stress.mc                |-6.11(1.08)  |-5.67  |-4.71(1.10)  |-4.28  |-5.89(1.62)  |-3.63  |
## |8  |s.nd.mc                  |             |       |-6.28(1.11)  |-5.67  |-6.32(1.11)  |-5.70  |
## |9  |insomnia [1]             |             |       |             |       |2.97(7.54)   |0.39   |
## |10 |stress.mc * insomnia [1] |             |       |             |       |2.13(2.15)   |0.99   |
## |11 |N                        |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations             |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)           |34.48(NA)    |       |34.49(NA)    |       |34.45(NA)    |       |
## |7  |SD (Observations)        |7.76(NA)     |       |7.75(NA)     |       |7.75(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST by worry 
## ###########################################
## 
## Running GLMER analysis of TST ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): TST ~ (1|ID)
##  - model M1: TST ~ SO.num.mc + (1|ID)
##  - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TST ~ SO.num.mc + weekday.sleep + worry.mc + (1|ID)
##  - model M4: TST ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (1|ID)
##  - model M5: TST ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: TST ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: worry.mc
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline          |    5| 42192.10| 42223.31| -21091.05| 42182.10|     NA| NA|         NA|
## |worry.mc          |    6| 42146.44| 42183.89| -21067.22| 42134.44| 47.659|  1|      0.000|
## |w.nd.mc           |    7| 42147.98| 42191.68| -21066.99| 42133.98|  0.456|  1|      0.928|
## |insomnia          |    8| 42149.83| 42199.76| -21066.91| 42133.83|  0.153|  1|      0.928|
## |worry.mc:insomnia |    9| 42151.82| 42208.00| -21066.91| 42133.82|  0.004|  1|      0.952|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0 
##    - worry.mc vs. Baseline model = 1
##    - w.nd.mc = 0.316
##    - insomnia = 0.112
##    - worry.mc:insomnia = 0.039
##    Selected model based on Aw: worry.mc
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)             |399.22(3.82) |104.43 |399.21(3.82) |104.42 |397.73(5.38) |73.95  |
## |3  |SO.num.mc               |-31.97(0.88) |-36.14 |-31.96(0.88) |-36.12 |-31.96(0.88) |-36.12 |
## |4  |weekday.sleep [weekend] |46.85(2.25)  |20.78  |46.88(2.25)  |20.79  |46.87(2.26)  |20.78  |
## |5  |worry.mc                |-7.70(1.11)  |-6.93  |-7.85(1.14)  |-6.92  |-7.93(1.66)  |-4.76  |
## |8  |w.nd.mc                 |             |       |0.76(1.13)   |0.68   |0.76(1.13)   |0.67   |
## |9  |insomnia [1]            |             |       |             |       |2.95(7.54)   |0.39   |
## |10 |worry.mc * insomnia [1] |             |       |             |       |0.13(2.22)   |0.06   |
## |11 |N                       |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations            |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)          |34.49(NA)    |       |34.49(NA)    |       |34.44(NA)    |       |
## |7  |SD (Observations)       |7.76(NA)     |       |7.76(NA)     |       |7.76(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST by mood 
## ###########################################
## 
## Running GLMER analysis of TST ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): TST ~ (1|ID)
##  - model M1: TST ~ SO.num.mc + (1|ID)
##  - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TST ~ SO.num.mc + weekday.sleep + mood.mc + (1|ID)
##  - model M4: TST ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (1|ID)
##  - model M5: TST ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: TST ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    5| 42192.10| 42223.31| -21091.05| 42182.10|    NA| NA|         NA|
## |mood.mc          |    6| 42190.72| 42228.17| -21089.36| 42178.72| 3.379|  1|      0.264|
## |m.nd.mc          |    7| 42192.31| 42236.01| -21089.16| 42178.31| 0.403|  1|      0.708|
## |insomnia         |    8| 42194.16| 42244.10| -21089.08| 42178.16| 0.151|  1|      0.708|
## |mood.mc:insomnia |    9| 42196.02| 42252.20| -21089.01| 42178.02| 0.141|  1|      0.708|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.334 
##    - mood.mc vs. Baseline model = 0.666
##    - m.nd.mc = 0.231
##    - insomnia = 0.084
##    - mood.mc:insomnia = 0.032
##    Selected model based on Aw: mood.mc
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)             |398.86(3.82) |104.32 |398.87(3.82) |104.32 |397.40(5.38) |73.88  |
## |3  |SO.num.mc               |-31.80(0.89) |-35.68 |-31.80(0.89) |-35.69 |-31.81(0.89) |-35.69 |
## |4  |weekday.sleep [weekend] |48.19(2.26)  |21.31  |48.15(2.26)  |21.28  |48.15(2.26)  |21.28  |
## |5  |mood.mc                 |-2.08(1.13)  |-1.84  |-2.00(1.14)  |-1.75  |-1.50(1.75)  |-0.86  |
## |8  |m.nd.mc                 |             |       |-0.72(1.13)  |-0.63  |-0.71(1.13)  |-0.63  |
## |9  |insomnia [1]            |             |       |             |       |2.93(7.54)   |0.39   |
## |10 |mood.mc * insomnia [1]  |             |       |             |       |-0.85(2.28)  |-0.38  |
## |11 |N                       |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations            |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)          |34.47(NA)    |       |34.47(NA)    |       |34.42(NA)    |       |
## |7  |SD (Observations)       |7.78(NA)     |       |7.78(NA)     |       |7.78(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST by PsyDist 
## ###########################################
## 
## Running GLMER analysis of TST ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): TST ~ (1|ID)
##  - model M1: TST ~ SO.num.mc + (1|ID)
##  - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + (1|ID)
##  - model M4: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: TST ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: PsyDist.mc
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline            |    5| 42192.10| 42223.31| -21091.05| 42182.10|     NA| NA|         NA|
## |PsyDist.mc          |    6| 42155.56| 42193.01| -21071.78| 42143.56| 38.538|  1|      0.000|
## |P.nd.mc             |    7| 42153.49| 42197.18| -21069.74| 42139.49|  4.069|  1|      0.087|
## |insomnia            |    8| 42155.34| 42205.27| -21069.67| 42139.34|  0.152|  1|      0.697|
## |PsyDist.mc:insomnia |    9| 42157.00| 42213.18| -21069.50| 42139.00|  0.336|  1|      0.697|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0 
##    - PsyDist.mc vs. Baseline model = 1
##    - P.nd.mc = 0.738
##    - insomnia = 0.226
##    - PsyDist.mc:insomnia = 0.09
##    Selected model based on Aw: P.nd.mc
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-------------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)               |399.31(3.83) |104.23 |399.38(3.83) |104.27 |397.92(5.39) |73.84  |
## |3  |SO.num.mc                 |-32.08(0.89) |-36.17 |-32.11(0.89) |-36.22 |-32.10(0.89) |-36.21 |
## |4  |weekday.sleep [weekend]   |46.86(2.26)  |20.74  |46.58(2.26)  |20.59  |46.55(2.26)  |20.57  |
## |5  |PsyDist.mc                |-8.91(1.43)  |-6.22  |-8.08(1.49)  |-5.43  |-9.04(2.23)  |-4.06  |
## |8  |P.nd.mc                   |             |       |-2.98(1.48)  |-2.02  |-3.01(1.48)  |-2.04  |
## |9  |insomnia [1]              |             |       |             |       |2.92(7.55)   |0.39   |
## |10 |PsyDist.mc * insomnia [1] |             |       |             |       |1.66(2.87)   |0.58   |
## |11 |N                         |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations              |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)            |34.56(NA)    |       |34.55(NA)    |       |34.51(NA)    |       |
## |7  |SD (Observations)         |7.76(NA)     |       |7.76(NA)     |       |7.76(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST by fs.w 
## ###########################################
## 
## Running GLMER analysis of TST ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): TST ~ (1|ID)
##  - model M1: TST ~ SO.num.mc + (1|ID)
##  - model M2: TST ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: TST ~ SO.num.mc + weekday.sleep + fs.w + (1|ID)
##  - model M4: TST ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (1|ID)
##  - model M5: TST ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: TST ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of TST on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: fs.w
## 
## |              | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline      |    5| 42192.10| 42223.31| -21091.05| 42182.10|     NA| NA|         NA|
## |fs.w          |    6| 42155.18| 42192.63| -21071.59| 42143.18| 38.915|  1|      0.000|
## |f.nd          |    7| 42155.47| 42199.17| -21070.74| 42141.47|  1.707|  1|      0.383|
## |insomnia      |    8| 42157.33| 42207.27| -21070.67| 42141.33|  0.144|  1|      0.705|
## |fs.w:insomnia |    9| 42159.13| 42215.31| -21070.56| 42141.13|  0.201|  1|      0.705|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0 
##    - fs.w vs. Baseline model = 1
##    - f.nd = 0.463
##    - insomnia = 0.155
##    - fs.w:insomnia = 0.059
##    Selected model based on Aw: fs.w
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)       |t      |B (SE)       |t      |B (SE)       |t      |
## |:--|:-----------------------|:------------|:------|:------------|:------|:------------|:------|
## |2  |(Intercept)             |399.33(3.83) |104.31 |399.36(3.83) |104.37 |397.95(5.38) |73.91  |
## |3  |SO.num.mc               |-32.08(0.89) |-36.17 |-32.10(0.89) |-36.19 |-32.09(0.89) |-36.18 |
## |4  |weekday.sleep [weekend] |46.84(2.26)  |20.73  |46.69(2.26)  |20.64  |46.66(2.26)  |20.62  |
## |5  |fs.w                    |-7.64(1.22)  |-6.25  |-7.21(1.27)  |-5.70  |-7.84(1.90)  |-4.14  |
## |8  |f.nd                    |             |       |-1.64(1.25)  |-1.31  |-1.66(1.26)  |-1.32  |
## |9  |insomnia [1]            |             |       |             |       |2.85(7.55)   |0.38   |
## |10 |fs.w * insomnia [1]     |             |       |             |       |1.10(2.45)   |0.45   |
## |11 |N                       |92 ID        |92 ID  |92 ID        |NA     |NA           |NA     |
## |12 |Observations            |3798         |3798   |3798         |NA     |NA           |NA     |
## |6  |SD (Intercept)          |34.53(NA)    |       |34.51(NA)    |       |34.47(NA)    |       |
## |7  |SD (Observations)       |7.76(NA)     |       |7.76(NA)     |       |7.76(NA)     |       |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc

  • model M5 including prior-day stress, worry, PsyDist, and fs.w, and model M6 with next-day stress are associated with a significant LRT and stronger evidence in terms of Aw (also characterizing prior-day mood and next-day PsyDist), compared to the baseline model

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for prior-day stress worry, PsyDist, and fs.w, and for next-day stress and PsyDist, while mood did not show substantial direct or inverse effects

  • overall, the results are highly consistent with those reported for TIB


WASO

In section 5.1, WASO was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (shorter WASO for later than usual SO), weekday.sleep (longer WASO during weekend), and age (longer WASO for older adolescents).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WASO by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","weekday.sleep","age",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  
  
  # saving key results (considering M3 for stress and PsyDist which showed higher Aw than M2 for all predictors)
  key.model <- ifelse(diaryVars[i]%in%c("stress","PsyDist","fs.w"),2,1)
  res[[i]] <- rbind(res[[i]],cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors, # day i
                                                          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="age",
                                                          mComp.baseline="age",p.adjust.method="BH",
                                                          outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],
                                                          messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,
                                                                modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                gmc.predictors="age",mComp.baseline="age",p.adjust.method="BH",
                                                                outputs="key.results",key.predictor=keys[2],key.model=keys[2],
                                                                messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,
                                                                  modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                  gmc.predictors="age",mComp.baseline="age",p.adjust.method="BH",
                                                                  outputs="key.results",key.predictor=keys[3],
                                                                  key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="WASO",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors, 
          mComp.baseline="age",p.adjust.method="BH",gmc.predictors="age",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing WASO by stress 
## ###########################################
## 
## Running GLMER analysis of WASO ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): WASO ~ (1|ID)
##  - model M1: WASO ~ SO.num.mc + (1|ID)
##  - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO ~ SO.num.mc + weekday.sleep + age.gmc + (1|ID)
##  - model M4: WASO ~ SO.num.mc + weekday.sleep + age.gmc + stress.mc + (1|ID)
##  - model M5: WASO ~ SO.num.mc + weekday.sleep + age.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M6: WASO ~ SO.num.mc + weekday.sleep + age.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M7: WASO ~ SO.num.mc + weekday.sleep + age.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc      weekday.sleep            age.gmc          stress.mc 
##           1.037417           1.056060           1.061749           2.306709 
##            s.nd.mc           insomnia stress.mc:insomnia 
##           1.077628           1.061786           2.259939 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: s.nd.mc
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline           |    6| 33460.99| 33498.44| -16724.49| 33448.99|     NA| NA|         NA|
## |stress.mc          |    7| 33456.38| 33500.08| -16721.19| 33442.38|  6.609|  1|      0.020|
## |s.nd.mc            |    8| 33448.34| 33498.28| -16716.17| 33432.34| 10.044|  1|      0.006|
## |insomnia           |    9| 33448.87| 33505.05| -16715.44| 33430.87|  1.464|  1|      0.226|
## |stress.mc:insomnia |   10| 33449.14| 33511.56| -16714.57| 33429.14|  1.732|  1|      0.226|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.091 
##    - stress.mc vs. Baseline model = 0.909
##    - s.nd.mc = 0.981
##    - insomnia = 0.429
##    - stress.mc:insomnia = 0.273
##    Selected model based on Aw: s.nd.mc
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)              |46.38(1.15) |40.23  |46.45(1.15) |40.29  |45.03(1.63) |27.56  |
## |3  |SO.num.mc                |-5.46(0.28) |-19.35 |-5.49(0.28) |-19.46 |-5.48(0.28) |-19.45 |
## |4  |weekday.sleep [weekend]  |6.03(0.72)  |8.40   |5.76(0.72)  |7.99   |5.75(0.72)  |7.98   |
## |5  |age.gmc                  |2.19(1.20)  |1.83   |2.19(1.20)  |1.83   |2.55(1.22)  |2.08   |
## |6  |stress.mc                |-0.88(0.34) |-2.57  |-0.63(0.35) |-1.80  |-1.13(0.52) |-2.19  |
## |9  |s.nd.mc                  |            |       |-1.12(0.35) |-3.17  |-1.14(0.35) |-3.21  |
## |10 |insomnia [1]             |            |       |            |       |2.82(2.32)  |1.21   |
## |11 |stress.mc * insomnia [1] |            |       |            |       |0.90(0.69)  |1.32   |
## |12 |N                        |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |13 |Observations             |3798        |3798   |3798        |NA     |NA          |NA     |
## |7  |SD (Intercept)           |10.32(NA)   |       |10.32(NA)   |       |10.23(NA)   |       |
## |8  |SD (Observations)        |4.38(NA)    |       |4.38(NA)    |       |4.38(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WASO by worry 
## ###########################################
## 
## Running GLMER analysis of WASO ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): WASO ~ (1|ID)
##  - model M1: WASO ~ SO.num.mc + (1|ID)
##  - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO ~ SO.num.mc + weekday.sleep + age.gmc + (1|ID)
##  - model M4: WASO ~ SO.num.mc + weekday.sleep + age.gmc + worry.mc + (1|ID)
##  - model M5: WASO ~ SO.num.mc + weekday.sleep + age.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M6: WASO ~ SO.num.mc + weekday.sleep + age.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M7: WASO ~ SO.num.mc + weekday.sleep + age.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: worry.mc
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    6| 33460.99| 33498.44| -16724.49| 33448.99|    NA| NA|         NA|
## |worry.mc          |    7| 33455.65| 33499.35| -16720.83| 33441.65| 7.337|  1|      0.027|
## |w.nd.mc           |    8| 33457.63| 33507.57| -16720.81| 33441.63| 0.025|  1|      0.983|
## |insomnia          |    9| 33458.17| 33514.35| -16720.08| 33440.17| 1.459|  1|      0.454|
## |worry.mc:insomnia |   10| 33460.17| 33522.59| -16720.08| 33440.17| 0.000|  1|      0.983|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.065 
##    - worry.mc vs. Baseline model = 0.935
##    - w.nd.mc = 0.258
##    - insomnia = 0.165
##    - worry.mc:insomnia = 0.057
##    Selected model based on Aw: worry.mc
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)             |46.39(1.15) |40.24  |46.39(1.15) |40.24  |44.97(1.63) |27.53  |
## |3  |SO.num.mc               |-5.46(0.28) |-19.36 |-5.46(0.28) |-19.35 |-5.46(0.28) |-19.35 |
## |4  |weekday.sleep [weekend] |5.98(0.72)  |8.32   |5.98(0.72)  |8.32   |5.98(0.72)  |8.31   |
## |5  |age.gmc                 |2.19(1.20)  |1.83   |2.19(1.20)  |1.83   |2.55(1.22)  |2.08   |
## |6  |worry.mc                |-0.96(0.35) |-2.71  |-0.97(0.36) |-2.69  |-0.96(0.53) |-1.82  |
## |9  |w.nd.mc                 |            |       |0.06(0.36)  |0.16   |0.06(0.36)  |0.16   |
## |10 |insomnia [1]            |            |       |            |       |2.82(2.32)  |1.21   |
## |11 |worry.mc * insomnia [1] |            |       |            |       |-0.01(0.71) |-0.02  |
## |12 |N                       |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |13 |Observations            |3798        |3798   |3798        |NA     |NA          |NA     |
## |7  |SD (Intercept)          |10.32(NA)   |       |10.32(NA)   |       |10.23(NA)   |       |
## |8  |SD (Observations)       |4.38(NA)    |       |4.38(NA)    |       |4.38(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WASO by mood 
## ###########################################
## 
## Running GLMER analysis of WASO ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): WASO ~ (1|ID)
##  - model M1: WASO ~ SO.num.mc + (1|ID)
##  - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO ~ SO.num.mc + weekday.sleep + age.gmc + (1|ID)
##  - model M4: WASO ~ SO.num.mc + weekday.sleep + age.gmc + mood.mc + (1|ID)
##  - model M5: WASO ~ SO.num.mc + weekday.sleep + age.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M6: WASO ~ SO.num.mc + weekday.sleep + age.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M7: WASO ~ SO.num.mc + weekday.sleep + age.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    6| 33460.99| 33498.44| -16724.49| 33448.99|    NA| NA|         NA|
## |mood.mc          |    7| 33462.06| 33505.75| -16724.03| 33448.06| 0.933|  1|      0.668|
## |m.nd.mc          |    8| 33463.92| 33513.86| -16723.96| 33447.92| 0.134|  1|      0.952|
## |insomnia         |    9| 33464.47| 33520.65| -16723.23| 33446.47| 1.456|  1|      0.668|
## |mood.mc:insomnia |   10| 33466.46| 33528.89| -16723.23| 33446.46| 0.001|  1|      0.972|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.63 
##    - mood.mc vs. Baseline model = 0.37
##    - m.nd.mc = 0.127
##    - insomnia = 0.088
##    - mood.mc:insomnia = 0.031
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)             |46.35(1.15) |40.21  |46.35(1.15) |40.21  |44.93(1.63) |27.50  |
## |3  |SO.num.mc               |-5.44(0.28) |-19.25 |-5.44(0.28) |-19.25 |-5.44(0.28) |-19.25 |
## |4  |weekday.sleep [weekend] |6.13(0.72)  |8.55   |6.14(0.72)  |8.55   |6.13(0.72)  |8.55   |
## |5  |age.gmc                 |2.19(1.20)  |1.83   |2.19(1.20)  |1.83   |2.55(1.22)  |2.08   |
## |6  |mood.mc                 |-0.35(0.36) |-0.97  |-0.36(0.36) |-1.00  |-0.35(0.55) |-0.63  |
## |9  |m.nd.mc                 |            |       |0.13(0.36)  |0.37   |0.13(0.36)  |0.37   |
## |10 |insomnia [1]            |            |       |            |       |2.81(2.32)  |1.21   |
## |11 |mood.mc * insomnia [1]  |            |       |            |       |-0.03(0.72) |-0.03  |
## |12 |N                       |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |13 |Observations            |3798        |3798   |3798        |NA     |NA          |NA     |
## |7  |SD (Intercept)          |10.32(NA)   |       |10.32(NA)   |       |10.23(NA)   |       |
## |8  |SD (Observations)       |4.38(NA)    |       |4.38(NA)    |       |4.38(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WASO by PsyDist 
## ###########################################
## 
## Running GLMER analysis of WASO ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): WASO ~ (1|ID)
##  - model M1: WASO ~ SO.num.mc + (1|ID)
##  - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO ~ SO.num.mc + weekday.sleep + age.gmc + (1|ID)
##  - model M4: WASO ~ SO.num.mc + weekday.sleep + age.gmc + PsyDist.mc + (1|ID)
##  - model M5: WASO ~ SO.num.mc + weekday.sleep + age.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M6: WASO ~ SO.num.mc + weekday.sleep + age.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M7: WASO ~ SO.num.mc + weekday.sleep + age.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: PsyDist.mc
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    6| 33460.99| 33498.44| -16724.49| 33448.99|    NA| NA|         NA|
## |PsyDist.mc          |    7| 33455.51| 33499.20| -16720.75| 33441.51| 7.483|  1|      0.025|
## |P.nd.mc             |    8| 33456.60| 33506.54| -16720.30| 33440.60| 0.906|  1|      0.455|
## |insomnia            |    9| 33457.14| 33513.32| -16719.57| 33439.14| 1.463|  1|      0.453|
## |PsyDist.mc:insomnia |   10| 33458.64| 33521.06| -16719.32| 33438.64| 0.497|  1|      0.481|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.061 
##    - PsyDist.mc vs. Baseline model = 0.939
##    - P.nd.mc = 0.352
##    - insomnia = 0.212
##    - PsyDist.mc:insomnia = 0.091
##    Selected model based on Aw: PsyDist.mc
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)               |46.41(1.15) |40.28  |46.42(1.15) |40.28  |45.01(1.63) |27.56  |
## |3  |SO.num.mc                 |-5.48(0.28) |-19.40 |-5.48(0.28) |-19.41 |-5.48(0.28) |-19.40 |
## |4  |weekday.sleep [weekend]   |5.96(0.72)  |8.28   |5.91(0.72)  |8.20   |5.90(0.72)  |8.18   |
## |5  |age.gmc                   |2.20(1.20)  |1.84   |2.20(1.20)  |1.84   |2.56(1.22)  |2.09   |
## |6  |PsyDist.mc                |-1.25(0.46) |-2.74  |-1.12(0.47) |-2.37  |-1.50(0.71) |-2.11  |
## |9  |P.nd.mc                   |            |       |-0.45(0.47) |-0.95  |-0.46(0.47) |-0.97  |
## |10 |insomnia [1]              |            |       |            |       |2.81(2.32)  |1.21   |
## |11 |PsyDist.mc * insomnia [1] |            |       |            |       |0.64(0.91)  |0.71   |
## |12 |N                         |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |13 |Observations              |3798        |3798   |3798        |NA     |NA          |NA     |
## |7  |SD (Intercept)            |10.32(NA)   |       |10.32(NA)   |       |10.22(NA)   |       |
## |8  |SD (Observations)         |4.38(NA)    |       |4.38(NA)    |       |4.38(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WASO by fs.w 
## ###########################################
## 
## Running GLMER analysis of WASO ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): WASO ~ (1|ID)
##  - model M1: WASO ~ SO.num.mc + (1|ID)
##  - model M2: WASO ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO ~ SO.num.mc + weekday.sleep + age.gmc + (1|ID)
##  - model M4: WASO ~ SO.num.mc + weekday.sleep + age.gmc + fs.w + (1|ID)
##  - model M5: WASO ~ SO.num.mc + weekday.sleep + age.gmc + fs.w + f.nd + (1|ID)
##  - model M6: WASO ~ SO.num.mc + weekday.sleep + age.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M7: WASO ~ SO.num.mc + weekday.sleep + age.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: fs.w
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    6| 33460.99| 33498.44| -16724.49| 33448.99|    NA| NA|         NA|
## |fs.w          |    7| 33455.69| 33499.38| -16720.84| 33441.69| 7.302|  1|      0.028|
## |f.nd          |    8| 33457.35| 33507.29| -16720.68| 33441.35| 0.334|  1|      0.598|
## |insomnia      |    9| 33457.90| 33514.08| -16719.95| 33439.90| 1.450|  1|      0.457|
## |fs.w:insomnia |   10| 33459.63| 33522.05| -16719.81| 33439.63| 0.278|  1|      0.598|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.066 
##    - fs.w vs. Baseline model = 0.934
##    - f.nd = 0.289
##    - insomnia = 0.18
##    - fs.w:insomnia = 0.071
##    Selected model based on Aw: fs.w
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)             |46.41(1.15) |40.28  |46.42(1.15) |40.29  |45.01(1.63) |27.56  |
## |3  |SO.num.mc               |-5.48(0.28) |-19.39 |-5.48(0.28) |-19.40 |-5.48(0.28) |-19.39 |
## |4  |weekday.sleep [weekend] |5.96(0.72)  |8.28   |5.94(0.72)  |8.24   |5.92(0.72)  |8.22   |
## |5  |age.gmc                 |2.20(1.20)  |1.84   |2.20(1.20)  |1.84   |2.55(1.22)  |2.09   |
## |6  |fs.w                    |-1.05(0.39) |-2.70  |-0.99(0.40) |-2.46  |-1.23(0.60) |-2.03  |
## |9  |f.nd                    |            |       |-0.23(0.40) |-0.58  |-0.24(0.40) |-0.59  |
## |10 |insomnia [1]            |            |       |            |       |2.80(2.32)  |1.21   |
## |11 |fs.w * insomnia [1]     |            |       |            |       |0.41(0.78)  |0.53   |
## |12 |N                       |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |13 |Observations            |3798        |3798   |3798        |NA     |NA          |NA     |
## |7  |SD (Intercept)          |10.32(NA)   |       |10.32(NA)   |       |10.22(NA)   |       |
## |8  |SD (Observations)       |4.38(NA)    |       |4.38(NA)    |       |4.38(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 7


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • model M5 including prior-day stress, worry, PsyDist, and fs.w, and model M6 with next-day stress are associated with a significant LRT and stronger evidence in terms of Aw, compared to the baseline model

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for prior-day worry, PsyDist, and fs.w, and for next-day stress, while the direct effect of stress was no more subtantial after the inclusion of next-day stress, and mood did not show substantial direct or inverse effects


SE

In section 5.1, SE was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by SO.num (higher SE for later than usual SO).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing SE by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","age",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }

  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="SE",glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors, # day i
                                                        modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="age",
                                                        mComp.baseline="age",p.adjust.method="BH",
                                                        outputs="key.results",key.predictor=keys[1],key.model=keys[1],
                                                        messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="SE",glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,
                                                              modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                              gmc.predictors="age", mComp.baseline="age",p.adjust.method="BH",
                                                              outputs="key.results",key.predictor=keys[2],key.model=keys[2],
                                                              messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="SE",glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,
                                                                modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                gmc.predictors="age",mComp.baseline="age",p.adjust.method="BH",
                                                                outputs="key.results",key.predictor=keys[3],key.model=keys[3],
                                                                messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="SE",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors, 
          mComp.baseline="age",p.adjust.method="BH",gmc.predictors="age",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing SE by stress 
## ###########################################
## 
## Running GLMER analysis of SE ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): SE ~ (1|ID)
##  - model M1: SE ~ SO.num.mc + (1|ID)
##  - model M2: SE ~ SO.num.mc + age.gmc + (1|ID)
##  - model M3: SE ~ SO.num.mc + age.gmc + stress.mc + (1|ID)
##  - model M4: SE ~ SO.num.mc + age.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M5: SE ~ SO.num.mc + age.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: SE ~ SO.num.mc + age.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SE on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc            age.gmc          stress.mc            s.nd.mc 
##           1.007064           1.061799           2.302333           1.062996 
##           insomnia stress.mc:insomnia 
##           1.061799           2.259866 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    5| 20357.07| 20388.28| -10173.54| 20347.07|    NA| NA|         NA|
## |stress.mc          |    6| 20359.01| 20396.46| -10173.50| 20347.01| 0.068|  1|      0.795|
## |s.nd.mc            |    7| 20360.73| 20404.43| -10173.37| 20346.73| 0.275|  1|      0.795|
## |insomnia           |    8| 20361.48| 20411.42| -10172.74| 20345.48| 1.248|  1|      0.795|
## |stress.mc:insomnia |    9| 20363.41| 20419.59| -10172.70| 20345.41| 0.075|  1|      0.795|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.724 
##    - stress.mc vs. Baseline model = 0.276
##    - s.nd.mc = 0.104
##    - insomnia = 0.067
##    - stress.mc:insomnia = 0.025
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)              |88.52(0.20) |441.11 |88.52(0.20) |441.11 |88.75(0.29) |309.00 |
## |3  |SO.num.mc                |0.15(0.05)  |3.11   |0.16(0.05)  |3.13   |0.16(0.05)  |3.13   |
## |4  |age.gmc                  |-0.48(0.21) |-2.27  |-0.48(0.21) |-2.27  |-0.54(0.22) |-2.48  |
## |5  |stress.mc                |-0.02(0.06) |-0.26  |-0.02(0.06) |-0.38  |-0.01(0.09) |-0.05  |
## |8  |s.nd.mc                  |            |       |0.03(0.06)  |0.52   |0.03(0.06)  |0.53   |
## |9  |insomnia [1]             |            |       |            |       |-0.46(0.41) |-1.12  |
## |10 |stress.mc * insomnia [1] |            |       |            |       |-0.03(0.12) |-0.27  |
## |11 |N                        |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |12 |Observations             |3798        |3798   |3798        |NA     |NA          |NA     |
## |6  |SD (Intercept)           |1.82(NA)    |       |1.82(NA)    |       |1.81(NA)    |       |
## |7  |SD (Observations)        |1.85(NA)    |       |1.85(NA)    |       |1.85(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SE by worry 
## ###########################################
## 
## Running GLMER analysis of SE ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): SE ~ (1|ID)
##  - model M1: SE ~ SO.num.mc + (1|ID)
##  - model M2: SE ~ SO.num.mc + age.gmc + (1|ID)
##  - model M3: SE ~ SO.num.mc + age.gmc + worry.mc + (1|ID)
##  - model M4: SE ~ SO.num.mc + age.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M5: SE ~ SO.num.mc + age.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: SE ~ SO.num.mc + age.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SE on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    5| 20357.07| 20388.28| -10173.54| 20347.07|    NA| NA|         NA|
## |worry.mc          |    6| 20358.80| 20396.26| -10173.40| 20346.80| 0.271|  1|       0.87|
## |w.nd.mc           |    7| 20360.77| 20404.47| -10173.39| 20346.77| 0.031|  1|       0.87|
## |insomnia          |    8| 20361.52| 20411.46| -10172.76| 20345.52| 1.248|  1|       0.87|
## |worry.mc:insomnia |    9| 20363.50| 20419.68| -10172.75| 20345.50| 0.027|  1|       0.87|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.704 
##    - worry.mc vs. Baseline model = 0.296
##    - w.nd.mc = 0.1
##    - insomnia = 0.064
##    - worry.mc:insomnia = 0.023
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)             |88.52(0.20) |441.11 |88.52(0.20) |441.11 |88.75(0.29) |309.00 |
## |3  |SO.num.mc               |0.16(0.05)  |3.16   |0.16(0.05)  |3.16   |0.16(0.05)  |3.16   |
## |4  |age.gmc                 |-0.48(0.21) |-2.27  |-0.48(0.21) |-2.27  |-0.54(0.22) |-2.48  |
## |5  |worry.mc                |0.03(0.06)  |0.52   |0.03(0.06)  |0.47   |0.04(0.09)  |0.44   |
## |8  |w.nd.mc                 |            |       |0.01(0.06)  |0.18   |0.01(0.06)  |0.18   |
## |9  |insomnia [1]            |            |       |            |       |-0.46(0.41) |-1.12  |
## |10 |worry.mc * insomnia [1] |            |       |            |       |-0.02(0.13) |-0.16  |
## |11 |N                       |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |12 |Observations            |3798        |3798   |3798        |NA     |NA          |NA     |
## |6  |SD (Intercept)          |1.82(NA)    |       |1.82(NA)    |       |1.81(NA)    |       |
## |7  |SD (Observations)       |1.85(NA)    |       |1.85(NA)    |       |1.85(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SE by mood 
## ###########################################
## 
## Running GLMER analysis of SE ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): SE ~ (1|ID)
##  - model M1: SE ~ SO.num.mc + (1|ID)
##  - model M2: SE ~ SO.num.mc + age.gmc + (1|ID)
##  - model M3: SE ~ SO.num.mc + age.gmc + mood.mc + (1|ID)
##  - model M4: SE ~ SO.num.mc + age.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M5: SE ~ SO.num.mc + age.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: SE ~ SO.num.mc + age.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SE on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    5| 20357.07| 20388.28| -10173.54| 20347.07|    NA| NA|         NA|
## |mood.mc          |    6| 20358.83| 20396.28| -10173.42| 20346.83| 0.243|  1|      0.622|
## |m.nd.mc          |    7| 20360.42| 20404.11| -10173.21| 20346.42| 0.413|  1|      0.622|
## |insomnia         |    8| 20361.17| 20411.11| -10172.58| 20345.17| 1.248|  1|      0.622|
## |mood.mc:insomnia |    9| 20362.89| 20419.07| -10172.45| 20344.89| 0.275|  1|      0.622|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.706 
##    - mood.mc vs. Baseline model = 0.294
##    - m.nd.mc = 0.117
##    - insomnia = 0.074
##    - mood.mc:insomnia = 0.03
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors             |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:----------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)            |88.52(0.20) |441.11 |88.52(0.20) |441.11 |88.75(0.29) |309.00 |
## |3  |SO.num.mc              |0.16(0.05)  |3.16   |0.16(0.05)  |3.16   |0.16(0.05)  |3.16   |
## |4  |age.gmc                |-0.48(0.21) |-2.27  |-0.48(0.21) |-2.27  |-0.54(0.22) |-2.48  |
## |5  |mood.mc                |0.03(0.06)  |0.49   |0.04(0.06)  |0.56   |-0.00(0.10) |-0.03  |
## |8  |m.nd.mc                |            |       |-0.04(0.06) |-0.64  |-0.04(0.06) |-0.65  |
## |9  |insomnia [1]           |            |       |            |       |-0.46(0.41) |-1.12  |
## |10 |mood.mc * insomnia [1] |            |       |            |       |0.07(0.13)  |0.52   |
## |11 |N                      |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |12 |Observations           |3798        |3798   |3798        |NA     |NA          |NA     |
## |6  |SD (Intercept)         |1.82(NA)    |       |1.82(NA)    |       |1.81(NA)    |       |
## |7  |SD (Observations)      |1.85(NA)    |       |1.85(NA)    |       |1.85(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SE by PsyDist 
## ###########################################
## 
## Running GLMER analysis of SE ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): SE ~ (1|ID)
##  - model M1: SE ~ SO.num.mc + (1|ID)
##  - model M2: SE ~ SO.num.mc + age.gmc + (1|ID)
##  - model M3: SE ~ SO.num.mc + age.gmc + PsyDist.mc + (1|ID)
##  - model M4: SE ~ SO.num.mc + age.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: SE ~ SO.num.mc + age.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: SE ~ SO.num.mc + age.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SE on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    5| 20357.07| 20388.28| -10173.54| 20347.07|    NA| NA|         NA|
## |PsyDist.mc          |    6| 20358.94| 20396.40| -10173.47| 20346.94| 0.131|  1|      0.979|
## |P.nd.mc             |    7| 20360.94| 20404.64| -10173.47| 20346.94| 0.001|  1|      0.979|
## |insomnia            |    8| 20361.69| 20411.63| -10172.85| 20345.69| 1.248|  1|      0.979|
## |PsyDist.mc:insomnia |    9| 20363.69| 20419.87| -10172.85| 20345.69| 0.001|  1|      0.979|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.718 
##    - PsyDist.mc vs. Baseline model = 0.282
##    - P.nd.mc = 0.094
##    - insomnia = 0.061
##    - PsyDist.mc:insomnia = 0.022
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-------------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)               |88.52(0.20) |441.16 |88.52(0.20) |441.16 |88.75(0.29) |309.04 |
## |3  |SO.num.mc                 |0.16(0.05)  |3.15   |0.16(0.05)  |3.15   |0.16(0.05)  |3.15   |
## |4  |age.gmc                   |-0.48(0.21) |-2.27  |-0.48(0.21) |-2.27  |-0.54(0.22) |-2.48  |
## |5  |PsyDist.mc                |0.03(0.08)  |0.36   |0.03(0.08)  |0.36   |0.03(0.13)  |0.26   |
## |8  |P.nd.mc                   |            |       |-0.00(0.08) |-0.03  |-0.00(0.08) |-0.03  |
## |9  |insomnia [1]              |            |       |            |       |-0.46(0.41) |-1.12  |
## |10 |PsyDist.mc * insomnia [1] |            |       |            |       |-0.00(0.16) |-0.03  |
## |11 |N                         |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |12 |Observations              |3798        |3798   |3798        |NA     |NA          |NA     |
## |6  |SD (Intercept)            |1.82(NA)    |       |1.82(NA)    |       |1.81(NA)    |       |
## |7  |SD (Observations)         |1.85(NA)    |       |1.85(NA)    |       |1.85(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SE by fs.w 
## ###########################################
## 
## Running GLMER analysis of SE ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering age
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): SE ~ (1|ID)
##  - model M1: SE ~ SO.num.mc + (1|ID)
##  - model M2: SE ~ SO.num.mc + age.gmc + (1|ID)
##  - model M3: SE ~ SO.num.mc + age.gmc + fs.w + (1|ID)
##  - model M4: SE ~ SO.num.mc + age.gmc + fs.w + f.nd + (1|ID)
##  - model M5: SE ~ SO.num.mc + age.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: SE ~ SO.num.mc + age.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of SE on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    5| 20357.07| 20388.28| -10173.54| 20347.07|    NA| NA|         NA|
## |fs.w          |    6| 20358.87| 20396.33| -10173.44| 20346.87| 0.200|  1|      0.996|
## |f.nd          |    7| 20360.87| 20404.56| -10173.43| 20346.87| 0.005|  1|      0.996|
## |insomnia      |    8| 20361.62| 20411.56| -10172.81| 20345.62| 1.248|  1|      0.996|
## |fs.w:insomnia |    9| 20363.62| 20419.80| -10172.81| 20345.62| 0.000|  1|      0.996|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.711 
##    - fs.w vs. Baseline model = 0.289
##    - f.nd = 0.096
##    - insomnia = 0.062
##    - fs.w:insomnia = 0.022
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors          |B (SE)      |t      |B (SE)      |t      |B (SE)      |t      |
## |:--|:-------------------|:-----------|:------|:-----------|:------|:-----------|:------|
## |2  |(Intercept)         |88.52(0.20) |441.15 |88.52(0.20) |441.15 |88.75(0.29) |309.03 |
## |3  |SO.num.mc           |0.16(0.05)  |3.16   |0.16(0.05)  |3.16   |0.16(0.05)  |3.16   |
## |4  |age.gmc             |-0.48(0.21) |-2.27  |-0.48(0.21) |-2.27  |-0.54(0.22) |-2.48  |
## |5  |fs.w                |0.03(0.07)  |0.45   |0.03(0.07)  |0.45   |0.03(0.11)  |0.30   |
## |8  |f.nd                |            |       |-0.01(0.07) |-0.07  |-0.01(0.07) |-0.08  |
## |9  |insomnia [1]        |            |       |            |       |-0.46(0.41) |-1.12  |
## |10 |fs.w * insomnia [1] |            |       |            |       |-0.00(0.14) |-0.00  |
## |11 |N                   |92 ID       |92 ID  |92 ID       |NA     |NA          |NA     |
## |12 |Observations        |3798        |3798   |3798        |NA     |NA          |NA     |
## |6  |SD (Intercept)      |1.82(NA)    |       |1.82(NA)    |       |1.81(NA)    |       |
## |7  |SD (Observations)   |1.85(NA)    |       |1.85(NA)    |       |1.85(NA)    |       |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed, although a marked deviation from normality can be seen in the lower tail of the residuals distribution (i.e., SE is bounded at 100), with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • none of the specified models shows significant LRT or stronger evidence in terms of Aw, compared to the baseline model

  • coherently, none of the additional predictors shows a substantial effect


light.p

In section 5.1, light.p was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by BMI (lower light.p for participants with higher BMI).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing light.p by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
  
  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="light.p",glmerAn(long=ema,wide=demos,resp="light.p",fix.eff=predictors,
                                                             modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                             gmc.predictors="BMI",mComp.baseline="BMI",p.adjust.method="BH",
                                                             outputs="key.results",key.predictor=keys[1],key.model=keys[1],
                                                             messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="light.p",glmerAn(long=ema,wide=demos,resp="light.p",
                                                                   fix.eff=predictors, # day i+1
                                                                   modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                   gmc.predictors="BMI",mComp.baseline="BMI",p.adjust.method="BH",
                                                                   outputs="key.results",key.predictor=keys[2],key.model=keys[2],
                                                                   messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="light.p",glmerAn(long=ema,wide=demos,resp="light.p",fix.eff=predictors,
                                                                     modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                     gmc.predictors="BMI",
                                                                     mComp.baseline="BMI",p.adjust.method="BH",
                                                                     outputs="key.results",key.predictor=keys[3],
                                                                     key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="light.p",fix.eff=predictors,mComp.baseline="BMI",p.adjust.method="BH",
          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing light.p by stress 
## ###########################################
## 
## Running GLMER analysis of light.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering stress , s.nd
## 
## Model specification:
##  - model M0 (null): light.p ~ (1|ID)
##  - model M1: light.p ~ BMI.gmc + (1|ID)
##  - model M2: light.p ~ BMI.gmc + stress.mc + (1|ID)
##  - model M3: light.p ~ BMI.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M4: light.p ~ BMI.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M5: light.p ~ BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of light.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##            BMI.gmc          stress.mc            s.nd.mc           insomnia 
##           1.032617           2.191690           1.062840           1.032617 
## stress.mc:insomnia 
##           2.148493 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    4| 22066.97| 22091.35| -11029.48| 22058.97|    NA| NA|         NA|
## |stress.mc          |    5| 22068.07| 22098.54| -11029.03| 22058.07| 0.902|  1|      0.606|
## |s.nd.mc            |    6| 22070.01| 22106.58| -11029.01| 22058.01| 0.052|  1|      0.819|
## |insomnia           |    7| 22071.00| 22113.66| -11028.50| 22057.00| 1.016|  1|      0.606|
## |stress.mc:insomnia |    8| 22072.44| 22121.19| -11028.22| 22056.44| 0.559|  1|      0.606|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.634 
##    - stress.mc vs. Baseline model = 0.366
##    - s.nd.mc = 0.121
##    - insomnia = 0.069
##    - stress.mc:insomnia = 0.033
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t      |B (SE)      |t      |B (SE)      |t     |
## |:--|:------------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2  |(Intercept)              |58.86(0.49) |119.86 |58.86(0.49) |119.86 |58.35(0.70) |83.53 |
## |3  |BMI.gmc                  |-0.37(0.15) |-2.46  |-0.37(0.15) |-2.46  |-0.35(0.15) |-2.26 |
## |4  |stress.mc                |-0.12(0.13) |-0.95  |-0.13(0.13) |-0.98  |-0.23(0.19) |-1.22 |
## |7  |s.nd.mc                  |            |       |0.03(0.13)  |0.23   |0.03(0.13)  |0.20  |
## |8  |insomnia [1]             |            |       |            |       |1.00(0.99)  |1.01  |
## |9  |stress.mc * insomnia [1] |            |       |            |       |0.19(0.26)  |0.75  |
## |10 |N                        |91 ID       |91 ID  |91 ID       |NA     |NA          |NA    |
## |11 |Observations             |3276        |3276   |3276        |NA     |NA          |NA    |
## |5  |SD (Intercept)           |4.49(NA)    |       |4.49(NA)    |       |4.45(NA)    |      |
## |6  |SD (Observations)        |2.60(NA)    |       |2.60(NA)    |       |2.60(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing light.p by worry 
## ###########################################
## 
## Running GLMER analysis of light.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering worry , w.nd
## 
## Model specification:
##  - model M0 (null): light.p ~ (1|ID)
##  - model M1: light.p ~ BMI.gmc + (1|ID)
##  - model M2: light.p ~ BMI.gmc + worry.mc + (1|ID)
##  - model M3: light.p ~ BMI.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M4: light.p ~ BMI.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M5: light.p ~ BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of light.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    4| 22066.97| 22091.35| -11029.48| 22058.97|    NA| NA|         NA|
## |worry.mc          |    5| 22067.65| 22098.12| -11028.82| 22057.65| 1.320|  1|      0.418|
## |w.nd.mc           |    6| 22069.65| 22106.21| -11028.82| 22057.65| 0.001|  1|      0.971|
## |insomnia          |    7| 22070.63| 22113.29| -11028.32| 22056.63| 1.016|  1|      0.418|
## |worry.mc:insomnia |    8| 22069.01| 22117.77| -11026.50| 22053.01| 3.620|  1|      0.228|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.584 
##    - worry.mc vs. Baseline model = 0.416
##    - w.nd.mc = 0.133
##    - insomnia = 0.075
##    - worry.mc:insomnia = 0.144
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t      |B (SE)      |t      |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2  |(Intercept)             |58.86(0.49) |119.86 |58.86(0.49) |119.86 |58.35(0.70) |83.53 |
## |3  |BMI.gmc                 |-0.37(0.15) |-2.46  |-0.37(0.15) |-2.46  |-0.35(0.15) |-2.26 |
## |4  |worry.mc                |-0.15(0.13) |-1.15  |-0.15(0.14) |-1.12  |0.11(0.19)  |0.58  |
## |7  |w.nd.mc                 |            |       |-0.00(0.14) |-0.04  |-0.00(0.14) |-0.01 |
## |8  |insomnia [1]            |            |       |            |       |1.00(0.99)  |1.01  |
## |9  |worry.mc * insomnia [1] |            |       |            |       |-0.51(0.27) |-1.90 |
## |10 |N                       |91 ID       |91 ID  |91 ID       |NA     |NA          |NA    |
## |11 |Observations            |3276        |3276   |3276        |NA     |NA          |NA    |
## |5  |SD (Intercept)          |4.49(NA)    |       |4.49(NA)    |       |4.45(NA)    |      |
## |6  |SD (Observations)       |2.60(NA)    |       |2.60(NA)    |       |2.60(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing light.p by mood 
## ###########################################
## 
## Running GLMER analysis of light.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering mood , m.nd
## 
## Model specification:
##  - model M0 (null): light.p ~ (1|ID)
##  - model M1: light.p ~ BMI.gmc + (1|ID)
##  - model M2: light.p ~ BMI.gmc + mood.mc + (1|ID)
##  - model M3: light.p ~ BMI.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M4: light.p ~ BMI.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M5: light.p ~ BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of light.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    4| 22066.97| 22091.35| -11029.48| 22058.97|    NA| NA|         NA|
## |mood.mc          |    5| 22068.93| 22099.40| -11029.47| 22058.93| 0.039|  1|      0.843|
## |m.nd.mc          |    6| 22070.58| 22107.14| -11029.29| 22058.58| 0.351|  1|      0.738|
## |insomnia         |    7| 22071.56| 22114.22| -11028.78| 22057.56| 1.016|  1|      0.627|
## |mood.mc:insomnia |    8| 22071.62| 22120.37| -11027.81| 22055.62| 1.943|  1|      0.627|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.727 
##    - mood.mc vs. Baseline model = 0.273
##    - m.nd.mc = 0.107
##    - insomnia = 0.061
##    - mood.mc:insomnia = 0.056
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors             |B (SE)      |t      |B (SE)      |t      |B (SE)      |t     |
## |:--|:----------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2  |(Intercept)            |58.86(0.49) |119.86 |58.86(0.49) |119.86 |58.35(0.70) |83.53 |
## |3  |BMI.gmc                |-0.37(0.15) |-2.46  |-0.37(0.15) |-2.46  |-0.35(0.15) |-2.26 |
## |4  |mood.mc                |-0.03(0.14) |-0.20  |-0.04(0.14) |-0.26  |0.17(0.20)  |0.85  |
## |7  |m.nd.mc                |            |       |0.08(0.14)  |0.59   |0.08(0.14)  |0.59  |
## |8  |insomnia [1]           |            |       |            |       |1.00(0.99)  |1.01  |
## |9  |mood.mc * insomnia [1] |            |       |            |       |-0.38(0.27) |-1.39 |
## |10 |N                      |91 ID       |91 ID  |91 ID       |NA     |NA          |NA    |
## |11 |Observations           |3276        |3276   |3276        |NA     |NA          |NA    |
## |5  |SD (Intercept)         |4.49(NA)    |       |4.49(NA)    |       |4.45(NA)    |      |
## |6  |SD (Observations)      |2.60(NA)    |       |2.60(NA)    |       |2.60(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing light.p by PsyDist 
## ###########################################
## 
## Running GLMER analysis of light.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): light.p ~ (1|ID)
##  - model M1: light.p ~ BMI.gmc + (1|ID)
##  - model M2: light.p ~ BMI.gmc + PsyDist.mc + (1|ID)
##  - model M3: light.p ~ BMI.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M4: light.p ~ BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M5: light.p ~ BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of light.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    4| 22066.97| 22091.35| -11029.48| 22058.97|    NA| NA|         NA|
## |PsyDist.mc          |    5| 22067.94| 22098.42| -11028.97| 22057.94| 1.024|  1|      0.430|
## |P.nd.mc             |    6| 22069.77| 22106.33| -11028.88| 22057.77| 0.175|  1|      0.676|
## |insomnia            |    7| 22070.75| 22113.41| -11028.38| 22056.75| 1.017|  1|      0.430|
## |PsyDist.mc:insomnia |    8| 22071.77| 22120.53| -11027.89| 22055.77| 0.980|  1|      0.430|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.62 
##    - PsyDist.mc vs. Baseline model = 0.38
##    - P.nd.mc = 0.133
##    - insomnia = 0.075
##    - PsyDist.mc:insomnia = 0.043
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t      |B (SE)      |t      |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2  |(Intercept)               |58.86(0.49) |119.86 |58.86(0.49) |119.86 |58.35(0.70) |83.50 |
## |3  |BMI.gmc                   |-0.37(0.15) |-2.46  |-0.37(0.15) |-2.46  |-0.35(0.15) |-2.26 |
## |4  |PsyDist.mc                |-0.17(0.17) |-1.01  |-0.19(0.18) |-1.09  |-0.01(0.26) |-0.03 |
## |7  |P.nd.mc                   |            |       |0.07(0.18)  |0.42   |0.08(0.18)  |0.44  |
## |8  |insomnia [1]              |            |       |            |       |1.01(0.99)  |1.02  |
## |9  |PsyDist.mc * insomnia [1] |            |       |            |       |-0.34(0.34) |-0.99 |
## |10 |N                         |91 ID       |91 ID  |91 ID       |NA     |NA          |NA    |
## |11 |Observations              |3276        |3276   |3276        |NA     |NA          |NA    |
## |5  |SD (Intercept)            |4.49(NA)    |       |4.49(NA)    |       |4.45(NA)    |      |
## |6  |SD (Observations)         |2.60(NA)    |       |2.60(NA)    |       |2.60(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing light.p by fs.w 
## ###########################################
## 
## Running GLMER analysis of light.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Grand-mean-centering BMI
## 
## Model specification:
##  - model M0 (null): light.p ~ (1|ID)
##  - model M1: light.p ~ BMI.gmc + (1|ID)
##  - model M2: light.p ~ BMI.gmc + fs.w + (1|ID)
##  - model M3: light.p ~ BMI.gmc + fs.w + f.nd + (1|ID)
##  - model M4: light.p ~ BMI.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M5: light.p ~ BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of light.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    4| 22066.97| 22091.35| -11029.48| 22058.97|    NA| NA|         NA|
## |fs.w          |    5| 22067.92| 22098.39| -11028.96| 22057.92| 1.050|  1|      0.417|
## |f.nd          |    6| 22069.80| 22106.36| -11028.90| 22057.80| 0.122|  1|      0.727|
## |insomnia      |    7| 22070.78| 22113.44| -11028.39| 22056.78| 1.019|  1|      0.417|
## |fs.w:insomnia |    8| 22071.09| 22119.84| -11027.54| 22055.09| 1.689|  1|      0.417|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.617 
##    - fs.w vs. Baseline model = 0.383
##    - f.nd = 0.13
##    - insomnia = 0.074
##    - fs.w:insomnia = 0.06
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors          |B (SE)      |t      |B (SE)      |t      |B (SE)      |t     |
## |:--|:-------------------|:-----------|:------|:-----------|:------|:-----------|:-----|
## |2  |(Intercept)         |58.86(0.49) |119.87 |58.86(0.49) |119.86 |58.35(0.70) |83.50 |
## |3  |BMI.gmc             |-0.37(0.15) |-2.46  |-0.37(0.15) |-2.46  |-0.35(0.15) |-2.26 |
## |4  |fs.w                |-0.15(0.15) |-1.02  |-0.16(0.15) |-1.08  |0.04(0.22)  |0.20  |
## |7  |f.nd                |            |       |0.05(0.15)  |0.35   |0.06(0.15)  |0.37  |
## |8  |insomnia [1]        |            |       |            |       |1.01(0.99)  |1.02  |
## |9  |fs.w * insomnia [1] |            |       |            |       |-0.38(0.29) |-1.30 |
## |10 |N                   |91 ID       |91 ID  |91 ID       |NA     |NA          |NA    |
## |11 |Observations        |3276        |3276   |3276        |NA     |NA          |NA    |
## |5  |SD (Intercept)      |4.49(NA)    |       |4.49(NA)    |       |4.45(NA)    |      |
## |6  |SD (Observations)   |2.60(NA)    |       |2.60(NA)    |       |2.60(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of both distributions) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • none of the specified models shows significant LRT or stronger evidence in terms of Aw, compared to the baseline model

  • coherently, none of the additional predictors shows a substantial effect


deep.p

In section 5.1, deep.p was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by SOL.num (higher deep.p for later SO than usual).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing deep.p by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) } 
  
  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="deep.p",glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,
                                                            modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                            mComp.baseline="SO.num",p.adjust.method="BH",
                                                            outputs="key.results",key.predictor=keys[1],key.model=keys[1],
                                                            messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="deep.p",glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,
                                                                  modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                  mComp.baseline="SO.num",p.adjust.method="BH",
                                                                  outputs="key.results",key.predictor=keys[2],key.model=keys[2],
                                                                  messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="deep.p",glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,
                                                                    modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                    mComp.baseline="SO.num",p.adjust.method="BH",
                                                                    outputs="key.results",key.predictor=keys[3],key.model=keys[3],
                                                                    messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="deep.p",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
          mComp.baseline="SO.num",p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing deep.p by stress 
## ###########################################
## 
## Running GLMER analysis of deep.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): deep.p ~ (1|ID)
##  - model M1: deep.p ~ SO.num.mc + (1|ID)
##  - model M2: deep.p ~ SO.num.mc + stress.mc + (1|ID)
##  - model M3: deep.p ~ SO.num.mc + stress.mc + s.nd.mc + (1|ID)
##  - model M4: deep.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M5: deep.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of deep.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc          stress.mc            s.nd.mc           insomnia 
##           1.004902           2.192285           1.065317           1.000000 
## stress.mc:insomnia 
##           2.148788 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    4| 19482.72| 19507.10| -9737.362| 19474.72|    NA| NA|         NA|
## |stress.mc          |    5| 19483.67| 19514.15| -9736.836| 19473.67| 1.052|  1|      0.610|
## |s.nd.mc            |    6| 19485.51| 19522.08| -9736.755| 19473.51| 0.162|  1|      0.687|
## |insomnia           |    7| 19487.14| 19529.80| -9736.568| 19473.14| 0.374|  1|      0.687|
## |stress.mc:insomnia |    8| 19487.46| 19536.22| -9735.730| 19471.46| 1.677|  1|      0.610|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.616 
##    - stress.mc vs. Baseline model = 0.384
##    - s.nd.mc = 0.133
##    - insomnia = 0.056
##    - stress.mc:insomnia = 0.045
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)              |19.78(0.29) |68.50 |19.78(0.29) |68.50 |19.95(0.41) |48.80 |
## |3  |SO.num.mc                |0.24(0.07)  |3.25  |0.24(0.07)  |3.27  |0.24(0.07)  |3.26  |
## |4  |stress.mc                |0.09(0.09)  |1.03  |0.08(0.09)  |0.90  |0.20(0.13)  |1.56  |
## |7  |s.nd.mc                  |            |      |0.04(0.09)  |0.40  |0.04(0.09)  |0.44  |
## |8  |insomnia [1]             |            |      |            |      |-0.35(0.58) |-0.61 |
## |9  |stress.mc * insomnia [1] |            |      |            |      |-0.23(0.17) |-1.30 |
## |10 |N                        |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations             |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)           |2.60(NA)    |      |2.60(NA)    |      |2.60(NA)    |      |
## |6  |SD (Observations)        |2.14(NA)    |      |2.14(NA)    |      |2.14(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing deep.p by worry 
## ###########################################
## 
## Running GLMER analysis of deep.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): deep.p ~ (1|ID)
##  - model M1: deep.p ~ SO.num.mc + (1|ID)
##  - model M2: deep.p ~ SO.num.mc + worry.mc + (1|ID)
##  - model M3: deep.p ~ SO.num.mc + worry.mc + w.nd.mc + (1|ID)
##  - model M4: deep.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M5: deep.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of deep.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    4| 19482.72| 19507.10| -9737.362| 19474.72|    NA| NA|         NA|
## |worry.mc          |    5| 19482.98| 19513.45| -9736.490| 19472.98| 1.745|  1|      0.541|
## |w.nd.mc           |    6| 19484.37| 19520.93| -9736.183| 19472.37| 0.613|  1|      0.541|
## |insomnia          |    7| 19485.99| 19528.65| -9735.996| 19471.99| 0.374|  1|      0.541|
## |worry.mc:insomnia |    8| 19487.60| 19536.36| -9735.802| 19471.60| 0.388|  1|      0.541|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.532 
##    - worry.mc vs. Baseline model = 0.468
##    - w.nd.mc = 0.19
##    - insomnia = 0.078
##    - worry.mc:insomnia = 0.033
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |19.78(0.29) |68.50 |19.78(0.29) |68.50 |19.95(0.41) |48.80 |
## |3  |SO.num.mc               |0.24(0.07)  |3.30  |0.24(0.07)  |3.27  |0.24(0.07)  |3.28  |
## |4  |worry.mc                |0.12(0.09)  |1.32  |0.13(0.09)  |1.45  |0.08(0.13)  |0.58  |
## |7  |w.nd.mc                 |            |      |-0.07(0.09) |-0.78 |-0.07(0.09) |-0.79 |
## |8  |insomnia [1]            |            |      |            |      |-0.35(0.58) |-0.61 |
## |9  |worry.mc * insomnia [1] |            |      |            |      |0.11(0.18)  |0.62  |
## |10 |N                       |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations            |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)          |2.60(NA)    |      |2.60(NA)    |      |2.60(NA)    |      |
## |6  |SD (Observations)       |2.14(NA)    |      |2.14(NA)    |      |2.14(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing deep.p by mood 
## ###########################################
## 
## Running GLMER analysis of deep.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): deep.p ~ (1|ID)
##  - model M1: deep.p ~ SO.num.mc + (1|ID)
##  - model M2: deep.p ~ SO.num.mc + mood.mc + (1|ID)
##  - model M3: deep.p ~ SO.num.mc + mood.mc + m.nd.mc + (1|ID)
##  - model M4: deep.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M5: deep.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of deep.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    4| 19482.72| 19507.10| -9737.362| 19474.72|    NA| NA|         NA|
## |mood.mc          |    5| 19484.23| 19514.70| -9737.116| 19474.23| 0.492|  1|      0.721|
## |m.nd.mc          |    6| 19486.12| 19522.69| -9737.063| 19474.12| 0.107|  1|      0.743|
## |insomnia         |    7| 19487.75| 19530.41| -9736.876| 19473.75| 0.374|  1|      0.721|
## |mood.mc:insomnia |    8| 19488.52| 19537.28| -9736.262| 19472.52| 1.228|  1|      0.721|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.68 
##    - mood.mc vs. Baseline model = 0.32
##    - m.nd.mc = 0.11
##    - insomnia = 0.047
##    - mood.mc:insomnia = 0.031
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors             |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)            |19.78(0.29) |68.50 |19.78(0.29) |68.50 |19.95(0.41) |48.80 |
## |3  |SO.num.mc              |0.24(0.07)  |3.25  |0.24(0.07)  |3.25  |0.24(0.07)  |3.26  |
## |4  |mood.mc                |0.07(0.09)  |0.70  |0.07(0.09)  |0.73  |-0.04(0.14) |-0.31 |
## |7  |m.nd.mc                |            |      |-0.03(0.09) |-0.33 |-0.03(0.09) |-0.33 |
## |8  |insomnia [1]           |            |      |            |      |-0.35(0.58) |-0.61 |
## |9  |mood.mc * insomnia [1] |            |      |            |      |0.21(0.19)  |1.11  |
## |10 |N                      |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations           |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)         |2.60(NA)    |      |2.60(NA)    |      |2.60(NA)    |      |
## |6  |SD (Observations)      |2.14(NA)    |      |2.14(NA)    |      |2.14(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing deep.p by PsyDist 
## ###########################################
## 
## Running GLMER analysis of deep.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): deep.p ~ (1|ID)
##  - model M1: deep.p ~ SO.num.mc + (1|ID)
##  - model M2: deep.p ~ SO.num.mc + PsyDist.mc + (1|ID)
##  - model M3: deep.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M4: deep.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M5: deep.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of deep.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    4| 19482.72| 19507.10| -9737.362| 19474.72|    NA| NA|         NA|
## |PsyDist.mc          |    5| 19483.06| 19513.53| -9736.528| 19473.06| 1.669|  1|      0.785|
## |P.nd.mc             |    6| 19484.89| 19521.46| -9736.444| 19472.89| 0.167|  1|      0.910|
## |insomnia            |    7| 19486.51| 19529.18| -9736.258| 19472.51| 0.373|  1|      0.910|
## |PsyDist.mc:insomnia |    8| 19488.51| 19537.26| -9736.254| 19472.51| 0.007|  1|      0.935|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.541 
##    - PsyDist.mc vs. Baseline model = 0.459
##    - P.nd.mc = 0.155
##    - insomnia = 0.064
##    - PsyDist.mc:insomnia = 0.023
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)               |19.78(0.29) |68.48 |19.78(0.29) |68.47 |19.95(0.41) |48.78 |
## |3  |SO.num.mc                 |0.24(0.07)  |3.31  |0.24(0.07)  |3.29  |0.24(0.07)  |3.30  |
## |4  |PsyDist.mc                |0.15(0.12)  |1.29  |0.16(0.12)  |1.35  |0.15(0.18)  |0.88  |
## |7  |P.nd.mc                   |            |      |-0.05(0.12) |-0.41 |-0.05(0.12) |-0.41 |
## |8  |insomnia [1]              |            |      |            |      |-0.35(0.58) |-0.61 |
## |9  |PsyDist.mc * insomnia [1] |            |      |            |      |0.02(0.23)  |0.08  |
## |10 |N                         |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations              |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)            |2.61(NA)    |      |2.61(NA)    |      |2.60(NA)    |      |
## |6  |SD (Observations)         |2.14(NA)    |      |2.14(NA)    |      |2.14(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing deep.p by fs.w 
## ###########################################
## 
## Running GLMER analysis of deep.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): deep.p ~ (1|ID)
##  - model M1: deep.p ~ SO.num.mc + (1|ID)
##  - model M2: deep.p ~ SO.num.mc + fs.w + (1|ID)
##  - model M3: deep.p ~ SO.num.mc + fs.w + f.nd + (1|ID)
##  - model M4: deep.p ~ SO.num.mc + fs.w + f.nd + insomnia + (1|ID)
##  - model M5: deep.p ~ SO.num.mc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of deep.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    4| 19482.72| 19507.10| -9737.362| 19474.72|    NA| NA|         NA|
## |fs.w          |    5| 19483.02| 19513.49| -9736.509| 19473.02| 1.707|  1|      0.743|
## |f.nd          |    6| 19484.74| 19521.30| -9736.368| 19472.74| 0.282|  1|      0.743|
## |insomnia      |    7| 19486.36| 19529.02| -9736.180| 19472.36| 0.375|  1|      0.743|
## |fs.w:insomnia |    8| 19488.25| 19537.01| -9736.126| 19472.25| 0.107|  1|      0.743|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.537 
##    - fs.w vs. Baseline model = 0.463
##    - f.nd = 0.164
##    - insomnia = 0.068
##    - fs.w:insomnia = 0.026
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors          |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)         |19.78(0.29) |68.47 |19.77(0.29) |68.47 |19.95(0.41) |48.78 |
## |3  |SO.num.mc           |0.24(0.07)  |3.31  |0.24(0.07)  |3.30  |0.24(0.07)  |3.30  |
## |4  |fs.w                |0.13(0.10)  |1.31  |0.14(0.10)  |1.40  |0.11(0.15)  |0.73  |
## |7  |f.nd                |            |      |-0.05(0.10) |-0.53 |-0.06(0.10) |-0.54 |
## |8  |insomnia [1]        |            |      |            |      |-0.35(0.58) |-0.61 |
## |9  |fs.w * insomnia [1] |            |      |            |      |0.07(0.20)  |0.33  |
## |10 |N                   |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations        |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)      |2.61(NA)    |      |2.61(NA)    |      |2.60(NA)    |      |
## |6  |SD (Observations)   |2.14(NA)    |      |2.14(NA)    |      |2.14(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term

  • none of the specified models shows significant LRT or stronger evidence in terms of Aw, compared to the baseline model

  • coherently, none of the additional predictors shows a substantial effect


rem.p

In section 5.1, rem.p was modeled by assuming a normal distribution for residuals, and it was only substantially predicted by SOL.num (lower rem.p for later than usual SO).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing rem.p by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) } 
  
  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="rem.p",glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,
                                          modelType=c("GLMER"),mc.predictors=mc.predictors,
                                          mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
                                          outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="rem.p",glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,
                                             modelType=c("GLMER"),mc.predictors=mc.predictors,
                                             mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
                                             outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="rem.p",glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,
                                             modelType=c("GLMER"),mc.predictors=mc.predictors,
                                             mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
                                             outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="rem.p",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
          mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing rem.p by stress 
## ###########################################
## 
## Running GLMER analysis of rem.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): rem.p ~ (1|ID)
##  - model M1: rem.p ~ SO.num.mc + (1|ID)
##  - model M2: rem.p ~ SO.num.mc + stress.mc + (1|ID)
##  - model M3: rem.p ~ SO.num.mc + stress.mc + s.nd.mc + (1|ID)
##  - model M4: rem.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M5: rem.p ~ SO.num.mc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of rem.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc          stress.mc            s.nd.mc           insomnia 
##           1.004902           2.192285           1.065317           1.000000 
## stress.mc:insomnia 
##           2.148788 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    4| 19763.24| 19787.62| -9877.621| 19755.24|    NA| NA|         NA|
## |stress.mc          |    5| 19765.11| 19795.58| -9877.553| 19755.11| 0.135|  1|      0.854|
## |s.nd.mc            |    6| 19766.60| 19803.16| -9877.298| 19754.60| 0.511|  1|      0.854|
## |insomnia           |    7| 19767.25| 19809.91| -9876.625| 19753.25| 1.347|  1|      0.854|
## |stress.mc:insomnia |    8| 19769.22| 19817.97| -9876.608| 19753.22| 0.034|  1|      0.854|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.718 
##    - stress.mc vs. Baseline model = 0.282
##    - s.nd.mc = 0.118
##    - insomnia = 0.079
##    - stress.mc:insomnia = 0.029
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)              |21.36(0.44) |49.11 |21.36(0.44) |49.11 |21.87(0.61) |35.72 |
## |3  |SO.num.mc                |-0.23(0.07) |-3.10 |-0.23(0.07) |-3.13 |-0.23(0.08) |-3.13 |
## |4  |stress.mc                |0.03(0.09)  |0.37  |0.05(0.09)  |0.53  |0.03(0.13)  |0.23  |
## |7  |s.nd.mc                  |            |      |-0.07(0.09) |-0.71 |-0.07(0.09) |-0.72 |
## |8  |insomnia [1]             |            |      |            |      |-1.01(0.86) |-1.17 |
## |9  |stress.mc * insomnia [1] |            |      |            |      |0.03(0.18)  |0.18  |
## |10 |N                        |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations             |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)           |4.04(NA)    |      |4.04(NA)    |      |4.00(NA)    |      |
## |6  |SD (Observations)        |2.17(NA)    |      |2.17(NA)    |      |2.17(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing rem.p by worry 
## ###########################################
## 
## Running GLMER analysis of rem.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): rem.p ~ (1|ID)
##  - model M1: rem.p ~ SO.num.mc + (1|ID)
##  - model M2: rem.p ~ SO.num.mc + worry.mc + (1|ID)
##  - model M3: rem.p ~ SO.num.mc + worry.mc + w.nd.mc + (1|ID)
##  - model M4: rem.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M5: rem.p ~ SO.num.mc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of rem.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    4| 19763.24| 19787.62| -9877.621| 19755.24|    NA| NA|         NA|
## |worry.mc          |    5| 19765.11| 19795.58| -9877.553| 19755.11| 0.136|  1|      0.713|
## |w.nd.mc           |    6| 19766.44| 19803.01| -9877.222| 19754.44| 0.661|  1|      0.555|
## |insomnia          |    7| 19767.10| 19809.76| -9876.549| 19753.10| 1.347|  1|      0.492|
## |worry.mc:insomnia |    8| 19764.60| 19813.36| -9874.302| 19748.60| 4.493|  1|      0.136|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.718 
##    - worry.mc vs. Baseline model = 0.282
##    - w.nd.mc = 0.126
##    - insomnia = 0.084
##    - worry.mc:insomnia = 0.225
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |21.36(0.44) |49.11 |21.36(0.44) |49.11 |21.87(0.61) |35.72 |
## |3  |SO.num.mc               |-0.23(0.08) |-3.09 |-0.23(0.08) |-3.06 |-0.23(0.08) |-3.04 |
## |4  |worry.mc                |0.03(0.09)  |0.37  |0.02(0.10)  |0.19  |-0.19(0.14) |-1.38 |
## |7  |w.nd.mc                 |            |      |0.08(0.10)  |0.81  |0.08(0.10)  |0.79  |
## |8  |insomnia [1]            |            |      |            |      |-1.01(0.86) |-1.17 |
## |9  |worry.mc * insomnia [1] |            |      |            |      |0.39(0.19)  |2.12  |
## |10 |N                       |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations            |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)          |4.04(NA)    |      |4.04(NA)    |      |4.00(NA)    |      |
## |6  |SD (Observations)       |2.17(NA)    |      |2.17(NA)    |      |2.17(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing rem.p by mood 
## ###########################################
## 
## Running GLMER analysis of rem.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): rem.p ~ (1|ID)
##  - model M1: rem.p ~ SO.num.mc + (1|ID)
##  - model M2: rem.p ~ SO.num.mc + mood.mc + (1|ID)
##  - model M3: rem.p ~ SO.num.mc + mood.mc + m.nd.mc + (1|ID)
##  - model M4: rem.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M5: rem.p ~ SO.num.mc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of rem.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    4| 19763.24| 19787.62| -9877.621| 19755.24|    NA| NA|         NA|
## |mood.mc          |    5| 19765.08| 19795.56| -9877.542| 19755.08| 0.158|  1|      0.691|
## |m.nd.mc          |    6| 19766.80| 19803.37| -9877.401| 19754.80| 0.282|  1|      0.691|
## |insomnia         |    7| 19767.45| 19810.12| -9876.727| 19753.45| 1.347|  1|      0.691|
## |mood.mc:insomnia |    8| 19768.60| 19817.36| -9876.303| 19752.60| 0.849|  1|      0.691|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.715 
##    - mood.mc vs. Baseline model = 0.285
##    - m.nd.mc = 0.108
##    - insomnia = 0.072
##    - mood.mc:insomnia = 0.039
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors             |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)            |21.36(0.44) |49.11 |21.36(0.44) |49.11 |21.87(0.61) |35.72 |
## |3  |SO.num.mc              |-0.24(0.08) |-3.14 |-0.24(0.08) |-3.15 |-0.24(0.08) |-3.14 |
## |4  |mood.mc                |-0.04(0.10) |-0.40 |-0.03(0.10) |-0.34 |-0.13(0.14) |-0.91 |
## |7  |m.nd.mc                |            |      |-0.05(0.10) |-0.53 |-0.05(0.10) |-0.53 |
## |8  |insomnia [1]           |            |      |            |      |-1.01(0.86) |-1.17 |
## |9  |mood.mc * insomnia [1] |            |      |            |      |0.18(0.19)  |0.92  |
## |10 |N                      |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations           |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)         |4.04(NA)    |      |4.04(NA)    |      |4.00(NA)    |      |
## |6  |SD (Observations)      |2.17(NA)    |      |2.17(NA)    |      |2.17(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing rem.p by PsyDist 
## ###########################################
## 
## Running GLMER analysis of rem.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): rem.p ~ (1|ID)
##  - model M1: rem.p ~ SO.num.mc + (1|ID)
##  - model M2: rem.p ~ SO.num.mc + PsyDist.mc + (1|ID)
##  - model M3: rem.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M4: rem.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M5: rem.p ~ SO.num.mc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of rem.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    4| 19763.24| 19787.62| -9877.621| 19755.24|    NA| NA|         NA|
## |PsyDist.mc          |    5| 19765.21| 19795.68| -9877.603| 19755.21| 0.036|  1|      0.849|
## |P.nd.mc             |    6| 19767.17| 19803.73| -9877.583| 19755.17| 0.039|  1|      0.849|
## |insomnia            |    7| 19767.82| 19810.48| -9876.909| 19753.82| 1.348|  1|      0.491|
## |PsyDist.mc:insomnia |    8| 19768.02| 19816.78| -9876.012| 19752.02| 1.795|  1|      0.491|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.727 
##    - PsyDist.mc vs. Baseline model = 0.273
##    - P.nd.mc = 0.093
##    - insomnia = 0.063
##    - PsyDist.mc:insomnia = 0.054
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)               |21.36(0.43) |49.11 |21.36(0.43) |49.11 |21.87(0.61) |35.71 |
## |3  |SO.num.mc                 |-0.23(0.08) |-3.09 |-0.23(0.08) |-3.10 |-0.23(0.08) |-3.08 |
## |4  |PsyDist.mc                |0.02(0.12)  |0.19  |0.03(0.13)  |0.24  |-0.15(0.18) |-0.80 |
## |7  |P.nd.mc                   |            |      |-0.02(0.12) |-0.20 |-0.03(0.12) |-0.22 |
## |8  |insomnia [1]              |            |      |            |      |-1.01(0.86) |-1.17 |
## |9  |PsyDist.mc * insomnia [1] |            |      |            |      |0.32(0.24)  |1.34  |
## |10 |N                         |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations              |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)            |4.04(NA)    |      |4.04(NA)    |      |4.00(NA)    |      |
## |6  |SD (Observations)         |2.17(NA)    |      |2.17(NA)    |      |2.17(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing rem.p by fs.w 
## ###########################################
## 
## Running GLMER analysis of rem.p ...
## 
## Preparing data...
##  - Excluding 2943 incomplete observations ( 47.3 % ) in the response var. or in any of the predictors,
##    and 2 participants with no complete variables
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): rem.p ~ (1|ID)
##  - model M1: rem.p ~ SO.num.mc + (1|ID)
##  - model M2: rem.p ~ SO.num.mc + fs.w + (1|ID)
##  - model M3: rem.p ~ SO.num.mc + fs.w + f.nd + (1|ID)
##  - model M4: rem.p ~ SO.num.mc + fs.w + f.nd + insomnia + (1|ID)
##  - model M5: rem.p ~ SO.num.mc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of rem.p on 3276 observations from 91 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    4| 19763.24| 19787.62| -9877.621| 19755.24|    NA| NA|         NA|
## |fs.w          |    5| 19765.21| 19795.68| -9877.603| 19755.21| 0.036|  1|      0.988|
## |f.nd          |    6| 19767.21| 19803.77| -9877.603| 19755.21| 0.000|  1|      0.988|
## |insomnia      |    7| 19767.86| 19810.52| -9876.929| 19753.86| 1.347|  1|      0.491|
## |fs.w:insomnia |    8| 19767.46| 19816.22| -9875.731| 19751.46| 2.397|  1|      0.486|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.728 
##    - fs.w vs. Baseline model = 0.272
##    - f.nd = 0.091
##    - insomnia = 0.062
##    - fs.w:insomnia = 0.07
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors          |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)         |21.36(0.43) |49.11 |21.36(0.43) |49.11 |21.87(0.61) |35.71 |
## |3  |SO.num.mc           |-0.23(0.08) |-3.09 |-0.23(0.08) |-3.09 |-0.23(0.08) |-3.07 |
## |4  |fs.w                |0.02(0.10)  |0.19  |0.02(0.11)  |0.18  |-0.15(0.15) |-1.00 |
## |7  |f.nd                |            |      |0.00(0.11)  |0.02  |-0.00(0.11) |-0.01 |
## |8  |insomnia [1]        |            |      |            |      |-1.01(0.86) |-1.17 |
## |9  |fs.w * insomnia [1] |            |      |            |      |0.32(0.21)  |1.55  |
## |10 |N                   |91 ID       |91 ID |91 ID       |NA    |NA          |NA    |
## |11 |Observations        |3276        |3276  |3276        |NA    |NA          |NA    |
## |5  |SD (Intercept)      |4.04(NA)    |      |4.04(NA)    |      |4.00(NA)    |      |
## |6  |SD (Observations)   |2.17(NA)    |      |2.17(NA)    |      |2.17(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 5


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the residuals distribution) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • none of the specified models shows significant LRT or stronger evidence in terms of Aw, compared to the baseline model

  • coherently, none of the additional predictors shows a substantial effect


1.2. Sleep timing

s.timing variables are modeled by considering the subset of complete s.timing and dailyDiary data, whereas dailyAct data are ignored since none of the s.archit variables was substantially predicted by TotalSteps1000 (i.e., it negatively predicted SO.num but the relationship was small and not supported by the Aw and the LRT). sex is excluded as well, for parsimony, and since it only predicted small differences in SO.num, but not in diary ratings.

s.timing <- c("SO.num","WakeUp.num")

SO.num

In section 5.1, SO.num was modeled by assuming a normal distribution for residuals, and it was substantially predicted by weekday.sleep (later SO.num during weekend), TotalSteps (earlier SO.num in days with more steps than usual), BMI (earlier SO.num for participants with higher BMI), and sex (later SO.num for boys compared to girls). Here, we do not include sex and TotalSteps1000 for parsimony, and because the latter was not selected based on the LRT or the Aw, and showed the less substantial effect in section 5.1.

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing SO.num by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
  
  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="SO.num",glmerAn(long=ema,wide=demos,resp="SO.num",fix.eff=predictors,
                                          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                                          mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
                                          outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="SO.num",glmerAn(long=ema,wide=demos,resp="SO.num",
                                                                  fix.eff=predictors,
                                             modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                                             mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
                                             outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="SO.num",glmerAn(long=ema,wide=demos,resp="SO.num",fix.eff=predictors,
                                          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                                          mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
                                          outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="SO.num",fix.eff=predictors,
          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
          mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing SO.num by stress 
## ###########################################
## 
## Running GLMER analysis of SO.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering stress , s.nd
## 
## Model specification:
##  - model M0 (null): SO.num ~ (1|ID)
##  - model M1: SO.num ~ weekday.sleep + (1|ID)
##  - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + (1|ID)
##  - model M4: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M5: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: SO.num ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##      weekday.sleep            BMI.gmc          stress.mc            s.nd.mc 
##           1.025164           1.030002           2.305676           1.076796 
##           insomnia stress.mc:insomnia 
##           1.030019           2.259677 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: stress.mc
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    5| 11958.27| 11989.48| -5974.136| 11948.27|    NA| NA|         NA|
## |stress.mc          |    6| 11950.81| 11988.27| -5969.407| 11938.81| 9.458|  1|      0.008|
## |s.nd.mc            |    7| 11949.84| 11993.54| -5967.920| 11935.84| 2.973|  1|      0.169|
## |insomnia           |    8| 11951.75| 12001.69| -5967.875| 11935.75| 0.090|  1|      0.764|
## |stress.mc:insomnia |    9| 11953.32| 12009.50| -5967.660| 11935.32| 0.431|  1|      0.682|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.023 
##    - stress.mc vs. Baseline model = 0.977
##    - s.nd.mc = 0.614
##    - insomnia = 0.191
##    - stress.mc:insomnia = 0.08
##    Selected model based on Aw: s.nd.mc
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)              |0.49(0.11)  |4.38  |0.49(0.11)  |4.40  |0.53(0.16)  |3.30  |
## |3  |weekday.sleep [weekend]  |0.45(0.04)  |10.87 |0.44(0.04)  |10.58 |0.44(0.04)  |10.58 |
## |4  |BMI.gmc                  |-0.09(0.03) |-2.47 |-0.09(0.03) |-2.47 |-0.09(0.04) |-2.49 |
## |5  |stress.mc                |-0.06(0.02) |-3.08 |-0.05(0.02) |-2.61 |-0.04(0.03) |-1.29 |
## |8  |s.nd.mc                  |            |      |-0.04(0.02) |-1.72 |-0.04(0.02) |-1.70 |
## |9  |insomnia [1]             |            |      |            |      |-0.07(0.23) |-0.30 |
## |10 |stress.mc * insomnia [1] |            |      |            |      |-0.03(0.04) |-0.66 |
## |11 |N                        |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |12 |Observations             |3798        |3798  |3798        |NA    |NA          |NA    |
## |6  |SD (Intercept)           |1.05(NA)    |      |1.05(NA)    |      |1.05(NA)    |      |
## |7  |SD (Observations)        |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SO.num by worry 
## ###########################################
## 
## Running GLMER analysis of SO.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering worry , w.nd
## 
## Model specification:
##  - model M0 (null): SO.num ~ (1|ID)
##  - model M1: SO.num ~ weekday.sleep + (1|ID)
##  - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + (1|ID)
##  - model M4: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M5: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: SO.num ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: worry.mc
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    5| 11958.27| 11989.48| -5974.136| 11948.27|    NA| NA|         NA|
## |worry.mc          |    6| 11952.09| 11989.54| -5970.045| 11940.09| 8.181|  1|      0.017|
## |w.nd.mc           |    7| 11952.30| 11996.00| -5969.151| 11938.30| 1.788|  1|      0.362|
## |insomnia          |    8| 11954.21| 12004.15| -5969.106| 11938.21| 0.090|  1|      0.764|
## |worry.mc:insomnia |    9| 11956.04| 12012.22| -5969.019| 11938.04| 0.175|  1|      0.764|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.043 
##    - worry.mc vs. Baseline model = 0.957
##    - w.nd.mc = 0.462
##    - insomnia = 0.151
##    - worry.mc:insomnia = 0.057
##    Selected model based on Aw: worry.mc
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |0.49(0.11)  |4.38  |0.49(0.11)  |4.38  |0.53(0.16)  |3.30  |
## |3  |weekday.sleep [weekend] |0.45(0.04)  |10.80 |0.44(0.04)  |10.77 |0.44(0.04)  |10.78 |
## |4  |BMI.gmc                 |-0.09(0.03) |-2.47 |-0.09(0.03) |-2.47 |-0.09(0.04) |-2.49 |
## |5  |worry.mc                |-0.06(0.02) |-2.86 |-0.05(0.02) |-2.53 |-0.04(0.03) |-1.42 |
## |8  |w.nd.mc                 |            |      |-0.03(0.02) |-1.34 |-0.03(0.02) |-1.32 |
## |9  |insomnia [1]            |            |      |            |      |-0.07(0.23) |-0.30 |
## |10 |worry.mc * insomnia [1] |            |      |            |      |-0.02(0.04) |-0.42 |
## |11 |N                       |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |12 |Observations            |3798        |3798  |3798        |NA    |NA          |NA    |
## |6  |SD (Intercept)          |1.05(NA)    |      |1.05(NA)    |      |1.05(NA)    |      |
## |7  |SD (Observations)       |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SO.num by mood 
## ###########################################
## 
## Running GLMER analysis of SO.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering mood , m.nd
## 
## Model specification:
##  - model M0 (null): SO.num ~ (1|ID)
##  - model M1: SO.num ~ weekday.sleep + (1|ID)
##  - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + (1|ID)
##  - model M4: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M5: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: SO.num ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: mood.mc
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline         |    5| 11958.27| 11989.48| -5974.136| 11948.27|     NA| NA|         NA|
## |mood.mc          |    6| 11942.45| 11979.91| -5965.228| 11930.45| 17.816|  1|      0.000|
## |m.nd.mc          |    7| 11944.33| 11988.03| -5965.167| 11930.33|  0.121|  1|      0.764|
## |insomnia         |    8| 11946.24| 11996.18| -5965.122| 11930.24|  0.090|  1|      0.764|
## |mood.mc:insomnia |    9| 11947.28| 12003.46| -5964.639| 11929.28|  0.966|  1|      0.651|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0 
##    - mood.mc vs. Baseline model = 1
##    - m.nd.mc = 0.281
##    - insomnia = 0.098
##    - mood.mc:insomnia = 0.055
##    Selected model based on Aw: mood.mc
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |0.49(0.11)  |4.39  |0.49(0.11)  |4.39  |0.53(0.16)  |3.30  |
## |3  |weekday.sleep [weekend] |0.44(0.04)  |10.78 |0.44(0.04)  |10.77 |0.44(0.04)  |10.78 |
## |4  |BMI.gmc                 |-0.09(0.03) |-2.47 |-0.09(0.03) |-2.47 |-0.09(0.04) |-2.49 |
## |5  |mood.mc                 |-0.09(0.02) |-4.23 |-0.09(0.02) |-4.16 |-0.06(0.03) |-1.96 |
## |8  |m.nd.mc                 |            |      |-0.01(0.02) |-0.35 |-0.01(0.02) |-0.33 |
## |9  |insomnia [1]            |            |      |            |      |-0.07(0.23) |-0.30 |
## |10 |mood.mc * insomnia [1]  |            |      |            |      |-0.04(0.04) |-0.98 |
## |11 |N                       |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |12 |Observations            |3798        |3798  |3798        |NA    |NA          |NA    |
## |6  |SD (Intercept)          |1.05(NA)    |      |1.05(NA)    |      |1.05(NA)    |      |
## |7  |SD (Observations)       |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SO.num by PsyDist 
## ###########################################
## 
## Running GLMER analysis of SO.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): SO.num ~ (1|ID)
##  - model M1: SO.num ~ weekday.sleep + (1|ID)
##  - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + (1|ID)
##  - model M4: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: SO.num ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: PsyDist.mc
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline            |    5| 11958.27| 11989.48| -5974.136| 11948.27|     NA| NA|         NA|
## |PsyDist.mc          |    6| 11941.15| 11978.60| -5964.573| 11929.15| 19.126|  1|      0.000|
## |P.nd.mc             |    7| 11942.07| 11985.77| -5964.035| 11928.07|  1.075|  1|      0.583|
## |insomnia            |    8| 11943.98| 11993.92| -5963.991| 11927.98|  0.089|  1|      0.765|
## |PsyDist.mc:insomnia |    9| 11945.38| 12001.56| -5963.688| 11927.38|  0.604|  1|      0.583|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0 
##    - PsyDist.mc vs. Baseline model = 1
##    - P.nd.mc = 0.386
##    - insomnia = 0.129
##    - PsyDist.mc:insomnia = 0.06
##    Selected model based on Aw: PsyDist.mc
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)               |0.50(0.11)  |4.42  |0.50(0.11)  |4.42  |0.53(0.16)  |3.32  |
## |3  |weekday.sleep [weekend]   |0.44(0.04)  |10.55 |0.43(0.04)  |10.46 |0.43(0.04)  |10.48 |
## |4  |BMI.gmc                   |-0.09(0.03) |-2.47 |-0.09(0.03) |-2.47 |-0.09(0.04) |-2.48 |
## |5  |PsyDist.mc                |-0.12(0.03) |-4.38 |-0.11(0.03) |-3.92 |-0.08(0.04) |-2.04 |
## |8  |P.nd.mc                   |            |      |-0.03(0.03) |-1.04 |-0.03(0.03) |-1.01 |
## |9  |insomnia [1]              |            |      |            |      |-0.07(0.23) |-0.30 |
## |10 |PsyDist.mc * insomnia [1] |            |      |            |      |-0.04(0.05) |-0.78 |
## |11 |N                         |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |12 |Observations              |3798        |3798  |3798        |NA    |NA          |NA    |
## |6  |SD (Intercept)            |1.05(NA)    |      |1.05(NA)    |      |1.05(NA)    |      |
## |7  |SD (Observations)         |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing SO.num by fs.w 
## ###########################################
## 
## Running GLMER analysis of SO.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
## 
## Model specification:
##  - model M0 (null): SO.num ~ (1|ID)
##  - model M1: SO.num ~ weekday.sleep + (1|ID)
##  - model M2: SO.num ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: SO.num ~ weekday.sleep + BMI.gmc + fs.w + (1|ID)
##  - model M4: SO.num ~ weekday.sleep + BMI.gmc + fs.w + f.nd + (1|ID)
##  - model M5: SO.num ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: SO.num ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: fs.w
## 
## |              | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline      |    5| 11958.27| 11989.48| -5974.136| 11948.27|     NA| NA|         NA|
## |fs.w          |    6| 11941.68| 11979.13| -5964.839| 11929.68| 18.594|  1|      0.000|
## |f.nd          |    7| 11942.68| 11986.37| -5964.338| 11928.68|  1.002|  1|      0.601|
## |insomnia      |    8| 11944.58| 11994.52| -5964.292| 11928.58|  0.092|  1|      0.762|
## |fs.w:insomnia |    9| 11946.01| 12002.19| -5964.007| 11928.01|  0.569|  1|      0.601|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0 
##    - fs.w vs. Baseline model = 1
##    - f.nd = 0.378
##    - insomnia = 0.127
##    - fs.w:insomnia = 0.058
##    Selected model based on Aw: fs.w
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |0.50(0.11)  |4.42  |0.50(0.11)  |4.42  |0.53(0.16)  |3.32  |
## |3  |weekday.sleep [weekend] |0.44(0.04)  |10.56 |0.43(0.04)  |10.49 |0.43(0.04)  |10.50 |
## |4  |BMI.gmc                 |-0.09(0.03) |-2.47 |-0.09(0.03) |-2.47 |-0.09(0.04) |-2.48 |
## |5  |fs.w                    |-0.10(0.02) |-4.32 |-0.09(0.02) |-3.90 |-0.07(0.04) |-2.04 |
## |8  |f.nd                    |            |      |-0.02(0.02) |-1.00 |-0.02(0.02) |-0.98 |
## |9  |insomnia [1]            |            |      |            |      |-0.07(0.23) |-0.30 |
## |10 |fs.w * insomnia [1]     |            |      |            |      |-0.03(0.05) |-0.75 |
## |11 |N                       |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |12 |Observations            |3798        |3798  |3798        |NA    |NA          |NA    |
## |6  |SD (Intercept)          |1.05(NA)    |      |1.05(NA)    |      |1.05(NA)    |      |
## |7  |SD (Observations)       |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed, despite some marked deviations in the tails of the residuals distribution, with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • models M5 including all raw and aggregate diary ratings (but not next day ratings) are associated with a significant LRT, whereas stronger evidence in terms of Aw is also shown by model M6 including next day stress

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for all prior-day diary ratings; whereas neither next day ratings nor insomnia, or its interaction with diary ratings showed a substantial effect


WakeUp.num

In section 5.1, WakeUp.num was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (later WakeUp.num for later than usual SO), weekday.sleep (later WakeUp.num during weekend), and BMI (earlier WakeUp.num for participants with higher BMI).

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WakeUp.num by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  
  # saving key results (considering M3 for stress, which showed higher Aw than M2 for all predictors)
  key.model <- ifelse(diaryVars[i]=="stress",2,1)
  res[[i]] <- rbind(res[[i]],cbind(measure="WakeUp.num",glmerAn(long=ema,wide=demos,resp="WakeUp.num",fix.eff=predictors,
                                                                modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                gmc.predictors="BMI",mComp.baseline="BMI",p.adjust.method="BH",
                                                                outputs="key.results",key.predictor=keys[1],
                                                                key.model=keys[key.model],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WakeUp.num",glmerAn(long=ema,wide=demos,resp="WakeUp.num",fix.eff=predictors,
                                                                      modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                      gmc.predictors="BMI",
                                                                      mComp.baseline="BMI",p.adjust.method="BH",
                                                                      outputs="key.results",key.predictor=keys[2],
                                                                      key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WakeUp.num",glmerAn(long=ema,wide=demos,resp="WakeUp.num",fix.eff=predictors,
                                                                        modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                        gmc.predictors="BMI",
                                                                        mComp.baseline="BMI",p.adjust.method="BH",
                                                                        outputs="key.results",key.predictor=keys[3],
                                                                        key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="WakeUp.num",fix.eff=predictors,
          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
          mComp.baseline="BMI",p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing WakeUp.num by stress 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num ~ (1|ID)
##  - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
##  - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + (1|ID)
##  - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc      weekday.sleep            BMI.gmc          stress.mc 
##           1.037432           1.056083           1.030432           2.306712 
##            s.nd.mc           insomnia stress.mc:insomnia 
##           1.077636           1.030455           2.259939 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: s.nd.mc
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline           |    6| 12005.91| 12043.36| -5996.953| 11993.91|     NA| NA|         NA|
## |stress.mc          |    7| 11974.48| 12018.18| -5980.241| 11960.48| 33.425|  1|      0.000|
## |s.nd.mc            |    8| 11941.07| 11991.01| -5962.536| 11925.07| 35.410|  1|      0.000|
## |insomnia           |    9| 11943.07| 11999.25| -5962.534| 11925.07|  0.003|  1|      0.955|
## |stress.mc:insomnia |   10| 11943.47| 12005.89| -5961.734| 11923.47|  1.599|  1|      0.275|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0 
##    - stress.mc vs. Baseline model = 1
##    - s.nd.mc = 1
##    - insomnia = 0.269
##    - stress.mc:insomnia = 0.181
##    Selected model based on Aw: s.nd.mc
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)              |8.03(0.09)  |87.47 |8.04(0.09)  |87.54 |8.03(0.13)  |61.50 |
## |3  |SO.num.mc                |0.38(0.02)  |22.75 |0.37(0.02)  |22.68 |0.37(0.02)  |22.70 |
## |4  |weekday.sleep [weekend]  |0.89(0.04)  |21.17 |0.86(0.04)  |20.43 |0.86(0.04)  |20.43 |
## |5  |BMI.gmc                  |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.09 |
## |6  |stress.mc                |-0.12(0.02) |-5.79 |-0.09(0.02) |-4.33 |-0.12(0.03) |-3.87 |
## |9  |s.nd.mc                  |            |      |-0.12(0.02) |-5.96 |-0.12(0.02) |-6.00 |
## |10 |insomnia [1]             |            |      |            |      |0.01(0.18)  |0.06  |
## |11 |stress.mc * insomnia [1] |            |      |            |      |0.05(0.04)  |1.26  |
## |12 |N                        |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |13 |Observations             |3798        |3798  |3798        |NA    |NA          |NA    |
## |7  |SD (Intercept)           |0.85(NA)    |      |0.85(NA)    |      |0.85(NA)    |      |
## |8  |SD (Observations)        |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num by worry 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num ~ (1|ID)
##  - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
##  - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + (1|ID)
##  - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: worry.mc
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline          |    6| 12005.91| 12043.36| -5996.953| 11993.91|     NA| NA|         NA|
## |worry.mc          |    7| 11959.72| 12003.42| -5972.860| 11945.72| 48.186|  1|      0.000|
## |w.nd.mc           |    8| 11961.29| 12011.23| -5972.647| 11945.29|  0.427|  1|      0.962|
## |insomnia          |    9| 11963.29| 12019.47| -5972.645| 11945.29|  0.003|  1|      0.962|
## |worry.mc:insomnia |   10| 11965.29| 12027.71| -5972.644| 11945.29|  0.002|  1|      0.962|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0 
##    - worry.mc vs. Baseline model = 1
##    - w.nd.mc = 0.313
##    - insomnia = 0.103
##    - worry.mc:insomnia = 0.037
##    Selected model based on Aw: worry.mc
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |8.03(0.09)  |87.49 |8.03(0.09)  |87.49 |8.02(0.13)  |61.47 |
## |3  |SO.num.mc               |0.38(0.02)  |22.77 |0.38(0.02)  |22.78 |0.38(0.02)  |22.78 |
## |4  |weekday.sleep [weekend] |0.88(0.04)  |20.92 |0.88(0.04)  |20.93 |0.88(0.04)  |20.92 |
## |5  |BMI.gmc                 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.09 |
## |6  |worry.mc                |-0.14(0.02) |-6.96 |-0.15(0.02) |-6.95 |-0.15(0.03) |-4.77 |
## |9  |w.nd.mc                 |            |      |0.01(0.02)  |0.65  |0.01(0.02)  |0.65  |
## |10 |insomnia [1]            |            |      |            |      |0.01(0.18)  |0.05  |
## |11 |worry.mc * insomnia [1] |            |      |            |      |0.00(0.04)  |0.05  |
## |12 |N                       |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |13 |Observations            |3798        |3798  |3798        |NA    |NA          |NA    |
## |7  |SD (Intercept)          |0.85(NA)    |      |0.85(NA)    |      |0.85(NA)    |      |
## |8  |SD (Observations)       |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num by mood 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num ~ (1|ID)
##  - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
##  - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + (1|ID)
##  - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    6| 12005.91| 12043.36| -5996.953| 11993.91|    NA| NA|         NA|
## |mood.mc          |    7| 12004.21| 12047.90| -5995.104| 11990.21| 3.698|  1|      0.218|
## |m.nd.mc          |    8| 12005.99| 12055.93| -5994.996| 11989.99| 0.217|  1|      0.959|
## |insomnia         |    9| 12007.99| 12064.17| -5994.995| 11989.99| 0.003|  1|      0.959|
## |mood.mc:insomnia |   10| 12009.87| 12072.29| -5994.935| 11989.87| 0.119|  1|      0.959|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.3 
##    - mood.mc vs. Baseline model = 0.7
##    - m.nd.mc = 0.223
##    - insomnia = 0.076
##    - mood.mc:insomnia = 0.029
##    Selected model based on Aw: mood.mc
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |8.02(0.09)  |87.44 |8.02(0.09)  |87.44 |8.02(0.13)  |61.44 |
## |3  |SO.num.mc               |0.38(0.02)  |22.79 |0.38(0.02)  |22.79 |0.38(0.02)  |22.78 |
## |4  |weekday.sleep [weekend] |0.91(0.04)  |21.44 |0.91(0.04)  |21.42 |0.91(0.04)  |21.43 |
## |5  |BMI.gmc                 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.15 |-0.09(0.03) |-3.09 |
## |6  |mood.mc                 |-0.04(0.02) |-1.92 |-0.04(0.02) |-1.86 |-0.03(0.03) |-0.95 |
## |9  |m.nd.mc                 |            |      |-0.01(0.02) |-0.47 |-0.01(0.02) |-0.46 |
## |10 |insomnia [1]            |            |      |            |      |0.01(0.18)  |0.05  |
## |11 |mood.mc * insomnia [1]  |            |      |            |      |-0.01(0.04) |-0.35 |
## |12 |N                       |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |13 |Observations            |3798        |3798  |3798        |NA    |NA          |NA    |
## |7  |SD (Intercept)          |0.85(NA)    |      |0.85(NA)    |      |0.85(NA)    |      |
## |8  |SD (Observations)       |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num by PsyDist 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num ~ (1|ID)
##  - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
##  - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + (1|ID)
##  - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: PsyDist.mc
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline            |    6| 12005.91| 12043.36| -5996.953| 11993.91|     NA| NA|         NA|
## |PsyDist.mc          |    7| 11967.83| 12011.52| -5976.913| 11953.83| 40.081|  1|      0.000|
## |P.nd.mc             |    8| 11965.56| 12015.50| -5974.780| 11949.56|  4.265|  1|      0.078|
## |insomnia            |    9| 11967.56| 12023.74| -5974.779| 11949.56|  0.003|  1|      0.955|
## |PsyDist.mc:insomnia |   10| 11969.07| 12031.50| -5974.536| 11949.07|  0.485|  1|      0.648|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0 
##    - PsyDist.mc vs. Baseline model = 1
##    - P.nd.mc = 0.756
##    - insomnia = 0.218
##    - PsyDist.mc:insomnia = 0.093
##    Selected model based on Aw: P.nd.mc
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)               |8.03(0.09)  |87.43 |8.03(0.09)  |87.45 |8.03(0.13)  |61.43 |
## |3  |SO.num.mc                 |0.37(0.02)  |22.58 |0.37(0.02)  |22.55 |0.37(0.02)  |22.56 |
## |4  |weekday.sleep [weekend]   |0.88(0.04)  |20.87 |0.88(0.04)  |20.72 |0.87(0.04)  |20.70 |
## |5  |BMI.gmc                   |-0.09(0.03) |-3.14 |-0.09(0.03) |-3.14 |-0.09(0.03) |-3.08 |
## |6  |PsyDist.mc                |-0.17(0.03) |-6.35 |-0.15(0.03) |-5.54 |-0.18(0.04) |-4.22 |
## |9  |P.nd.mc                   |            |      |-0.06(0.03) |-2.07 |-0.06(0.03) |-2.09 |
## |10 |insomnia [1]              |            |      |            |      |0.01(0.19)  |0.05  |
## |11 |PsyDist.mc * insomnia [1] |            |      |            |      |0.04(0.05)  |0.70  |
## |12 |N                         |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |13 |Observations              |3798        |3798  |3798        |NA    |NA          |NA    |
## |7  |SD (Intercept)            |0.85(NA)    |      |0.85(NA)    |      |0.85(NA)    |      |
## |8  |SD (Observations)         |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num by fs.w 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num ...
## 
## Preparing data...
##  - Excluding 2421 incomplete observations ( 38.9 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): WakeUp.num ~ (1|ID)
##  - model M1: WakeUp.num ~ SO.num.mc + (1|ID)
##  - model M2: WakeUp.num ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + (1|ID)
##  - model M5: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + f.nd + (1|ID)
##  - model M6: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M7: WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num on 3798 observations from 92 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: fs.w
## 
## |              | npar|      AIC|      BIC|    logLik| deviance|  Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|------:|--:|----------:|
## |Baseline      |    6| 12005.91| 12043.36| -5996.953| 11993.91|     NA| NA|         NA|
## |fs.w          |    7| 11967.65| 12011.35| -5976.827| 11953.65| 40.253|  1|      0.000|
## |f.nd          |    8| 11967.95| 12017.89| -5975.977| 11951.95|  1.700|  1|      0.385|
## |insomnia      |    9| 11969.95| 12026.13| -5975.975| 11951.95|  0.002|  1|      0.961|
## |fs.w:insomnia |   10| 11971.67| 12034.09| -5975.836| 11951.67|  0.279|  1|      0.797|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0 
##    - fs.w vs. Baseline model = 1
##    - f.nd = 0.463
##    - insomnia = 0.146
##    - fs.w:insomnia = 0.058
##    Selected model based on Aw: fs.w
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |8.03(0.09)  |87.47 |8.03(0.09)  |87.48 |8.03(0.13)  |61.46 |
## |3  |SO.num.mc               |0.37(0.02)  |22.59 |0.37(0.02)  |22.57 |0.37(0.02)  |22.57 |
## |4  |weekday.sleep [weekend] |0.88(0.04)  |20.86 |0.88(0.04)  |20.78 |0.88(0.04)  |20.76 |
## |5  |BMI.gmc                 |-0.09(0.03) |-3.14 |-0.09(0.03) |-3.14 |-0.09(0.03) |-3.08 |
## |6  |fs.w                    |-0.15(0.02) |-6.36 |-0.14(0.02) |-5.80 |-0.15(0.04) |-4.26 |
## |9  |f.nd                    |            |      |-0.03(0.02) |-1.30 |-0.03(0.02) |-1.32 |
## |10 |insomnia [1]            |            |      |            |      |0.01(0.18)  |0.05  |
## |11 |fs.w * insomnia [1]     |            |      |            |      |0.02(0.05)  |0.53  |
## |12 |N                       |92 ID       |92 ID |92 ID       |NA    |NA          |NA    |
## |13 |Observations            |3798        |3798  |3798        |NA    |NA          |NA    |
## |7  |SD (Intercept)          |0.85(NA)    |      |0.85(NA)    |      |0.85(NA)    |      |
## |8  |SD (Observations)       |1.06(NA)    |      |1.06(NA)    |      |1.06(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed (despite some deviations in the tails of the both distributions) with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term

  • model M5 including prior-day stress, worry, PsyDist, and fs.w, and model M6 with next-day stress are associated with a significant LRT and stronger evidence in terms of Aw (also characterizing prior-day mood), compared to the baseline model

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for prior-day stress, worry, PsyDist, and fs.w, and for next-day stress, PsyDist and fs.w, while mood did not show substantial direct or inverse effects


1.3. Daily variability

s.variab variables are modeled by considering the subset of complete s.variab and dailyDiary data, whereas dailyAct data are ignored since none of the s.variab variables was substantially predicted by TotalSteps1000. Note that all models are specified with nAGQ = 0 due to convergence problems, implying quite conservative estimates with large standard errors.

s.variab <- paste(c(s.archit[1:3],s.timing),"SSD",sep=".")

TIB.SSD

In section 5.1, TIB.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher TIB.SSD during weekend), BMI (higher TIB.SSD for participants with higher BMI), and insomnia (lower TIB.SSD for insomnia than controls, even when controlling for sex). Here, insomnia is added after diary ratings for better consistency with the other models.

# adding constant to each value to avoid zeros
ema$TIB.SSDc <- ema$TIB.SSD + 0.001 

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TIB.SSD by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
  
  # saving key results (considering M3 for stress and PsyDist, which showed higher Aw than M2 for all predictors)
  key.model <- ifelse(diaryVars[i]%in%c("stress","PsyDist","fs.w"),2,1)
  res[[i]] <- rbind(res[[i]],cbind(measure="TIB.SSDc",glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,
                                                              modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                              gmc.predictors="BMI",mComp.baseline="BMI",p.adjust.method="BH",
                                                              family="gamma",link="log",transform="exp",
                                                              nAGQ=0, # nAGQ = 0 to reach convergence in all models
                                                              outputs="key.results",key.predictor=keys[1],
                                                              key.model=keys[key.model],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="TIB.SSDc",glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,
                                                                    mComp.baseline="BMI",p.adjust.method="BH",
                                                                    nAGQ=0, # nAGQ = 0 to reach convergence in all models
                                                                    modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                    gmc.predictors="BMI",family="gamma",link="log",transform="exp",
                                                                    outputs="key.results",key.predictor=keys[2],
                                                                    key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="TIB.SSDc",glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,
                                                                      modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                      gmc.predictors="BMI",family="gamma",link="log",
                                                                      transform="exp",nAGQ=0, # nAGQ = 0 to reach convergence
                                                                      mComp.baseline="BMI",p.adjust.method="BH",
                                                                      outputs="key.results",key.predictor=keys[3],
                                                                      key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="TIB.SSDc",fix.eff=predictors,
          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
          family="gamma",link="log",transform="exp",outputs=outputs,
          mComp.baseline="BMI",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
          coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing TIB.SSD by stress 
## ###########################################
## 
## Running GLMER analysis of TIB.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering stress , s.nd
## 
## Model specification:
##  - model M0 (null): TIB.SSDc ~ (1|ID)
##  - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + (1|ID)
##  - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##      weekday.sleep            BMI.gmc          stress.mc            s.nd.mc 
##           1.025237           1.031972           2.352937           1.076483 
##           insomnia stress.mc:insomnia 
##           1.032001           2.305039 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    5| 70653.05| 70683.89| -35321.53| 70643.05|    NA| NA|         NA|
## |stress.mc          |    6| 70654.77| 70691.78| -35321.39| 70642.77| 0.282|  1|      0.636|
## |s.nd.mc            |    7| 70654.96| 70698.14| -35320.48| 70640.96| 1.808|  1|      0.357|
## |insomnia           |    8| 70653.36| 70702.70| -35318.68| 70637.36| 3.602|  1|      0.231|
## |stress.mc:insomnia |    9| 70655.14| 70710.64| -35318.57| 70637.14| 0.224|  1|      0.636|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.702 
##    - stress.mc vs. Baseline model = 0.298
##    - s.nd.mc = 0.213
##    - insomnia = 0.322
##    - stress.mc:insomnia = 0.117
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)          |t     |B (SE)          |t     |B (SE)            |t     |
## |:--|:------------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2  |(Intercept)              |9700.72(903.82) |98.53 |9720.68(906.80) |98.43 |10935.37(1414.80) |71.88 |
## |3  |weekday.sleep [weekend]  |1.39(0.08)      |5.71  |1.38(0.08)      |5.50  |1.38(0.08)        |5.51  |
## |4  |BMI.gmc                  |1.06(0.03)      |2.00  |1.06(0.03)      |1.99  |1.05(0.03)        |1.78  |
## |5  |stress.mc                |0.98(0.03)      |-0.63 |0.99(0.03)      |-0.32 |0.98(0.04)        |-0.54 |
## |8  |s.nd.mc                  |                |      |0.96(0.03)      |-1.34 |0.96(0.03)        |-1.34 |
## |9  |insomnia [1]             |                |      |                |      |0.79(0.14)        |-1.28 |
## |10 |stress.mc * insomnia [1] |                |      |                |      |1.02(0.06)        |0.41  |
## |11 |N                        |92 ID           |92 ID |92 ID           |NA    |NA                |NA    |
## |12 |Observations             |3524            |3524  |3524            |NA    |NA                |NA    |
## |6  |SD (Intercept)           |2.28(NA)        |      |2.29(NA)        |      |2.24(NA)          |      |
## |7  |SD (Observations)        |3.43(NA)        |      |3.43(NA)        |      |3.42(NA)          |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB.SSD by worry 
## ###########################################
## 
## Running GLMER analysis of TIB.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering worry , w.nd
## 
## Model specification:
##  - model M0 (null): TIB.SSDc ~ (1|ID)
##  - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + (1|ID)
##  - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    5| 70653.05| 70683.89| -35321.53| 70643.05|    NA| NA|         NA|
## |worry.mc          |    6| 70655.00| 70692.01| -35321.50| 70643.00| 0.052|  1|      0.819|
## |w.nd.mc           |    7| 70655.68| 70698.85| -35320.84| 70641.68| 1.327|  1|      0.424|
## |insomnia          |    8| 70653.94| 70703.28| -35318.97| 70637.94| 3.734|  1|      0.213|
## |worry.mc:insomnia |    9| 70654.95| 70710.45| -35318.47| 70636.95| 0.997|  1|      0.424|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.726 
##    - worry.mc vs. Baseline model = 0.274
##    - w.nd.mc = 0.164
##    - insomnia = 0.28
##    - worry.mc:insomnia = 0.145
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)          |t     |B (SE)          |t     |B (SE)            |t     |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2  |(Intercept)             |9691.55(901.62) |98.67 |9681.29(902.30) |98.48 |10901.97(1407.00) |72.03 |
## |3  |weekday.sleep [weekend] |1.40(0.08)      |5.75  |1.40(0.08)      |5.77  |1.40(0.08)        |5.85  |
## |4  |BMI.gmc                 |1.06(0.03)      |2.00  |1.06(0.03)      |1.99  |1.05(0.03)        |1.79  |
## |5  |worry.mc                |1.00(0.03)      |0.15  |1.01(0.03)      |0.39  |1.04(0.05)        |0.96  |
## |8  |w.nd.mc                 |                |      |0.96(0.03)      |-1.23 |0.97(0.03)        |-1.19 |
## |9  |insomnia [1]            |                |      |                |      |0.79(0.14)        |-1.30 |
## |10 |worry.mc * insomnia [1] |                |      |                |      |0.95(0.06)        |-0.93 |
## |11 |N                       |92 ID           |92 ID |92 ID           |NA    |NA                |NA    |
## |12 |Observations            |3524            |3524  |3524            |NA    |NA                |NA    |
## |6  |SD (Intercept)          |2.28(NA)        |      |2.28(NA)        |      |2.23(NA)          |      |
## |7  |SD (Observations)       |3.43(NA)        |      |3.43(NA)        |      |3.42(NA)          |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB.SSD by mood 
## ###########################################
## 
## Running GLMER analysis of TIB.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering mood , m.nd
## 
## Model specification:
##  - model M0 (null): TIB.SSDc ~ (1|ID)
##  - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + (1|ID)
##  - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    5| 70653.05| 70683.89| -35321.53| 70643.05|    NA| NA|         NA|
## |mood.mc          |    6| 70655.03| 70692.03| -35321.51| 70643.03| 0.026|  1|      0.871|
## |m.nd.mc          |    7| 70653.51| 70696.68| -35319.75| 70639.51| 3.523|  1|      0.121|
## |insomnia         |    8| 70651.63| 70700.97| -35317.82| 70635.63| 3.872|  1|      0.121|
## |mood.mc:insomnia |    9| 70653.34| 70708.84| -35317.67| 70635.34| 0.296|  1|      0.782|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.728 
##    - mood.mc vs. Baseline model = 0.272
##    - m.nd.mc = 0.368
##    - insomnia = 0.484
##    - mood.mc:insomnia = 0.171
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)          |t     |B (SE)          |t     |B (SE)            |t     |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2  |(Intercept)             |9692.69(901.89) |98.65 |9684.72(897.62) |99.03 |10941.28(1405.90) |72.38 |
## |3  |weekday.sleep [weekend] |1.40(0.08)      |5.76  |1.39(0.08)      |5.74  |1.39(0.08)        |5.71  |
## |4  |BMI.gmc                 |1.06(0.03)      |2.00  |1.06(0.03)      |2.01  |1.05(0.03)        |1.79  |
## |5  |mood.mc                 |1.00(0.03)      |0.13  |1.01(0.03)      |0.33  |0.99(0.05)        |-0.26 |
## |8  |m.nd.mc                 |                |      |0.95(0.03)      |-1.79 |0.95(0.03)        |-1.83 |
## |9  |insomnia [1]            |                |      |                |      |0.79(0.14)        |-1.33 |
## |10 |mood.mc * insomnia [1]  |                |      |                |      |1.03(0.06)        |0.56  |
## |11 |N                       |92 ID           |92 ID |92 ID           |NA    |NA                |NA    |
## |12 |Observations            |3524            |3524  |3524            |NA    |NA                |NA    |
## |6  |SD (Intercept)          |2.28(NA)        |      |2.27(NA)        |      |2.22(NA)          |      |
## |7  |SD (Observations)       |3.43(NA)        |      |3.43(NA)        |      |3.42(NA)          |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB.SSD by PsyDist 
## ###########################################
## 
## Running GLMER analysis of TIB.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): TIB.SSDc ~ (1|ID)
##  - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + (1|ID)
##  - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    5| 70653.05| 70683.89| -35321.53| 70643.05|    NA| NA|         NA|
## |PsyDist.mc          |    6| 70655.07| 70692.08| -35321.54| 70643.07| 0.000|  1|      1.000|
## |P.nd.mc             |    7| 70653.18| 70696.35| -35319.59| 70639.18| 3.893|  1|      0.106|
## |insomnia            |    8| 70651.44| 70700.78| -35317.72| 70635.44| 3.742|  1|      0.106|
## |PsyDist.mc:insomnia |    9| 70653.44| 70708.94| -35317.72| 70635.44| 0.000|  1|      1.000|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.733 
##    - PsyDist.mc vs. Baseline model = 0.267
##    - P.nd.mc = 0.408
##    - insomnia = 0.494
##    - PsyDist.mc:insomnia = 0.154
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)          |t     |B (SE)          |t     |B (SE)            |t     |
## |:--|:-------------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2  |(Intercept)               |9696.30(902.62) |98.61 |9691.44(901.70) |98.66 |10924.79(1410.06) |72.04 |
## |3  |weekday.sleep [weekend]   |1.39(0.08)      |5.71  |1.39(0.08)      |5.62  |1.39(0.08)        |5.63  |
## |4  |BMI.gmc                   |1.06(0.03)      |2.00  |1.06(0.03)      |1.99  |1.05(0.03)        |1.78  |
## |5  |PsyDist.mc                |1.00(0.04)      |-0.12 |1.02(0.04)      |0.44  |1.02(0.06)        |0.28  |
## |8  |P.nd.mc                   |                |      |0.93(0.04)      |-1.97 |0.93(0.04)        |-1.98 |
## |9  |insomnia [1]              |                |      |                |      |0.79(0.14)        |-1.30 |
## |10 |PsyDist.mc * insomnia [1] |                |      |                |      |1.00(0.07)        |0.01  |
## |11 |N                         |92 ID           |92 ID |92 ID           |NA    |NA                |NA    |
## |12 |Observations              |3524            |3524  |3524            |NA    |NA                |NA    |
## |6  |SD (Intercept)            |2.28(NA)        |      |2.28(NA)        |      |2.23(NA)          |      |
## |7  |SD (Observations)         |3.43(NA)        |      |3.43(NA)        |      |3.42(NA)          |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TIB.SSD by fs.w 
## ###########################################
## 
## Running GLMER analysis of TIB.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
## 
## Model specification:
##  - model M0 (null): TIB.SSDc ~ (1|ID)
##  - model M1: TIB.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TIB.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + (1|ID)
##  - model M4: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + (1|ID)
##  - model M5: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: TIB.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of TIB.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    5| 70653.05| 70683.89| -35321.53| 70643.05|    NA| NA|         NA|
## |fs.w          |    6| 70655.06| 70692.07| -35321.53| 70643.06| 0.000|  1|      1.000|
## |f.nd          |    7| 70653.57| 70696.75| -35319.79| 70639.57| 3.486|  1|      0.124|
## |insomnia      |    8| 70651.74| 70701.08| -35317.87| 70635.74| 3.834|  1|      0.124|
## |fs.w:insomnia |    9| 70653.71| 70709.21| -35317.85| 70635.71| 0.034|  1|      1.000|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.732 
##    - fs.w vs. Baseline model = 0.268
##    - f.nd = 0.361
##    - insomnia = 0.474
##    - fs.w:insomnia = 0.151
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)          |t     |B (SE)          |t     |B (SE)            |t     |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:-----------------|:-----|
## |2  |(Intercept)             |9694.26(902.25) |98.63 |9688.87(902.70) |98.52 |10935.78(1412.71) |71.99 |
## |3  |weekday.sleep [weekend] |1.40(0.08)      |5.72  |1.39(0.08)      |5.67  |1.39(0.08)        |5.69  |
## |4  |BMI.gmc                 |1.06(0.03)      |2.00  |1.06(0.03)      |1.99  |1.05(0.03)        |1.78  |
## |5  |fs.w                    |1.00(0.03)      |-0.02 |1.02(0.03)      |0.48  |1.02(0.05)        |0.44  |
## |8  |f.nd                    |                |      |0.94(0.03)      |-1.91 |0.94(0.03)        |-1.92 |
## |9  |insomnia [1]            |                |      |                |      |0.79(0.14)        |-1.32 |
## |10 |fs.w * insomnia [1]     |                |      |                |      |0.99(0.06)        |-0.15 |
## |11 |N                       |92 ID           |92 ID |92 ID           |NA    |NA                |NA    |
## |12 |Observations            |3524            |3524  |3524            |NA    |NA                |NA    |
## |6  |SD (Intercept)          |2.28(NA)        |      |2.28(NA)        |      |2.23(NA)          |      |
## |7  |SD (Observations)       |3.43(NA)        |      |3.43(NA)        |      |3.42(NA)          |      |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress

  • none of the specified models shows a significant LRT or stronger evidence in terms of Aw (with the exception of some models including insomnia group differences), compared to the baseline model

  • coherently, none of the included predictors shows a substantial effect


TST.SSD

In section 5.1, TST.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher TST.SSD during weekend), BMI (higher TST.SSD for participants with higher BMI), and insomnia (lower TST.SSD for insomnia than controls, even when controlling for sex). Here, insomnia is added after diary ratings for better consistency with the other models.

# adding constant to each value to avoid zeros
ema$TST.SSDc <- ema$TST.SSD + 0.001

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing TST.SSD by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("weekday.sleep","BMI",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) } 
  
  # saving key results (considering M3 for mood and PsyDist, which showed higher Aw than M2 for all predictors)
  key.model <- ifelse(diaryVars[i]%in%c("mood","PsyDist","fs.w"),2,1)
  res[[i]] <- rbind(res[[i]],cbind(measure="TST.SSDc",glmerAn(long=ema,wide=demos,resp="TST.SSDc",fix.eff=predictors,
                                                              modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                              gmc.predictors="BMI",family="gamma",link="log",transform="exp",
                                                              nAGQ=0, # nAGQ = 0 to reach convergence in all models
                                                              mComp.baseline="BMI",p.adjust.method="BH",
                                                              outputs="key.results",key.predictor=keys[1],
                                                              key.model=keys[key.model],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="TST.SSDc",glmerAn(long=ema,wide=demos,resp="TST.SSDc",
                                                                    fix.eff=predictors, # day i+1
                                                                    modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                    gmc.predictors="BMI",nAGQ=0, # nAGQ = 0 to reach convergence
                                                                    family="gamma",link="log",transform="exp",
                                                                    mComp.baseline="BMI",p.adjust.method="BH",
                                                                    outputs="key.results",key.predictor=keys[2],
                                                                    key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="TST.SSDc",glmerAn(long=ema,wide=demos,resp="TST.SSDc",fix.eff=predictors,
                                                                      modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                      gmc.predictors="BMI",nAGQ=0, # nAGQ = 0 to reach convergence
                                                                      family="gamma",link="log",transform="exp",
                                                                      mComp.baseline="BMI",p.adjust.method="BH",
                                                                      outputs="key.results",key.predictor=keys[3],
                                                                      key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="TST.SSDc",fix.eff=predictors,
          modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI", # GLMER with mean-centered pred.
          family="gamma",link="log",transform="exp",outputs=outputs,nAGQ=0, # nAGQ = 0 to reach convergence
          mComp.baseline=predictors[which(predictors==diaryVars[i])-1],p.adjust.method="BH",
          coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing TST.SSD by stress 
## ###########################################
## 
## Running GLMER analysis of TST.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering stress , s.nd
## 
## Model specification:
##  - model M0 (null): TST.SSDc ~ (1|ID)
##  - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + (1|ID)
##  - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (1|ID)
##  - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##      weekday.sleep            BMI.gmc          stress.mc            s.nd.mc 
##           1.025237           1.031855           2.352937           1.076484 
##           insomnia stress.mc:insomnia 
##           1.031884           2.305039 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    5| 69218.09| 69248.93| -34604.04| 69208.09|    NA| NA|         NA|
## |stress.mc          |    6| 69219.95| 69256.96| -34603.98| 69207.95| 0.139|  1|      0.878|
## |s.nd.mc            |    7| 69220.48| 69263.65| -34603.24| 69206.48| 1.469|  1|      0.451|
## |insomnia           |    8| 69219.78| 69269.12| -34601.89| 69203.78| 2.700|  1|      0.401|
## |stress.mc:insomnia |    9| 69221.76| 69277.26| -34601.88| 69203.76| 0.024|  1|      0.878|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.717 
##    - stress.mc vs. Baseline model = 0.283
##    - s.nd.mc = 0.178
##    - insomnia = 0.202
##    - stress.mc:insomnia = 0.07
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)          |t     |B (SE)          |t     |B (SE)           |t     |
## |:--|:------------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2  |(Intercept)              |7845.32(717.15) |98.10 |7861.79(719.66) |97.99 |8707.06(1111.98) |71.04 |
## |3  |weekday.sleep [weekend]  |1.36(0.08)      |5.52  |1.35(0.08)      |5.31  |1.35(0.08)       |5.31  |
## |4  |BMI.gmc                  |1.05(0.03)      |1.90  |1.05(0.03)      |1.89  |1.05(0.03)       |1.70  |
## |5  |stress.mc                |0.99(0.03)      |-0.49 |0.99(0.03)      |-0.20 |0.99(0.04)       |-0.21 |
## |8  |s.nd.mc                  |                |      |0.97(0.03)      |-1.25 |0.97(0.03)       |-1.24 |
## |9  |insomnia [1]             |                |      |                |      |0.82(0.15)       |-1.12 |
## |10 |stress.mc * insomnia [1] |                |      |                |      |1.01(0.06)       |0.11  |
## |11 |N                        |92 ID           |92 ID |92 ID           |NA    |NA               |NA    |
## |12 |Observations             |3524            |3524  |3524            |NA    |NA               |NA    |
## |6  |SD (Intercept)           |2.25(NA)        |      |2.25(NA)        |      |2.22(NA)         |      |
## |7  |SD (Observations)        |3.37(NA)        |      |3.37(NA)        |      |3.37(NA)         |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST.SSD by worry 
## ###########################################
## 
## Running GLMER analysis of TST.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering worry , w.nd
## 
## Model specification:
##  - model M0 (null): TST.SSDc ~ (1|ID)
##  - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + (1|ID)
##  - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + (1|ID)
##  - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    5| 69218.09| 69248.93| -34604.04| 69208.09|    NA| NA|         NA|
## |worry.mc          |    6| 69219.66| 69256.66| -34603.83| 69207.66| 0.432|  1|      0.511|
## |w.nd.mc           |    7| 69219.84| 69263.01| -34602.92| 69205.84| 1.817|  1|      0.355|
## |insomnia          |    8| 69219.06| 69268.40| -34601.53| 69203.06| 2.783|  1|      0.355|
## |worry.mc:insomnia |    9| 69219.97| 69275.47| -34600.98| 69201.97| 1.092|  1|      0.395|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.687 
##    - worry.mc vs. Baseline model = 0.313
##    - w.nd.mc = 0.222
##    - insomnia = 0.248
##    - worry.mc:insomnia = 0.136
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)          |t     |B (SE)          |t     |B (SE)           |t     |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2  |(Intercept)             |7833.85(715.06) |98.23 |7826.16(715.20) |98.10 |8672.90(1103.30) |71.28 |
## |3  |weekday.sleep [weekend] |1.37(0.08)      |5.60  |1.37(0.08)      |5.61  |1.38(0.08)       |5.68  |
## |4  |BMI.gmc                 |1.05(0.03)      |1.90  |1.05(0.03)      |1.89  |1.05(0.03)       |1.71  |
## |5  |worry.mc                |1.02(0.03)      |0.59  |1.02(0.03)      |0.83  |1.06(0.05)       |1.30  |
## |8  |w.nd.mc                 |                |      |0.96(0.03)      |-1.43 |0.96(0.03)       |-1.39 |
## |9  |insomnia [1]            |                |      |                |      |0.81(0.15)       |-1.14 |
## |10 |worry.mc * insomnia [1] |                |      |                |      |0.95(0.05)       |-1.00 |
## |11 |N                       |92 ID           |92 ID |92 ID           |NA    |NA               |NA    |
## |12 |Observations            |3524            |3524  |3524            |NA    |NA               |NA    |
## |6  |SD (Intercept)          |2.25(NA)        |      |2.25(NA)        |      |2.21(NA)         |      |
## |7  |SD (Observations)       |3.37(NA)        |      |3.37(NA)        |      |3.36(NA)         |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST.SSD by mood 
## ###########################################
## 
## Running GLMER analysis of TST.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering mood , m.nd
## 
## Model specification:
##  - model M0 (null): TST.SSDc ~ (1|ID)
##  - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + (1|ID)
##  - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + (1|ID)
##  - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    5| 69218.09| 69248.93| -34604.04| 69208.09|    NA| NA|         NA|
## |mood.mc          |    6| 69219.75| 69256.75| -34603.87| 69207.75| 0.345|  1|      0.743|
## |m.nd.mc          |    7| 69216.39| 69259.56| -34601.19| 69202.39| 5.359|  1|      0.082|
## |insomnia         |    8| 69215.43| 69264.77| -34599.71| 69199.43| 2.957|  1|      0.171|
## |mood.mc:insomnia |    9| 69217.38| 69272.89| -34599.69| 69199.38| 0.045|  1|      0.832|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.696 
##    - mood.mc vs. Baseline model = 0.304
##    - m.nd.mc = 0.62
##    - insomnia = 0.5
##    - mood.mc:insomnia = 0.158
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)          |t     |B (SE)          |t     |B (SE)           |t     |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2  |(Intercept)             |7836.45(715.62) |98.19 |7826.97(711.18) |98.67 |8704.09(1102.14) |71.64 |
## |3  |weekday.sleep [weekend] |1.37(0.08)      |5.59  |1.37(0.08)      |5.58  |1.37(0.08)       |5.59  |
## |4  |BMI.gmc                 |1.05(0.03)      |1.90  |1.05(0.03)      |1.92  |1.05(0.03)       |1.72  |
## |5  |mood.mc                 |1.02(0.03)      |0.55  |1.02(0.03)      |0.79  |1.03(0.05)       |0.68  |
## |8  |m.nd.mc                 |                |      |0.94(0.03)      |-2.28 |0.94(0.03)       |-2.30 |
## |9  |insomnia [1]            |                |      |                |      |0.81(0.14)       |-1.18 |
## |10 |mood.mc * insomnia [1]  |                |      |                |      |0.99(0.06)       |-0.21 |
## |11 |N                       |92 ID           |92 ID |92 ID           |NA    |NA               |NA    |
## |12 |Observations            |3524            |3524  |3524            |NA    |NA               |NA    |
## |6  |SD (Intercept)          |2.25(NA)        |      |2.24(NA)        |      |2.20(NA)         |      |
## |7  |SD (Observations)       |3.37(NA)        |      |3.36(NA)        |      |3.36(NA)         |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST.SSD by PsyDist 
## ###########################################
## 
## Running GLMER analysis of TST.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): TST.SSDc ~ (1|ID)
##  - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + (1|ID)
##  - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    5| 69218.09| 69248.93| -34604.04| 69208.09|    NA| NA|         NA|
## |PsyDist.mc          |    6| 69219.92| 69256.92| -34603.96| 69207.92| 0.174|  1|      0.677|
## |P.nd.mc             |    7| 69216.84| 69260.01| -34601.42| 69202.84| 5.081|  1|      0.097|
## |insomnia            |    8| 69216.02| 69265.35| -34600.01| 69200.02| 2.821|  1|      0.186|
## |PsyDist.mc:insomnia |    9| 69217.77| 69273.28| -34599.89| 69199.77| 0.243|  1|      0.677|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.714 
##    - PsyDist.mc vs. Baseline model = 0.286
##    - P.nd.mc = 0.572
##    - insomnia = 0.463
##    - PsyDist.mc:insomnia = 0.161
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)          |t     |B (SE)          |t     |B (SE)           |t     |
## |:--|:-------------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2  |(Intercept)               |7835.39(715.23) |98.23 |7832.89(714.24) |98.33 |8684.45(1104.14) |71.33 |
## |3  |weekday.sleep [weekend]   |1.37(0.08)      |5.56  |1.36(0.08)      |5.44  |1.36(0.08)       |5.47  |
## |4  |BMI.gmc                   |1.05(0.03)      |1.90  |1.05(0.03)      |1.89  |1.05(0.03)       |1.70  |
## |5  |PsyDist.mc                |1.01(0.04)      |0.31  |1.04(0.04)      |0.92  |1.06(0.06)       |1.00  |
## |8  |P.nd.mc                   |                |      |0.92(0.03)      |-2.30 |0.92(0.03)       |-2.30 |
## |9  |insomnia [1]              |                |      |                |      |0.81(0.15)       |-1.14 |
## |10 |PsyDist.mc * insomnia [1] |                |      |                |      |0.97(0.07)       |-0.49 |
## |11 |N                         |92 ID           |92 ID |92 ID           |NA    |NA               |NA    |
## |12 |Observations              |3524            |3524  |3524            |NA    |NA               |NA    |
## |6  |SD (Intercept)            |2.25(NA)        |      |2.25(NA)        |      |2.21(NA)         |      |
## |7  |SD (Observations)         |3.37(NA)        |      |3.37(NA)        |      |3.36(NA)         |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing TST.SSD by fs.w 
## ###########################################
## 
## Running GLMER analysis of TST.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Grand-mean-centering BMI
## 
## Model specification:
##  - model M0 (null): TST.SSDc ~ (1|ID)
##  - model M1: TST.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: TST.SSDc ~ weekday.sleep + BMI.gmc + (1|ID)
##  - model M3: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + (1|ID)
##  - model M4: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + (1|ID)
##  - model M5: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: TST.SSDc ~ weekday.sleep + BMI.gmc + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of TST.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    5| 69218.09| 69248.93| -34604.04| 69208.09|    NA| NA|         NA|
## |fs.w          |    6| 69219.79| 69256.80| -34603.90| 69207.79| 0.298|  1|      0.585|
## |f.nd          |    7| 69217.08| 69260.26| -34601.54| 69203.08| 4.709|  1|      0.120|
## |insomnia      |    8| 69216.18| 69265.52| -34600.09| 69200.18| 2.901|  1|      0.177|
## |fs.w:insomnia |    9| 69217.77| 69273.28| -34599.89| 69199.77| 0.411|  1|      0.585|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.701 
##    - fs.w vs. Baseline model = 0.299
##    - f.nd = 0.537
##    - insomnia = 0.457
##    - fs.w:insomnia = 0.171
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)          |t     |B (SE)          |t     |B (SE)           |t     |
## |:--|:-----------------------|:---------------|:-----|:---------------|:-----|:----------------|:-----|
## |2  |(Intercept)             |7832.96(714.89) |98.24 |7830.13(715.02) |98.18 |8692.13(1105.98) |71.28 |
## |3  |weekday.sleep [weekend] |1.37(0.08)      |5.58  |1.36(0.08)      |5.50  |1.37(0.08)       |5.54  |
## |4  |BMI.gmc                 |1.05(0.03)      |1.90  |1.05(0.03)      |1.89  |1.05(0.03)       |1.70  |
## |5  |fs.w                    |1.01(0.03)      |0.43  |1.03(0.03)      |0.99  |1.06(0.05)       |1.15  |
## |8  |f.nd                    |                |      |0.93(0.03)      |-2.25 |0.93(0.03)       |-2.25 |
## |9  |insomnia [1]            |                |      |                |      |0.81(0.15)       |-1.16 |
## |10 |fs.w * insomnia [1]     |                |      |                |      |0.96(0.06)       |-0.62 |
## |11 |N                       |92 ID           |92 ID |92 ID           |NA    |NA               |NA    |
## |12 |Observations            |3524            |3524  |3524            |NA    |NA               |NA    |
## |6  |SD (Intercept)          |2.25(NA)        |      |2.25(NA)        |      |2.21(NA)         |      |
## |7  |SD (Observations)       |3.37(NA)        |      |3.37(NA)        |      |3.36(NA)         |      |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc

  • weekday.sleep, BMI, stress, and next day PsyDist, and fs are associated with a significant LRT, and showed stronger evidence in terms of Aw; significant LRT is also shown by next day mood

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for next day Mood, PsyDist, and fs; whereas neither insomnia nor its interaction with diary ratings showed a substantial effect; in particular, insomnia is no longer substantially associated with TST after the inclusion of any diary rating in the model (possibly due to nAGQ=0)


WASO.SSD

In section 5.1, WASO.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by SO.num (lower WASO.SSD for later than usual SO) and weekday.sleep (higher WASO.SSD during weekend).

# adding constant to each value to avoid zeros
ema$WASO.SSDc <- ema$WASO.SSD + 0.001

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WASO.SSD by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  
  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="WASO.SSDc",glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,
                                                               modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                               family="gamma",link="log",transform="exp",
                                                               nAGQ=0, # nAGQ = 0 to reach convergence in all models
                                                               mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                                               outputs="key.results",key.predictor=keys[1],
                                                               key.model=keys[1],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WASO.SSDc",glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,
                                                                     modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                     family="gamma",link="log",transform="exp",
                                                                     nAGQ=0, # nAGQ = 0 to reach convergence in all models
                                                                     mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                                                     outputs="key.results",key.predictor=keys[2],
                                                                     key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WASO.SSDc",glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,
                                                                       modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                       family="gamma",link="log",transform="exp",
                                                                       nAGQ=0, # nAGQ = 0 to reach convergence in all models
                                                                       mComp.baseline="weekday.sleep",p.adjust.method="BH",
                                                                       outputs="key.results",key.predictor=keys[3],
                                                                       key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="WASO.SSDc",fix.eff=predictors,
          modelType=c("GLMER"),mc.predictors=mc.predictors, # GLMER with mean-centered pred.
          family="gamma",link="log",transform="exp",outputs=outputs, 
          mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
          coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing WASO.SSD by stress 
## ###########################################
## 
## Running GLMER analysis of WASO.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , stress , s.nd
## 
## Model specification:
##  - model M0 (null): WASO.SSDc ~ (1|ID)
##  - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
##  - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + (1|ID)
##  - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + (1|ID)
##  - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc      weekday.sleep          stress.mc            s.nd.mc 
##           1.038619           1.057446           2.353562           1.077772 
##           insomnia stress.mc:insomnia 
##           1.000052           2.305243 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    5| 50239.96| 50270.80| -25114.98| 50229.96|    NA| NA|         NA|
## |stress.mc          |    6| 50240.56| 50277.56| -25114.28| 50228.56| 1.408|  1|      0.373|
## |s.nd.mc            |    7| 50242.50| 50285.67| -25114.25| 50228.50| 0.058|  1|      0.810|
## |insomnia           |    8| 50243.33| 50292.67| -25113.67| 50227.33| 1.170|  1|      0.373|
## |stress.mc:insomnia |    9| 50242.71| 50298.22| -25112.36| 50224.71| 2.616|  1|      0.373|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.573 
##    - stress.mc vs. Baseline model = 0.427
##    - s.nd.mc = 0.139
##    - insomnia = 0.084
##    - stress.mc:insomnia = 0.103
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)        |t     |B (SE)        |t     |B (SE)        |t     |
## |:--|:------------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2  |(Intercept)              |552.65(48.94) |71.31 |552.84(48.96) |71.31 |582.90(71.68) |51.78 |
## |3  |SO.num.mc                |0.93(0.03)    |-2.58 |0.93(0.03)    |-2.59 |0.93(0.03)    |-2.63 |
## |4  |weekday.sleep [weekend]  |1.39(0.10)    |4.53  |1.38(0.10)    |4.48  |1.38(0.10)    |4.49  |
## |5  |stress.mc                |0.97(0.03)    |-0.98 |0.97(0.03)    |-0.90 |0.92(0.05)    |-1.65 |
## |8  |s.nd.mc                  |              |      |0.99(0.04)    |-0.22 |0.99(0.04)    |-0.23 |
## |9  |insomnia [1]             |              |      |              |      |0.90(0.15)    |-0.62 |
## |10 |stress.mc * insomnia [1] |              |      |              |      |1.10(0.08)    |1.35  |
## |11 |N                        |92 ID         |92 ID |92 ID         |NA    |NA            |NA    |
## |12 |Observations             |3524          |3524  |3524          |NA    |NA            |NA    |
## |6  |SD (Intercept)           |2.11(NA)      |      |2.11(NA)      |      |2.09(NA)      |      |
## |7  |SD (Observations)        |3.91(NA)      |      |3.91(NA)      |      |3.91(NA)      |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing WASO.SSD by worry 
## ###########################################
## 
## Running GLMER analysis of WASO.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , worry , w.nd
## 
## Model specification:
##  - model M0 (null): WASO.SSDc ~ (1|ID)
##  - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
##  - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + (1|ID)
##  - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + (1|ID)
##  - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    5| 50239.96| 50270.80| -25114.98| 50229.96|    NA| NA|         NA|
## |worry.mc          |    6| 50241.25| 50278.25| -25114.62| 50229.25| 0.714|  1|      0.531|
## |w.nd.mc           |    7| 50241.74| 50284.91| -25113.87| 50227.74| 1.509|  1|      0.516|
## |insomnia          |    8| 50242.46| 50291.80| -25113.23| 50226.46| 1.279|  1|      0.516|
## |worry.mc:insomnia |    9| 50244.45| 50299.96| -25113.22| 50226.45| 0.013|  1|      0.910|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.655 
##    - worry.mc vs. Baseline model = 0.345
##    - w.nd.mc = 0.212
##    - insomnia = 0.129
##    - worry.mc:insomnia = 0.046
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)        |t     |B (SE)        |t     |B (SE)        |t     |
## |:--|:-----------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2  |(Intercept)             |552.51(48.97) |71.25 |551.89(48.86) |71.31 |582.93(71.72) |51.76 |
## |3  |SO.num.mc               |0.93(0.03)    |-2.59 |0.93(0.03)    |-2.56 |0.93(0.03)    |-2.57 |
## |4  |weekday.sleep [weekend] |1.39(0.10)    |4.53  |1.39(0.10)    |4.57  |1.39(0.10)    |4.57  |
## |5  |worry.mc                |0.98(0.03)    |-0.64 |0.97(0.04)    |-0.84 |0.97(0.05)    |-0.65 |
## |8  |w.nd.mc                 |              |      |1.04(0.04)    |1.01  |1.04(0.04)    |1.01  |
## |9  |insomnia [1]            |              |      |              |      |0.90(0.15)    |-0.63 |
## |10 |worry.mc * insomnia [1] |              |      |              |      |1.01(0.07)    |0.11  |
## |11 |N                       |92 ID         |92 ID |92 ID         |NA    |NA            |NA    |
## |12 |Observations            |3524          |3524  |3524          |NA    |NA            |NA    |
## |6  |SD (Intercept)          |2.11(NA)      |      |2.11(NA)      |      |2.09(NA)      |      |
## |7  |SD (Observations)       |3.91(NA)      |      |3.91(NA)      |      |3.91(NA)      |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing WASO.SSD by mood 
## ###########################################
## 
## Running GLMER analysis of WASO.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , mood , m.nd
## 
## Model specification:
##  - model M0 (null): WASO.SSDc ~ (1|ID)
##  - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
##  - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + (1|ID)
##  - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + (1|ID)
##  - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    5| 50239.96| 50270.80| -25114.98| 50229.96|    NA| NA|         NA|
## |mood.mc          |    6| 50241.96| 50278.96| -25114.98| 50229.96| 0.008|  1|      0.929|
## |m.nd.mc          |    7| 50241.78| 50284.95| -25113.89| 50227.78| 2.174|  1|      0.281|
## |insomnia         |    8| 50242.47| 50291.81| -25113.23| 50226.47| 1.314|  1|      0.335|
## |mood.mc:insomnia |    9| 50241.69| 50297.19| -25111.84| 50223.69| 2.781|  1|      0.281|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.73 
##    - mood.mc vs. Baseline model = 0.27
##    - m.nd.mc = 0.227
##    - insomnia = 0.139
##    - mood.mc:insomnia = 0.17
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)        |t     |B (SE)        |t     |B (SE)        |t     |
## |:--|:-----------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2  |(Intercept)             |551.98(49.02) |71.09 |550.92(48.75) |71.32 |582.86(71.22) |52.11 |
## |3  |SO.num.mc               |0.93(0.03)    |-2.55 |0.93(0.03)    |-2.55 |0.93(0.03)    |-2.61 |
## |4  |weekday.sleep [weekend] |1.39(0.10)    |4.59  |1.40(0.10)    |4.69  |1.40(0.10)    |4.64  |
## |5  |mood.mc                 |1.00(0.04)    |-0.05 |0.99(0.04)    |-0.15 |0.94(0.05)    |-1.17 |
## |8  |m.nd.mc                 |              |      |1.04(0.04)    |1.13  |1.04(0.04)    |1.10  |
## |9  |insomnia [1]            |              |      |              |      |0.90(0.15)    |-0.64 |
## |10 |mood.mc * insomnia [1]  |              |      |              |      |1.10(0.08)    |1.29  |
## |11 |N                       |92 ID         |92 ID |92 ID         |NA    |NA            |NA    |
## |12 |Observations            |3524          |3524  |3524          |NA    |NA            |NA    |
## |6  |SD (Intercept)          |2.12(NA)      |      |2.11(NA)      |      |2.08(NA)      |      |
## |7  |SD (Observations)       |3.92(NA)      |      |3.91(NA)      |      |3.91(NA)      |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing WASO.SSD by PsyDist 
## ###########################################
## 
## Running GLMER analysis of WASO.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): WASO.SSDc ~ (1|ID)
##  - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
##  - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + (1|ID)
##  - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    5| 50239.96| 50270.80| -25114.98| 50229.96|    NA| NA|         NA|
## |PsyDist.mc          |    6| 50241.10| 50278.10| -25114.55| 50229.10| 0.870|  1|      0.351|
## |P.nd.mc             |    7| 50241.81| 50284.98| -25113.90| 50227.81| 1.288|  1|      0.345|
## |insomnia            |    8| 50242.53| 50291.87| -25113.27| 50226.53| 1.274|  1|      0.345|
## |PsyDist.mc:insomnia |    9| 50242.16| 50297.67| -25112.08| 50224.16| 2.370|  1|      0.345|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.638 
##    - PsyDist.mc vs. Baseline model = 0.362
##    - P.nd.mc = 0.202
##    - insomnia = 0.123
##    - PsyDist.mc:insomnia = 0.129
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)        |t     |B (SE)        |t     |B (SE)        |t     |
## |:--|:-------------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2  |(Intercept)               |552.89(48.98) |71.29 |552.11(48.82) |71.40 |584.03(71.62) |51.95 |
## |3  |SO.num.mc                 |0.93(0.03)    |-2.59 |0.93(0.03)    |-2.58 |0.93(0.03)    |-2.64 |
## |4  |weekday.sleep [weekend]   |1.39(0.10)    |4.52  |1.40(0.10)    |4.59  |1.39(0.10)    |4.58  |
## |5  |PsyDist.mc                |0.97(0.04)    |-0.69 |0.96(0.05)    |-0.92 |0.89(0.06)    |-1.62 |
## |8  |P.nd.mc                   |              |      |1.04(0.05)    |0.88  |1.04(0.05)    |0.85  |
## |9  |insomnia [1]              |              |      |              |      |0.90(0.15)    |-0.65 |
## |10 |PsyDist.mc * insomnia [1] |              |      |              |      |1.12(0.10)    |1.24  |
## |11 |N                         |92 ID         |92 ID |92 ID         |NA    |NA            |NA    |
## |12 |Observations              |3524          |3524  |3524          |NA    |NA            |NA    |
## |6  |SD (Intercept)            |2.11(NA)      |      |2.11(NA)      |      |2.09(NA)      |      |
## |7  |SD (Observations)         |3.91(NA)      |      |3.91(NA)      |      |3.91(NA)      |      |
## 
## 
##  - Plotting effect(s) estimated by model 6

## 
## 
## 
## ###########################################
## Analyzing WASO.SSD by fs.w 
## ###########################################
## 
## Running GLMER analysis of WASO.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering SO.num
## 
## Model specification:
##  - model M0 (null): WASO.SSDc ~ (1|ID)
##  - model M1: WASO.SSDc ~ SO.num.mc + (1|ID)
##  - model M2: WASO.SSDc ~ SO.num.mc + weekday.sleep + (1|ID)
##  - model M3: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + (1|ID)
##  - model M4: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + f.nd + (1|ID)
##  - model M5: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + (1|ID)
##  - model M6: WASO.SSDc ~ SO.num.mc + weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of WASO.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    5| 50239.96| 50270.80| -25114.98| 50229.96|    NA| NA|         NA|
## |fs.w          |    6| 50241.24| 50278.24| -25114.62| 50229.24| 0.725|  1|      0.394|
## |f.nd          |    7| 50241.65| 50284.82| -25113.83| 50227.65| 1.586|  1|      0.352|
## |insomnia      |    8| 50242.41| 50291.75| -25113.20| 50226.41| 1.248|  1|      0.352|
## |fs.w:insomnia |    9| 50242.64| 50298.14| -25112.32| 50224.64| 1.770|  1|      0.352|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.654 
##    - fs.w vs. Baseline model = 0.346
##    - f.nd = 0.219
##    - insomnia = 0.131
##    - fs.w:insomnia = 0.104
##    Selected model based on Aw: Baseline
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)        |t     |B (SE)        |t     |B (SE)        |t     |
## |:--|:-----------------------|:-------------|:-----|:-------------|:-----|:-------------|:-----|
## |2  |(Intercept)             |552.75(49.14) |71.03 |551.72(49.02) |71.06 |583.38(71.64) |51.87 |
## |3  |SO.num.mc               |0.93(0.03)    |-2.58 |0.93(0.03)    |-2.58 |0.93(0.03)    |-2.63 |
## |4  |weekday.sleep [weekend] |1.39(0.10)    |4.52  |1.40(0.10)    |4.61  |1.40(0.10)    |4.59  |
## |5  |fs.w                    |0.98(0.04)    |-0.63 |0.97(0.04)    |-0.88 |0.92(0.06)    |-1.45 |
## |8  |f.nd                    |              |      |1.04(0.04)    |0.99  |1.04(0.04)    |0.95  |
## |9  |insomnia [1]            |              |      |              |      |0.90(0.15)    |-0.64 |
## |10 |fs.w * insomnia [1]     |              |      |              |      |1.09(0.09)    |1.08  |
## |11 |N                       |92 ID         |92 ID |92 ID         |NA    |NA            |NA    |
## |12 |Observations            |3524          |3524  |3524          |NA    |NA            |NA    |
## |6  |SD (Intercept)          |2.12(NA)      |      |2.12(NA)      |      |2.09(NA)      |      |
## |7  |SD (Observations)       |3.91(NA)      |      |3.91(NA)      |      |3.91(NA)      |      |
## 
## 
##  - Plotting effect(s) estimated by model 6


Comments:

  • both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc

  • only SO.num and weekday.sleep are associated with a significant LRT, and showed stronger evidence in terms of Aw

  • coherently, only the effects reported in section 5.1 are substantial


SO.num.SSD

In section 5.1, SO.num.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher SO.num.SSD during weekend), and insomnia (lower SO.num.SSD for insomnia than controls, even when controlling for sex). Here, insomnia is added after diary ratings for better consistency with the other models.

# adding constant to each value to avoid zeros
ema$SO.num.SSDc <- ema$SO.num.SSD + 0.001

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing SO.num.SSD by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
  
  # saving key results
  res[[i]] <- rbind(res[[i]],cbind(measure="SO.num.SSDc",
      glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,
              modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
              mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
              outputs="key.results",key.predictor=keys[1],key.model=keys[1],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="SO.num.SSDc",
      glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors, # day i+1
              modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
              mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
              outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="SO.num.SSDc",
      glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,
              modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
              mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
              outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
          family="gamma",link="log",transform="exp",
          mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing SO.num.SSD by stress 
## ###########################################
## 
## Running GLMER analysis of SO.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering stress , s.nd
## 
## Model specification:
##  - model M0 (null): SO.num.SSDc ~ (1|ID)
##  - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: SO.num.SSDc ~ weekday.sleep + stress.mc + (1|ID)
##  - model M3: SO.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + (1|ID)
##  - model M4: SO.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M5: SO.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##      weekday.sleep          stress.mc            s.nd.mc           insomnia 
##           1.025231           2.352940           1.076493           1.000020 
## stress.mc:insomnia 
##           2.305039 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    4| 8805.134| 8829.804| -4398.567| 8797.134|    NA| NA|         NA|
## |stress.mc          |    5| 8806.860| 8837.697| -4398.430| 8796.860| 0.274|  1|      0.603|
## |s.nd.mc            |    6| 8808.589| 8845.593| -4398.295| 8796.589| 0.271|  1|      0.603|
## |insomnia           |    7| 8805.575| 8848.747| -4395.788| 8791.575| 5.014|  1|      0.089|
## |stress.mc:insomnia |    8| 8803.544| 8852.883| -4393.772| 8787.544| 4.031|  1|      0.089|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.703 
##    - stress.mc vs. Baseline model = 0.297
##    - s.nd.mc = 0.111
##    - insomnia = 0.334
##    - stress.mc:insomnia = 0.48
##    Selected model based on Aw: stress.mc:insomnia
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)              |1.52(0.20) |3.14  |1.52(0.20) |3.15  |1.81(0.33) |3.28  |
## |3  |weekday.sleep [weekend]  |1.33(0.09) |4.42  |1.33(0.09) |4.33  |1.33(0.09) |4.34  |
## |4  |stress.mc                |0.98(0.03) |-0.49 |0.99(0.03) |-0.37 |0.93(0.04) |-1.58 |
## |7  |s.nd.mc                  |           |      |0.99(0.03) |-0.46 |0.98(0.03) |-0.47 |
## |8  |insomnia [1]             |           |      |           |      |0.71(0.18) |-1.36 |
## |9  |stress.mc * insomnia [1] |           |      |           |      |1.12(0.07) |1.76  |
## |10 |N                        |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations             |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)           |3.38(NA)   |      |3.38(NA)   |      |3.23(NA)   |      |
## |6  |SD (Observations)        |3.68(NA)   |      |3.68(NA)   |      |3.67(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing SO.num.SSD by worry 
## ###########################################
## 
## Running GLMER analysis of SO.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering worry , w.nd
## 
## Model specification:
##  - model M0 (null): SO.num.SSDc ~ (1|ID)
##  - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: SO.num.SSDc ~ weekday.sleep + worry.mc + (1|ID)
##  - model M3: SO.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + (1|ID)
##  - model M4: SO.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M5: SO.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    4| 8805.134| 8829.804| -4398.567| 8797.134|    NA| NA|         NA|
## |worry.mc          |    5| 8806.921| 8837.758| -4398.460| 8796.921| 0.213|  1|      0.644|
## |w.nd.mc           |    6| 8808.058| 8845.062| -4398.029| 8796.058| 0.863|  1|      0.514|
## |insomnia          |    7| 8805.001| 8848.172| -4395.500| 8791.001| 5.058|  1|      0.098|
## |worry.mc:insomnia |    8| 8806.248| 8855.587| -4395.124| 8790.248| 0.753|  1|      0.514|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.71 
##    - worry.mc vs. Baseline model = 0.29
##    - w.nd.mc = 0.141
##    - insomnia = 0.394
##    - worry.mc:insomnia = 0.175
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)             |1.52(0.20) |3.15  |1.52(0.20) |3.15  |1.81(0.33) |3.27  |
## |3  |weekday.sleep [weekend] |1.33(0.09) |4.38  |1.33(0.09) |4.37  |1.33(0.09) |4.33  |
## |4  |worry.mc                |0.99(0.03) |-0.38 |0.99(0.03) |-0.23 |0.96(0.05) |-0.81 |
## |7  |w.nd.mc                 |           |      |0.97(0.03) |-0.78 |0.97(0.03) |-0.85 |
## |8  |insomnia [1]            |           |      |           |      |0.71(0.18) |-1.35 |
## |9  |worry.mc * insomnia [1] |           |      |           |      |1.06(0.07) |0.86  |
## |10 |N                       |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations            |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)          |3.38(NA)   |      |3.37(NA)   |      |3.24(NA)   |      |
## |6  |SD (Observations)       |3.69(NA)   |      |3.68(NA)   |      |3.68(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing SO.num.SSD by mood 
## ###########################################
## 
## Running GLMER analysis of SO.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering mood , m.nd
## 
## Model specification:
##  - model M0 (null): SO.num.SSDc ~ (1|ID)
##  - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: SO.num.SSDc ~ weekday.sleep + mood.mc + (1|ID)
##  - model M3: SO.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + (1|ID)
##  - model M4: SO.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M5: SO.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    4| 8805.134| 8829.804| -4398.567| 8797.134|    NA| NA|         NA|
## |mood.mc          |    5| 8805.214| 8836.051| -4397.607| 8795.214| 1.920|  1|      0.221|
## |m.nd.mc          |    6| 8805.218| 8842.222| -4396.609| 8793.218| 1.996|  1|      0.221|
## |insomnia         |    7| 8802.165| 8845.337| -4394.083| 8788.165| 5.053|  1|      0.098|
## |mood.mc:insomnia |    8| 8803.760| 8853.099| -4393.880| 8787.760| 0.405|  1|      0.524|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.51 
##    - mood.mc vs. Baseline model = 0.49
##    - m.nd.mc = 0.328
##    - insomnia = 0.602
##    - mood.mc:insomnia = 0.213
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)             |1.52(0.20) |3.16  |1.52(0.20) |3.17  |1.82(0.33) |3.29  |
## |3  |weekday.sleep [weekend] |1.32(0.09) |4.28  |1.32(0.09) |4.25  |1.32(0.09) |4.25  |
## |4  |mood.mc                 |0.96(0.03) |-1.20 |0.97(0.03) |-1.07 |0.94(0.05) |-1.14 |
## |7  |m.nd.mc                 |           |      |0.96(0.03) |-1.25 |0.96(0.03) |-1.26 |
## |8  |insomnia [1]            |           |      |           |      |0.71(0.18) |-1.36 |
## |9  |mood.mc * insomnia [1]  |           |      |           |      |1.04(0.07) |0.58  |
## |10 |N                       |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations            |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)          |3.37(NA)   |      |3.36(NA)   |      |3.23(NA)   |      |
## |6  |SD (Observations)       |3.68(NA)   |      |3.68(NA)   |      |3.68(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing SO.num.SSD by PsyDist 
## ###########################################
## 
## Running GLMER analysis of SO.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): SO.num.SSDc ~ (1|ID)
##  - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + (1|ID)
##  - model M3: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M4: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M5: SO.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    4| 8805.134| 8829.804| -4398.567| 8797.134|    NA| NA|         NA|
## |PsyDist.mc          |    5| 8806.174| 8837.011| -4398.087| 8796.174| 0.960|  1|      0.327|
## |P.nd.mc             |    6| 8806.918| 8843.922| -4397.459| 8794.918| 1.257|  1|      0.327|
## |insomnia            |    7| 8803.907| 8847.079| -4394.954| 8789.907| 5.010|  1|      0.101|
## |PsyDist.mc:insomnia |    8| 8803.560| 8852.898| -4393.780| 8787.560| 2.348|  1|      0.251|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.627 
##    - PsyDist.mc vs. Baseline model = 0.373
##    - P.nd.mc = 0.205
##    - insomnia = 0.48
##    - PsyDist.mc:insomnia = 0.363
##    Selected model based on Aw: PsyDist.mc:insomnia
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)               |1.52(0.20) |3.16  |1.53(0.20) |3.17  |1.82(0.33) |3.29  |
## |3  |weekday.sleep [weekend]   |1.32(0.09) |4.31  |1.32(0.09) |4.25  |1.31(0.09) |4.20  |
## |4  |PsyDist.mc                |0.96(0.04) |-0.86 |0.98(0.04) |-0.56 |0.91(0.06) |-1.44 |
## |7  |P.nd.mc                   |           |      |0.96(0.04) |-0.97 |0.96(0.04) |-1.01 |
## |8  |insomnia [1]              |           |      |           |      |0.71(0.18) |-1.36 |
## |9  |PsyDist.mc * insomnia [1] |           |      |           |      |1.12(0.09) |1.39  |
## |10 |N                         |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations              |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)            |3.37(NA)   |      |3.37(NA)   |      |3.23(NA)   |      |
## |6  |SD (Observations)         |3.68(NA)   |      |3.68(NA)   |      |3.67(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing SO.num.SSD by fs.w 
## ###########################################
## 
## Running GLMER analysis of SO.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
## 
## Model specification:
##  - model M0 (null): SO.num.SSDc ~ (1|ID)
##  - model M1: SO.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: SO.num.SSDc ~ weekday.sleep + fs.w + (1|ID)
##  - model M3: SO.num.SSDc ~ weekday.sleep + fs.w + f.nd + (1|ID)
##  - model M4: SO.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + (1|ID)
##  - model M5: SO.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of SO.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    4| 8805.134| 8829.804| -4398.567| 8797.134|    NA| NA|         NA|
## |fs.w          |    5| 8806.203| 8837.040| -4398.102| 8796.203| 0.931|  1|      0.335|
## |f.nd          |    6| 8807.018| 8844.022| -4397.509| 8795.018| 1.186|  1|      0.335|
## |insomnia      |    7| 8803.965| 8847.136| -4394.982| 8789.965| 5.053|  1|      0.098|
## |fs.w:insomnia |    8| 8804.068| 8853.407| -4394.034| 8788.068| 1.897|  1|      0.335|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.631 
##    - fs.w vs. Baseline model = 0.369
##    - f.nd = 0.197
##    - insomnia = 0.476
##    - fs.w:insomnia = 0.311
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)             |1.52(0.20) |3.16  |1.53(0.20) |3.17  |1.82(0.33) |3.30  |
## |3  |weekday.sleep [weekend] |1.32(0.09) |4.30  |1.32(0.09) |4.26  |1.32(0.09) |4.20  |
## |4  |fs.w                    |0.97(0.03) |-0.84 |0.98(0.04) |-0.57 |0.93(0.05) |-1.35 |
## |7  |f.nd                    |           |      |0.97(0.04) |-0.96 |0.96(0.04) |-1.02 |
## |8  |insomnia [1]            |           |      |           |      |0.70(0.18) |-1.37 |
## |9  |fs.w * insomnia [1]     |           |      |           |      |1.09(0.08) |1.27  |
## |10 |N                       |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations            |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)          |3.37(NA)   |      |3.37(NA)   |      |3.24(NA)   |      |
## |6  |SD (Observations)       |3.68(NA)   |      |3.68(NA)   |      |3.68(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5


Comments:

  • both (1) deviance residuals and (2) random effects are quite normally distributed (despite some marked deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc

  • only weekday.sleep and insomnia are associated with a significant LRT, whereas only weekday.sleep showed stronger evidence in terms of Aw

  • coherently, only weekday.sleep shows a substantial effect; in particular,insomnia is no longer substantially associated with SO.num.SSD after the inclusion of any diary rating in the model (possibly due to nAGQ=0)


WakeUp.num.SSD

In section 5.1, WakeUp.num.SSD was modeled by assuming a gamma distribution with a log link function for residuals, and it was substantially predicted by weekday.sleep (higher WakeUp.num.SSD during weekend).

# adding constant to each value to avoid zeros
ema$WakeUp.num.SSDc <- ema$WakeUp.num.SSD + 0.001

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing WakeUp.num.SSD by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c(diaryVars[i],nd) }
  
  # saving key results (considering M3, which showed sig. LRT and/or higher AW compared to M2)
  res[[i]] <- rbind(res[[i]],cbind(measure="WakeUp.num.SSDc",
       glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,
               mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
               modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
               outputs="key.results",key.predictor=keys[1],key.model=keys[2],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="WakeUp.num.SSDc",
      glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,
               modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
               mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
               outputs="key.results",key.predictor=keys[2],key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="WakeUp.num.SSDc",
      glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,
              modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
              mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
              outputs="key.results",key.predictor=keys[3],key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="WakeUp.num.SSDc",fix.eff=predictors,
          modelType=c("GLMER"),mc.predictors=mc.predictors,family="gamma",link="log",transform="exp",
          mComp.baseline="weekday.sleep",p.adjust.method="BH",nAGQ=0, # nAGQ = 0 to reach convergence in all models
          outputs=outputs, coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing WakeUp.num.SSD by stress 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering stress , s.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
##  - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + (1|ID)
##  - model M3: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + (1|ID)
##  - model M4: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M5: WakeUp.num.SSDc ~ weekday.sleep + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##      weekday.sleep          stress.mc            s.nd.mc           insomnia 
##           1.025230           2.352938           1.076487           1.000027 
## stress.mc:insomnia 
##           2.305039 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    4| 10047.11| 10071.78| -5019.557| 10039.11|    NA| NA|         NA|
## |stress.mc          |    5| 10045.84| 10076.67| -5017.919| 10035.84| 3.277|  1|      0.141|
## |s.nd.mc            |    6| 10043.26| 10080.26| -5015.629| 10031.26| 4.579|  1|      0.129|
## |insomnia           |    7| 10044.25| 10087.42| -5015.123| 10030.25| 1.012|  1|      0.419|
## |stress.mc:insomnia |    8| 10046.18| 10095.52| -5015.090| 10030.18| 0.066|  1|      0.798|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.346 
##    - stress.mc vs. Baseline model = 0.654
##    - s.nd.mc = 0.704
##    - insomnia = 0.3
##    - stress.mc:insomnia = 0.102
##    Selected model based on Aw: s.nd.mc
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)              |1.91(0.20) |6.12  |1.91(0.20) |6.16  |2.04(0.30) |4.87  |
## |3  |weekday.sleep [weekend]  |1.43(0.09) |5.94  |1.41(0.09) |5.61  |1.41(0.09) |5.60  |
## |4  |stress.mc                |0.95(0.03) |-1.83 |0.96(0.03) |-1.27 |0.96(0.04) |-0.96 |
## |7  |s.nd.mc                  |           |      |0.94(0.03) |-2.07 |0.94(0.03) |-2.07 |
## |8  |insomnia [1]             |           |      |           |      |0.88(0.18) |-0.64 |
## |9  |stress.mc * insomnia [1] |           |      |           |      |1.01(0.06) |0.15  |
## |10 |N                        |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations             |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)           |2.57(NA)   |      |2.57(NA)   |      |2.54(NA)   |      |
## |6  |SD (Observations)        |3.53(NA)   |      |3.53(NA)   |      |3.53(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num.SSD by worry 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering worry , w.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
##  - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + (1|ID)
##  - model M3: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + (1|ID)
##  - model M4: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M5: WakeUp.num.SSDc ~ weekday.sleep + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    4| 10047.11| 10071.78| -5019.557| 10039.11|    NA| NA|         NA|
## |worry.mc          |    5| 10048.93| 10079.77| -5019.465| 10038.93| 0.185|  1|      0.667|
## |w.nd.mc           |    6| 10045.43| 10082.43| -5016.714| 10033.43| 5.502|  1|      0.076|
## |insomnia          |    7| 10046.28| 10089.45| -5016.140| 10032.28| 1.147|  1|      0.568|
## |worry.mc:insomnia |    8| 10048.02| 10097.36| -5016.009| 10032.02| 0.262|  1|      0.667|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.713 
##    - worry.mc vs. Baseline model = 0.287
##    - w.nd.mc = 0.623
##    - insomnia = 0.289
##    - worry.mc:insomnia = 0.108
##    Selected model based on Aw: w.nd.mc
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)             |1.91(0.20) |6.16  |1.90(0.20) |6.14  |2.04(0.30) |4.87  |
## |3  |weekday.sleep [weekend] |1.44(0.09) |5.95  |1.44(0.09) |5.97  |1.44(0.09) |5.97  |
## |4  |worry.mc                |0.99(0.03) |-0.46 |1.00(0.03) |-0.01 |1.02(0.05) |0.38  |
## |7  |w.nd.mc                 |           |      |0.93(0.03) |-2.37 |0.93(0.03) |-2.36 |
## |8  |insomnia [1]            |           |      |           |      |0.87(0.18) |-0.69 |
## |9  |worry.mc * insomnia [1] |           |      |           |      |0.97(0.06) |-0.55 |
## |10 |N                       |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations            |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)          |2.56(NA)   |      |2.56(NA)   |      |2.54(NA)   |      |
## |6  |SD (Observations)       |3.53(NA)   |      |3.52(NA)   |      |3.52(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num.SSD by mood 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering mood , m.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
##  - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + (1|ID)
##  - model M3: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + (1|ID)
##  - model M4: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M5: WakeUp.num.SSDc ~ weekday.sleep + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: m.nd.mc
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    4| 10047.11| 10071.78| -5019.557| 10039.11|    NA| NA|         NA|
## |mood.mc          |    5| 10048.52| 10079.36| -5019.263| 10038.52| 0.589|  1|      0.501|
## |m.nd.mc          |    6| 10043.21| 10080.21| -5015.605| 10031.21| 7.316|  1|      0.027|
## |insomnia         |    7| 10044.12| 10087.29| -5015.058| 10030.12| 1.093|  1|      0.501|
## |mood.mc:insomnia |    8| 10045.67| 10095.00| -5014.832| 10029.67| 0.452|  1|      0.501|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.669 
##    - mood.mc vs. Baseline model = 0.331
##    - m.nd.mc = 0.825
##    - insomnia = 0.344
##    - mood.mc:insomnia = 0.137
##    Selected model based on Aw: m.nd.mc
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)             |1.91(0.20) |6.16  |1.90(0.20) |6.15  |2.04(0.30) |4.88  |
## |3  |weekday.sleep [weekend] |1.43(0.09) |5.93  |1.43(0.09) |5.90  |1.43(0.09) |5.87  |
## |4  |mood.mc                 |0.98(0.03) |-0.76 |0.98(0.03) |-0.53 |0.96(0.05) |-0.78 |
## |7  |m.nd.mc                 |           |      |0.92(0.03) |-2.61 |0.92(0.03) |-2.63 |
## |8  |insomnia [1]            |           |      |           |      |0.87(0.18) |-0.67 |
## |9  |mood.mc * insomnia [1]  |           |      |           |      |1.03(0.06) |0.55  |
## |10 |N                       |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations            |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)          |2.56(NA)   |      |2.56(NA)   |      |2.54(NA)   |      |
## |6  |SD (Observations)       |3.53(NA)   |      |3.52(NA)   |      |3.52(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num.SSD by PsyDist 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
##  - Mean-centering PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
##  - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + (1|ID)
##  - model M3: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M4: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M5: WakeUp.num.SSDc ~ weekday.sleep + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: P.nd.mc
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    4| 10047.11| 10071.78| -5019.557| 10039.11|    NA| NA|         NA|
## |PsyDist.mc          |    5| 10047.48| 10078.32| -5018.740| 10037.48| 1.634|  1|      0.401|
## |P.nd.mc             |    6| 10039.88| 10076.88| -5013.937| 10027.88| 9.606|  1|      0.008|
## |insomnia            |    7| 10040.80| 10083.97| -5013.401| 10026.80| 1.072|  1|      0.401|
## |PsyDist.mc:insomnia |    8| 10042.71| 10092.05| -5013.357| 10026.71| 0.089|  1|      0.766|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.546 
##    - PsyDist.mc vs. Baseline model = 0.454
##    - P.nd.mc = 0.953
##    - insomnia = 0.375
##    - PsyDist.mc:insomnia = 0.126
##    Selected model based on Aw: P.nd.mc
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-------------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)               |1.91(0.20) |6.16  |1.91(0.20) |6.16  |2.04(0.30) |4.88  |
## |3  |weekday.sleep [weekend]   |1.43(0.09) |5.84  |1.41(0.09) |5.69  |1.41(0.09) |5.68  |
## |4  |PsyDist.mc                |0.95(0.04) |-1.29 |0.98(0.04) |-0.40 |0.98(0.06) |-0.40 |
## |7  |P.nd.mc                   |           |      |0.88(0.04) |-3.08 |0.88(0.04) |-3.08 |
## |8  |insomnia [1]              |           |      |           |      |0.87(0.18) |-0.66 |
## |9  |PsyDist.mc * insomnia [1] |           |      |           |      |1.01(0.08) |0.18  |
## |10 |N                         |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations              |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)            |2.57(NA)   |      |2.56(NA)   |      |2.54(NA)   |      |
## |6  |SD (Observations)         |3.53(NA)   |      |3.52(NA)   |      |3.52(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5

## 
## 
## 
## ###########################################
## Analyzing WakeUp.num.SSD by fs.w 
## ###########################################
## 
## Running GLMER analysis of WakeUp.num.SSDc ...
## 
## Preparing data...
##  - Excluding 2695 incomplete observations ( 43.3 % ) in the response var. or in any of the predictors,
##    and 1 participants with no complete variables
## 
## Model specification:
##  - model M0 (null): WakeUp.num.SSDc ~ (1|ID)
##  - model M1: WakeUp.num.SSDc ~ weekday.sleep + (1|ID)
##  - model M2: WakeUp.num.SSDc ~ weekday.sleep + fs.w + (1|ID)
##  - model M3: WakeUp.num.SSDc ~ weekday.sleep + fs.w + f.nd + (1|ID)
##  - model M4: WakeUp.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + (1|ID)
##  - model M5: WakeUp.num.SSDc ~ weekday.sleep + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of WakeUp.num.SSDc on 3524 observations from 92 participants 
##    using the gamma family with the log link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: f.nd
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    4| 10047.11| 10071.78| -5019.557| 10039.11|    NA| NA|         NA|
## |fs.w          |    5| 10047.94| 10078.77| -5018.968| 10037.94| 1.177|  1|      0.373|
## |f.nd          |    6| 10040.47| 10077.47| -5014.234| 10028.47| 9.468|  1|      0.008|
## |insomnia      |    7| 10041.30| 10084.47| -5013.651| 10027.30| 1.167|  1|      0.373|
## |fs.w:insomnia |    8| 10043.27| 10092.61| -5013.637| 10027.27| 0.027|  1|      0.869|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.601 
##    - fs.w vs. Baseline model = 0.399
##    - f.nd = 0.943
##    - insomnia = 0.383
##    - fs.w:insomnia = 0.125
##    Selected model based on Aw: f.nd
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)     |t     |B (SE)     |t     |B (SE)     |t     |
## |:--|:-----------------------|:----------|:-----|:----------|:-----|:----------|:-----|
## |2  |(Intercept)             |1.91(0.20) |6.16  |1.91(0.20) |6.14  |2.05(0.30) |4.89  |
## |3  |weekday.sleep [weekend] |1.43(0.09) |5.85  |1.42(0.09) |5.76  |1.42(0.09) |5.75  |
## |4  |fs.w                    |0.96(0.03) |-1.11 |0.99(0.03) |-0.30 |0.99(0.05) |-0.25 |
## |7  |f.nd                    |           |      |0.90(0.03) |-3.09 |0.90(0.03) |-3.09 |
## |8  |insomnia [1]            |           |      |           |      |0.87(0.18) |-0.69 |
## |9  |fs.w * insomnia [1]     |           |      |           |      |1.01(0.07) |0.08  |
## |10 |N                       |92 ID      |92 ID |92 ID      |NA    |NA         |NA    |
## |11 |Observations            |3524       |3524  |3524       |NA    |NA         |NA    |
## |5  |SD (Intercept)          |2.56(NA)   |      |2.56(NA)   |      |2.54(NA)   |      |
## |6  |SD (Observations)       |3.53(NA)   |      |3.52(NA)   |      |3.52(NA)   |      |
## 
## 
##  - Plotting effect(s) estimated by model 5


Comments:

  • both (1) deviance residuals and (2) random effects are quite normally distributed (despite some deviations in the lower tails of both distributions) with (3) no substantial linear relationship between residuals and fitted values; although categorical factors do not show substantially different dispersion, (4) the SD is slightly proportional to the mean (as assumed by the gamma distribution); there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less, with the only exception of the interactive term and stress.mc

  • weekday.sleep and all next day raw and aggregate diary ratings are associated with a significant LRT, whereas weekday.sleep, stress, PsyDist, and next day stress, mood, PsyDist, and fs showed stronger evidence in terms of Aw

  • in addition to the effects reported in section 5.1, substantial negative effects are estimated for all next day raw and aggregate diary ratings (with the weakest effect estimated for stress), whereas neither insomnia nor its interaction with diary ratings showed a substantial effect


1.4. Sleep autonomic func.

s.auton variables are modeled by considering the subset of complete s.auton, dailyDiary, and dailyAct data.

s.auton <- c("HR_NREM","HR_REM")

HR_NREM

In section 5.1, HR_NREM was modeled by assuming a normal distribution for residuals, and it was substantially predicted by TotalSleep1000 (higher HR_NREM for higher than usual TotalSleep1000), weekday.sleep (higher HR_NREM during weekends), BMI (higher stageHR_TST for participants with higher BMI), sex (higher stageHR_TST in girls compared to boys), and the interaction between insomnia and sex (lower stageHR_TST in female insomnia compared to control insomnia). Contrarily to the other analyses, here sex is included (since it is an important predictor), while insomnia is added after diary ratings for better consistency.

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing HR_NREM by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("TotalSteps1000","weekday.sleep","BMI","sex",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "TotalSteps1000" # selecting mean-centered predictors (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("TotalSteps1000",diaryVars[i],nd) }
  
  # saving key results (considering M3 for mood, which showed higher Aw than M2 for all predictors)
  key.model <- ifelse(diaryVars[i]=="mood",2,1)
  res[[i]] <- rbind(res[[i]],cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,
                                                             modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                             gmc.predictors="BMI",mComp.baseline="sex",p.adjust.method="BH",
                                                             outputs="key.results",key.predictor=keys[1],key.model=keys[key.model],
                                                             messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,
                                                                   gmc.predictors="BMI",modelType=c("GLMER"),
                                                                   mc.predictors=mc.predictors,
                                                                   mComp.baseline="sex",p.adjust.method="BH",
                                                                   outputs="key.results",key.predictor=keys[2],
                                                                   key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,
                                                                     gmc.predictors="BMI",
                                                                     modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                     mComp.baseline="sex",p.adjust.method="BH",
                                                                     outputs="key.results",key.predictor=keys[3],
                                                                     key.model=keys[3],messages=FALSE)))
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,modelType=c("GLMER"),
          mc.predictors=mc.predictors,gmc.predictors="BMI",mComp.baseline="sex",p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing HR_NREM by stress 
## ###########################################
## 
## Running GLMER analysis of HR_NREM ...
## 
## Preparing data...
##  - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering TotalSteps1000 , stress , s.nd
## 
## Model specification:
##  - model M0 (null): HR_NREM ~ (1|ID)
##  - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
##  - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
##  - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
##  - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + (1|ID)
##  - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + s.nd.mc + (1|ID)
##  - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##  TotalSteps1000.mc      weekday.sleep            BMI.gmc                sex 
##           1.017624           1.032531           1.038264           1.005895 
##          stress.mc            s.nd.mc           insomnia stress.mc:insomnia 
##           2.169455           1.076165           1.036155           2.130629 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    7| 15729.16| 15770.65| -7857.577| 15715.16|    NA| NA|         NA|
## |stress.mc          |    8| 15727.33| 15774.75| -7855.663| 15711.33| 3.829|  1|      0.067|
## |s.nd.mc            |    9| 15729.00| 15782.35| -7855.502| 15711.00| 0.321|  1|      0.571|
## |insomnia           |   10| 15725.56| 15784.83| -7852.778| 15705.56| 5.448|  1|      0.060|
## |stress.mc:insomnia |   11| 15722.83| 15788.04| -7850.418| 15700.83| 4.721|  1|      0.060|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.286 
##    - stress.mc vs. Baseline model = 0.714
##    - s.nd.mc = 0.236
##    - insomnia = 0.569
##    - stress.mc:insomnia = 0.689
##    Selected model based on Aw: stress.mc:insomnia
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)              |61.53(0.81) |75.91 |61.54(0.81) |75.91 |63.16(1.04) |60.67 |
## |3  |TotalSteps1000.mc        |0.15(0.02)  |7.68  |0.15(0.02)  |7.64  |0.15(0.02)  |7.79  |
## |4  |weekday.sleep [weekend]  |0.37(0.17)  |2.22  |0.36(0.17)  |2.13  |0.36(0.17)  |2.14  |
## |5  |BMI.gmc                  |0.55(0.20)  |2.72  |0.55(0.20)  |2.72  |0.47(0.20)  |2.33  |
## |6  |sex [M]                  |-4.26(1.38) |-3.08 |-4.26(1.38) |-3.08 |-4.41(1.34) |-3.29 |
## |7  |stress.mc                |0.16(0.08)  |1.96  |0.17(0.08)  |2.03  |-0.02(0.12) |-0.13 |
## |10 |s.nd.mc                  |            |      |-0.05(0.08) |-0.57 |-0.05(0.08) |-0.59 |
## |11 |insomnia [1]             |            |      |            |      |-3.07(1.29) |-2.37 |
## |12 |stress.mc * insomnia [1] |            |      |            |      |0.35(0.16)  |2.17  |
## |13 |N                        |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |14 |Observations             |2773        |2773  |2773        |NA    |NA          |NA    |
## |8  |SD (Intercept)           |6.15(NA)    |      |6.15(NA)    |      |5.96(NA)    |      |
## |9  |SD (Observations)        |1.96(NA)    |      |1.96(NA)    |      |1.96(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 8

## 
## 
## 
## ###########################################
## Analyzing HR_NREM by worry 
## ###########################################
## 
## Running GLMER analysis of HR_NREM ...
## 
## Preparing data...
##  - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering TotalSteps1000 , worry , w.nd
## 
## Model specification:
##  - model M0 (null): HR_NREM ~ (1|ID)
##  - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
##  - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
##  - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
##  - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + (1|ID)
##  - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + w.nd.mc + (1|ID)
##  - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    7| 15729.16| 15770.65| -7857.577| 15715.16|    NA| NA|         NA|
## |worry.mc          |    8| 15731.15| 15778.57| -7857.574| 15715.15| 0.006|  1|      0.937|
## |w.nd.mc           |    9| 15732.95| 15786.30| -7857.476| 15714.95| 0.196|  1|      0.877|
## |insomnia          |   10| 15729.50| 15788.78| -7854.753| 15709.50| 5.447|  1|      0.078|
## |worry.mc:insomnia |   11| 15727.97| 15793.18| -7852.986| 15705.97| 3.534|  1|      0.120|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.73 
##    - worry.mc vs. Baseline model = 0.27
##    - w.nd.mc = 0.099
##    - insomnia = 0.356
##    - worry.mc:insomnia = 0.434
##    Selected model based on Aw: worry.mc:insomnia
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |61.54(0.81) |75.92 |61.54(0.81) |75.92 |63.16(1.04) |60.68 |
## |3  |TotalSteps1000.mc       |0.15(0.02)  |7.59  |0.15(0.02)  |7.60  |0.15(0.02)  |7.63  |
## |4  |weekday.sleep [weekend] |0.35(0.17)  |2.04  |0.35(0.17)  |2.05  |0.34(0.17)  |2.01  |
## |5  |BMI.gmc                 |0.55(0.20)  |2.73  |0.55(0.20)  |2.73  |0.47(0.20)  |2.33  |
## |6  |sex [M]                 |-4.26(1.38) |-3.08 |-4.26(1.38) |-3.08 |-4.41(1.34) |-3.29 |
## |7  |worry.mc                |-0.01(0.08) |-0.08 |-0.01(0.09) |-0.16 |-0.17(0.12) |-1.45 |
## |10 |w.nd.mc                 |            |      |0.04(0.09)  |0.44  |0.04(0.09)  |0.44  |
## |11 |insomnia [1]            |            |      |            |      |-3.07(1.29) |-2.37 |
## |12 |worry.mc * insomnia [1] |            |      |            |      |0.31(0.17)  |1.88  |
## |13 |N                       |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |14 |Observations            |2773        |2773  |2773        |NA    |NA          |NA    |
## |8  |SD (Intercept)          |6.15(NA)    |      |6.15(NA)    |      |5.96(NA)    |      |
## |9  |SD (Observations)       |1.96(NA)    |      |1.96(NA)    |      |1.96(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 8

## 
## 
## 
## ###########################################
## Analyzing HR_NREM by mood 
## ###########################################
## 
## Running GLMER analysis of HR_NREM ...
## 
## Preparing data...
##  - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering TotalSteps1000 , mood , m.nd
## 
## Model specification:
##  - model M0 (null): HR_NREM ~ (1|ID)
##  - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
##  - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
##  - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
##  - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + (1|ID)
##  - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + m.nd.mc + (1|ID)
##  - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: insomnia
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    7| 15729.16| 15770.65| -7857.577| 15715.16|    NA| NA|         NA|
## |mood.mc          |    8| 15731.03| 15778.45| -7857.515| 15715.03| 0.125|  1|      0.724|
## |m.nd.mc          |    9| 15727.49| 15780.84| -7854.747| 15709.49| 5.537|  1|      0.039|
## |insomnia         |   10| 15724.05| 15783.32| -7852.023| 15704.05| 5.447|  1|      0.039|
## |mood.mc:insomnia |   11| 15725.42| 15790.62| -7851.709| 15703.42| 0.628|  1|      0.571|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.719 
##    - mood.mc vs. Baseline model = 0.281
##    - m.nd.mc = 0.623
##    - insomnia = 0.777
##    - mood.mc:insomnia = 0.281
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |61.54(0.81) |75.92 |61.54(0.81) |75.92 |63.16(1.04) |60.67 |
## |3  |TotalSteps1000.mc       |0.15(0.02)  |7.52  |0.15(0.02)  |7.59  |0.15(0.02)  |7.61  |
## |4  |weekday.sleep [weekend] |0.34(0.17)  |2.03  |0.36(0.17)  |2.11  |0.36(0.17)  |2.11  |
## |5  |BMI.gmc                 |0.55(0.20)  |2.73  |0.55(0.20)  |2.72  |0.47(0.20)  |2.33  |
## |6  |sex [M]                 |-4.26(1.38) |-3.08 |-4.26(1.38) |-3.08 |-4.41(1.34) |-3.29 |
## |7  |mood.mc                 |-0.03(0.09) |-0.35 |-0.05(0.09) |-0.58 |-0.12(0.13) |-0.98 |
## |10 |m.nd.mc                 |            |      |0.20(0.09)  |2.35  |0.20(0.09)  |2.36  |
## |11 |insomnia [1]            |            |      |            |      |-3.07(1.29) |-2.37 |
## |12 |mood.mc * insomnia [1]  |            |      |            |      |0.14(0.17)  |0.79  |
## |13 |N                       |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |14 |Observations            |2773        |2773  |2773        |NA    |NA          |NA    |
## |8  |SD (Intercept)          |6.15(NA)    |      |6.15(NA)    |      |5.96(NA)    |      |
## |9  |SD (Observations)       |1.96(NA)    |      |1.96(NA)    |      |1.96(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 8

## 
## 
## 
## ###########################################
## Analyzing HR_NREM by PsyDist 
## ###########################################
## 
## Running GLMER analysis of HR_NREM ...
## 
## Preparing data...
##  - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering TotalSteps1000 , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): HR_NREM ~ (1|ID)
##  - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
##  - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
##  - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
##  - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + (1|ID)
##  - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    7| 15729.16| 15770.65| -7857.577| 15715.16|    NA| NA|         NA|
## |PsyDist.mc          |    8| 15730.63| 15778.05| -7857.313| 15714.63| 0.529|  1|      0.467|
## |P.nd.mc             |    9| 15731.71| 15785.06| -7856.853| 15713.71| 0.919|  1|      0.450|
## |insomnia            |   10| 15728.25| 15787.53| -7854.126| 15708.25| 5.455|  1|      0.078|
## |PsyDist.mc:insomnia |   11| 15725.98| 15791.19| -7851.991| 15703.98| 4.269|  1|      0.078|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.676 
##    - PsyDist.mc vs. Baseline model = 0.324
##    - P.nd.mc = 0.159
##    - insomnia = 0.472
##    - PsyDist.mc:insomnia = 0.595
##    Selected model based on Aw: PsyDist.mc:insomnia
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)               |61.54(0.81) |75.93 |61.53(0.81) |75.92 |63.16(1.04) |60.66 |
## |3  |TotalSteps1000.mc         |0.15(0.02)  |7.63  |0.15(0.02)  |7.66  |0.15(0.02)  |7.76  |
## |4  |weekday.sleep [weekend]   |0.36(0.17)  |2.14  |0.38(0.17)  |2.21  |0.37(0.17)  |2.18  |
## |5  |BMI.gmc                   |0.55(0.20)  |2.73  |0.55(0.20)  |2.72  |0.47(0.20)  |2.33  |
## |6  |sex [M]                   |-4.26(1.38) |-3.08 |-4.26(1.38) |-3.08 |-4.43(1.34) |-3.30 |
## |7  |PsyDist.mc                |0.08(0.11)  |0.73  |0.05(0.11)  |0.47  |-0.19(0.16) |-1.17 |
## |10 |P.nd.mc                   |            |      |0.11(0.11)  |0.96  |0.11(0.11)  |0.96  |
## |11 |insomnia [1]              |            |      |            |      |-3.08(1.29) |-2.38 |
## |12 |PsyDist.mc * insomnia [1] |            |      |            |      |0.45(0.22)  |2.07  |
## |13 |N                         |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |14 |Observations              |2773        |2773  |2773        |NA    |NA          |NA    |
## |8  |SD (Intercept)            |6.15(NA)    |      |6.15(NA)    |      |5.96(NA)    |      |
## |9  |SD (Observations)         |1.96(NA)    |      |1.96(NA)    |      |1.96(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 8

## 
## 
## 
## ###########################################
## Analyzing HR_NREM by fs.w 
## ###########################################
## 
## Running GLMER analysis of HR_NREM ...
## 
## Preparing data...
##  - Excluding 3446 incomplete observations ( 55.4 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Grand-mean-centering BMI
##  - Mean-centering TotalSteps1000
## 
## Model specification:
##  - model M0 (null): HR_NREM ~ (1|ID)
##  - model M1: HR_NREM ~ TotalSteps1000.mc + (1|ID)
##  - model M2: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + (1|ID)
##  - model M3: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + (1|ID)
##  - model M4: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + (1|ID)
##  - model M5: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + (1|ID)
##  - model M6: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + f.nd + (1|ID)
##  - model M7: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + f.nd + insomnia + (1|ID)
##  - model M8: HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_NREM on 2773 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: Baseline
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    7| 15729.16| 15770.65| -7857.577| 15715.16|    NA| NA|         NA|
## |fs.w          |    8| 15730.94| 15778.36| -7857.472| 15714.94| 0.212|  1|      0.645|
## |f.nd          |    9| 15731.67| 15785.02| -7856.836| 15713.67| 1.272|  1|      0.346|
## |insomnia      |   10| 15728.22| 15787.50| -7854.111| 15708.22| 5.450|  1|      0.078|
## |fs.w:insomnia |   11| 15726.21| 15791.42| -7852.107| 15704.21| 4.008|  1|      0.091|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.71 
##    - fs.w vs. Baseline model = 0.29
##    - f.nd = 0.168
##    - insomnia = 0.485
##    - fs.w:insomnia = 0.57
##    Selected model based on Aw: fs.w:insomnia
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |61.54(0.81) |75.92 |61.54(0.81) |75.93 |63.16(1.04) |60.67 |
## |3  |TotalSteps1000.mc       |0.15(0.02)  |7.61  |0.15(0.02)  |7.64  |0.15(0.02)  |7.73  |
## |4  |weekday.sleep [weekend] |0.36(0.17)  |2.11  |0.37(0.17)  |2.17  |0.36(0.17)  |2.14  |
## |5  |BMI.gmc                 |0.55(0.20)  |2.73  |0.55(0.20)  |2.73  |0.47(0.20)  |2.33  |
## |6  |sex [M]                 |-4.26(1.38) |-3.08 |-4.25(1.38) |-3.08 |-4.42(1.34) |-3.29 |
## |7  |fs.w                    |0.04(0.09)  |0.46  |0.02(0.10)  |0.19  |-0.18(0.14) |-1.31 |
## |10 |f.nd                    |            |      |0.11(0.10)  |1.13  |0.11(0.10)  |1.13  |
## |11 |insomnia [1]            |            |      |            |      |-3.08(1.29) |-2.38 |
## |12 |fs.w * insomnia [1]     |            |      |            |      |0.37(0.18)  |2.00  |
## |13 |N                       |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |14 |Observations            |2773        |2773  |2773        |NA    |NA          |NA    |
## |8  |SD (Intercept)          |6.15(NA)    |      |6.15(NA)    |      |5.96(NA)    |      |
## |9  |SD (Observations)       |1.96(NA)    |      |1.96(NA)    |      |1.96(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 8


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed, despite a marked deviation in the upper tail of the residuals distribution, with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • only model M6 including next-day mood shows a significant LRT, whereas models M5 including prior-day stress, models M7 also including insomnia group differences, and the interactive model M8 with prior-day stress showed stronger evidence in terms of Aw, compared to the baseline model

  • in addition to the effects reported in section 5.1, a substantial effect is only estiamted for next-day mood (higher HR_NREM for higher-than-usual negative mood) and the interaction between prior-day stress and insomnia (higher HR_NREM for higher-than-usual stress but only in the insomnia group)


HR_REM

In section 5.1, HR_REM was modeled by assuming a normal distribution for residuals, and it was substantially predicted by SO.num (higher HR_REM for later than usual SO), TotalSleep1000 (higher HR_NREM for higher than usual TotalSleep1000), sex (higher stageHR_TST in girls compared to boys), and the interaction between insomnia and sex (lower stageHR_TST in female insomnia compared to control insomnia). Contrarily to the other analyses, here sex is included (since it is an important predictor), while insomnia is added after diary ratings for better consistency.

for(i in 1:length(diaryVars)){ cat("\n\n\n###########################################\nAnalyzing HR_REM by",diaryVars[i],
                                   "\n###########################################\n\n")
  # selecting predictors
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary rating
  predictors <- c("SO.num","TotalSteps1000","sex",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  keys <- c(paste(diaryVars[i],".mc",sep=""),paste(nd,".mc",sep=""),  # key predictors (M2, M3, and M4)
            paste(diaryVars[i],".mc:insomnia",sep="")) # fit diagnostics only for the first predictor
  if(i==1){ outputs <- c("fit","mComp","coeff","plotEff") } else { outputs <- c("mComp","coeff","plotEff") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # selecting mean-centered pred. (not fs)
    keys <- gsub(".mc","",keys) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  
  # saving key results (considering M3 for mood, which showed higher Aw than M2 for all predictors)
  key.model <- ifelse(diaryVars[i]=="mood",2,1)
  res[[i]] <- rbind(res[[i]],cbind(measure="HR_REM",glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,
                                                            modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                            mComp.baseline="sex",p.adjust.method="BH",
                                                            outputs="key.results",key.predictor=keys[1],
                                                            key.model=keys[key.model],messages=FALSE)))
  res.nd[[i]] <- rbind(res.nd[[i]],cbind(measure="HR_REM",glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,
                                                                  modelType=c("GLMER"),mc.predictors=mc.predictors,
                                                                  mComp.baseline="sex",p.adjust.method="BH",
                                                                  outputs="key.results",key.predictor=keys[2],
                                                                  key.model=keys[2],messages=FALSE)))
  res.int[[i]] <- rbind(res.int[[i]],cbind(measure="HR_REM",glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,
                                                                    gmc.predictors="BMI",modelType=c("GLMER"),
                                                                    mc.predictors=mc.predictors,
                                                                    mComp.baseline="sex",p.adjust.method="BH",
                                                                    outputs="key.results",key.predictor=keys[3],
                                                                    key.model=keys[3],messages=FALSE)))
  
  # showing analysis
  glmerAn(long=ema,wide=demos,resp="HR_REM",fix.eff=predictors,modelType=c("GLMER"),mc.predictors=mc.predictors,
          mComp.baseline="sex",p.adjust.method="BH",
          outputs=outputs,coeff.models=c(keys[1],keys[2],keys[3]),plot.model=keys[3],show.data=TRUE) }
## 
## 
## 
## ###########################################
## Analyzing HR_REM by stress 
## ###########################################
## 
## Running GLMER analysis of HR_REM ...
## 
## Preparing data...
##  - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Mean-centering SO.num , TotalSteps1000 , stress , s.nd
## 
## Model specification:
##  - model M0 (null): HR_REM ~ (1|ID)
##  - model M1: HR_REM ~ SO.num.mc + (1|ID)
##  - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
##  - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
##  - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + (1|ID)
##  - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + s.nd.mc + (1|ID)
##  - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + s.nd.mc + insomnia + (1|ID)
##  - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + stress.mc + s.nd.mc + insomnia + stress.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Plotting diagnostics of the most complex model:

## 
##   Printing Variance Inflation Factors (VIF):
##          SO.num.mc  TotalSteps1000.mc                sex          stress.mc 
##           1.004485           1.010607           1.001423           2.171109 
##            s.nd.mc           insomnia stress.mc:insomnia 
##           1.059222           1.001423           2.136406 
## 
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: insomnia
## 
## |                   | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline           |    6| 15954.63| 15990.23| -7971.315| 15942.63|    NA| NA|         NA|
## |stress.mc          |    7| 15950.38| 15991.91| -7968.188| 15936.38| 6.254|  1|      0.025|
## |s.nd.mc            |    8| 15951.99| 15999.45| -7967.994| 15935.99| 0.388|  1|      0.533|
## |insomnia           |    9| 15947.39| 16000.79| -7964.695| 15929.39| 6.598|  1|      0.025|
## |stress.mc:insomnia |   10| 15948.74| 16008.08| -7964.371| 15928.74| 0.648|  1|      0.533|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. stress.mc : = 0.106 
##    - stress.mc vs. Baseline model = 0.894
##    - s.nd.mc = 0.285
##    - insomnia = 0.74
##    - stress.mc:insomnia = 0.273
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models stress.mc , s.nd.mc , stress.mc:insomnia
## 
## |   |Predictors               |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)              |63.53(0.84) |75.59 |63.53(0.84) |75.59 |65.33(1.06) |61.58 |
## |3  |SO.num.mc                |0.20(0.07)  |2.97  |0.20(0.07)  |2.94  |0.20(0.07)  |2.95  |
## |4  |TotalSteps1000.mc        |0.13(0.02)  |6.65  |0.13(0.02)  |6.61  |0.13(0.02)  |6.65  |
## |5  |sex [M]                  |-4.17(1.43) |-2.91 |-4.17(1.43) |-2.91 |-4.31(1.38) |-3.12 |
## |6  |stress.mc                |0.21(0.08)  |2.50  |0.22(0.08)  |2.58  |0.15(0.12)  |1.22  |
## |9  |s.nd.mc                  |            |      |-0.05(0.09) |-0.62 |-0.05(0.09) |-0.63 |
## |10 |insomnia [1]             |            |      |            |      |-3.44(1.31) |-2.62 |
## |11 |stress.mc * insomnia [1] |            |      |            |      |0.13(0.17)  |0.80  |
## |12 |N                        |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |13 |Observations             |2789        |2789  |2789        |NA    |NA          |NA    |
## |7  |SD (Intercept)           |6.39(NA)    |      |6.39(NA)    |      |6.14(NA)    |      |
## |8  |SD (Observations)        |1.98(NA)    |      |1.98(NA)    |      |1.98(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing HR_REM by worry 
## ###########################################
## 
## Running GLMER analysis of HR_REM ...
## 
## Preparing data...
##  - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Mean-centering SO.num , TotalSteps1000 , worry , w.nd
## 
## Model specification:
##  - model M0 (null): HR_REM ~ (1|ID)
##  - model M1: HR_REM ~ SO.num.mc + (1|ID)
##  - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
##  - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
##  - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + (1|ID)
##  - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + w.nd.mc + (1|ID)
##  - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + w.nd.mc + insomnia + (1|ID)
##  - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + worry.mc + w.nd.mc + insomnia + worry.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: insomnia
## 
## |                  | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline          |    6| 15954.63| 15990.23| -7971.315| 15942.63|    NA| NA|         NA|
## |worry.mc          |    7| 15956.05| 15997.58| -7971.023| 15942.05| 0.583|  1|      0.445|
## |w.nd.mc           |    8| 15956.63| 16004.10| -7970.316| 15940.63| 1.414|  1|      0.384|
## |insomnia          |    9| 15952.03| 16005.44| -7967.017| 15934.03| 6.598|  1|      0.041|
## |worry.mc:insomnia |   10| 15952.91| 16012.24| -7966.452| 15932.91| 1.130|  1|      0.384|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. worry.mc : = 0.67 
##    - worry.mc vs. Baseline model = 0.33
##    - w.nd.mc = 0.198
##    - insomnia = 0.663
##    - worry.mc:insomnia = 0.3
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models worry.mc , w.nd.mc , worry.mc:insomnia
## 
## |   |Predictors              |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)             |63.53(0.84) |75.59 |63.53(0.84) |75.59 |65.33(1.06) |61.58 |
## |3  |SO.num.mc               |0.19(0.07)  |2.82  |0.20(0.07)  |2.86  |0.20(0.07)  |2.87  |
## |4  |TotalSteps1000.mc       |0.13(0.02)  |6.49  |0.13(0.02)  |6.51  |0.13(0.02)  |6.52  |
## |5  |sex [M]                 |-4.17(1.43) |-2.91 |-4.17(1.43) |-2.91 |-4.31(1.38) |-3.12 |
## |6  |worry.mc                |-0.07(0.09) |-0.76 |-0.08(0.09) |-0.97 |-0.18(0.12) |-1.43 |
## |9  |w.nd.mc                 |            |      |0.10(0.09)  |1.19  |0.10(0.09)  |1.19  |
## |10 |insomnia [1]            |            |      |            |      |-3.44(1.31) |-2.62 |
## |11 |worry.mc * insomnia [1] |            |      |            |      |0.18(0.17)  |1.06  |
## |12 |N                       |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |13 |Observations            |2789        |2789  |2789        |NA    |NA          |NA    |
## |7  |SD (Intercept)          |6.39(NA)    |      |6.39(NA)    |      |6.14(NA)    |      |
## |8  |SD (Observations)       |1.98(NA)    |      |1.98(NA)    |      |1.98(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing HR_REM by mood 
## ###########################################
## 
## Running GLMER analysis of HR_REM ...
## 
## Preparing data...
##  - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Mean-centering SO.num , TotalSteps1000 , mood , m.nd
## 
## Model specification:
##  - model M0 (null): HR_REM ~ (1|ID)
##  - model M1: HR_REM ~ SO.num.mc + (1|ID)
##  - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
##  - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
##  - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + (1|ID)
##  - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + m.nd.mc + (1|ID)
##  - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + m.nd.mc + insomnia + (1|ID)
##  - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + mood.mc + m.nd.mc + insomnia + mood.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: insomnia
## 
## |                 | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:----------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline         |    6| 15954.63| 15990.23| -7971.315| 15942.63|    NA| NA|         NA|
## |mood.mc          |    7| 15955.71| 15997.24| -7970.854| 15941.71| 0.922|  1|      0.449|
## |m.nd.mc          |    8| 15952.93| 16000.39| -7968.463| 15936.93| 4.782|  1|      0.058|
## |insomnia         |    9| 15948.33| 16001.73| -7965.164| 15930.33| 6.598|  1|      0.041|
## |mood.mc:insomnia |   10| 15950.25| 16009.59| -7965.128| 15930.25| 0.073|  1|      0.787|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. mood.mc : = 0.632 
##    - mood.mc vs. Baseline model = 0.368
##    - m.nd.mc = 0.597
##    - insomnia = 0.856
##    - mood.mc:insomnia = 0.246
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models mood.mc , m.nd.mc , mood.mc:insomnia
## 
## |   |Predictors             |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:----------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)            |63.53(0.84) |75.59 |63.53(0.84) |75.59 |65.33(1.06) |61.58 |
## |3  |SO.num.mc              |0.19(0.07)  |2.79  |0.19(0.07)  |2.82  |0.19(0.07)  |2.82  |
## |4  |TotalSteps1000.mc      |0.13(0.02)  |6.38  |0.13(0.02)  |6.44  |0.13(0.02)  |6.43  |
## |5  |sex [M]                |-4.17(1.43) |-2.91 |-4.17(1.43) |-2.91 |-4.31(1.38) |-3.12 |
## |6  |mood.mc                |-0.08(0.09) |-0.96 |-0.10(0.09) |-1.17 |-0.08(0.13) |-0.60 |
## |9  |m.nd.mc                |            |      |0.19(0.09)  |2.19  |0.19(0.09)  |2.19  |
## |10 |insomnia [1]           |            |      |            |      |-3.44(1.31) |-2.62 |
## |11 |mood.mc * insomnia [1] |            |      |            |      |-0.05(0.18) |-0.27 |
## |12 |N                      |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |13 |Observations           |2789        |2789  |2789        |NA    |NA          |NA    |
## |7  |SD (Intercept)         |6.39(NA)    |      |6.39(NA)    |      |6.14(NA)    |      |
## |8  |SD (Observations)      |1.98(NA)    |      |1.98(NA)    |      |1.98(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing HR_REM by PsyDist 
## ###########################################
## 
## Running GLMER analysis of HR_REM ...
## 
## Preparing data...
##  - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Mean-centering SO.num , TotalSteps1000 , PsyDist , P.nd
## 
## Model specification:
##  - model M0 (null): HR_REM ~ (1|ID)
##  - model M1: HR_REM ~ SO.num.mc + (1|ID)
##  - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
##  - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
##  - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + (1|ID)
##  - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + P.nd.mc + (1|ID)
##  - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + P.nd.mc + insomnia + (1|ID)
##  - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + PsyDist.mc + P.nd.mc + insomnia + PsyDist.mc:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: insomnia
## 
## |                    | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline            |    6| 15954.63| 15990.23| -7971.315| 15942.63|    NA| NA|         NA|
## |PsyDist.mc          |    7| 15956.43| 15997.97| -7971.217| 15942.43| 0.196|  1|      0.658|
## |P.nd.mc             |    8| 15956.92| 16004.38| -7970.458| 15940.92| 1.518|  1|      0.436|
## |insomnia            |    9| 15952.32| 16005.72| -7967.158| 15934.32| 6.600|  1|      0.041|
## |PsyDist.mc:insomnia |   10| 15953.85| 16013.19| -7966.927| 15933.85| 0.463|  1|      0.658|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. PsyDist.mc : = 0.711 
##    - PsyDist.mc vs. Baseline model = 0.289
##    - P.nd.mc = 0.185
##    - insomnia = 0.648
##    - PsyDist.mc:insomnia = 0.231
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models PsyDist.mc , P.nd.mc , PsyDist.mc:insomnia
## 
## |   |Predictors                |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)               |63.53(0.84) |75.61 |63.53(0.84) |75.60 |65.34(1.06) |61.58 |
## |3  |SO.num.mc                 |0.20(0.07)  |2.90  |0.20(0.07)  |2.94  |0.20(0.07)  |2.95  |
## |4  |TotalSteps1000.mc         |0.13(0.02)  |6.55  |0.13(0.02)  |6.58  |0.13(0.02)  |6.61  |
## |5  |sex [M]                   |-4.18(1.43) |-2.91 |-4.18(1.43) |-2.91 |-4.32(1.38) |-3.13 |
## |6  |PsyDist.mc                |0.05(0.11)  |0.44  |0.01(0.11)  |0.12  |-0.07(0.17) |-0.41 |
## |9  |P.nd.mc                   |            |      |0.14(0.11)  |1.23  |0.14(0.11)  |1.23  |
## |10 |insomnia [1]              |            |      |            |      |-3.44(1.31) |-2.62 |
## |11 |PsyDist.mc * insomnia [1] |            |      |            |      |0.15(0.22)  |0.68  |
## |12 |N                         |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |13 |Observations              |2789        |2789  |2789        |NA    |NA          |NA    |
## |7  |SD (Intercept)            |6.39(NA)    |      |6.39(NA)    |      |6.14(NA)    |      |
## |8  |SD (Observations)         |1.98(NA)    |      |1.98(NA)    |      |1.98(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7

## 
## 
## 
## ###########################################
## Analyzing HR_REM by fs.w 
## ###########################################
## 
## Running GLMER analysis of HR_REM ...
## 
## Preparing data...
##  - Excluding 3430 incomplete observations ( 55.2 % ) in the response var. or in any of the predictors,
##    and 3 participants with no complete variables
##  - Mean-centering SO.num , TotalSteps1000
## 
## Model specification:
##  - model M0 (null): HR_REM ~ (1|ID)
##  - model M1: HR_REM ~ SO.num.mc + (1|ID)
##  - model M2: HR_REM ~ SO.num.mc + TotalSteps1000.mc + (1|ID)
##  - model M3: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + (1|ID)
##  - model M4: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + (1|ID)
##  - model M5: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + f.nd + (1|ID)
##  - model M6: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + f.nd + insomnia + (1|ID)
##  - model M7: HR_REM ~ SO.num.mc + TotalSteps1000.mc + sex + fs.w + f.nd + insomnia + fs.w:insomnia + (1|ID)
## 
## Fitting GLMER models of HR_REM on 2789 observations from 90 participants 
##    using the normal family with the identity link function using ML estimator...
## 
## Generating models outputs...
## 
##  - Running likelihood ratio test: (applying BH p-values correction)
##    Selected model: insomnia
## 
## |              | npar|      AIC|      BIC|    logLik| deviance| Chisq| Df| Pr(>Chisq)|
## |:-------------|----:|--------:|--------:|---------:|--------:|-----:|--:|----------:|
## |Baseline      |    6| 15954.63| 15990.23| -7971.315| 15942.63|    NA| NA|         NA|
## |fs.w          |    7| 15956.63| 15998.16| -7971.314| 15942.63| 0.001|  1|      0.977|
## |f.nd          |    8| 15956.40| 16003.87| -7970.201| 15940.40| 2.226|  1|      0.271|
## |insomnia      |    9| 15951.81| 16005.21| -7966.904| 15933.81| 6.594|  1|      0.041|
## |fs.w:insomnia |   10| 15953.31| 16012.65| -7966.657| 15933.31| 0.494|  1|      0.643|
## 
## 
##  - Computing Aw coefficients for each model vs. all previous models: 
##    - Baseline vs. fs.w : = 0.731 
##    - fs.w vs. Baseline model = 0.269
##    - f.nd = 0.231
##    - insomnia = 0.697
##    - fs.w:insomnia = 0.247
##    Selected model based on Aw: insomnia
## 
##  - Printing estimated coefficients for models fs.w , f.nd , fs.w:insomnia
## 
## |   |Predictors          |B (SE)      |t     |B (SE)      |t     |B (SE)      |t     |
## |:--|:-------------------|:-----------|:-----|:-----------|:-----|:-----------|:-----|
## |2  |(Intercept)         |63.53(0.84) |75.59 |63.53(0.84) |75.61 |65.34(1.06) |61.58 |
## |3  |SO.num.mc           |0.20(0.07)  |2.87  |0.20(0.07)  |2.92  |0.20(0.07)  |2.93  |
## |4  |TotalSteps1000.mc   |0.13(0.02)  |6.51  |0.13(0.02)  |6.55  |0.13(0.02)  |6.58  |
## |5  |sex [M]             |-4.17(1.43) |-2.91 |-4.17(1.43) |-2.91 |-4.31(1.38) |-3.12 |
## |6  |fs.w                |0.00(0.09)  |0.03  |-0.03(0.10) |-0.33 |-0.10(0.14) |-0.73 |
## |9  |f.nd                |            |      |0.14(0.10)  |1.49  |0.14(0.10)  |1.49  |
## |10 |insomnia [1]        |            |      |            |      |-3.44(1.31) |-2.62 |
## |11 |fs.w * insomnia [1] |            |      |            |      |0.13(0.19)  |0.70  |
## |12 |N                   |90 ID       |90 ID |90 ID       |NA    |NA          |NA    |
## |13 |Observations        |2789        |2789  |2789        |NA    |NA          |NA    |
## |7  |SD (Intercept)      |6.39(NA)    |      |6.39(NA)    |      |6.14(NA)    |      |
## |8  |SD (Observations)   |1.98(NA)    |      |1.98(NA)    |      |1.98(NA)    |      |
## 
## 
##  - Plotting effect(s) estimated by model 7


Comments:

  • both (1) residuals and (2) random effects are quite normally distributed, despite a marked deviation in the upper tail of the residuals distribution, with (3) homogeneity between the variances across sex and insomnia levels, and (4) no substantial linear relationship between residuals and fitted values; there is (5) not strong evidence of multicollinearity as all VIFs are 2 or less

  • SO.num, TotalSteps1000, sex, insomnia, stress, PsyDist, fs, and next day mood are associated with a significant LRT, whereas SO.num, TotalSteps1000, sex, insomnia, stress, PsyDist, fs, and next day stress, PsyDist, and fs showed stronger evidence in terms of Aw

  • in addition to the effects reported in section 5.1, a substantial positive effect is only estimated for stress and next day mood


1.5. Summary of results

Here, we use the key.resPlot function to graphically summarize the results obtained from the models above. The figure below shows the t-values associated with the `*diary ratings preceding the sleep periods by considering either model M2 (main effect of prior-day diary ratings) or model M3 (main effect of the next day diary ratings**). The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, and |t| > 1.96 ) are shown in green

  • those relationships showing a |t| > 1.96 but either a nonsignificant LRT or a lower Aw than the previous model are shown in light green (or lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT and lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT or a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT and lower Aw than the previous models are shown in red

PRIOR-DAY

# all results in one data.frame
RES <- rbind(cbind(res[[1]],pred=rep("stress",16)),cbind(res[[2]],pred=rep("worry",16)),
             cbind(res[[3]],pred=rep("mood",16)),cbind(res[[4]],pred=rep("PsyDist",16)),
             cbind(res[[5]],pred=rep("fs.w",16)))
RES$pred <- factor(RES$pred,levels=c("fs.w","PsyDist","mood","worry","stress"))

# stress
key.resPlot(RES,robCheck="pred")


Comments:

  • the analysis of the relationships between sleep outcomes and diary ratings highlighted substantial negative relationships between prior-day diary ratings and TIB (negatively related to all ratings), TST and WakeUp.num (related to all ratings but mood), WASO (only substantially related with worry and PsyDist), and SO.num (only insubstantially related to stress)

  • a substantial positive relationship is also observed between stress and HR_REM


NEXT DAY

# all results in one data.frame
RES.nd <- rbind(cbind(res.nd[[1]],pred=rep("stress",16)),cbind(res.nd[[2]],pred=rep("worry",16)),
                cbind(res.nd[[3]],pred=rep("mood",16)),cbind(res.nd[[4]],pred=rep("PsyDist",16)),
                cbind(res.nd[[5]],pred=rep("fs.w",16)))
RES.nd$pred <- factor(RES.nd$pred,levels=c("fs.w","PsyDist","mood","worry","stress"))

# stress
key.resPlot(RES.nd,robCheck="pred")


Comments:

  • the analysis of the relationships between sleep outcomes and next day diary ratings highlighted substantial negative relationships between the next day stress ratings and TIB, TST, WASO, and WakeUp.num

  • WakeUp.num.SSD is negatively associated with all next day ratings (although the relationship with worry is not supported by the Aw)

  • TIB.SSD and TST.SSD only show some substantial negative relationships with next day PsyDist

  • next day mood ratings show a negative relationship with TST.SSD, and a positive relationship with both HR_NREM, and HR_REM, although some of them was not supported by higher Aw than the previous model


INTERACTION

# all results in one data.frame
RES.int <- rbind(cbind(res.int[[1]],pred=rep("stress",16)),cbind(res.int[[2]],pred=rep("worry",16)),
                cbind(res.int[[3]],pred=rep("mood",16)),cbind(res.int[[4]],pred=rep("PsyDist",16)),
                cbind(res.int[[5]],pred=rep("fs.w",16)))
RES.int$pred <- factor(RES.int$pred,levels=c("fs.w","PsyDist","mood","worry","stress"))

# stress
key.resPlot(RES.int,robCheck="pred")


Comments:

  • the analysis of the interactive model highlighted substantial interactions between insomnia and stress, worry, and fs only in predicting HR_NREM (i.e., stronger positive relationship between diary ratings and HR_NREM in insomnia compared to controls)

  • none of the other sleep outcomes are substantially predicted by the interactive terms


1.6. Robustness checks

Here, we conduct several robustness checks to account for the arbitrariness of our data processing and analytical choices, including (1) the consideration of insomnia.group instead of the insomnia variable, (2) the inclusion of the covid19 variable as a further covariate, (3) the exclusion of participants with extreme missing data, (4) the exclusion of TotalSteps1000, (5) the use of alternative family distributions for the analyses.

In addition to the glmerAn and the keyResPlot functions reported in section 5.1.6, we also use the predSelect function to select the covariates of each sleep outcome, based on the results in section 5.1.

show predSelect

predSelect <- function(sleepVar){ 
  
  # SE, deep.p, and rem.p were only predicted by SO.num
  if(sleepVar%in%c("deep.p","rem.p")){ 
    predictors <- c("SO.num") 
    
    # SO.num.SSDc and WakeUp.num.SSDc were only predicted by weekday.sleep
    } else if(sleepVar%in%c("SO.num.SSDc","WakeUp.num.SSDc")){
      predictors <- "weekday.sleep"
      
      # light.p was only predicted by BMI
      } else if(sleepVar=="light.p"){ 
        predictors <- "BMI"
    
        # SO.num, TIB.SSDc, and TST.SSDc were predicted by weekday.sleep and BMI
        } else if(sleepVar%in%c("SO.num","TIB.SSDc","TST.SSDc")){
          predictors <- c("weekday.sleep","BMI")
          
          # WakeUp.num was predicted by SO.num, weekday.sleep, and BMI
          } else if(sleepVar=="WakeUp.num"){ 
            predictors <- c("SO.num","weekday.sleep","BMI")
            
            # HR_NREM was predicted by TotalSteps1000, weekday.sleep, BMI, and sex
            } else if(sleepVar=="HR_NREM"){
              predictors <- c("TotalSteps1000","weekday.sleep","BMI","sex")
              
              # HR_NREM was predicted by SO.num, TotalSteps1000, and sex
              } else if(sleepVar=="HR_REM"){ 
                predictors <- c("SO.num","TotalSteps1000","sex")
                
                # SE was predicted by SO.num and age
                } else if(sleepVar=="SE"){
                  predictors <- c("SO.num","age")
                  
                  # WASO was predicted by SO.num, weekday.sleep, and age
                  } else if(sleepVar=="WASO"){
                    predictors <- c("SO.num","weekday.sleep","age")
                    
                    # all remaining sleep outcomes were predicted by SO.num and weekday.sleep
                    } else { predictors <- c("SO.num","weekday.sleep") }
  
  return(predictors)}



1.6.1. insomnia.group

Here, we inspect the results on the interactive term obtained by considering the insomnia.group (i.e., 46 controls, 26 DSM.ins and 21 sub.ins) rather than the insomnia variable (i.e., 46 controls vs. 47 insomnia).

The figure below shows the t-values associated with the interactive term for each sleep outcome and diary predictor, by considering model M4 (interactive model). The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia.group",paste(diaryVars[i],"insomnia.group",sep=":"))
  key <- paste(diaryVars[i],".mc:insomnia.group",sep="") 
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
sleepVars <- c(s.archit[2:length(s.archit)],s.timing,paste(s.variab,"c",sep=""),s.auton)
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    key <- paste(diaryVars[i],":insomnia.group",sep="")
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia.group",key)
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    key <- paste(diaryVars[i],".mc:insomnia.group",sep="")
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}

# plotting robustness check
RES.int <- list()
for(i in 1:length(res.int)){
  res.int[[i]]$robCheck <- "Original"
  res2[[i]]$robCheck <- "insomnia.group"
  RES.int[[i]] <- rbind(res.int[[i]],res2[[i]])
  print(key.resPlot(RES.int[[i]],robCheck = "robCheck") + ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }


Comments:

  • results are highly consistent with the main analyses for most sleep outcomes

  • the only difference is that even the interactions on HR_NREM are not substantial, and that worry is now substantially associated with both TIB.SSD and TST.SSD


1.6.2. COVID-19 emergency

Here, we inspect the results obtained by including the covid19 variable as a further covariate. As shown in section 1.2.8, the covid19 factor discriminates the data collected pre-COVID19 (63%) and the data collected post-COVID19 (37%). The covariate is included at the first step (model M1, before the first predictor).

The figures below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


Separate robustness checks are conducted for each effect of interest.

PRIOR-DAY

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd)
  key.pred <- paste(diaryVars[i],".mc",sep="") # selecting target predictor (prior-day ratings) and target model (M2 or M3)
  if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
  key.model <- paste(nd,".mc",sep="") # selecting model including next day day rating 
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key.pred <- gsub(".mc","",key.pred)
    key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c("covid19",predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    # selecting target predictor (prior-day rating) and target model (M2 or M3 based on above)
    key.pred <- paste(diaryVars[i],".mc",sep="") # M2 (prior-day rating)
    if(sleepVar=="WakeUp.num.SSDc" | (diaryVars[i]=="stress"  & sleepVar%in%c("TST","WASO","WakeUp.num")) | # M3 (next day ratings)
       (diaryVars[i]=="mood"  & sleepVar%in%c("TST.SSDc","HR_NREM","HR_REM")) |
       (diaryVars[i]=="PsyDist"  & sleepVar%in%c("WakeUp.num","TIB.SSDc","TST.SSDc","WakeUp.SSDc")) |
       (diaryVars[i]=="fs.w"  & sleepVar=="TST.SSDc")){ key.model <- paste(nd,"mc",sep=".") 
       } else { key.model <- paste(diaryVars[i],"mc",sep=".") } 
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key.pred <- gsub(".mc","",key.pred)
      key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family=fam[1],link=fam[2],outputs="key.results",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                               key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}

# plotting robustness check
RES.pd <- list()
for(i in 1:length(res)){
  res[[i]]$robCheck <- "Original"
  res2[[i]]$robCheck <- "covid19"
  RES.pd[[i]] <- rbind(res[[i]],res2[[i]])
  print(key.resPlot(RES.pd[[i]],robCheck = "robCheck") + ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are highly consistent with the main analyses

  • the only difference is highlighted for SO.num (showing no longer substantial relationship with worry)


NEXT DAY

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd)
  key <- paste(nd,".mc",sep="") # selecting model including next day day rating
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c("covid19",predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key <- paste(nd,".mc",sep="") # selecting target predictor (next day rating) and target model (M3)
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}

# plotting robustness check
RES.nd <- list()
for(i in 1:length(res)){
  res.nd[[i]]$robCheck <- "Original"
  res2[[i]]$robCheck <- "covid19"
  RES.nd[[i]] <- rbind(res.nd[[i]],res2[[i]])
  print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","covid19"),],
                    robCheck = "robCheck") + ggtitle(paste("Next day",diaryVars[i]))) }


Comments:

  • results are highly consistent with the main analyses


In conclusion, the results of this robustness check were highly consistent with those obtained with the main analyses, although questioning the generalizability of the relationships observed between next day PsyDist and WakeUp.num.


INTERACTION

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  key <- paste(diaryVars[i],":insomnia",sep="")
  predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",key)
  key <- paste(diaryVars[i],".mc:insomnia",sep="")
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=ema,wide=demos,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M4)
    key <- paste(diaryVars[i],":insomnia",sep="")
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c("covid19",predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia",key)
    key <- paste(diaryVars[i],".mc:insomnia",sep="")
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "covid19"
  RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
  print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","covid19"),],robCheck = "robCheck") + 
          ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }


Comments:

  • results are overall consistent with the main analyses for most sleep outcomes

  • the main difference is that the interactive term for PsyDist is substantial on HR_NREM with the inclusion of covid19 as a further covariate


1.6.3. Low compliance

Here, we inspect the results obtained by excluding seven participants (7.5%) with less than two weeks of valid observations in any data type. In section 3.2, these participants were marked with majMiss = 1.

The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


Separate robustness checks are conducted for each effect of interest.

PRIOR-DAY

# excluding participants with extreme missing data
EMA <- ema[ema$majMiss!=1,]
DEMOS <- demos[demos$ID%in%levels(as.factor(as.character(EMA$ID))),]
cat("Excluded",nrow(ema)-nrow(EMA),"days, ",nrow(demos)-nrow(DEMOS),"participants")
## Excluded 465 days,  7 participants
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
  key.pred <- paste(diaryVars[i],".mc",sep="") # prior-day rating
  if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key.pred <- gsub(".mc","",key.pred)
    key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    # selecting target predictor (prior-day rating) and target model (M2 or M3 based on above)
    key.pred <- paste(diaryVars[i],".mc",sep="") # M2 (prior-day rating)
    if(sleepVar=="WakeUp.num.SSDc" | (diaryVars[i]=="stress"  & sleepVar%in%c("TST","WASO","WakeUp.num")) | # M3 (next day ratings)
       (diaryVars[i]=="mood"  & sleepVar%in%c("TST.SSDc","HR_NREM","HR_REM")) |
       (diaryVars[i]=="PsyDist"  & sleepVar%in%c("WakeUp.num","TIB.SSDc","TST.SSDc","WakeUp.SSDc")) |
       (diaryVars[i]=="fs.w"  & sleepVar=="TST.SSDc")){ key.model <- paste(nd,"mc",sep=".") 
    } else { key.model <- paste(diaryVars[i],"mc",sep=".") }
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key.pred <- gsub(".mc","",key.pred)
      key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family=fam[1],link=fam[2],outputs="key.results",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                               key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}

# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "majMiss"
  RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
  print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","majMiss"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are partially inconsistent with the main analyses

  • the main differences are highlighted for mood, whose relationship with TIB is no longer substantial after the exclusion of participants with majMiss

  • similarly, the relationship between worry and SO.num is no longer substantial


NEXT DAY

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
  key <- paste(nd,".mc",sep="") # selecting model including next day day rating
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key <- paste(nd,".mc",sep="") # selecting target predictor (next day rating) and target model (M3)
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") } # selecting family distribution
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "majMiss"
  RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
  print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","majMiss"),],robCheck = "robCheck") + 
           ggtitle(paste("Next day",diaryVars[i]))) }


Comments:

  • results are overall consistent with the main analyses

  • the main differences are highlighted for TST.SSD (showing no longer substantial relationship with next day mood), TIB.SSD (showing no longer substantial relationship with next day PsyDist), and WakeUp.num.SSDc (showing no longer substantial relationship with next day stress)


INTERACTION

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  key <- paste(diaryVars[i],":insomnia",sep="")
  predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",key)
  key <- paste(diaryVars[i],".mc:insomnia",sep="")
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M4)
    key <- paste(diaryVars[i],":insomnia",sep="")
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia",key)
    key <- paste(diaryVars[i],".mc:insomnia",sep="")
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "majMiss"
  RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
  print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","majMiss"),],robCheck = "robCheck") + 
          ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }


Comments:

  • results are overall consistent with the main analyses

  • the only difference is that the interactions between insomnia and worry on both rem.p and HR_REM are no longer substantial (although nor really diminished) after the exclusion of majMiss participants


1.6.4. TotalStep1000

Here, we inspect the results obtained by excluding TotalSteps1000 from the models predictors. This is done in order to replicate the analyses by including cases with invalid daily steps data (thus, with higher sample size). Note that for these analyses, TotalSteps1000 was only included in HR_NREM models.

The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


Separate robustness checks are conducted for each effect of interest.

PRIOR-DAY

# computing key results for HR_NREM
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("weekday.sleep","BMI","sex",diaryVars[i],nd)
  key.pred <- paste(diaryVars[i],".mc",sep="") # prior-day rating
  if(diaryVars[i]=="mood"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- key.pred } # model M3 only for mood
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # mean-centered predictors
    key.pred <- gsub(".mc","",key.pred)
    key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c(diaryVars[i],nd) }
  
  # updating results
  res2[[i]] <- cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,
                                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "no-TotalSteps"
  RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
  print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","no-TotalSteps"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are overall consistent with the main analyses

  • the only difference is that stress now shows a substantial positive relationship with HR_NREM


NEXT DAY

# computing key results for HR_NREM
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("weekday.sleep","BMI","sex",diaryVars[i],nd)
  key <- paste(nd,".mc",sep="") # next day rating
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # mean-centered predictors (not fs)
    key <- gsub(".mc","",key) } else { mc.predictors <- c(diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,
                                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                               outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "no-TotalSteps"
  RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
  print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","no-TotalSteps"),],robCheck = "robCheck") + 
           ggtitle(paste("Next day day",diaryVars[i]))) }


Comments:

  • results are highly consistent with the main analyses


INTERACTION

# computing key results for HR_NREM
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  key <- paste(diaryVars[i],":insomnia",sep="")
  predictors <- c("weekday.sleep","BMI","sex",diaryVars[i],nd,"insomnia",key)
  key <- paste(diaryVars[i],".mc:insomnia",sep="")
  if(diaryVars[i]=="fs.w"){ mc.predictors <- NA # mean-centered predictors
    key <- gsub(".mc","",key) } else { mc.predictors <- c(diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="HR_NREM",glmerAn(long=ema,wide=demos,resp="HR_NREM",fix.eff=predictors,
                                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                               outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "no-TotalSteps"
  RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
  print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","no-TotalSteps"),],robCheck = "robCheck") + 
           ggtitle(paste("Next day day",diaryVars[i]))) }


Comments:

  • results are partially inconsistent with the main analyses: the interaction between insomnia and both worry and fs are no longer substantial

  • in contrast, the interaction between insomnia and PsyDist becomes substantial with the removal of TotalSteps1000


1.6.5. Family distribution

Here, we replicate the models predicting those variables that showed poor fit in the model diagnostics above by re-specifying the models with different distribution families and link functions. As done in section 5.1.6.6, we model:

  • WASO and both s.auton outcomes by using the gamma distribution

  • all s.variab outcomes by assuming a normal distribution


The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


Separate robustness checks are conducted for each effect of interest.

PRIOR-DAY

# computing key results for WASO
ema$WASOc <- ema$WASO + 0.001 # adding little constant to have no zero values
res2 <- list()
for(i in 1:length(diaryVars)){
  # selecting predictors (up to model M3)
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
  key.pred <- paste(diaryVars[i],".mc",sep="") # prior-day rating
  if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors
    key.pred <- gsub(".mc","",key.pred)
    key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASOc",fix.eff=predictors,modelType=c("GLMER"),
                                            family="gamma",link="log", # gamma with log link function
                                            mc.predictors=mc.predictors,
                                            mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                                            outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE,
                                            nAGQ=0)) } # nAGQ = 0 to reach convergence
# computing key results for s.variab
for(sleepVar in paste(s.variab,"c",sep="")){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    # selecting target predictor (prior-day rating) and target model (M2 or M3 based on above)
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key.pred <- paste(diaryVars[i],".mc",sep="") # prior-day rating
    if(sleepVar=="WakeUp.num.SSDc" | (sleepVar=="TIB.SSDc" & diaryVars[i]=="PsyDist") |
       (sleepVar=="TST.SSDc" & diaryVars[i]%in%c("mood","PsyDist","fs.w"))){ key.model <- paste(nd,"mc",sep=".") 
       } else { key.model <- paste(diaryVars[i],"mc",sep=".") } 
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num") # mean-centered predictors
      key.pred <- gsub(".mc","",key.pred)
      key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
    
    # updating results
    if(!(sleepVar=="TIB.SSDc" & diaryVars[i]=="fs.w")){ # model that doesn't converge
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family="normal",link="identity", # normal with identity funct
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                               outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}}

# computing key results for s.auton
for(sleepVar in s.auton){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    # selecting target predictor (prior-day rating) and target model (M2 or M3 based on above)
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key.pred <- paste(diaryVars[i],".mc",sep="") # prior-day rating
    if(diaryVars[i]=="mood"){ key.model <- paste(nd,"mc",sep=".") } else { key.model <- paste(diaryVars[i],"mc",sep=".") } 
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key.pred <- gsub(".mc","",key.pred)
      key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family="gamma",link="log", # normal with identity funct
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                               outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE,
                               nAGQ=0))) }} # nAGQ = 0 to reach convergence
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "familyDistr"
  RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
  print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","familyDistr"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are overall consistent with the main analyses

  • the main differences are highlighted for stress, whose relationship with WASO becomes substantial when modeled by assuming a gamma distribution for residuals, whereas its relationship with HR_REM becomes not substantial when modeled with the same assumption


NEXT DAY

# computing key results for WASO
ema$WASOc <- ema$WASO + 0.001 # adding little constant to have no zero values
res2 <- list()
for(i in 1:length(diaryVars)){
  # selecting predictors (model M3)
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
  key <- paste(nd,".mc",sep="")
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors (not fs)
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASOc",fix.eff=predictors,modelType=c("GLMER"),
                                            family="gamma",link="log",mc.predictors=mc.predictors,  # gamma with log link function
                                            outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
                                            mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                            nAGQ=0)) } # nAGQ = 0 to reach convergence
# computing key results for s.variab
for(sleepVar in paste(s.variab,"c",sep="")){
  for(i in 1:length(diaryVars)){
    # selecting predictors (model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    # selecting target predictor (next day rating) and target model (M3)
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key <- paste(nd,".mc",sep="")
    if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors (not fs)
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
    
    # updating results
    if(!(sleepVar=="TIB.SSDc" & diaryVars[i]=="fs.w")){ # model that doesn't converge 
      res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family="normal",link="identity", # normal with identity funct
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}}

# computing key results for s.auton
for(sleepVar in s.auton){
  for(i in 1:length(diaryVars)){
    # selecting predictors (model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    # selecting target predictor (next day rating) and target model (M3)
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key <- paste(nd,"mc",sep=".") 
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family="gamma",link="log", # normal with identity funct
                               outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               nAGQ=0))) }} # nAGQ = 0 to reach convergence

# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "familyDistr"
  RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
  print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","familyDistr"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are partially inconsistent with the main analyses

  • the main differences are highlighted for s.variab outcomes, with no longer substantial relationships between next day worry and WakeUp.num.SSD, between next day PsyDist and both TIB.SSD and TST.SSD, and between next day fs and TST.SSD when modeled by assuming a normal distribution for residuals


INTERACTION

# computing key results for WASO
ema$WASOc <- ema$WASO + 0.001 # adding little constant to have no zero values
res2 <- list()
for(i in 1:length(diaryVars)){
  # selecting predictors (model M4)
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  key <- paste(diaryVars[i],".mc:insomnia",sep="")
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,gsub(".mc","",key))
  if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
  # updating results
  res2[[i]] <- cbind(measure="WASO",glmerAn(long=ema,wide=demos,resp="WASOc",fix.eff=predictors,modelType=c("GLMER"),
                                            family="gamma",link="log", # gamma with log link function
                                            mc.predictors=mc.predictors,
                                            mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-3],p.adjust.method="BH",
                                            outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
                                            nAGQ=0)) } # nAGQ = 0 to reach convergence
# computing key results for s.variab
for(sleepVar in paste(s.variab,"c",sep="")){
  for(i in 1:length(diaryVars)){
    # selecting predictors (model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    # selecting target predictor (next day rating) and target model (M4)
    key <- paste(diaryVars[i],".mc:insomnia",sep="")
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,gsub(".mc","",key))
    if(diaryVars[i]=="fs.w"){ mc.predictors <- "SO.num" # mean-centered predictors
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num",diaryVars[i],nd) }
    
    # updating results
    if(!(sleepVar=="TIB.SSDc" & diaryVars[i]=="fs.w")){ # model that doesn't converge
      res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family="normal",link="identity", # normal with identity funct
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-3],p.adjust.method="BH",
                               outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}}

# computing key results for s.auton
for(sleepVar in s.auton){
  for(i in 1:length(diaryVars)){
    # selecting predictors (model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    # selecting target predictor (next day rating) and target model (M4)
    key <- paste(diaryVars[i],".mc:insomnia",sep="")
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,gsub(".mc","",key))
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=ema,wide=demos,resp=sleepVar,fix.eff=predictors,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family="gamma",link="log", # normal with identity funct
                               outputs="key.results",key.predictor=key,key.model=key,messages=FALSE,
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-3],p.adjust.method="BH",
                               nAGQ=0))) }} # nAGQ = 0 to reach convergence
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "familyDistr"
  RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
  print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","familyDistr"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are partially inconsistent with the main analyses

  • the main difference is is that the interaction between insomnia and both worry and fs are no longer substantial (similarly to what resulted in section 5.3.6.5), whereas the interaction with stress is still substantial although not supported by the Aw


1.6.6. Late responses

Here, we inspect the results obtained by excluding 1,010 cases (25.5%) in which participants filled the diary on the following day. In section 1.2.6, these cases were marked with diary.nextDay = 1.

The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM. The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


Separate robustness checks are conducted for each effect of interest.

PRIOR-DAY

# excluding cases with diary responses in the next day
EMA <- ema[ema$diary.nextDay!=1,]
DEMOS <- demos[demos$ID%in%levels(as.factor(as.character(EMA$ID))),]
cat("Excluded",nrow(ema)-nrow(EMA),"days,",nrow(demos)-nrow(DEMOS),"participants")
## Excluded 1010 days, 0 participants
# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  key.pred <- paste(diaryVars[i],".mc",sep="") # prior-day rating
  if(diaryVars[i]=="stress"){ key.model <- paste(nd,".mc",sep="") } else { key.model <- paste(diaryVars[i],".mc",sep="") }
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key.pred <- gsub(".mc","",key.pred)
    key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key.pred,key.model=key.model,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    # selecting target predictor (prior-day rating) and target model (M2 or M3 based on above)
    key.pred <- paste(diaryVars[i],".mc",sep="") # M2 (prior-day rating)
    if(sleepVar=="WakeUp.num.SSDc" | (diaryVars[i]=="stress"  & sleepVar%in%c("TST","WASO","WakeUp.num")) | # M3 (next day ratings)
       (diaryVars[i]=="mood"  & sleepVar%in%c("TST.SSDc","HR_NREM","HR_REM")) |
       (diaryVars[i]=="PsyDist"  & sleepVar%in%c("WakeUp.num","TIB.SSDc","TST.SSDc","WakeUp.SSDc")) |
       (diaryVars[i]=="fs.w"  & sleepVar=="TST.SSDc")){ key.model <- paste(nd,"mc",sep=".") 
       } else { key.model <- paste(diaryVars[i],"mc",sep=".") }
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key.pred <- gsub(".mc","",key.pred)
      key.model <- gsub(".mc","",key.model)} else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               family=fam[1],link=fam[2],outputs="key.results",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key.pred))-1],p.adjust.method="BH",
                               key.predictor=key.pred,key.model=key.model,messages=FALSE))) }}

# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "lateResp"
  RES.pd[[i]] <- rbind(RES.pd[[i]],res2[[i]])
  print(key.resPlot(RES.pd[[i]][RES.pd[[i]]$robCheck%in%c("Original","lateResp"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are partially inconsistent with the main analyses

  • the main differences are highlighted for mood, whose relationships with TIB is no longer substantial after the exclusion of participants with majMiss, similarly to the results in section 5.3.6.3.


NEXT DAY

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("SO.num","weekday.sleep",diaryVars[i],nd)
  key <- paste(nd,".mc",sep="") # selecting model including next day day rating
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M3)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd)
    key <- paste(nd,".mc",sep="") # selecting target predictor (next day rating) and target model (M3)
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors (not fs)
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") } # selecting family distribution
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"),mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "lateResp"
  RES.nd[[i]] <- rbind(RES.nd[[i]],res2[[i]])
  print(key.resPlot(RES.nd[[i]][RES.nd[[i]]$robCheck%in%c("Original","lateResp"),],robCheck = "robCheck") + 
           ggtitle(paste("prior-day",diaryVars[i]))) }


Comments:

  • results are partially inconsistent with the main analyses

  • with the exclusion of **late responses, **next day**stressis now negatively related withSO.num,TIB.SSDc, andTST.SSD`

  • in contrast, next day mood is no longer substantially associated with both TST.SSD and HR_NREM

  • a few unsubstantial changes are observed also for the relationships between next day fs and both TIB.SSD and TST.SSD


INTERACTION

# computing key results for TIB
res2 <- list()
for(i in 1:length(diaryVars)){
  nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
  predictors <- c("covid19","SO.num","weekday.sleep",diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
  key <- paste(diaryVars[i],".mc:insomnia",sep="")
  if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
    key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
  res2[[i]] <- cbind(measure="TIB",glmerAn(long=EMA,wide=DEMOS,resp="TIB",fix.eff=predictors,modelType=c("GLMER"),
                                           mc.predictors=mc.predictors,gmc.predictors="BMI",
                                           mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                                           outputs="key.results",key.predictor=key,key.model=key,messages=FALSE)) }

# computing key results for the following sleep outcomes
for(sleepVar in sleepVars){
  for(i in 1:length(diaryVars)){
    # selecting predictors (up to model M4)
    nd <- paste(substr(diaryVars[i],1,1),"nd",sep=".") # selecting next day diary ratings
    predictors <- c(predSelect(sleepVar=sleepVar),diaryVars[i],nd,"insomnia",paste(diaryVars[i],"insomnia",sep=":"))
    key <- paste(diaryVars[i],".mc:insomnia",sep="")
    if(diaryVars[i]=="fs.w"){ mc.predictors <- c("SO.num","TotalSteps1000") # mean-centered predictors
      key <- gsub(".mc","",key) } else { mc.predictors <- c("SO.num","TotalSteps1000",diaryVars[i],nd) }
    # selecting family distribution
    if(grepl("SSD",sleepVar)){ fam <- c("gamma","log") }else{ fam <- c("normal","identity") }
    
    # updating results
    res2[[i]] <- rbind(res2[[i]],cbind(measure=sleepVar,
                               glmerAn(long=EMA,wide=DEMOS,resp=sleepVar,fix.eff=predictors,nAGQ=0,
                               modelType=c("GLMER"), mc.predictors=mc.predictors,gmc.predictors="BMI",
                               mComp.baseline=predictors[which(predictors==gsub(".mc","",key))-2],p.adjust.method="BH",
                               family=fam[1],link=fam[2],outputs="key.results",key.predictor=key,key.model=key,messages=FALSE))) }}
# plotting robustness check
for(i in 1:length(res)){
  res2[[i]]$robCheck <- "lateResp"
  RES.int[[i]] <- rbind(RES.int[[i]],res2[[i]])
  print(key.resPlot(RES.int[[i]][RES.int[[i]]$robCheck%in%c("Original","lateResp"),],robCheck = "robCheck") + 
          ggtitle(paste("Interactive effect insomnia:",diaryVars[i],sep=""))) }


Comments:

  • results are overall consistent with the main analyses

  • the only difference is that with the removal of lateResp the interaction between insomnia and mood on WASO.SSDc, and that between insomnia and PsyDist on HR_NREM become substantial

  • in contrast, the interaction with worry on rem.p is strongly diminished, becoming not substantial


1.6.7. Summary of results

Here, we summarize the results from all robustness checks. The figure below shows the t-values associated with the group differences between insomnia and controls for each sleep outcome, by considering either model M2 (main effect of insomnia) or model M3 (main effect of insomnia and sex) when sex differences were substantial (i.e., HR_NREM and HR_REM). The figure uses the following color code:

  • substantial relationships (i.e., significant LRT, Aw higher than previous models, AND |t| > 1.96 ) are shown in green

  • those showing a |t| > 1.96 but nonsignificant LRT OR lower Aw than the previous model are shown in light green (lime)

  • those showing a |t| > 1.96 but both nonsignificant LRT AND lower Aw than the previous models are shown in yellow

  • those showing a |t| < 1.96 and either a nonsignificant LRT OR a lower Aw than the previous models are shown in orange

  • those showing a |t| < 1.96 and both nonsignificant LRT AND lower Aw than the previous models are shown in red


The robustness checks are separately visualized for each effect of interest.

PRIOR-DAY

# stress
key.resPlot(RES.pd[[1]],robCheck = "robCheck")

# worry
key.resPlot(RES.pd[[2]],robCheck = "robCheck")

# mood
key.resPlot(RES.pd[[3]],robCheck = "robCheck")

# PsyDist
key.resPlot(RES.pd[[4]],robCheck = "robCheck")

# fs
key.resPlot(RES.pd[[5]],robCheck = "robCheck")


Comments:

  • the null results observed from the main analyses (especially on s.archit and s.variab) are highly consistent across the robustness checks

  • the most consistent effects are those of stress, worry, and PsyDist on TIB, TST, and WakeUp.num, in addition to the negative relationship between SO.num and both mood and PsyDist, and that between WASO and both worry and PsyDist

  • the positive relationship between stress and HR_REM is also relatively consistent, but diminished by the exclusion of lateResp and by the use of the gamma distribution

  • lower consistency is shown by the relationship between mood and TIB (not substantial in 2 out of 4 robustness checks), and that between worry and SO.num (not substantial in 2 out of 4)


In conclusion, the results obtained with the main analyses are quite robust, indicating consistent negative relationships between diary ratings and TIB, TST, WASO, SO.num, and WakeUp.num, in addition to a positive relationship between stress and HR_REM.


NEXT DAY

# stress
key.resPlot(RES.nd[[1]],robCheck = "robCheck")

# worry
key.resPlot(RES.nd[[2]],robCheck = "robCheck")

# mood
key.resPlot(RES.nd[[3]],robCheck = "robCheck")

# PsyDist
key.resPlot(RES.nd[[4]],robCheck = "robCheck")

# fs
key.resPlot(RES.nd[[5]],robCheck = "robCheck")


Comments:

  • the null results observed from the main analyses (especially on s.archit and s.variab) are highly consistent across the robustness checks

  • the most consistent effects are those of next day stress on TIB, TST, WASO, and WakeUp.num, those of mood on both HR_NREM and HR_REM, and those of all diary ratings on Wake.up.num.SSD

  • lower consistency is shown by the relationship between mood and TST.SSD (not substantial in 2 out of 5 robustness checks), and that between PsyDist and TIB.SSD (not substantial in 2 out of 5)


In conclusion, the results obtained with the main analyses are quite robust, indicating consistent negative relationships between next day stress and TIB, TST, WASO, and WakeUp.num, between mood and both HR_NREM and HR_REM, and between WakeUp.num.SSD and all diary ratings.


INTERACTION

# stress
key.resPlot(RES.int[[1]],robCheck = "robCheck")

# worry
key.resPlot(RES.int[[2]],robCheck = "robCheck")

# mood
key.resPlot(RES.int[[3]],robCheck = "robCheck")

# PsyDist
key.resPlot(RES.int[[4]],robCheck = "robCheck")

# fs
key.resPlot(RES.int[[5]],robCheck = "robCheck")


Comments:

  • the null results observed from the main analyses are highly consistent across the robustness checks

  • the interaction between stress and insomnia on HR_NREM is quite consistent (substantial in 6 out of 7 robustness check)

  • lower consistency is shown by the interaction between insomnia and worry (substantial in 3 out of 7 robustness checks) and that with fs (substantial in 3 out of 7 robustness checks)


In conclusion, the results obtained with the main analyses are quite robust, indicating consistent cross-level interactions between insomnia and stress on HR_NREM


2. Final outputs

Here, we summarize the results obtained from the regression analyses conducted above.


2.1. Sleep characterization

First, we aimed at characterizing sleep patterns in adolescents with and without insomnia. This was done by specifying models in which s.archit, s.timing, s.variab, and s.auton variables were predicted by (1) meaningful covariates (SO.num, TotalSteps1000, weekday, and BMI), (2) insomnia, (3) participants’ sex, and (4) the interaction between sex and insomnia.


The results indicated:

  • no substantial relationships between insomnia and any s.archit or s.timing variable

  • most s.archit (i.e., TIB, TST, WASO) and s.timing (i.e., WakeUp.num) variables were negatively predicted by SO.num (whereas it positively predicted SE) and showed higher values during weekend compared to weekdays (also affecting SO.num), with boys showing shorter TST and later SO.num than girls

  • deep.p and rem.p variables were only predicted by SO.num (positively associated with %deep and negatively associated with %rem sleep)

  • participants’ BMI negatively predicted light.p, SO.num, and WakeUp.num

  • participants’ age positively predicted WASO and negatively predicted SE


  • some s.variab variables, namely TIB.SSD, TST.SSD, and SO.SSD were lower in insomnia than in controls, although the results for TIB.SSD and TST.SSD were not statistically significant; these were overall consistent across the robustness checks

  • all s.varab variables were higher in weekend days, with some (TIB.SSD, TST.SSD) being positively predicted by BMI, and others (WASO.SSD) being negatively predicted by SO.num


  • both s.auton variables were substantially predicted by the interaction between insomnia and sex, with lower HR in female insomnia than female controls but not between males

  • in contrast, the main effect of insomnia on s.auton variables was less substantial and consistent

  • both s.auton variables were positively predicted by TotalSteps1000, while HR_NREM was positively predicted by weekday.sleep and BMI, whereas HR_REM was positively predicted by SO.num


Conclusion:

Overall, our results do not support a distinction between insomnia and controls in terms of objective sleep parameters, with the exception of some night-to-night variability outcomes.


Here, we visualize representative examples of the most substantial and consistent results.

predictors <- c("TotalSteps1000","weekday.sleep","BMI","age","insomnia")
dat <- ema
dat$insomnia <- as.factor(gsub("1","Insomnia",gsub("0","Controls",dat$insomnia)))
dat$sex <- factor(gsub("M","Boys",gsub("F","Girls",dat$sex)),levels=c("Girls","Boys"))
library(gridExtra)
p <- grid.arrange(glmerAn(long=dat,wide=demos,resp="TST.SSDc",fix.eff=c("SO.num",predictors),modelType="GLMER",
                       mc.predictors=c("SO.num","TotalSteps1000"),gmc.predictors=c("BMI","age"),family="gamma",link="log",
                       outputs="plotEff",plot.model="insomnia",plot.pred="insomnia",messages=FALSE,return.plot=TRUE,
                       dot.size=3,dodge=1.3) + ggtitle("") + labs(x="",y=expression(TST~SSD~(min^2))),
                  glmerAn(long=dat,wide=demos,resp="SO.num.SSDc",fix.eff=predictors,modelType="GLMER",family="gamma",link="log",
                          mc.predictors=c("TotalSteps1000"),gmc.predictors=c("BMI","age"),
                          outputs="plotEff",plot.model="insomnia",plot.pred="insomnia",messages=FALSE,return.plot=TRUE,
                          dot.size=3,dodge=1.3) + ggtitle("") + labs(x="",y=expression(SO~SSD~(hours^2))),
               glmerAn(long=dat,wide=demos,resp="HR_NREM",fix.eff=c("SO.num",predictors,"sex","sex:insomnia"),modelType="GLMER",
                       mc.predictors=c("SO.num","TotalSteps1000"),gmc.predictors=c("BMI","age"),
                       outputs="plotEff",plot.model="sex:insomnia",plot.pred="sex:insomnia",messages=FALSE,return.plot=TRUE,
                       dot.size=3,dodge=0.5) + ggtitle("") + labs(x="",y=expression(NREM~HR~(bpm))) +
                 theme(legend.title=element_blank(),legend.position=c(0.65,0.85),
                       legend.direction = "horizontal"),
               glmerAn(long=dat,wide=demos,resp="HR_REM",fix.eff=c("SO.num",predictors,"sex","sex:insomnia"),modelType="GLMER",
                       mc.predictors=c("SO.num","TotalSteps1000"),gmc.predictors=c("BMI","age"),
                       outputs="plotEff",plot.model="sex:insomnia",plot.pred="sex:insomnia",messages=FALSE,return.plot=TRUE,
                       dot.size=3,dodge=0.5) + ggtitle("") + labs(x="",y=expression(REM~HR~(bpm))) + 
                 theme(legend.title=element_blank(),legend.position=c(0.65,0.85),
                       legend.direction = "horizontal"),nrow=2)

ggsave(filename="RESULTS/Figure3.tiff",plot=p,dpi=500) # saving figure for the manuscript


2.2. Diary ratings

Second, we aimed at characterizing the patterns of stress, worry, and mood among adolescents with and without insomnia. This was done by specifying models predicting diary ratings by (1) meaningful covariates (TotalSteps1000 and weekday), (2) the insomnia group, (3) participants’ sex, and (4) the interaction between sex and insomnia groups.


The results indicated:

  • no substantial relationships between insomnia and any diary rating

  • however, a better examination of the three insomnia.group subgroups revealed a main effect of insomnia, with higher stress, worry, and fs in the DSM.insomnia group compared to the control group, and no difference between the ‘sub-clinical’ DSM and the control group; such subgroup differences were consistent across all robustness checks

  • in addition, lower stress, worry, and bad mood were predicted by weekend days, whereas higher-than-usual TotalSteps1000 predicted lower stress and bad mood


Conclusion:

Overall, our results consistently showed higher stress, worry, and fs in the full DSM.insomnia subgroup compared to the control group, but no differences when the two subgroup are joined


2.3. Sleep by diary ratings

Third, we aimed at evaluating the direct and bidirectional relationships between sleep and psychological distress, and the interaction between the latter and insomnia. This was done by specifying models predicting s.archit, s.timing, s.variab, and s.auton variables measured at day i by the selected model in step 1 in addition to (1) PsyDist measured at day i, and (2) PsyDist measured at day i+1, as well as (3) the interaction between PsyDist and insomnia.


2.3.1. Prior-day

The results indicated:

  • substantial negative relationships were between some sleep.archit and sleep.timing variables (i.e., TIB, TST, and WakeUp.num) and stress, worry, and PsyDist, whereas earlier SO.num was substantially predicted by worry and mood, and shorter WASO was only predicted by prior-day worry and PsyDist

  • a positive relationship was also found between prior-day stress ratings and HR_REM

  • in contrast, no substantial relationships were found between previous diary ratings and both sleep stages and s.variab outcomes

  • overall, the results obtained for prior-day single item ratings were consistent with those found for aggregate ratings, and across the robustness checks, with the exception of the relationships found for mood (insubstantial in 2 to 3 out of 4 robustness checks) and that found between worry and SO (insubstantial in 2 out of 4 checks)


Here, we generate the outputs of representative examples of sleep outcomes only predicted by prior-day ratings, that is the models predicting TIB, TST, and WakeUp.num by worry.

# preparing data
dat <- ema[!is.na(ema$TIB) & !is.na(ema$worry),] # removing incomplete cases
demos$SO.num.cm <- summarySE(dat,measurevar="SO.num",groupvars="ID",na.rm=TRUE)[,3] # worry & SO individual means
demos$worry.cm <- summarySE(dat,measurevar="worry",groupvars="ID",na.rm=TRUE)[,3]
demos$BMI.gmc <- demos$BMI - mean(demos$BMI) # grand-mean centering BMI
dat <- plyr::join(dat,demos[,c("ID","worry.cm","SO.num.cm","BMI.gmc")],by="ID",type="left")
dat$SO.num.mc <- dat$SO.num - dat$SO.num.cm # mean-centering worry & SO
dat$worry.mc <- dat$worry - dat$worry.cm

# modeling
fit1 <- lmer(TIB ~ SO.num.mc + weekday.sleep + worry.mc + (1|ID),data=dat,REML=FALSE) # TIB by worry
fit2 <- lmer(TST ~ SO.num.mc + weekday.sleep + sex + worry.mc + (1|ID),data=dat,REML=FALSE) # TST by worry
fit3 <- lmer(WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + worry.mc + (1|ID),data=dat,REML=FALSE) # WakeUp.num by worry

# showing models
tab_model(fit1,fit2,fit3,
          show.p=FALSE,show.stat=FALSE,show.icc=FALSE,show.r2=FALSE,show.se=TRUE,collapse.se=TRUE,
          string.est="B (SE)")
  TIB TST Wake Up num
Predictors B (SE) CI B (SE) CI B (SE) CI
(Intercept) 451.33
(4.45)
442.60 – 460.05 406.24
(4.55)
397.33 – 415.15 8.00
(0.09)
7.81 – 8.18
SO.num.mc -35.28
(0.91)
-37.07 – -33.49 -30.21
(0.82)
-31.81 – -28.61 0.41
(0.02)
0.38 – 0.44
weekday.sleep [weekend] 49.41
(2.39)
44.72 – 54.10 43.88
(2.14)
39.69 – 48.07 0.83
(0.04)
0.76 – 0.91
worry.mc -8.11
(1.18)
-10.43 – -5.79 -7.22
(1.06)
-9.29 – -5.15 -0.13
(0.02)
-0.17 – -0.09
SD (Intercept) 40.93
(NA)
33.29
(NA)
0.88
(NA)
SD (Observations) 8.27
(NA)
7.81
(NA)
1.07
(NA)
sex [M] -20.37
(7.51)
-35.09 – -5.64
BMI.gmc -0.10
(0.03)
-0.16 – -0.04
Random Effects
σ2 4672.91 3724.56 1.31
τ00 1675.31 ID 1108.42 ID 0.77 ID
N 93 ID 93 ID 93 ID
Observations 4333 4333 4333
# computing profile-likelihood CI
confint.merMod(fit1,method="profile")
##                          2.5 %     97.5 %
## .sig01                35.25054  48.084656
## .sigma                66.92915  69.839836
## (Intercept)          442.49796 460.129363
## SO.num.mc            -37.07433 -33.489705
## weekday.sleepweekend  44.71550  54.096491
## worry.mc             -10.42828  -5.787147
confint.merMod(fit2,method="profile")
##                           2.5 %     97.5 %
## .sig01                28.583016  39.214419
## .sigma                59.752816  62.351698
## (Intercept)          397.219133 415.227549
## SO.num.mc            -31.807316 -28.607037
## weekday.sleepweekend  39.691827  48.066629
## sexM                 -35.241126  -5.470686
## worry.mc              -9.294996  -5.151493
confint.merMod(fit3,method="profile")
##                           2.5 %      97.5 %
## .sig01                0.7545922  1.02723463
## .sigma                1.1199271  1.16865413
## (Intercept)           7.8119435  8.18264335
## SO.num.mc             0.3772468  0.43722926
## weekday.sleepweekend  0.7561540  0.91314258
## BMI.gmc              -0.1558034 -0.04078409
## worry.mc             -0.1715723 -0.09391137


2.3.2. Next day

The results indicated:

  • some s.archit and s.timing variables (i.e., TIB, TST, and WakeUp.num) were bidirectionally associated with stress, with higher-than-usual prior-day and next-day stress predicting shorter TIB and TST, and earlier WakeUp time

  • WASO was only (negatively) related to next day stress but not to prior-day stress; similarly, HR_NREM and HR_REM were positively associated with next day mood but not with prior-day mood

  • WakeUp.num.SSD was negatively associated with all next day diary ratings, whereas relationships between next day ratings and other s.variab outcomes were less consistent

  • overall, these results were consistent across the robustness checks but not replicated by the aggregate diary ratings


2.3.3. Interaction

The results indicated:

  • a substantial (but not statistically significant) interaction between insomnnia and prior-day ratings was only found for stress on HR_NREM, such that stress predicted higher HR_NREM in the insomnia but not the control group; this result was overall consistent across the robustness checks, becoming not substantial only when considering the insomnia.group

  • a similar but less consistent result was found for worry and fs

  • none of the other diary ratings and sleep outcomes showed substantial interactions, consistently across the robustness checks


Here, we generate the outputs of representative examples of sleep outcomes predicted by the next day and the interactive term, that is the models predicting TST, WakeUp.num and HR_NREM by stress.

# preparing data
dat1 <- ema[!is.na(ema$TST) & !is.na(ema$stress) & !is.na(ema$s.nd),] # removing incomplete cases
datwide <- summarySE(dat1,measurevar="stress",groupvars="ID",na.rm=TRUE)[,c(1,3)] # ind means
colnames(datwide)[2] <- "stress.cm"
datwide$s.nd.cm <- summarySE(dat1,measurevar="s.nd",groupvars="ID",na.rm=TRUE)[,3] # individual means
datwide <- plyr::join(datwide,demos[,c("ID","SO.num.cm","BMI.gmc")],by="ID",type="left")
dat1 <- plyr::join(dat1,datwide[,c("ID","stress.cm","s.nd.cm","SO.num.cm","BMI.gmc")],by="ID",type="left")
dat1$SO.num.mc <- dat1$SO.num - dat1$SO.num.cm # mean-centering SO and stress
dat1$stress.mc <- dat1$stress - dat1$stress.cm
dat1$s.nd.mc <- dat1$s.nd - dat1$s.nd.cm
# same operation for HR_NREM
dat2 <- ema[!is.na(ema$HR_NREM) & !is.na(ema$stress) & !is.na(ema$s.nd) & !is.na(ema$TotalSteps1000),]
datwide <- datwide[datwide$ID%in%dat2$ID,]
datwide$TotalSteps1000.cm <- summarySE(dat2,measurevar="TotalSteps1000",groupvars="ID",na.rm=TRUE)[,3] 
dat2 <- plyr::join(dat2,datwide[,c("ID","stress.cm","s.nd.cm","SO.num.cm","TotalSteps1000.cm","BMI.gmc")],
                   by="ID",type="left")
dat2$SO.num.mc <- dat2$SO.num - dat2$SO.num.cm # mean-centering SO and stress
dat2$TotalSteps1000.mc <- dat2$TotalSteps1000 - dat2$TotalSteps1000.cm
dat2$stress.mc <- dat2$stress - dat2$stress.cm
dat2$s.nd.mc <- dat2$s.nd - dat2$s.nd.cm

# modeling
fit1 <- lmer(TST ~ SO.num.mc + weekday.sleep + sex + stress.mc + s.nd.mc + (1|ID), # TST 
             data=dat1,REML=FALSE) 
fit2 <- lmer(WakeUp.num ~ SO.num.mc + weekday.sleep + BMI.gmc + stress.mc + s.nd.mc + (1|ID), # WakeUp.num
             data=dat1,REML=FALSE)
fit3 <- lmer(HR_NREM ~ TotalSteps1000.mc + weekday.sleep + BMI.gmc + sex + insomnia + # HR_NREM
               stress.mc + s.nd.mc + stress.mc:insomnia + (1|ID),
             data=dat2,REML=FALSE)

# showing models
tab_model(fit1,fit2,fit3,
          show.p=FALSE,show.stat=FALSE,show.icc=FALSE,show.r2=FALSE,show.se=TRUE,collapse.se=TRUE,
          string.est="B (SE)")
  TST Wake Up num HR NREM
Predictors B (SE) CI B (SE) CI B (SE) CI
(Intercept) 406.12
(4.61)
397.09 – 415.14 8.03
(0.09)
7.85 – 8.21 63.15
(1.04)
61.11 – 65.19
SO.num.mc -32.03
(0.88)
-33.77 – -30.30 0.37
(0.02)
0.34 – 0.41
weekday.sleep [weekend] 45.92
(2.26)
41.49 – 50.35 0.86
(0.04)
0.78 – 0.94 0.36
(0.17)
0.03 – 0.70
sex [M] -18.55
(7.69)
-33.63 – -3.47 -4.42
(1.34)
-7.05 – -1.79
stress.mc -4.71
(1.10)
-6.87 – -2.55 -0.09
(0.02)
-0.13 – -0.05 -0.01
(0.12)
-0.25 – 0.22
s.nd.mc -6.28
(1.11)
-8.45 – -4.11 -0.12
(0.02)
-0.16 – -0.08 -0.05
(0.08)
-0.21 – 0.12
SD (Intercept) 33.50
(NA)
0.84
(NA)
5.96
(NA)
SD (Observations) 7.75
(NA)
1.06
(NA)
1.96
(NA)
BMI.gmc -0.09
(0.03)
-0.14 – -0.04 0.47
(0.20)
0.07 – 0.86
TotalSteps1000.mc 0.16
(0.02)
0.12 – 0.19
insomnia [1] -3.07
(1.29)
-5.61 – -0.54
insomnia [1] * stress.mc 0.35
(0.16)
0.03 – 0.67
Random Effects
σ2 3602.46 1.25 14.73
τ00 1122.47 ID 0.70 ID 35.49 ID
N 92 ID 92 ID 90 ID
Observations 3798 3798 2773
# computing profile-likelihood CI
confint.merMod(fit1,method="profile")
##                           2.5 %     97.5 %
## .sig01                28.657000  39.602049
## .sigma                58.679341  61.413611
## (Intercept)          396.962369 415.214158
## SO.num.mc            -33.765529 -30.303228
## weekday.sleepweekend  41.486976  50.349133
## sexM                 -33.766476  -3.276160
## stress.mc             -6.866485  -2.547190
## s.nd.mc               -8.449076  -4.107441
confint.merMod(fit2,method="profile")
##                           2.5 %      97.5 %
## .sig01                0.7199407  0.98778634
## .sigma                1.0951713  1.14622793
## (Intercept)           7.8532196  8.21307253
## SO.num.mc             0.3422956  0.40692438
## weekday.sleepweekend  0.7791092  0.94454857
## BMI.gmc              -0.1457209 -0.03472166
## stress.mc            -0.1293620 -0.04874716
## s.nd.mc              -0.1637682 -0.08273627
confint.merMod(fit3,method="profile")
##                            2.5 %     97.5 %
## .sig01                5.16429481  6.9664538
## .sigma                3.73766566  3.9431270
## (Intercept)          61.08857220 65.2151967
## TotalSteps1000.mc     0.11598178  0.1940396
## weekday.sleepweekend  0.03067717  0.6975890
## BMI.gmc               0.06965821  0.8611187
## sexM                 -7.08058270 -1.7635497
## insomnia1            -5.63440763 -0.5074162
## stress.mc            -0.24615576  0.2182411
## s.nd.mc              -0.21242925  0.1166598
## insomnia1:stress.mc   0.03254828  0.6658275


R packages

Barton, Kamil. 2020. MuMIn: Multi-Model Inference. https://CRAN.R-project.org/package=MuMIn.
Bates, Douglas, Martin Maechler, Ben Bolker, and Steven Walker. 2020. Lme4: Linear Mixed-Effects Models Using Eigen and S4. https://github.com/lme4/lme4/.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.” Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Christensen, Rune Haubo Bojesen. 2019. Ordinal: Regression Models for Ordinal Data. https://github.com/runehaubo/ordinal.
Fox, John, and Sanford Weisberg. 2019. An R Companion to Applied Regression. Third. Thousand Oaks CA: Sage. https://socialsciences.mcmaster.ca/jfox/Books/Companion/.
Fox, John, Sanford Weisberg, and Brad Price. 2020. Car: Companion to Applied Regression. https://CRAN.R-project.org/package=car.
Hope, Ryan M. 2013. Rmisc: Ryan Miscellaneous. https://CRAN.R-project.org/package=Rmisc.
Lüdecke, Daniel. 2020. sjPlot: Data Visualization for Statistics in Social Science. https://strengejacke.github.io/sjPlot/.
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Temple Lang, Duncan. 2020. XML: Tools for Parsing and Generating XML Within r and s-Plus. http://www.omegahat.net/RSXML.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.
———. 2020. Reshape2: Flexibly Reshape Data: A Reboot of the Reshape Package. https://github.com/hadley/reshape.
Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, Hiroaki Yutani, and Dewey Dunnington. 2021. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2021. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.