-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2sim_based_2step_calib.py
More file actions
55 lines (45 loc) · 1.55 KB
/
2sim_based_2step_calib.py
File metadata and controls
55 lines (45 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""
2sim_based_2step_calib.py
- Reads simulated or real investor response data (vc_investor_responses.csv).
- Prepares data for a multi-logit or 2-step Stan model (observation->states->action).
- Fits the Stan model, saves results.
"""
import os
import pandas as pd
import numpy as np
from cmdstanpy import CmdStanModel
# Example Stan code snippet: observation->states->action.
PATH_TO_VC_RESP = "decode-venturing/vc_investor_responses.csv"
PATH_TO_STAN_CODE = "decode-venturing/stan/two_step_model.stan"
PATH_TO_POSTERIOR_CSV = "decode-venturing/two_step_stan_output"
def main():
# 1) Read the investor response data
df = pd.read_csv(PATH_TO_VC_RESP)
print("Loaded responses shape:", df.shape)
# 2) Build Stan data
# We'll treat each row as one observation
# Let "execution_score" and "idea_score" be the states
# Let "would_invest" be the 0/1 outcome
stan_data = {
"N": len(df),
"exec_score": df["execution_score"].astype(float).values,
"idea_score": df["idea_score"].astype(float).values,
"invest": df["would_invest"].astype(int).values
}
# 3) Compile & sample
model = CmdStanModel(stan_file=PATH_TO_STAN_CODE)
fit = model.sample(
data=stan_data,
chains=2,
parallel_chains=2,
iter_sampling=500,
iter_warmup=200,
seed=123
)
# 4) Save results or print summary
print(fit.summary())
# Optionally save posterior draws to a CSV
fit.save_csvfiles(PATH_TO_POSTERIOR_CSV)
if __name__ == "__main__":
main()