Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/ingest-colleges/ingest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const FIELDS = [
'latest.admissions.sat_scores.75th_percentile.math',
'latest.admissions.act_scores.25th_percentile.cumulative',
'latest.admissions.act_scores.75th_percentile.cumulative',
'latest.admissions.test_requirements',
'latest.cost.avg_net_price.overall',
'latest.cost.attendance.academic_year',
'latest.cost.net_price.public.by_income_level',
Expand Down Expand Up @@ -126,6 +127,9 @@ function mapRow(r) {
sat_math_75: r['latest.admissions.sat_scores.75th_percentile.math'] ?? null,
act_25: r['latest.admissions.act_scores.25th_percentile.cumulative'] ?? null,
act_75: r['latest.admissions.act_scores.75th_percentile.cumulative'] ?? null,
// IPEDS ADMCON7: 1 required, 2 recommended, 5 considered if sent, 3 not
// considered. Feeds asApplied() in web/src/lib/collegeMatch.ts.
test_policy: { 1: 'required', 2: 'optional', 5: 'optional', 3: 'not_considered' }[r['latest.admissions.test_requirements']] ?? null,
avg_net_price_cents: cents(r['latest.cost.avg_net_price.overall']),
net_price_by_income: incomeBrackets(r),
cost_of_attendance_cents: cents(r['latest.cost.attendance.academic_year']),
Expand Down
4 changes: 2 additions & 2 deletions scripts/ranking-check/load.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const env = Object.fromEntries(readFileSync(`${root}web/.env.local`, 'utf8').spl
.map((l) => l.match(/^([A-Z0-9_]+)=(.*)$/)).filter(Boolean).map((m) => [m[1], m[2].trim().replace(/^"|"$/g, '')]))

const COLS = ['id', 'scorecard_id', 'name', 'slug', 'institution_type', 'city', 'state', 'region', 'ownership', 'locale', 'size',
'latitude', 'longitude', 'admit_rate', 'sat_reading_25', 'sat_reading_75', 'sat_math_25', 'sat_math_75', 'act_25', 'act_75',
'latitude', 'longitude', 'admit_rate', 'admit_rate_in_state', 'admit_rate_out_of_state', 'test_policy', 'sat_reading_25', 'sat_reading_75', 'sat_math_25', 'sat_math_75', 'act_25', 'act_75',
'avg_net_price_cents', 'net_price_by_income', 'cost_of_attendance_cents', 'programs', 'grad_rate', 'transfer_rate',
'median_earnings_10yr_cents', 'pell_pct', 'npc_url', 'url', 'status']
const TYPES = { id: 'uuid primary key', scorecard_id: 'int', size: 'int', latitude: 'numeric', longitude: 'numeric', admit_rate: 'numeric',
const TYPES = { id: 'uuid primary key', scorecard_id: 'int', size: 'int', latitude: 'numeric', longitude: 'numeric', admit_rate: 'numeric', admit_rate_in_state: 'numeric', admit_rate_out_of_state: 'numeric',
sat_reading_25: 'int', sat_reading_75: 'int', sat_math_25: 'int', sat_math_75: 'int', act_25: 'int', act_75: 'int',
avg_net_price_cents: 'int', net_price_by_income: 'jsonb', cost_of_attendance_cents: 'int', programs: 'jsonb', grad_rate: 'numeric',
transfer_rate: 'numeric', median_earnings_10yr_cents: 'int', pell_pct: 'numeric' }
Expand Down
249 changes: 249 additions & 0 deletions supabase/migrations/20261027000000_college_admission_inputs.sql

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions web/src/components/CollegeDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useModalA11y } from '../lib/useModalA11y'

const ACCENT = '#7048C8'
const pct = (x: number | null | undefined) => (x == null ? null : `${Math.round(x * 100)}%`)
const TEST_POLICY: Record<string, string> = { required: 'Required', optional: 'Optional', not_considered: 'Not considered' }
const dollars = (cents: number | null | undefined) => (cents == null ? null : `$${Math.round(cents / 100).toLocaleString()}`)
const prettyField = (k: string) => k.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase())
const typeWord = (c: College) => (c.institution_type === '2yr' ? 'Community college' : c.institution_type === 'trade' ? 'Trade / career' : '4-year')
Expand Down Expand Up @@ -57,6 +58,11 @@ export default function CollegeDetailModal({
const facts: Array<{ label: string; value: string }> = []
const openAdm = college.admit_rate == null && (college.institution_type === '2yr' || college.institution_type === 'trade')
facts.push({ label: 'Acceptance rate', value: openAdm ? 'Open admission' : pct(college.admit_rate) ?? '—' })
// The band is worked out from the student's own rate, so show both.
if (college.admit_rate_in_state != null && college.admit_rate_out_of_state != null) {
facts.push({ label: 'In-state / out-of-state', value: `${pct(college.admit_rate_in_state)} / ${pct(college.admit_rate_out_of_state)}` })
}
if (college.test_policy) facts.push({ label: 'SAT/ACT', value: TEST_POLICY[college.test_policy] ?? '—' })
const sat = satRange(college); if (sat) facts.push({ label: 'SAT range (25–75)', value: sat })
if (college.act_25 && college.act_75) facts.push({ label: 'ACT range (25–75)', value: `${college.act_25}–${college.act_75}` })
if (college.size != null) facts.push({ label: 'Undergrad size', value: college.size.toLocaleString() })
Expand Down
1 change: 1 addition & 0 deletions web/src/components/CollegeDiscoverTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const H = vi.hoisted(() => {
no_loan_policy: null, curated_at: null,
aid_guarantee: null, aid_guarantee_detail: null, aid_guarantee_needs_css: null, aid_guarantee_residents: null, aid_guarantee_action: null, aid_guarantee_url: null, aid_guarantee_checked_on: null,
application_fee_cents: null, fee_waiver_policy: null, fees_verified_at: null, carnegie_basic: null, single_sex: null, tuition_in_state_cents: null, tuition_out_of_state_cents: null,
test_policy: null, admit_rate_in_state: null, admit_rate_out_of_state: null, residency_rates_url: null, residency_rates_cycle: null,
...over,
})
const SAMPLE: College[] = [
Expand Down
30 changes: 30 additions & 0 deletions web/src/lib/collegeMatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function mk(over: Partial<College> = {}): College {
application_fee_cents: null,
fee_waiver_policy: null,
fees_verified_at: null,
test_policy: null,
admit_rate_in_state: null, admit_rate_out_of_state: null, residency_rates_url: null, residency_rates_cycle: null,
carnegie_basic: null,
single_sex: null,
tuition_in_state_cents: null,
Expand Down Expand Up @@ -210,6 +212,29 @@ describe('admissionBand', () => {
const c = mk({ admit_rate: 0.5 })
expect(admissionBand(c, { satTotal: 1050, act: 30 }).band).toBe(admissionBand(c, { act: 30 }).band)
})
it('uses the student\'s own admit rate where a school publishes in-state and out-of-state', () => {
const flagship = mk({ state: 'NC', admit_rate: 0.17, admit_rate_in_state: 0.43, admit_rate_out_of_state: 0.08 })
expect(admissionBand(flagship, { satTotal: 1200, homeState: 'NC' }).band).toBe('target')
expect(admissionBand(flagship, { satTotal: 1600, homeState: 'VA' }).band).toBe('reach')
// No home state: the blended rate.
expect(admissionBand(flagship, { satTotal: 1300 }).estAdmitPct).toBe(admissionBand(mk({ state: 'NC', admit_rate: 0.17 }), { satTotal: 1300 }).estAdmitPct)
})
// Default school: 50% admitted, SAT 1110-1310. A 1000 is far below it.
it('lets a low score go unsent where tests are optional, but not where they are required', () => {
const low = { satTotal: 1000, gpa: 3.9 }
const gpaOnly = { gpa: 3.9 }
expect(admissionBand(mk({ test_policy: 'optional' }), low).band).toBe(admissionBand(mk({ test_policy: 'optional' }), gpaOnly).band)
expect(admissionBand(mk({ test_policy: 'optional' }), low).band).toBe('likely')
expect(admissionBand(mk({ test_policy: 'required' }), low).band).toBe('reach')
// A strong score is still sent.
expect(admissionBand(mk({ test_policy: 'optional' }), { satTotal: 1400, gpa: 3.9 }).band).toBe('likely')
// With no GPA the score is all we know, sent or not.
expect(admissionBand(mk({ test_policy: 'optional' }), { satTotal: 1000 }).band).toBe('reach')
})
it('ignores scores at a test-blind school', () => {
const blind = mk({ test_policy: 'not_considered' })
expect(admissionBand(blind, { satTotal: 1600, gpa: 3.0 }).estAdmitPct).toBe(admissionBand(blind, { gpa: 3.0 }).estAdmitPct)
})
})

// Scorecard figures for real schools, and what a counselor would call them.
Expand Down Expand Up @@ -448,6 +473,11 @@ describe('academicGap', () => {
expect(m.academicGap).toBeNull()
expect(scoreCollegeForProfile(elite, { gpa: 2.8 }).academicGap).toBe('long_shot')
})
it('makes no long shot of a score the student would not send', () => {
const optional = mk({ admit_rate: 0.1, test_policy: 'optional' })
expect(scoreCollegeForProfile(optional, { satTotal: 1050, gpa: 3.9 }).academicGap).toBeNull()
expect(scoreCollegeForProfile(mk({ admit_rate: 0.1, test_policy: 'required' }), { satTotal: 1050, gpa: 3.9 }).academicGap).toBe('long_shot')
})
it('flags a school far below a strong student', () => {
expect(scoreCollegeForProfile(mk(), { satTotal: 1500 }).academicGap).toBe('far_below')
const noScores = mk({ admit_rate: 0.75, sat_reading_25: null, sat_math_25: null, sat_reading_75: null, sat_math_75: null, act_25: null, act_75: null })
Expand Down
60 changes: 42 additions & 18 deletions web/src/lib/collegeMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ function testPosition(college: College, profile: StudentCollegeProfile, gpaFallb
* How far the student's academics move a school's odds, in score half-ranges
* (0 leaves the admit rate as it is). A student at the admitted class's
* median counts half a range above the average applicant, whose scores run
* lower. Past half a range beyond either end of the middle 50%, scores stop
* counting: higher ones no longer help, and most schools are test-optional,
* so a far lower one need not be sent.
* lower. Scores count only to half a range beyond either end of the middle
* 50%: a narrow range (Harvard's is 70 points) would otherwise make a small
* difference look decisive.
*/
function academicLift(college: College, profile: StudentCollegeProfile, admitRate: number): number {
const z = testPosition(college, profile, true)
Expand All @@ -375,23 +375,44 @@ function academicLift(college: College, profile: StudentCollegeProfile, admitRat
*/
const scoreWeight = (admitRate: number) => 0.5 + clamp((admitRate - 0.1) / 0.5, 0, 1)

/**
* The student as the school will read them. A test-blind school ignores
* scores; a test-optional one sees them only if the student sends them, which
* they would do only when the scores help. An unknown policy counts as
* optional, as most are. With no GPA, the score is all we know of the
* student, so it counts whether it is sent or not.
*/
function asApplied(college: College, profile: StudentCollegeProfile, admitRate: number): StudentCollegeProfile {
if (college.test_policy === 'required' || profile.gpa == null || (profile.satTotal == null && profile.act == null)) return profile
const withheld = { ...profile, satTotal: null, act: null }
if (college.test_policy === 'not_considered') return withheld
return academicLift(college, profile, admitRate) >= academicLift(college, withheld, admitRate) ? profile : withheld
}

// ponytail: the lift's 0.5 offset and scoreWeight are hand-set from counselor
// rules of thumb. Fit both to real Accepted/Rejected outcomes once Application
// Tracking keeps the student's scores with each decision.
export function admissionBand(
college: College,
profile: StudentCollegeProfile,
): { band: AdmissionBand; estAdmitPct: number | null } {
): { band: AdmissionBand; estAdmitPct: number | null; applied: StudentCollegeProfile } {
if (college.admit_rate == null) {
// Genuinely open-enrollment (2yr / trade) vs. a 4-year that simply didn't report data.
const openEnrollment = college.institution_type === '2yr' || college.institution_type === 'trade'
return { band: openEnrollment ? 'open' : 'unknown', estAdmitPct: null }
return { band: openEnrollment ? 'open' : 'unknown', estAdmitPct: null, applied: profile }
}
// A selective public can admit its own state's students at several times
// the rate of everyone else. Where we hold both rates, use the student's;
// an unknown home state keeps the blended one.
const ownRate = !profile.homeState || !college.state ? null
: college.state === profile.homeState ? college.admit_rate_in_state : college.admit_rate_out_of_state
const admitRate = ownRate ?? college.admit_rate
// Moved on the log-odds scale, so the estimate stays a probability.
const rate = clamp(college.admit_rate, 0.01, 0.99)
const logOdds = Math.log(rate / (1 - rate)) + scoreWeight(rate) * academicLift(college, profile, rate)
const rate = clamp(admitRate, 0.01, 0.99)
const applied = asApplied(college, profile, rate)
const logOdds = Math.log(rate / (1 - rate)) + scoreWeight(rate) * academicLift(college, applied, rate)
const chance = 1 / (1 + Math.exp(-logOdds))
return { band: bandFor(college.admit_rate, chance), estAdmitPct: Math.round(chance * 100) }
return { band: bandFor(admitRate, chance), estAdmitPct: Math.round(chance * 100), applied }
}

/**
Expand All @@ -411,22 +432,25 @@ function bandFor(admitRate: number, chance: number): AdmissionBand {
/**
* Long shot: a reach where the student is below the school's 25th percentile,
* or, where scores can't be compared, the estimate is under 10% (unless the
* student scores 1500+ SAT / 34+ ACT). Far below: real scores more than half a
* range above the school's 75th percentile, or a 1400+ / 31+ student at a
* school that reports no scores and admits 60%+ or reports no admissions.
* student scores 1500+ SAT / 34+ ACT). Judged on what the school will read
* (`applied`), so a score the student wouldn't send makes no long shot.
* Far below: real scores more than half a range above the school's 75th
* percentile, or a 1400+ / 31+ student at a school that reports no scores and
* admits 60%+ or reports no admissions.
*/
function academicGap(
college: College,
profile: StudentCollegeProfile,
applied: StudentCollegeProfile,
band: AdmissionBand,
estAdmitPct: number | null,
): CollegeMatch['academicGap'] {
const z = testPosition(college, profile, true)
const z = testPosition(college, applied, true)
const scoresZ = testPosition(college, profile)
// A 1500+ / 34+ scorer, or a 3.7+ GPA with no scores yet, can't be ruled out
// by an estimate alone.
const inAnyRange = (profile.satTotal ?? 0) >= 1500 || (profile.act ?? 0) >= 34 ||
(profile.satTotal == null && profile.act == null && (profile.gpa ?? 0) >= 3.7)
// A 1500+ / 34+ scorer, or a 3.7+ GPA with no scores sent, can't be ruled
// out by an estimate alone.
const inAnyRange = (applied.satTotal ?? 0) >= 1500 || (applied.act ?? 0) >= 34 ||
(applied.satTotal == null && applied.act == null && (applied.gpa ?? 0) >= 3.7)
if (band === 'reach' && (z != null ? z < -1 : !inAnyRange && estAdmitPct != null && estAdmitPct < 10)) return 'long_shot'
const topScorer = (profile.satTotal ?? 0) >= 1400 || (profile.act ?? 0) >= 31
if (scoresZ != null ? scoresZ > 1.5 : topScorer && (college.admit_rate == null || college.admit_rate >= 0.6)) return 'far_below'
Expand Down Expand Up @@ -702,12 +726,12 @@ export function scoreCollegeForProfile(college: College, profile: StudentCollege
(100 * active.reduce((sum, k) => sum + WEIGHTS[k] * dimensions[k], 0)) /
active.reduce((sum, k) => sum + WEIGHTS[k], 0),
)
const { band, estAdmitPct } = admissionBand(college, profile)
const { band, estAdmitPct, applied } = admissionBand(college, profile)
return {
fitScore,
band,
estAdmitPct,
academicGap: academicGap(college, profile, band, estAdmitPct),
academicGap: academicGap(college, profile, applied, band, estAdmitPct),
netPriceForYouCents: netPrice,
pathway: pathwayType(college),
reasons: collegeMatchReasons(college, profile, dimensions, netPrice, band),
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/collegeSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { College } from './collegeMatch'
*/
export const SEARCH_COLS =
'id,scorecard_id,name,slug,institution_type,city,state,region,ownership,locale,size,latitude,longitude,' +
'admit_rate,sat_reading_25,sat_reading_75,sat_math_25,sat_math_75,act_25,act_75,' +
'admit_rate,admit_rate_in_state,admit_rate_out_of_state,test_policy,sat_reading_25,sat_reading_75,sat_math_25,sat_math_75,act_25,act_75,' +
'avg_net_price_cents,net_price_by_income,cost_of_attendance_cents,programs,grad_rate,' +
'transfer_rate,median_earnings_10yr_cents,pell_pct,npc_url,url,' +
'application_fee_cents,fee_waiver_policy,carnegie_basic,single_sex,tuition_in_state_cents,tuition_out_of_state_cents'
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/useColleges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { regionOf, incomeBracketFromCents, type College, type StudentCollegeProf

const COLLEGE_COLS =
'id,scorecard_id,name,slug,institution_type,city,state,region,ownership,locale,size,latitude,longitude,' +
'admit_rate,sat_reading_25,sat_reading_75,sat_math_25,sat_math_75,act_25,act_75,' +
'admit_rate,admit_rate_in_state,admit_rate_out_of_state,test_policy,sat_reading_25,sat_reading_75,sat_math_25,sat_math_75,act_25,act_75,' +
'avg_net_price_cents,net_price_by_income,cost_of_attendance_cents,programs,grad_rate,' +
'transfer_rate,median_earnings_10yr_cents,pell_pct,npc_url,url,carnegie_basic,single_sex,tuition_in_state_cents,tuition_out_of_state_cents'

Expand Down
18 changes: 18 additions & 0 deletions web/src/types/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export type Database = {
act_25: number | null
act_75: number | null
admit_rate: number | null
admit_rate_in_state: number | null
admit_rate_out_of_state: number | null
residency_rates_cycle: string | null
residency_rates_url: string | null
test_policy: string | null
aid_guarantee: string | null
aid_guarantee_action: string | null
aid_guarantee_checked_on: string | null
Expand Down Expand Up @@ -133,6 +138,11 @@ export type Database = {
act_25?: number | null
act_75?: number | null
admit_rate?: number | null
admit_rate_in_state?: number | null
admit_rate_out_of_state?: number | null
residency_rates_cycle?: string | null
residency_rates_url?: string | null
test_policy?: string | null
aid_guarantee?: string | null
aid_guarantee_action?: string | null
aid_guarantee_checked_on?: string | null
Expand Down Expand Up @@ -199,6 +209,11 @@ export type Database = {
act_25?: number | null
act_75?: number | null
admit_rate?: number | null
admit_rate_in_state?: number | null
admit_rate_out_of_state?: number | null
residency_rates_cycle?: string | null
residency_rates_url?: string | null
test_policy?: string | null
aid_guarantee?: string | null
aid_guarantee_action?: string | null
aid_guarantee_checked_on?: string | null
Expand Down Expand Up @@ -854,6 +869,9 @@ export type Database = {
act_25: number
act_75: number
admit_rate: number
admit_rate_in_state: number
admit_rate_out_of_state: number
test_policy: string
avg_net_price_cents: number
city: string
cost_of_attendance_cents: number
Expand Down
Loading