Hello there,

I am working with a panel collected from the Panel Study of Income Dynamics (survey data), and have written several programs that manipulate the variables in the dataset and estimate three different models. I am interested in obtaining bootstrap standard errors of the estimated coefficients. In order to do that, I had thought of writing something similar to the example below, where I draw 50 samples with replacement by using bsample, and then I estimate the coefficients of my model in each of those samples. However, the PSID extract that I am working with also contains sampling weights, and I was wondering whether I should account for these weights in any way at the time of computing my bootstrapped standard errors. If so, is there any way to "tell" the bsample command to use those weights?

Code:
webuse nlswork, clear
    
    ** Create and set the identifier cluster variables for the bootstrapped
    ** panels
    
    cap generate newid = .
    drop newid
    generate newid = idcode
    
    xtset newid year

    ** Obtain initial estimates and store them in a matrix
    
    regress ln_wage age race collgrad tenure
    matrix observe = (_b[age], _b[race], _b[collgrad], _b[tenure], _b[_cons])
    
    ** Write a program that samples the data with replacement and returns the
    ** statistic of interest
    
    capture program drop my_xtboot_2
    program define my_xtboot_2, rclass
        
        * Preserve the data before sampling
        
        preserve
        
        * Sample with replacement
        
        bsample, cluster(idcode) idcluster(newid)
        xtset, clear
        xtset newid year
        
        * Run the regression model and output the statistics of interest
        
        regress ln_wage age race collgrad tenure
        return scalar bage = _b[age]
        return scalar brace = _b[race]
        return scalar bcollgrad = _b[collgrad]
        return scalar btenure = _b[tenure]
        return scalar bcons = _b[_cons]
        
        * Return the data to the original state, prior to the bootstrapped
        * sample
        
        restore
    
    end
    
    ** Collect the estimates of the bootstrapped sample
    
    simulate bage = r(bage) brace = r(brace) bcollgrad = r(bcollgrad) ///
        btenure = r(btenure) bcons = r(bcons), reps(50) seed(123): my_xtboot_2
    
    ** Summarize the results, including the inital estimates and the sample size
    
    bstat, stat(observe) n(1000)