2
$\begingroup$

I am interested in the ratio of random slope variance from a random slope and intercept model. I fit the model using lme4 as

model_slopes <- lme4::lmer(trait ~ covariate + (covariate | individual_ID), data = example_dataset) 

and calculate the ratio as :

$R_S^2$ = ${V_S \over V_p}$ = ${V_VV_X +\mu^2V_V\over V_F+V_I+V\phi+V_R}$

Where $V_S$ is the random slope variance that is calculated using

  • $V_V$ - random-slope variance from the model
  • $V_X$ - Variance in covariate from the raw data
  • μ - Mean of covariate calculated from the raw data
  • and $V_P$ is the total variance in response

I want to estimate uncertainity associated with $R_S^2$ using bootstrapping. My questions are these:

  1. What type of bootstrapping should I use - parametric? case?
  2. I have a repeated measure of 5 observation per individual. How can I do parametric bootstrapping keeping this data structure in mind?
  3. Since I use variance in covariate from the raw data, how can I estimate this for each bootstrap sample?

When I sample with replacement the individuals (non-parametric bootstrapping), I get a distribution of estimate which is not centered around the estimate from the model (little triangles). Here is an example where the yellow distribution is for $R_S^2$ and green one for $V_S$ for different values of repeated measures per individual from a simulation:

enter image description here

$\endgroup$
3
  • $\begingroup$ The sampling distribution of $R_S^2$ does not need to be symmetric, but I would expect it to include the value from the original sample. Perhaps you could increase the number of Bootstrap samples. $\endgroup$ Commented Jun 21, 2023 at 10:55
  • $\begingroup$ The distribution is from 50000 bootstrapped samples $\endgroup$ Commented Jun 21, 2023 at 11:49
  • $\begingroup$ When I look further into the components of $R_S^2$, I see the variance in random slope $V_V$ is the one that does not include the value from the original sample with non-parametric bootsrapping. I am not sure why this is the case. $\endgroup$ Commented Jun 21, 2023 at 12:14

1 Answer 1

1
$\begingroup$

You can also use non-parametric Bootstrap by sampling with replacement from the subjects in your dataset. A simple R function to do this, is the following:

make_bootSample <- function (workDF, subject_id, seed = 1L) { # random seed if (!exists(".Random.seed", envir = .GlobalEnv)) runif(1L) RNGstate <- get(".Random.seed", envir = .GlobalEnv) on.exit(assign(".Random.seed", RNGstate, envir = .GlobalEnv)) # set seed set.seed(seed) ids <- workDF[[subject_id]] unq_ids <- unique(ids) ids <- factor(ids, levels = unq_ids) new_ids <- sample(unq_ids, replace = TRUE) new_workDF <- vector("list", length(unq_ids)) for (i in seq_along(unq_ids)) { keep <- workDF[[subject_id]] == new_ids[i] data_i <- workDF[keep, ] data_i[[subject_id]] <- i new_workDF[[i]] <- data_i } do.call("rbind", new_workDF) } 
$\endgroup$
1
  • $\begingroup$ I tried that and have edited the post to show the outcome from non-parametric bootstrapping. I am guessing that it is because it does not make any assumptions about the data and is more useful for the estimates related to the sample rather than the population? $\endgroup$ Commented Jun 21, 2023 at 10:19

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.