(defun raowu (sch_id num_resam weight_lst g) "Args: sch_id Raowu bootstrap: sch_id is a stratified sample of school ids, num_resam is the number of resample size. Returns a list of school ids which is resampled from the given sample, the number of observations in each stratum is proportional to the original stratum size." ; The following program computes the stratum size for the resample. (let* ( (l (length sch_id)) (len_lst (repeat 0 l)) (len_lst1 (repeat 0 l)) ) ) (dotimes (i l) (setf (nth i len_lst) (length (nth i sch_id))) ) (let* ( (total (sum len_lst)) ) ) (dotimes (i l) (setf (nth i len_lst1) (round (* (/ (nth i len_lst) total) num_resam))) ) ; The following program gives a list of resample. (let* ( (resam nil) (mean_lst (repeat 0 l)) ) ) (dotimes (i l) (let* ( (x (sample (nth i sch_id) (nth i len_lst1) t)) (resam (append resam (list (copy-list x)))) ) ) (setf (nth i mean_lst) (mean x)) ) ; A new sample (let* ( (ori_mean (repeat 0 l)) ) ) (dotimes (i l) (setf (nth i ori_mean) (mean (nth i sch_id) )) ) (let* ((y_tilde nil) (mean_lst nil))) (dotimes (i l) (let* (x(sum (nth i ori_mean) (prod (sqrt (nth i len_lst1)) (^ (- (nth i len_lst) 1) -.5) (- (nth i resam) (nth i ori_mean)) ) ) ) (y_tilde(append y_tilde (list (copy-list x))) (mean_lst(append mean_lst (mean x))) (t_tilde(g y_tilde)) ) ) (setf y_tilde1(prod weight_lst mean_lst)) (setf theta(g y_tilde1)) )