calc_power
Calculate statistical power for hypothesis tests given sample size, effect size, and significance level to determine if a study can detect meaningful effects.
Instructions
주어진 표본크기에서 검정력 계산
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| test_type | Yes | 검정 유형 | |
| n | Yes | 표본크기 | |
| effect_size | Yes | 효과크기 | |
| alpha | No | 유의수준 |
Implementation Reference
- src/tools/index.ts:1193-1209 (handler)Primary handler for 'calc_power' tool: extracts n, effectSize, alpha; computes power via helper; returns formatted result with interpretation and R code.function handleCalcPower(args: Record<string, unknown>) { const n = args.n as number; const effectSize = args.effect_size as number; const alpha = (args.alpha as number) || 0.05; // Simplified power calculation using helper function const power = calculatePower(n, effectSize, alpha); return { n, effect_size: effectSize, alpha, estimated_power: Math.min(power, 0.999).toFixed(3), interpretation: power >= 0.80 ? "적절한 검정력 (≥80%)" : "낮은 검정력 - 표본 증가 권장", r_code: `pwr.t.test(n = ${n}, d = ${effectSize}, sig.level = ${alpha}, type = "two.sample")` }; }
- src/utils/math.ts:61-70 (helper)Core power calculation using normal approximation for two-sample t-test (non-centrality parameter, CDF). Uses normalQuantile and normalCDF.export function calculatePower( n: number, effectSize: number, alpha: number = 0.05 ): number { const zAlpha = normalQuantile(1 - alpha / 2); const ncp = effectSize * Math.sqrt(n / 2); const power = 1 - normalCDF(zAlpha - ncp); return Math.min(Math.max(power, 0), 1); }
- src/tools/index.ts:127-140 (registration)Tool registration in exported tools array: defines name, description, input schema (note: test_type required but unused in handler).{ name: "calc_power", description: "주어진 표본크기에서 검정력 계산", inputSchema: { type: "object", properties: { test_type: { type: "string", description: "검정 유형" }, n: { type: "number", description: "표본크기" }, effect_size: { type: "number", description: "효과크기" }, alpha: { type: "number", description: "유의수준" }, }, required: ["test_type", "n", "effect_size"], }, },
- src/tools/index.ts:796-797 (registration)Dispatch registration in handleToolCall switch statement.case "calc_power": return handleCalcPower(args);