# Algorithm for nested bootstrap resampling of (X,Y) pairs in multiple linear regression

I'm writing up a procedure I used for meta-analyzing an experimental data set. My objective is to come up with a formalization that is clearly replicable. I used the bootstrap to sample observations (i.e. (X,Y) pairs) with replacement and then fit a multiple linear regression model to each sample to estimate the empirical distribution function $\hat{F}$ of the test statistic $\hat{T}$. Since my data is highly stratified, with data from several experiments and clusters of observations from different subjects, I had to do nested within-experiment resampling of subject clusters.

I am struggling to come up with a clear formalization of this complicated procedure. My attempt is provided below:

Specifically, I'm having trouble formalizing the fact that in each bootstrap sample, I build an intermediate sample where I combine data from different experiments and subject clusters.

Q1: How do I number the current subject observations $i=1, ..., n$ in the temporary data sample? In my attempt, I'm using a constant $l$ which stands for the length of the temporary set prior to adding the observations from the current subject. This is very confusing because $l$ is like a temporary constant, which is contradictory (or at least very infelicitous).

I also use $n$ to denote the number of observations to in experiment $N$, but later (i.e. in steps 5 & 6) I refer to then as $n_{exp}$ and $N_{exp}$.

Q2: Is it fine not to introduce the $exp$ subscript to $n$ in the earlier steps in order to avoid subscripting subscripts, which makes them illegible, without compromising the clarity of the formalization (i.e. making $n$ and $N$ ambiguous)?

Any advice will be greatly appreciated!