Borroer_id Year Loan amount Loan maturity Loan interest
1 2011 101 60 8.5
1 2011 95 55 5.7
2 2011 85 55 8.6
3 2011 90 44 6.5
3 2012 82 46 7.5
4 2011 65 60 6.2
4 2012 67 90 5.4
5 2011 85 45 6.5
5 2011 62 78 4.5
6 2012 55 23 6.5
I would like to calculate the weighted average for the (loan amount, loan maturity, and loan interest ) according to the weight by loan amount relative to the total amount in each borrower_id.
For instance, for borrower 1, the weighted average is (101/196, 95/196), respectively equal to 0.51, 0.48 and using these percentages to calculate the weighted loan average = (101*0.51+95*0.48)=97.11
Using the same weighted average percentage created from borrower_1 loans (0.51, 0.48), I would like to use them to be applied to both the loan maturity and loan interest as well.
thank you so much in advance for your help.
Related Posts with How to create a weighted average for multiple observations for a variable by borrower_id and year
Loops cannot capture words with spaceGood day Statalists, I have a panel data for hundreds countries in dozens years. Now I want to extr…
Announcing power tworates_zhu: Stata module to calculate sample size or power for a two-sample test of rates (negative binomial regression)Dear Statalisters, I have just posted my program -power tworates_zhu- on SSC. It implements the equ…
Calculating Daily Population of FacilitiesHello experts, I have a dataset with 10,181 observations where each observation represents an indiv…
correct to use*svy brr syntax with bootstrap weights and svy bootstrap syntax with brr weights?*Dear Statalisters, Is it correct to use the svy brr syntax with bootstrap weights and svy bootstrap…
Name confusion: Heckman or HeckitHello everyone, Regarding the Heckman two-step selection model for sample selection problem, Wooldri…
Subscribe to:
Post Comments (Atom)
0 Response to How to create a weighted average for multiple observations for a variable by borrower_id and year
Post a Comment