[Python] Is Panel Regression Suitable for Quantifying Doping Multiplier on Daily and Total...

Discussão em 'Python' iniciado por Stack, Agosto 22, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working with a DuckDB database (merged.duckdb) containing auction data in a table named auction_timeseries, ordered by auction_id and auction_active_date. The schema is:

    auction_id: Unique auction identifier.

    auction_active_date: Date of activity (likely DATE type).

    daily_view_count: Views for that day.

    total_view_count: Cumulative views up to that date.

    doping_is_active: Binary (0 or 1) indicating if doping (visibility boost) is active.

    doping_name: Doping type (e.g., 'Doping A', 'Dpoing B', 'Doping C', or NULL if no doping).

    cat_level_0_name to cat_level_3_name: Category hierarchy.

    I want to quantify the "multiplier effect" of doping on daily_view_count and total_view_count—e.g., how many times more views occur when doping_is_active = 1 vs. 0, or for specific doping types. For example, does doping yield 2x or 10x more daily views? I’m considering a panel regression with fixed effects for auction_id to account for auction-specific factors, but I’m unsure if this is the best approach given the time series nature of the data.

    I wrote a Python script to calculate simple multipliers by averaging views for doped vs. non-doped auctions and specific doping types, using DuckDB queries and pandas for plotting and anomaly detection. Here’s the relevant code:

    import duckdb
    import pandas as pd
    import numpy as np

    # Connect to DuckDB
    con = duckdb.connect('merged.duckdb')

    # Calculate doping multipliers
    multipliers = con.execute("""
    SELECT
    (AVG(CASE WHEN doping_is_active = 1 THEN daily_view_count ELSE NULL END) /
    NULLIF(AVG(CASE WHEN doping_is_active = 0 THEN daily_view_count ELSE NULL END), 0)) AS overall_doping_multiplier,
    (AVG(CASE WHEN doping_name = 'Doping A' THEN daily_view_count ELSE NULL END) /
    NULLIF(AVG(CASE WHEN doping_name IS NULL THEN daily_view_count ELSE NULL END), 0)) AS DopingA_multiplier,
    (AVG(CASE WHEN doping_name = 'Doping B' THEN daily_view_count ELSE NULL END) /
    NULLIF(AVG(CASE WHEN doping_name IS NULL THEN daily_view_count ELSE NULL END), 0)) AS DopingB_multiplier,
    (AVG(CASE WHEN doping_name = 'Doping C' THEN daily_view_count ELSE NULL END) /
    NULLIF(AVG(CASE WHEN doping_name IS NULL THEN daily_view_count ELSE NULL END), 0)) AS DopingC_multiplier
    FROM main.auction_timeseries
    """).fetchone()

    print("\nDoping Multipliers:")
    print(f"Overall Doping Multiplier: {multipliers[0] if multipliers[0] else 'Undefined'}")
    print(f"Doping A Multiplier: {multipliers[1] if multipliers[1] else 'Undefined'}")
    print(f"Doping B Multiplier: {multipliers[2] if multipliers[2] else 'Undefined'}")
    print(f"Doping C Multiplier: {multipliers[3] if multipliers[3] else 'Undefined'}")

    con.close()


    Questions:

    Is panel regression (e.g., fixed-effects model for auction_id) logical for estimating the doping multiplier? Why or why not?

    How can I account for potential autocorrelation in views (e.g., yesterday’s views affecting today’s) or confounding factors like categories (cat_level_*_name)?

    Are there better alternatives (e.g., ARIMA, Prophet, or causal inference methods like difference-in-differences) for this time series panel data?

    Continue reading...

Compartilhe esta Página