Skip to main content
Glama

generate_r_code

Generate R code for statistical analysis, diagnostics, and visualization to support quantitative research workflows.

Instructions

R 코드 생성 (분석, 진단, 시각화)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysis_typeYes분석 유형
variablesNo변수 정보
optionsNo추가 옵션

Implementation Reference

  • The main handler function for the 'generate_r_code' tool. It generates R code templates for various analysis types (OLS, panel FE, DID, etc.) based on the input 'analysis_type'.
    function handleGenerateRCode(args: Record<string, unknown>) { const analysisType = args.analysis_type as string; const templates: Record<string, string> = { ols: ` # OLS Regression library(tidyverse) library(fixest) library(modelsummary) # Estimate model <- lm(y ~ x1 + x2 + x3, data = df) # Robust SE model_robust <- feols(y ~ x1 + x2 + x3, data = df, vcov = "hetero") # Diagnostics car::vif(model) # Multicollinearity lmtest::bptest(model) # Heteroscedasticity # Results table modelsummary(list("OLS" = model, "Robust" = model_robust)) `, panel_fe: ` # Panel Fixed Effects library(fixest) library(modelsummary) # Entity FE model_fe <- feols(y ~ x1 + x2 | id, data = panel_df, vcov = ~id) # Entity + Time FE model_twfe <- feols(y ~ x1 + x2 | id + year, data = panel_df, vcov = ~id) # Results modelsummary(list("Entity FE" = model_fe, "TWFE" = model_twfe)) `, did: ` # Difference-in-Differences library(fixest) library(did) # Basic DID did_model <- feols(y ~ treat:post | id + time, data = df, vcov = ~id) # Event Study es_model <- feols(y ~ i(time, treat, ref = -1) | id + time, data = df, vcov = ~id) iplot(es_model) # Callaway-Sant'Anna (staggered) cs_did <- att_gt(yname = "y", tname = "time", idname = "id", gname = "first_treat", data = df) aggte(cs_did, type = "dynamic") |> ggdid() ` }; return { analysis_type: analysisType, r_code: templates[analysisType] || "# Analysis template not found\n# Use search_stats_knowledge for guidance" }; }
  • The tool registration in the exported tools array, including name, description, and input schema for validation.
    name: "generate_r_code", description: "R 코드 생성 (분석, 진단, 시각화)", inputSchema: { type: "object", properties: { analysis_type: { type: "string", description: "분석 유형" }, variables: { type: "object", description: "변수 정보" }, options: { type: "object", description: "추가 옵션" }, }, required: ["analysis_type"], }, },
  • The switch case in handleToolCall that routes calls to 'generate_r_code' to the specific handler function.
    case "generate_r_code": return handleGenerateRCode(args);

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