Skip to main content
Glama
seanshin0214

Dr. QuantMaster MCP Server

by seanshin0214

calc_sample_size

Calculate required sample sizes for statistical tests including t-tests, ANOVA, regression, and proportion analysis to ensure adequate study power.

Instructions

필요 표본크기 계산 (t-test, ANOVA, regression, proportion)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_typeYes검정 유형
effect_sizeYes효과크기 (Cohen's d, f, f²)
alphaNo유의수준 (기본: 0.05)
powerNo검정력 (기본: 0.80)
groupsNo집단 수 (ANOVA)
predictorsNo예측변수 수 (회귀)

Implementation Reference

  • The handler function executing the core logic for calc_sample_size tool. Computes required sample size for various tests (t-test, ANOVA, regression, etc.) using approximate formulas based on effect size, alpha, and power.
    function handleCalcSampleSize(args: Record<string, unknown>) {
      const testType = args.test_type as string;
      const effectSize = args.effect_size as number;
      const alpha = (args.alpha as number) || 0.05;
      const power = (args.power as number) || 0.80;
    
      // Simplified sample size formulas
      const zAlpha = alpha === 0.05 ? 1.96 : (alpha === 0.01 ? 2.576 : 1.645);
      const zBeta = power === 0.80 ? 0.84 : (power === 0.90 ? 1.28 : 0.52);
    
      let n: number;
      let formula: string;
    
      switch (testType) {
        case "t_test_two":
          n = Math.ceil(2 * ((zAlpha + zBeta) / effectSize) ** 2);
          formula = "n per group = 2 × ((z_α + z_β) / d)²";
          break;
        case "t_test_paired":
          n = Math.ceil(((zAlpha + zBeta) / effectSize) ** 2);
          formula = "n = ((z_α + z_β) / d)²";
          break;
        case "anova":
          const groups = (args.groups as number) || 3;
          n = Math.ceil((groups * (zAlpha + zBeta) ** 2) / (effectSize ** 2));
          formula = "n per group = k × (z_α + z_β)² / f²";
          break;
        case "regression":
          const predictors = (args.predictors as number) || 5;
          n = Math.ceil((8 / (effectSize ** 2)) + predictors);
          formula = "n ≈ 8/f² + k (Green, 1991 rule)";
          break;
        default:
          n = Math.ceil(2 * ((zAlpha + zBeta) / effectSize) ** 2);
          formula = "Generic formula used";
      }
    
      return {
        test_type: testType,
        effect_size: effectSize,
        alpha,
        power,
        required_n: n,
        formula,
        interpretation: `${power * 100}% 검정력으로 효과크기 ${effectSize} 탐지에 필요한 최소 표본: ${n}`,
        note: "실제 계산은 G*Power 또는 pwr 패키지 사용 권장"
      };
    }
  • Tool registration entry in the exported tools array, defining the name, description, and input schema for validation.
      name: "calc_sample_size",
      description: "필요 표본크기 계산 (t-test, ANOVA, regression, proportion)",
      inputSchema: {
        type: "object",
        properties: {
          test_type: {
            type: "string",
            enum: ["t_test_two", "t_test_paired", "anova", "regression", "proportion", "chi_square"],
            description: "검정 유형"
          },
          effect_size: { type: "number", description: "효과크기 (Cohen's d, f, f²)" },
          alpha: { type: "number", description: "유의수준 (기본: 0.05)" },
          power: { type: "number", description: "검정력 (기본: 0.80)" },
          groups: { type: "number", description: "집단 수 (ANOVA)" },
          predictors: { type: "number", description: "예측변수 수 (회귀)" },
        },
        required: ["test_type", "effect_size"],
      },
    },
  • Registration in the handleToolCall switch statement, dispatching calls to the specific handler function.
      return handleCalcSampleSize(args);
    case "calc_power":
  • Input schema definition for the calc_sample_size tool, specifying parameters like test_type, effect_size, alpha, power with types, enums, and required fields.
    inputSchema: {
      type: "object",
      properties: {
        test_type: {
          type: "string",
          enum: ["t_test_two", "t_test_paired", "anova", "regression", "proportion", "chi_square"],
          description: "검정 유형"
        },
        effect_size: { type: "number", description: "효과크기 (Cohen's d, f, f²)" },
        alpha: { type: "number", description: "유의수준 (기본: 0.05)" },
        power: { type: "number", description: "검정력 (기본: 0.80)" },
        groups: { type: "number", description: "집단 수 (ANOVA)" },
        predictors: { type: "number", description: "예측변수 수 (회귀)" },
      },
      required: ["test_type", "effect_size"],
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/seanshin0214/quantmaster-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server