Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error with bootstrap and mixed model: “insufficient observations to compute bootstrap standard errors”

    Hi everyone,

    I am getting an error message when trying to bootstrap a mixed-effects model with unstructured residuals. Anyone knows why this could be the case?

    Code:
    *Dummy repeated-measures dataset
        clear
        set obs 60
        gen id=ceil(_n/3)
        bysort id: gen time=_n
        gen x=rnormal()
    
    *Mixed model:
        mixed x || id:, res(unstructured, t(time))
    I get this error message with bootstrap:
    Code:
    .         bootstrap _b[_cons], reps(50) cluster(id) : mixed x || id:, res(unstructured, t(time))
    (running mixed on estimation sample)
    
    Bootstrap replications (50)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    50
    insufficient observations to compute bootstrap standard errors
    no results will be saved
    I am using Stata version 17.

    Thank you,

    Baptiste

  • #2
    The x's indicate that the model fitting failed in some way. This is because of the repeating sampling of some of the same cluster ids. The bootstrap and mixed commands need to be updated to account for the -idcluster()- option.

    Code:
    bootstrap _b[_cons], reps(10) cluster(id) idcluster(newid) : mixed x || newid:, res(unstructured, t(time))
    What happens is that the -cluster()- option of bootstrap identifies to Stata that cluster bootstrapping is to take place. When these clusters are resampled, so too are their original identifiers (-id-, in your case). To make the estimation valid, you now need to "renumber" the clusters so that you don't have multiple copies of the same cluster having the same identifier. This is what the -idcluster()- option does, it assigns a new pseudo-id for the resampled clusters, named -newid- here. Next, you'll need to use -newid- wherever you had used -id- in your estimation command so that Stata knows to used the pseudo-id instead of the original id.

    Comment


    • #3
      Thank you so much Leonardo. This makes sense, and it is working fine with a new ID variable.

      Comment

      Working...
      X