(def stud (read-data-columns "stud.dat" 8)) (def SCH_ID (select stud 0)) (def STU_ID (select stud 1)) (def SEX (select stud 2)) (def RACE (select stud 3)) (def BYS79A (select stud 4)) (def SES (select stud 5)) (def BYPARED (select stud 6)) (def BYTXMSTD (select stud 7)) (def stud-code-miss (mapcar #'code-missing (list '() '() '() '8 '(96 98) '99.998 '(7 8) '999.998) stud)) (def stud-miss-ind (make-ind stud-code-miss)) (defun sum-list (x) (let ((sum 0)) (dolist (i x sum) (setf sum (+ sum i))))) (def num-miss-stud (mapcar #'sum-list stud-miss-ind)) ;;;;;; Note: number missing for each variable. (defun stud-per-sch (var) "Args: (VAR) VAR is the list of a given school level variable for the entire list of students." (let* ((ind (remove-duplicates var)) (result 0)) (dolist (i ind result) (setf ind-list (mapcar #'(lambda (x) (if (equalp i x) 1 0)) var)) (setf new (sum-list ind-list)) (setf result (append result (list new)))))) (load "casep") (def stud-comp (select-observed stud-code-miss)) (def stud-var-obs (var-present stud-code-miss)) (def stud-var-miss (var-missing stud-code-miss)) ;; the positions of the missing(observed) values in each variable. (def RACE-obs (select stud-var-obs 3)) (def BYS79A-obs (select stud-var-obs 4)) (def SES-obs (select stud-var-obs 5)) (def BYPARED-obs (select stud-var-obs 6)) (def BYTXMSTD-obs (select stud-var-obs 7)) (def RACE-miss (select stud-var-miss 3)) (def BYS79A-miss (select stud-var-miss 4)) (def SES-miss (select stud-var-miss 5)) (def BYPARED-miss (select stud-var-miss 6)) (def BYTXMSTD-miss (select stud-var-miss 7)) (def sex-race-miss (select sex RACE-miss)) (def sex-race-obs (select sex RACE-obs)) (def sex-perm (sample sex (length sex))) (def sex-perm-miss (select sex-perm (iseq (length race-miss)))) (def sex-perm-obs (select sex-perm (iseq (length race-miss) (- (length sex) 1)))) ;(def SCH_ID (select stud-comp 0)) ;(def STU_ID (select stud-comp 1)) ;(def SEX (select stud-comp 2)) ;(def RACE (select stud-comp 3)) ;(def BYS79A (select stud-comp 4)) ;(def SES (select stud-comp 5)) ;(def BYPARED (select stud-comp 6)) ;(def BYTXMSTD (select stud-comp 7))