Public
Edited
Oct 30, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof donation_size = cell(`donation_size = 100000`)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
household_size_mean = 4.7
Insert cell
Insert cell
consumption_per_person_per_year_usd = monthly_consumption_per_household_ppp / household_size_mean / ppp_multiplier * 12
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
consumption_observations = Array(consumption_sample_count).fill(Math.log(consumption_per_person_per_year_usd))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
household_sizes = household_size_data.map(x => parseFloat(x["Total household size"])).filter(x => x !== 0)
Insert cell
FrequencyChart(household_sizes)
Insert cell
Insert cell
Insert cell
household_sizes_posterior = poisson_gamma_bayes_update(household_sizes_prior, household_sizes)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
minor_changes = [`We use the continuous version of present value, with the formula detailed above. This is because I think it models the situation better.`, `We multiply, rather than add the adjustment percentages. This is because [you can't add percentages](https://towardsdatascience.com/most-people-screw-up-multiple-percent-changes-heres-how-to-do-get-them-right-b86bd6ef4b72)`, `We the [implicit parameter for duration of initial consumption](https://forum.effectivealtruism.org/posts/WmQwtYEajNDuPdyZx/type-checking-givewell-s-givedirectly-cost-effective#Results) explicit. *This makes no changes to the result*.`, `We remove the donation size parameter. The choice of this parameter is entirely arbitrary and does not impact the result at all. It is simply multiplied then divided out to calculate the doublings of consumption per dollar. On discussion with David Reinstein, I thought it better to remove it.`]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
list = (items) => items.map((x, i) => `${i + 1}. ${x}`).join("\n")
Insert cell
$ = tex.options({trust: true, displayMode: true, macros: {"\\param": context => {
const args = context.consumeArgs(1);
const name = args[0].reverse().map(x => x.text).join("")
const url = name.replaceAll(" ", "_")
return `\\textit{\\href{\\#${url}}{${name}}}`}, "\\ref": context => {
const args = context.consumeArgs(1);
const name = args[0].reverse().map(x => x.text).join("")
const url = name.replaceAll(" ", "_")
return `\\text{\\href{\\#${url}}{${name}}}` }
}})
Insert cell
gw_gd_cea = FileAttachment("gw_gd_cea.csv").csv()
Insert cell
Insert cell
compare_givewell = (name, cell, index) => {
let formatPercent = (x) => new Intl.NumberFormat('en-US', {style: 'percent', maximumSignificantDigits: 3, signDisplay: "always"}).format(x)
let result = project.getResult(cell).value
let env = project.getEnvironment()
let givewell = parseFloat(gw_gd_cea.filter(x => x["Cash Transfers - GiveDirectly"] === name)[index ?? 0]["Overall"].replace(",",""))
if(result.tag === "Number"){
let value = result.value;
let difference = (value - givewell) / givewell;
return Inputs.table([{ "GiveWell": formatFloat(givewell) ,"Value": formatFloat(value), "Difference": formatPercent(difference)}])
}
else {
let dist = result.value
let mean = dist.mean(env).value
let lowCI = dist.inv(env, 0.025).value
let highCI = dist.inv(env, 0.975).value
let difference = (mean - givewell) / givewell
return Inputs.table([{ "GiveWell": formatFloat(givewell) ,"Mean": formatFloat(mean), "95% CI": `${formatFloat(lowCI)} - ${formatFloat(highCI)}`, "Difference": formatPercent(difference)}])
}
}
Insert cell
sensitivity = (func, params, b) => {
let result = run(`cov(x,y) = mean(x * y) - mean(x) * mean(y)
corr(x,y) = cov(x, y) / stdev(x) / stdev(y)
r_squared(x, y) = corr(x, y) ^ 2
all_to_sample_set(x) = Dict.fromList(map(Dict.keys(x), {|param| [param, SampleSet.fromDist(x[param])]}))
sensitivity(f, params) = {
ss_params = all_to_sample_set(params)
result = f(ss_params)
Dict.fromList(map(Dict.keys(ss_params), {|param| [param, r_squared(ss_params[param], result)]}))
}
sensitivity(${func}, ${params})`, b).value.value.entries()
return Plot.plot({
marks: [
Plot.barX(result, {x: d => d[1].value, y: d => d[0], sort: {y: "x", reverse: true}}),
Plot.ruleX([0])
],
marginLeft: 200
})
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more