I need help to create my instrumental varibale.
i am investigating the causal relationship between education and fertility of senegalese women in 2019. i need to create a variable (IV) which represents the mean of the years of schooling of the respondent's household memebers . however i have to select only the members older than the respodent, because their educational level can impact the educational level of the respondent.
in my dataframe I have the years of education of each member and the line number of the respondent. I have to select only the member before the line number of the respondent and i need to create a function.
##compute average years of schooling of the household members - older than the respondent ( 1st instrumental variable )
H <- household[ , c( 927 : 985)] #select the columns with the years of education of all the household
however i need to compute the mean of a different number of columns for each row and the number should be < of the line number of the respondent ( older household members) .
should I transform all the numbers contained in columns after the respondent column in NA and then compute the mean? but how?