PY
py
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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colormaps
import matplotlib.patches as mpatches
# Simulate the data (with ranges and more realistic relationships)
np.random.seed(1)
num_observations = 32 # Total observations
outcomes = ['Time_Sport', 'Money_Sport']
treats = ['A', 'B']
data = []
for outcome in outcomes:
for treat in treats:
for _ in range(num_observations // (len(outcomes) * len(treats))):
age = np.random.randint(18, 66) # Corrected age range: 18 to 65 (inclusive)
income = np.random.randint(3000, 6001)
education = np.random.choice(['High School', 'College', 'Professional'])
access = np.random.randint(2, 11)
# More realistic relationships (example)
estimate = np.random.randn() + (age/30) + (income/4000) - (access/3) # Adjusted relationships
data.append({
'outcome': outcome,
'Age': age,
'Income': income,
Enter to Rename, Shift+Enter to Preview
OUTPUT
Exécuter