I am trying to estimate the following equation in SAS. Unfortunately I do not have access to SAS/OR
I have 5 accounts and I would like to find the delta that solves the following:
(∑[1/(1+ e^(-(delta+S×(Rate) ) )] )/n =Target
The parameters S, Target and the Rate for each account are saved in data table in SAS. As shown below
Ac Rate S Target
1 -5.9 1.059086 0.25
2 -6.9 1.059086 0.25
3 -8.1 1.059086 0.25
4 -6 1.218584 0.25
5 -5.1 1.218584 0.25
I run this example in Solver in excel and I got a delta of 5.850219
I have 2 groups, so I would like to repeat this calculation by group
Any help you can provide would be greatly appreciated
Related
I have Probability of Default (PD) estimates for 5 risk grades and for 6 year horizon using Markov Chain.
I need to calibrate the first year to long run average and therefore change the first year column values. However the PD for following years should be adjusted as such that the new PDs and originally estimated PD converge (exponential convergence) after about 5 years.
I have to code to logic in SAS.
Originally Estimated PDs
RatingGrade Year1 Year2 Year3 Year4 Year5 Year6
1 0.02% 0.03% 0.05% 0.15% 0.25% 0.45%
2 0.07% 0.12% 0.24% 0.35% 0.45% 0.55%
3 0.16% 0.30% 0.55% 0.75% 0.90% 1.30%
4 0.25% 0.55% 1.20% 1.60% 2.00% 2.40%
5 0.50% 1.15% 2.25% 3.00% 3.80% 4.25%
First column from where I need to start with calibration factor of 1.3:
RatingGrade Year1
1 0.03%
2 0.09%
3 0.21%
4 0.33%
5 0.65%
Not sure about the weights to be applied for next years and therefore no aware of the weights - this is what I need - Using some exponential estimator (maybe alpha or something), I need to find a set of weights that goes on decreasing and doesn't move the estimated PD value after certain year say 5th year onwards.
Any pointers would be of great help!
I have tried applying fixed set of weights which reduces to zero after 5th year. But it doesn't guarantee exponential decay and is not flexible for different calibration factor and time frames (say I want it to converge between 7th and 10th year, assuming I have longer horizon of 20 years).
I have a dataset which looks like this:
loan client time interest loan amount country
1 1 w 0.1 500.000 USA
2 1 x 0.2 250.000 Germany
3 2 y 0.1 300.000 France
4 2 y 0.15 400.000 France
5 2 y 0.2 100.000 France
6 3 z 0.1 50.000 England
. . . . . .
. . . . . .
I observe different clients at different point in times. For some observations I observe the same client at the same time receiving 2 different loans (in this example observing client 2 at time y 3 times). I want to bundle these observations together meaning that I want to replace loans "3", "4" & "5" with one observation "3", summing the loan amount, averaging the interest rate and using the entries for all other variables from observation "3". I am wondering how I can perform these operations using Stata.
This ended up working for me:
collapse (mean) interest (sum) loanamount (firstnm) country, by (client time)
I have a fact table named meetings containing the following:
- staff
- minutes
- type
I then created a summarized table with the following:
TableA =
SUMMARIZECOLUMNS (
'meetings'[staff]
, 'meetings'[type]
, "SumMinutesByStaffAndType", SUM( 'meetings'[minutes] )
)
This makes a pivot table with staff as rows and columns as types.
For this pivottable I need to calculate each cell as a percent of the column total. For each staff I need the average of their percents. There are only 5 meeting types so I need the sum of these percents divided by 5.
I don't know how to divide one number grouped by two columns by another number grouped by one column. I'm coming from the SQL world so my DAX is terrible and I'm desperate for advice.
I tried creating another summarized table to get the sum of minutes for each type.
TableB =
SUMMARIZECOLUMNS (
'meetings'[type]
, "SumMinutesByType", SUM( 'meetings'[minutes] )
)
From there I want 'TableA'[SumMinutesByStaffAndType] / 'TableB'[SumMinutesByType].
TableC =
SUMMARIZECOLUMNS (
'TableA'[staff],
'TableB'[type],
DIVIDE ( 'TableA'[SumMinutesByType], 'TableB'[SumMinutesByType]
)
"A single value for column 'Minutes' in table 'Min by Staff-Contact' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
I keep arriving at this error which leads me to believe I'm not going about this the "Power BI way".
I have tried making measures and creating matrices on the reports view. I've tried using the group by feature in the Query Editor. I even tried both measures and aggregate tables. I'm likely overcomplicating it and way off the mark so any help is greatly appreciated.
Here's an example of what I'm trying to do.
## Input/First table
staff minutes type
--------- --------- -----------
Bill 5 TELEPHONE
Bill 10 FACE2FACE
Bill 5 INDIRECT
Bill 5 EMAIL
Bill 10 OTHER
Gary 10 TELEPHONE
Gary 5 EMAIL
Gary 5 OTHER
Madison 20 FACE2FACE
Madison 5 INDIRECT
Madison 15 EMAIL
Rob 5 FACE2FACE
Rob 5 INDIRECT
Rob 20 TELEPHONE
Rob 45 FACE2FACE
## Second table with SUM of minutes, Grand Total is column total.
Row Labels EMAIL FACE2FACE INDIRECT OTHER TELEPHONE
------------- ------- ----------- ---------- ------- -----------
Bill 5 10 5 10 5
Gary 5 5 10
Madison 15 20 5
Rob 50 5 20
Grand Total 25 80 15 15 35
## Third table where each of the above cells is divided by its column total.
Row Labels EMAIL FACE2FACE INDIRECT OTHER TELEPHONE
------------- ------- ----------- ------------- ------------- -------------
Bill 0.2 0.125 0.333333333 0.666666667 0.142857143
Gary 0.2 0 0 0.333333333 0.285714286
Madison 0.6 0.25 0.333333333 0 0
Rob 0 0.625 0.333333333 0 0.571428571
Grand Total 25 80 15 15 35
## Final table with the sum of the rows in the third table divided by 5.
staff AVERAGE
--------- -------------
Bill 29.35714286
Gary 16.38095238
Madison 23.66666667
Rob 30.5952381
Please let me know if I can clarify an aspect.
You can make use of the built in functions like %Row total in Power BI, Please find the snapshot below
If this is not what you are looking for, kindly let me know (I have used your Input table)
In one field I want to accept numbers that could be decimal figure for weight but it should not be over 15. Previously I had the following regex code:
[1-9]\d*(\.\d+)?$
This is to be entered in Google Forms. In other words, all these numbers are OK:
0.05
1.5
2
3.56
But these are not ok:
2 kg
0
15.1
16
This should work for values 0 to 15
^((1[0-5])|([1-9]))?(\.\d*)?$
I just started using Python.
I want to draw firstly an histogram and then a plot from a text file
this file presents two columns and about 12 millions lines.
this is an example of the file data
0.69359481 1
0.64862049 1
-1.00000000 5
-0.07840061 1
-0.13079703 1
0.54300547 1
-0.55758357 1
1.00000000 9
0.48491240 1
-0.32764208 1
-0.98689210 1
So as you see, the x value is a float ranged from -1.00000000 to 1.00000000
and the y axis is an integer (minimum is 1 maximum can be more than 100000)
I need your help to do so
Thanks