处理贷款数据。 我有一个包含以下列的数据框:
df_irr = df1[['id', 'funded_amnt_t', 'Expect_NoPayments','installment']]
贷款ID |资金金额|预期付款次数|年金的固定分期付款。你知道吗
我用回归分析法估计了付款的次数。 这些贷款有36或60个月的到期日。你知道吗
现在我正试图计算预期的内部收益率(irr)。你知道吗
但我被困住了
我打算用numpy.irr
然而,我从来没有机会使用它-因为我的日期不是在正确的格式?你知道吗
我尝试过旋转和重塑功能。运气不好。你知道吗
现金流时间序列: -列:月0,…,60 -行:每个贷款的ID -第0个月的值=-资金金额 -第0-60个月的值:分期付款(如果预期的话)\付款次数\u>;个月
我以前的状态代码是:
keep id installment funded_amnt expectednumberofpayments
sort id
expand 61, generate(expand)
bysort id : gen month = _n
gen cf = 0
replace cf = installment if (expectednumberofpayments+1)>=month
replace cf = funded_amnt*-1 if month==1
numpy.irr
是错误的公式。该公式适用于不定期付款(例如,第1个月为100美元,第2个月为0美元,第3个月为400美元)。相反,您希望使用numpy.rate
。我对这个解决方案的数据做了一些假设:更多信息可以在这里找到numpy documentation。你知道吗
相关问题 更多 >
编程相关推荐