Understanding/using the output from ezBoot function

79 views
Skip to first unread message

Alison Wills

unread,
Feb 16, 2017, 2:05:53 PM2/16/17
to ez4r
Hi all,

I apologise if this is a stupid question, I have been trying to bootstrap my data in order to then run a repeated measures ANOVA on the dataset. I have managed to successfully use the ezBoot function and have managed to extract a dataframe that contains the bootstrap iterations which was what I was after. I then want to run this data through ezANOVA to test for statistical differences in my dataset.

The problem I have is that the output from the ezBoot function contains the values (post bootstrapping) and the variables that were specified but not the subject ID 'wid' which I would need to run the ANOVA, as I do not know which values pertain to which subject. However, I may be completely misunderstanding the use of bootstrapping and this may not be the aim of this function, I appreciate you can plot the output and I have done this. If there is a better way to achieve this in R I am more than happy to attempt it another way, but options for robust mixed ANOVAs with repeated measures seem somewhat limited. I have explored the WRS2 package and have used functions from this with bootstrapping previously. 

I have a dataset called 'vocalising'. In my experimental design, the vocalisation (VocalisingFreq) of dogs was recorded under four different olfactory conditions (Condition) and within each condition there were two time periods (Hour) as data collection took place in the morning and the afternoon. It was a repeated measures design as all 15 dogs were recorded in the four different conditions. What I have tried so far is:

bootstrap<-ezBoot(vocalising, dv = .(VocalisingFreq), within = .(Hour,Condition), wid = Dog, resample_within=FALSE)

I tried setting resample_within to TRUE but it didn't like the fact that whilst there are multiple values for each subject for the two different hours per condition there are not repeated values for each condition per subject in addition to per hour (if that makes any sense). I can attach a sample of my data if that helps.

Many thanks in advance for any help/suggestions.

Alison

 

Mike Lawrence

unread,
Feb 16, 2017, 2:46:55 PM2/16/17
to ez...@googlegroups.com
The way bootstrapping works, it wouldn't make sense to try to submit the bootstrap samples to an ANOVA. You should instead simply use the ezPlot2 to visualize (or get a table, using "do_plot=F") the the data and any differences you're interested in (using the "diff" argument to ezPlot2):

  # Compute the bootstrap samples ----
  bootstrap = ezBoot(
    data = vocalising
    , dv = VocalisingFreq
    , within = .(Hour,Condition)
    , wid = Dog
    , resample_within = FALSE
  )

  # Look at the main effect of Hour ----

  #first a plot of the two levels
  ezPlot2(
    preds = bootstrap
    , x = Hour
  )

  #now a table of the difference
  ezPlot2(
    preds = bootstrap
    , diff = Hour
    , do_plot = FALSE
  )

  # Look at the main effect of Condition ----

  #first a plot of the four levels
  ezPlot2(
    preds = bootstrap
    , x = Condition
  )

  #now a table for the difference between the first two levels
  ezPlot2(
    preds = bootstrap
    , diff = Condition
    , do_plot = FALSE
  )

  #compare the 2nd & 3rd levels
  ezPlot2(
    preds = bootstrap
    , diff = Condition
    , do_plot = FALSE
    , levels = list(
      Condition = list(
        new_order = levels(bootstrap$cells$Condition)[2,3,4,1]
      )
    )
  )

  #etc for all comparisons

  # Look at the Hour X Condition interaction

  #first a plot of the 2x4 cells
  ezPlot2(
    preds = bootstrap
    , x = Condition
    , split = Hour
  )

  #Now a plot of the Hour effect at each level of Condition
  #first a plot of the 2x4 cells
  ezPlot2(
    preds = bootstrap
    , x = Condition
    , diff = Hour
  )

  #compare the first two levels of Condition on their Hour effect
  ezPlot2(
    preds = bootstrap
    , diff = .(Hour,Condition)
    , do_plot = FALSE
  )

  #compare the 2nd & 3rd levels of Condition on their Hour effect
  ezPlot2(
    preds = bootstrap
    , diff = .(Hour,Condition)
    , do_plot = FALSE
    , levels = list(
      Condition = list(
        new_order = levels(bootstrap$cells$Condition)[2,3,4,1]
      )
    )
  )

  #etc for all comparisons


By the way, if you're advanced enough to be considering bootstrap analyses, I suggest you look at Bayesian methods instead. I've personally switched over to the Bayesian approach completely, using the package rstan. You can easily implement models that have non-normal error, robustness to outliers, etc. 



--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Alison Wills

unread,
Feb 17, 2017, 3:01:29 AM2/17/17
to ez4r
Hi Mike,

Many thanks for your response this is really helpful.

Alison
Reply all
Reply to author
Forward
0 new messages