analysis

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultEngineModelSettings

func DefaultEngineModelSettings() map[string]string

func GenerateMetaforScript

func GenerateMetaforScript(run AnalysisRun) string

func MetaRegressionValuesFromEvidence

func MetaRegressionValuesFromEvidence(items []evidence.EvidenceItem, field string) (map[string]float64, error)

func SubgroupValuesFromEvidence

func SubgroupValuesFromEvidence(items []evidence.EvidenceItem, field string) (map[string]string, error)

func WriteAnalysisArtifactManifest

func WriteAnalysisArtifactManifest(path string, manifest AnalysisArtifactManifest) error

Types

type AnalysisArtifactManifest

type AnalysisArtifactManifest struct {
	SchemaVersion   string                    `json:"schemaVersion"`
	RunID           string                    `json:"runId"`
	Plots           []PlotArtifactManifest    `json:"plots"`
	Script          ScriptArtifactManifest    `json:"script"`
	EngineVersions  map[string]string         `json:"engineVersions"`
	Warnings        []string                  `json:"warnings,omitempty"`
	ReportEmbedding []ReportEmbeddingMetadata `json:"reportEmbedding"`
}

func NewAnalysisArtifactManifest

func NewAnalysisArtifactManifest(run AnalysisRun, result AnalysisResult) AnalysisArtifactManifest

type AnalysisResult

type AnalysisResult struct {
	Versions            map[string]string
	ScriptChecksum      string
	OutputChecksum      string
	Warnings            []string
	ForestPlot          Artifact
	FunnelPlot          Artifact
	Metrics             HeterogeneityMetrics
	MetaRegression      Scaffold
	SubgroupAnalysis    Scaffold
	PublicationBias     Scaffold
	SensitivityAnalysis Scaffold
}

func RunMetafor

func RunMetafor(dir string, run AnalysisRun, runner Runner) (AnalysisResult, error)

type AnalysisRun

type AnalysisRun struct {
	SchemaVersion string
	ID            string
	InputRows     []InputRow
}

func ExcludeByViSource added in v0.1.6

func ExcludeByViSource(run AnalysisRun, viSource string) AnalysisRun

ExcludeByViSource returns a copy of run omitting rows whose ViSource equals the given tag.

func Prepare

func Prepare(id string, items []evidence.EvidenceItem) (AnalysisRun, error)

func PrepareRawContinuous added in v0.1.6

func PrepareRawContinuous(id string, items []evidence.EvidenceItem, varianceFloor float64, moderatorFields []string) (AnalysisRun, error)

PrepareRawContinuous builds an AnalysisRun for scientific benchmarking meta-analysis. It records ViSource provenance per row and copies moderatorFields from evidence values.

func PrepareWithCalculator

func PrepareWithCalculator(id string, items []evidence.EvidenceItem, calc EffectSizeCalculator) (AnalysisRun, error)

type Artifact

type Artifact struct {
	Path     string
	Checksum string
}

type BayesianEngine

type BayesianEngine interface {
	Name() string
	Run(AnalysisRun, BayesianEngineOptions) (BayesianReport, error)
}

type BayesianEngineOptions

type BayesianEngineOptions struct{ PriorMean, PriorVariance float64 }

type BayesianReport

type BayesianReport struct {
	RunID          string  `json:"runId"`
	Method         string  `json:"method"`
	Engine         string  `json:"engine,omitempty"`
	Studies        int     `json:"studies"`
	PriorMean      float64 `json:"priorMean"`
	PriorVariance  float64 `json:"priorVariance"`
	PosteriorMean  float64 `json:"posteriorMean"`
	PosteriorVar   float64 `json:"posteriorVariance"`
	CredibleLow95  float64 `json:"credibleLow95"`
	CredibleHigh95 float64 `json:"credibleHigh95"`
}

BayesianReport records a lightweight normal-normal Bayesian meta-analysis approximation.

func BayesianNormalApproximation

func BayesianNormalApproximation(run AnalysisRun, priorMean, priorVariance float64) (BayesianReport, error)

BayesianNormalApproximation computes a conjugate normal fixed-effect approximation.

func RunBayesianEngine

func RunBayesianEngine(run AnalysisRun, engine BayesianEngine, opts BayesianEngineOptions) (BayesianReport, error)

type DisagreementResolution

type DisagreementResolution struct {
	RequiresReview bool    `json:"requiresReview"`
	Tolerance      float64 `json:"tolerance"`
	Reason         string  `json:"reason,omitempty"`
}

type EffectSizeCalculator

type EffectSizeCalculator interface {
	Calculate(map[string]string) (float64, float64, error)
}

type EngineComparisonReport

type EngineComparisonReport struct {
	SchemaVersion      string                 `json:"schemaVersion"`
	RunID              string                 `json:"runId"`
	PrimaryEngine      string                 `json:"primaryEngine"`
	SecondaryEngine    string                 `json:"secondaryEngine"`
	InputHash          string                 `json:"inputHash"`
	EnvironmentLocks   []EnvironmentLock      `json:"environmentLocks"`
	ModelSettingParity bool                   `json:"modelSettingParity"`
	ModelSettings      map[string]string      `json:"modelSettings"`
	Warnings           []EngineWarning        `json:"warnings,omitempty"`
	OutputDeltas       EngineOutputDeltas     `json:"outputDeltas"`
	Disagreement       DisagreementResolution `json:"disagreement"`
}

func CompareAnalysisEngines

func CompareAnalysisEngines(run AnalysisRun, primary, secondary EngineResult, tolerance float64) EngineComparisonReport

type EngineOutputDeltas

type EngineOutputDeltas struct {
	EstimateDelta float64 `json:"estimateDelta"`
	VarianceDelta float64 `json:"varianceDelta"`
}

type EngineResult

type EngineResult struct {
	Engine        string            `json:"engine"`
	Estimate      float64           `json:"estimate"`
	Variance      float64           `json:"variance"`
	InputHash     string            `json:"inputHash"`
	Versions      map[string]string `json:"versions"`
	Warnings      []string          `json:"warnings,omitempty"`
	ModelSettings map[string]string `json:"modelSettings"`
}

func BuildMetaforFixtureResult

func BuildMetaforFixtureResult(run AnalysisRun, result AnalysisResult) (EngineResult, error)

func BuildPyMAREFixtureResult

func BuildPyMAREFixtureResult(run AnalysisRun, estimateDelta float64) (EngineResult, error)

type EngineWarning

type EngineWarning struct {
	Engine  string `json:"engine"`
	Message string `json:"message"`
}

type EnvironmentLock

type EnvironmentLock struct {
	Engine   string            `json:"engine"`
	Versions map[string]string `json:"versions"`
}

type FakeRunner

type FakeRunner struct {
	Stdout   string
	Stderr   string
	Versions map[string]string
}

func (FakeRunner) Run

func (f FakeRunner) Run(script string) (RunOutput, error)

func (FakeRunner) ToolVersions

func (f FakeRunner) ToolVersions() map[string]string

type FisherZCorrelation

type FisherZCorrelation struct{}

func (FisherZCorrelation) Calculate

func (FisherZCorrelation) Calculate(values map[string]string) (float64, float64, error)

type GridBayesianEngine

type GridBayesianEngine struct{ GridPoints int }

func (GridBayesianEngine) Name

func (GridBayesianEngine) Name() string

func (GridBayesianEngine) Run

type HeterogeneityMetrics

type HeterogeneityMetrics struct {
	I2   float64
	Tau2 float64
	Q    float64
}

func ParseHeterogeneity

func ParseHeterogeneity(output string) (HeterogeneityMetrics, error)

type InfluenceReport

type InfluenceReport struct {
	RunID            string         `json:"runId"`
	BaselineEstimate float64        `json:"baselineEstimate"`
	BaselineVariance float64        `json:"baselineVariance"`
	Rows             []InfluenceRow `json:"rows"`
}

func InfluenceDiagnostics

func InfluenceDiagnostics(run AnalysisRun) (InfluenceReport, error)

type InfluenceRow

type InfluenceRow struct {
	PaperID       string  `json:"paperId"`
	LeaveOneOut   float64 `json:"leaveOneOut"`
	Delta         float64 `json:"delta"`
	AbsoluteDelta float64 `json:"absoluteDelta"`
	Weight        float64 `json:"weight"`
}

type InputRow

type InputRow struct {
	PaperID    string
	EffectSize float64
	Variance   float64
	ViSource   string            // "ci", "se", "floor", or "" for arm-pair calculators
	Moderators map[string]string // benchmarking moderator fields keyed by field name
}

type LeaveOneOutRow

type LeaveOneOutRow struct {
	OmittedPaperID string  `json:"omittedPaperId"`
	Estimate       float64 `json:"estimate"`
	Variance       float64 `json:"variance"`
	Delta          float64 `json:"delta"`
	AbsoluteDelta  float64 `json:"absoluteDelta"`
	Studies        int     `json:"studies"`
}

LeaveOneOutRow is one leave-one-study-out sensitivity result.

type LogOddsRatio

type LogOddsRatio struct{}

func (LogOddsRatio) Calculate

func (LogOddsRatio) Calculate(values map[string]string) (float64, float64, error)

type MeanDifference

type MeanDifference struct{}

func (MeanDifference) Calculate

func (MeanDifference) Calculate(values map[string]string) (float64, float64, error)

type MetaRegressionReport

type MetaRegressionReport struct {
	RunID     string  `json:"runId"`
	Moderator string  `json:"moderator"`
	Studies   int     `json:"studies"`
	Intercept float64 `json:"intercept"`
	Slope     float64 `json:"slope"`
}

MetaRegressionReport records a simple weighted meta-regression diagnostic.

func MetaRegression

func MetaRegression(run AnalysisRun, moderator string, values map[string]float64) (MetaRegressionReport, error)

MetaRegression fits a weighted linear regression of effect size on a numeric moderator.

type MethodCategory

type MethodCategory struct {
	Name    string         `json:"name"`
	Options []MethodOption `json:"options"`
}

type MethodComparisonReport

type MethodComparisonReport struct {
	Category               string              `json:"category"`
	Options                []MethodOption      `json:"options"`
	RequiresReviewerChoice bool                `json:"requiresReviewerChoice"`
	Recommendation         string              `json:"recommendation"`
	LockedSelection        MethodLockSelection `json:"lockedSelection,omitempty"`
}

type MethodComparisonWorkbench

type MethodComparisonWorkbench struct {
	SchemaVersion string           `json:"schemaVersion"`
	GeneratedFrom string           `json:"generatedFrom"`
	Categories    []MethodCategory `json:"categories"`
}

func DefaultMethodComparisonWorkbench

func DefaultMethodComparisonWorkbench() MethodComparisonWorkbench

func (MethodComparisonWorkbench) Compare

func (w MethodComparisonWorkbench) Compare(category string, names []string) MethodComparisonReport

func (MethodComparisonWorkbench) CompareWithSelection

func (w MethodComparisonWorkbench) CompareWithSelection(category string, names []string, selection MethodSelectionInput) MethodComparisonReport

func (MethodComparisonWorkbench) OptionsByCategory

func (w MethodComparisonWorkbench) OptionsByCategory(category string) []MethodOption

type MethodLockSelection

type MethodLockSelection struct {
	Method                string `json:"method"`
	Reviewer              string `json:"reviewer"`
	Reason                string `json:"reason"`
	LockedIntoFinalReport bool   `json:"lockedIntoFinalReport"`
}

type MethodOption

type MethodOption struct {
	Name               string   `json:"name"`
	Role               string   `json:"role"`
	AuditArtifact      string   `json:"auditArtifact"`
	ComparisonCriteria []string `json:"comparisonCriteria"`
	Tradeoffs          []string `json:"tradeoffs"`
}

type MethodSelectionInput

type MethodSelectionInput struct {
	SelectedMethod string
	Reviewer       string
	Reason         string
}

type ModeratorField

type ModeratorField struct {
	Name        string `json:"name"`
	Papers      int    `json:"papers"`
	Numeric     bool   `json:"numeric"`
	Categorical bool   `json:"categorical"`
}

type ModeratorPreview

type ModeratorPreview struct {
	Fields []ModeratorField `json:"fields"`
}

func ModeratorPreviewFromEvidence

func ModeratorPreviewFromEvidence(items []evidence.EvidenceItem) ModeratorPreview

type PlotArtifactManifest

type PlotArtifactManifest struct {
	Kind     string            `json:"kind"`
	Path     string            `json:"path"`
	Checksum string            `json:"checksum"`
	Settings map[string]string `json:"settings"`
}

type PublicationBiasReport

type PublicationBiasReport struct {
	RunID      string  `json:"runId"`
	Method     string  `json:"method"`
	Studies    int     `json:"studies"`
	Intercept  float64 `json:"intercept,omitempty"`
	Slope      float64 `json:"slope,omitempty"`
	KendallTau float64 `json:"kendallTau,omitempty"`
	Warning    string  `json:"warning,omitempty"`
}

PublicationBiasReport records a lightweight publication-bias diagnostic.

func BeggRankCorrelation

func BeggRankCorrelation(run AnalysisRun) (PublicationBiasReport, error)

func EggerRegression

func EggerRegression(run AnalysisRun) (PublicationBiasReport, error)

EggerRegression computes an Egger-style regression of standardized effects on precision.

type RawContinuousOutcome added in v0.1.6

type RawContinuousOutcome struct {
	VarianceFloor float64 // floor vi when no CI or SE is reported; defaults to 0.0025
}

RawContinuousOutcome pools a single continuous metric per study (e.g., STH efficiency %). It implements EffectSizeCalculator for use with PrepareWithCalculator and also exposes CalculateRaw for PrepareRawContinuous, which also records ViSource and Moderators.

func (RawContinuousOutcome) Calculate added in v0.1.6

func (r RawContinuousOutcome) Calculate(values map[string]string) (float64, float64, error)

Calculate implements EffectSizeCalculator.

func (RawContinuousOutcome) CalculateRaw added in v0.1.6

func (r RawContinuousOutcome) CalculateRaw(values map[string]string) (RawContinuousResult, error)

CalculateRaw returns the full result including ViSource provenance tag.

type RawContinuousResult added in v0.1.6

type RawContinuousResult struct {
	Yi       float64
	Vi       float64
	ViSource string // "ci", "se", or "floor"
}

RawContinuousResult holds the output of a single raw-continuous effect calculation.

type ReadinessIssue added in v0.1.6

type ReadinessIssue struct {
	PaperID      string `json:"paperId"`
	MissingField string `json:"missingField"`
}

ReadinessIssue records a missing required field for one accepted evidence item.

type ReadinessReport added in v0.1.6

type ReadinessReport struct {
	RunID      string           `json:"runId"`
	Ready      bool             `json:"ready"`
	TotalItems int              `json:"totalItems"`
	ReadyItems int              `json:"readyItems"`
	Issues     []ReadinessIssue `json:"issues"`
}

ReadinessReport summarises whether all accepted evidence items carry the required fields.

func BenchmarkingReadiness added in v0.1.6

func BenchmarkingReadiness(runID string, items []evidence.EvidenceItem, requiredFields []string) ReadinessReport

BenchmarkingReadiness checks that every accepted evidence item has all requiredFields populated. Pass nil requiredFields to use the default STH% set.

type ReportEmbeddingMetadata

type ReportEmbeddingMetadata struct {
	Kind     string `json:"kind"`
	Path     string `json:"path"`
	Markdown string `json:"markdown"`
	AltText  string `json:"altText"`
}

type RiskDifference

type RiskDifference struct{}

func (RiskDifference) Calculate

func (RiskDifference) Calculate(values map[string]string) (float64, float64, error)

type RiskRatio

type RiskRatio struct{}

func (RiskRatio) Calculate

func (RiskRatio) Calculate(values map[string]string) (float64, float64, error)

type RscriptRunner

type RscriptRunner struct {
	// Path is the Rscript binary to invoke; it defaults to "Rscript" (resolved
	// from PATH) when empty.
	Path string
	// Timeout bounds a single Rscript execution; it defaults to 5 minutes.
	Timeout time.Duration
}

RscriptRunner executes generated metafor scripts with a real Rscript binary. It implements Runner for opt-in R/metafor integration runs; the deterministic FakeRunner remains the default for normal, network-free tests.

func (RscriptRunner) Run

func (r RscriptRunner) Run(script string) (RunOutput, error)

Run writes the metafor script to a temporary file and executes it with Rscript, capturing stdout and stderr. Arguments are passed directly (no shell), so the script content cannot inject extra commands.

func (RscriptRunner) ToolVersions

func (r RscriptRunner) ToolVersions() map[string]string

ToolVersions reports the detected R version on a best-effort basis; it returns an empty map when the Rscript binary is unavailable.

type RunOutput

type RunOutput struct {
	Stdout string
	Stderr string
}

type Runner

type Runner interface {
	Run(script string) (RunOutput, error)
	ToolVersions() map[string]string
}

type Scaffold

type Scaffold struct{ Available bool }

type ScriptArtifactManifest

type ScriptArtifactManifest struct {
	Path     string `json:"path"`
	Checksum string `json:"checksum"`
	Engine   string `json:"engine"`
}

type SensitivityReport

type SensitivityReport struct {
	RunID            string           `json:"runId"`
	Method           string           `json:"method"`
	BaselineEstimate float64          `json:"baselineEstimate"`
	BaselineVariance float64          `json:"baselineVariance"`
	MaxAbsoluteDelta float64          `json:"maxAbsoluteDelta"`
	Rows             []LeaveOneOutRow `json:"rows"`
}

SensitivityReport records deterministic sensitivity-analysis artifacts.

func LeaveOneOut

func LeaveOneOut(run AnalysisRun) (SensitivityReport, error)

LeaveOneOut computes inverse-variance fixed-effect estimates after omitting each study.

type StandardizedMeanDifference

type StandardizedMeanDifference struct{}

func (StandardizedMeanDifference) Calculate

func (StandardizedMeanDifference) Calculate(values map[string]string) (float64, float64, error)

type SubgroupEstimate

type SubgroupEstimate struct {
	Group    string  `json:"group"`
	Studies  int     `json:"studies"`
	Estimate float64 `json:"estimate"`
	Variance float64 `json:"variance"`
}

SubgroupEstimate is one inverse-variance pooled subgroup estimate.

type SubgroupReport

type SubgroupReport struct {
	RunID    string             `json:"runId"`
	Variable string             `json:"variable"`
	Groups   []SubgroupEstimate `json:"groups"`
}

SubgroupReport records pooled estimates split by a categorical moderator.

func SubgroupAnalysis

func SubgroupAnalysis(run AnalysisRun, variable string, groups map[string]string) (SubgroupReport, error)

SubgroupAnalysis computes fixed-effect inverse-variance pooled estimates per group.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL