<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bernhard Piskernik on Medium]]></title>
        <description><![CDATA[Stories by Bernhard Piskernik on Medium]]></description>
        <link>https://medium.com/@b.piskernik?source=rss-ccde92507c16------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HeTrnImP4R_0MEYRPCcQKg.png</url>
            <title>Stories by Bernhard Piskernik on Medium</title>
            <link>https://medium.com/@b.piskernik?source=rss-ccde92507c16------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:19:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@b.piskernik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Tyranny of Dinner: How to Solve Small-Group Indecision With Game Theory]]></title>
            <link>https://medium.com/@b.piskernik/the-tyranny-of-dinner-how-to-solve-small-group-indecision-with-game-theory-ee6cdf0fe530?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee6cdf0fe530</guid>
            <category><![CDATA[decision-making]]></category>
            <category><![CDATA[game-theory]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[behavioral-economics]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Sat, 05 Dec 2026 13:13:30 GMT</pubDate>
            <atom:updated>2026-12-05T15:01:51.414Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z0N3CNIF_4iZk6FKq1dezQ.png" /></figure><p><strong>Why “I don’t care, you pick” breaks group decisions — and how aliquot credit sharing and recency dampening fix it without social friction.</strong></p><p>Every week, millions of hours of human life vanish into the same polite standoff.</p><p>It happens on a Tuesday evening when two exhausted partners spend twenty-five minutes cycling through <em>“What do you feel like?”</em> and <em>“Honestly, anything is fine”</em> before ordering the exact same takeout they had last week. It happens on Friday night when four friends stand on a sidewalk trying to agree on a bar, subtly lobbying without wanting to sound bossy. And it happens every board game night, when a shelf full of great boxes sits untouched because one assertive player always steers the table toward heavy strategy games while everyone else nods along to keep the peace.</p><p>As a psychologist and data scientist, I find this deadlock fascinating. On paper, choosing where to eat or what to play is a trivial optimization problem. In practice, it is a social minefield. Nobody wants to be the person who forces their preference on the group, yet nobody wants to sit through a three-hour game or an overpriced meal they had zero enthusiasm for.</p><p>So we fall back on informal hacks — and almost all of them are mathematically broken.</p><h3>Why Our Default Fixes Fail</h3><p>When groups get tired of debating, they usually reach for one of three tie-breakers. Each fails in a predictable way:</p><p><strong>1. Simple majority voting creates static coalitions.</strong> In a four-person group, if two or three people consistently gravitate toward mainstream options and one friend prefers something more niche, simple majority rule means the consensus bloc wins almost every time. Minority preferences never surface, and the outvoted friend quietly stops suggesting places altogether.</p><p><strong>2. Pure randomness has no memory.</strong> Flipping a coin or spinning a digital wheel feels fair in theory because every vote carries equal weight on any given night. The problem is that independent random draws are completely memoryless. Over a month of weekly meetups, pure chance will happily let consensus picks sweep while a minority voter gets shut out. Human intuition is wired to detect patterns, so a string of bad luck doesn’t feel like variance — it feels rigged.</p><p><strong>3. Strict turn-taking collapses in real life.</strong> Taking turns (<em>“It’s Sarah’s pick this week, Mark’s next week”</em>) works reasonably well for a couple, until someone travels for work, a fifth friend joins for the evening, or you want to pick a restaurant that actually fits the mood of the group tonight rather than one person’s unilateral decree.</p><p>To solve small-group decisions cleanly, a system needs to do two things at once: reward <strong>group consensus</strong> when several people want the same thing, and track <strong>who got their way</strong> so minority preferences aren’t permanently steamrolled.</p><h3>Step 1: Zero-Sum Fairness With Aliquot Credit Sharing</h3><p>In most group polls, people simply vote for the option they want tonight. The problem is what happens <em>after</em> the winner is chosen: standard voting resets to zero, treating a three-person consensus win the exact same way as a solo pick.</p><p>Instead, <strong>aliquot credit sharing</strong> treats each round’s decision as a fixed 1.0-unit budget divided into exact <em>aliquot</em> (equal) shares across the <em>n</em> participants:</p><ul><li>Every participant earns +1/n credit simply for taking part in the round (for example, +0.25 in a group of four).</li><li>Whoever backed the winning option (<em>m</em> winners) splits the 1.0 cost of winning equally (−1/m each).</li></ul><p>Because +1/n across all <em>n</em> participants minus 1/m across all <em>m</em> winners always equals zero, the group’s cumulative credit balance (<em>K</em>ᵢ) stays strictly zero-sum—and creates two natural incentives:</p><ul><li><strong>Consensus picks are cheap:</strong> If three friends back the same Thai restaurant and win (<em>m</em> = 3), each winner’s net credit drops by only 0.25 − 0.33 = −0.08, while the lone outvoted friend gains +0.25.</li><li><strong>Solo wins carry full weight:</strong> If one person’s niche pick wins alone (<em>m</em> = 1), their net credit drops by 0.25 − 1.0 = −0.75, while the other three each gain +0.25.</li></ul><p>Each person’s accumulated credit (<em>K</em>ᵢ) feeds directly into their effective voting weight (<em>W</em>ᵢ = max(0.1, 1 + <em>K</em>ᵢ − <em>R</em>ᵢ)). Every round someone loses, their voting power quietly grows until their preferred option has enough weight to break through.</p><h3>Step 2: Preventing Streaks With Recency Dampening</h3><p>Cumulative credit balances fairness over weeks and months, but one edge case remains: if someone builds up a large credit surplus after a long dry spell, they could win two or three times in a row before their balance drops back down.</p><p>This is where <strong>recency dampening</strong> (<em>R</em>ᵢ) comes in.</p><p>Alongside the long-term credit ledger, winning a round triggers an immediate, temporary cooldown (0.25 × 0.5ᵈⁱ, where <em>d</em>ᵢ is the number of rounds since your last win). Right after your pick wins, your effective weight takes an immediate dip, then recovers exponentially over the next couple of sessions.</p><p>The beauty of pairing aliquot credit with recency dampening is what it removes from the room: <strong>social accounting.</strong> Nobody has to say, <em>“Well, we went to your place last Friday, so I get to pick tonight.”</em> The algorithm gently bends the arc of repeated choices toward equity while keeping every individual night genuinely undecided until the votes are cast.</p><h3>What Happens Over 20 Nights?</h3><p>To see how this plays out in practice, imagine a group of four friends meeting once a week for 20 weeks, voting among four restaurants or board games each night. Three of them (Alex, Sam, and Maya) have flexible, overlapping tastes across three mainstream options, while one friend (Leo) has a distinct niche preference — voting for his favorite fourth option on <strong>80% of nights</strong> (roughly four out of every five sessions).</p><p>If you run a Monte Carlo simulation using a standard memoryless lottery (where every vote carries a static weight of <em>W</em> = 1), the flexible consensus bloc dominates. In a paired 20-night run, Sam ends up satisfied on <strong>14 out of 20 nights</strong> and Maya on <strong>11</strong>, while Leo gets his pick just <strong>twice</strong>. Across 10,000 simulated 20-night cycles, a memoryless lottery leaves Leo stuck in a drought (3 or fewer wins over five months) <strong>7.3% of the time</strong>.</p><p>When you run the exact same nightly votes through Pari’s aliquot credit sharing and recency dampening, Leo’s accumulated credit (<em>K</em>ᵢ) steadily boosts his voting weight whenever he gets outvoted:</p><ul><li><strong>In Pari Mode B (Weighted Lottery):</strong> Leo jumps from <strong>2 to 5</strong> satisfied nights in the paired run — and across 10,000 cycles, he gets at least 4 wins <strong>99.97% of the time</strong>, virtually eliminating minority shutouts while keeping individual nights probabilistic.</li><li><strong>In Pari Mode A (Highest Weight):</strong> Leo reaches <strong>7</strong> satisfied nights while Alex (8), Sam (10), and Maya (11) still see high overall satisfaction on consensus picks.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssZgzmpvdauiU68iIoFneQ.png" /><figcaption>Distribution of satisfied nights across a paired 20-session multi-option cycle (Panel A) and 10,000 simulated 20-night cycles for an 80% niche voter (Panel B): Memoryless Lottery vs. Pari’s Weighted Lottery (Mode B) and Highest Weight (Mode A).</figcaption></figure><p>If you want to inspect the update equations or run the Monte Carlo simulation yourself, the full Python code is available on <a href="https://github.com/MoodPatterns/pari_sim"><strong>GitHub</strong></a>.</p><h3>From Whiteboard to Pocket Tool</h3><p>Once I had the math working, I ran into a very practical UX reality: nobody standing on a street corner deciding where to eat — or sitting around a table with game boxes open — is going to open a spreadsheet, create an account, or verify an email address just to cast a vote. If a group tool takes more than ten seconds to join, one person will sigh and say, <em>“Forget it, let’s just go to the usual place.”</em></p><p>So I built <strong>Pari</strong> as a lightweight, serverless mobile app for <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.pari"><strong>Android</strong></a> and <a href="https://www.google.com/search?q=https://apps.apple.com/app/pari-fair-family-group-vote/id6837479006"><strong>iOS</strong></a>. There are no user accounts, no sign-ups, and no central profiles. One person creates a decision, shares a quick link with whoever is at the table that night, everyone taps their choice, and the app handles the aliquot credit balance and recency memory locally.</p><p>If your partner, roommates, or gaming group still burn twenty minutes every week negotiating what to eat, play, or do next, give it a test run on your next night out — grab it on <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.pari"><strong>Google Play</strong></a> or the <a href="https://www.google.com/search?q=https://apps.apple.com/app/pari-fair-family-group-vote/id6837479006"><strong>App Store</strong></a> (or inspect the cryptographic and architectural details at <a href="https://moodpatterns.info/pari/"><strong>moodpatterns.info/pari</strong></a>).</p><p>At the very least, it gives you someone else to blame when you end up eating Thai food again — and this time, the math will make sure it’s your turn next week.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee6cdf0fe530" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Your Free Bets]]></title>
            <link>https://medium.com/@b.piskernik/optimizing-your-free-bets-25a27610d50d?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/25a27610d50d</guid>
            <category><![CDATA[sports-betting]]></category>
            <category><![CDATA[football]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[betting]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 13:33:34 GMT</pubDate>
            <atom:updated>2025-07-20T13:33:34.596Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7ckfhTEoJdPUKKZnXAngg.png" /><figcaption>Image generated with Gemini Flash 2.5</figcaption></figure><h4>A Data-Driven Approach to Maximizing Returns</h4><p>In the exciting world of sports betting, “free bets” often feel like a golden ticket. They offer the thrill of a wager without the immediate financial risk of your own stake. However, as any seasoned punter knows, not all free bets are created equal, and simply picking a favorite won’t necessarily yield the best long-term returns.</p><p>In my <a href="https://medium.com/@b.piskernik/how-sports-betting-odds-impact-your-return-to-player-rtp-2bd02999bcf0">previous article</a>, I explored how Return to Player (RTP) generally decreases as odds increase in standard 3-way sports bets. This time, I’ve delved into a crucial follow-up question: <strong>What are the optimal odds to maximize the value of a free bet, where you only receive the winnings, not your original stake?</strong></p><p>This scenario introduces two opposing forces: the previously identified trend of lower RTP at higher odds, and the fact that with lower odds, the “missing stake” (which you don’t get back with a free bet) represents a larger portion of the potential total return. To navigate this complexity, I’ve conducted a similar methodical analysis, focusing specifically on the unique payout structure of free bets.</p><p><strong>My Analytical Approach</strong></p><p>Using the same comprehensive football match data from football-data.co.uk, I replicated my previous methodology for 3-way bets (Home Win, Draw, Away Win). The key difference this time was to calculate the RTP by <em>disregarding the stake in the payout</em>. This directly models the free bet scenario.</p><p>To ensure robust findings, I focused on the four providers with the most extensive match data in my dataset: <strong>William Hill, Bet365, Interwetten, and VC Bet</strong>. For each provider, I sampled 10,000 random bets (one per game to avoid dependencies). These sampled bets were then binned by odds in 0.2 increments, and for each bin, I calculated the mean RTP. These 10,000 randomly sampled RTP means per odds step were then used to model the relationship between odds and free bet RTP.</p><p><strong>Visualizing the Data: Provider Coverage and RTP Trends</strong></p><p>Before diving into the core findings, it’s useful to understand the distribution of the data I analyzed. <strong>Figure 1</strong> illustrates the number of games with available bets for each of the four selected providers. This highlights the data volume I worked with for each bookmaker.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F12.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F12%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/6df0272b833fb4f97b050ec6482b61aa/href">https://medium.com/media/6df0272b833fb4f97b050ec6482b61aa/href</a></iframe><p>The heart of my analysis is presented in <strong>Figure 2</strong>, a line chart that displays the mean RTP on the y-axis against odds on the x-axis, faceted by provider. This visualization clearly depicts the trends discussed below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F14.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F14%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/746530dd1eceab4b73b4bfa0954337de/href">https://medium.com/media/746530dd1eceab4b73b4bfa0954337de/href</a></iframe><p><strong>Key Findings: The Sweet Spot for Free Bets</strong></p><p>My analysis revealed fascinating insights into the optimal odds range for free bets, clearly visible in <strong>Figure 2</strong>:</p><ul><li><strong>Small Odds Underperform:</strong> As expected, very small odds consistently yielded the worst results for free bets. At these odds, the potential winnings are minimal, and since you don’t get your stake back, the effective return on the “value” of the free bet is significantly diminished.</li><li><strong>A Sharp Increase and Peak:</strong> There’s a clear and sharp increase in free bet RTP as odds rise, generally peaking around <strong>odds of 7.0</strong>. This indicates that as the potential winnings grow, the absence of the stake becomes less impactful relative to the overall payout.</li><li><strong>Interwetten’s Nuance:</strong> Interestingly, Interwetten showed a slightly different behavior, with its free bet RTP peaking earlier, around <strong>odds of 4.5</strong>. This highlights that even among leading bookmakers, there can be subtle variations in their pricing models that affect free bet optimization.</li><li><strong>Gradual Decline After the Peak:</strong> After reaching their respective peaks, the free bet RTP slowly declines. This is consistent with the general principle that excessively high odds often come with a lower inherent statistical value, as discussed in my previous article.</li><li><strong>High Odds Anomaly (with Caution):</strong> For William Hill and Bet365, there appeared to be another slight increase in RTP at very high odds (above 15.0). However, it’s crucial to approach this finding with caution. My dataset predominantly consists of league games, where such extremely high odds in 3-way markets are rare. Therefore, the number of sampled bets for these very high odds was small, making this observation less statistically significant. I wouldn’t place too much faith in this particular finding for practical betting.</li></ul><p><strong>My Recommendation: The 3.5 to 10.0 Odds Range</strong></p><p>Based on this comprehensive analysis, and supported by the trends observed in <strong>Figure 2</strong>, my general recommendation for maximizing the value of your free bets would be to <strong>choose bets within the odds range of 3.5 to 10.0</strong>. This range consistently delivered the best long-term returns across the major providers I examined.</p><p>Specifically, for the optimal odds around 7.0 (and 4.5 for Interwetten), one can statistically expect to earn approximately <strong>0.75 cents on the dollar of a free bet in the long run</strong> (assuming one regularly receives and utilizes free bets). This provides a tangible benchmark for what you can anticipate from your free bet strategy.</p><p><strong>Navigating Volatility:</strong></p><p>It’s important to remember that higher odds, even within this optimal range, will naturally lead to higher volatility. While the expected return is higher, wins will be less frequent. Your choice within the 3.5 to 10.0 range should therefore also consider your personal tolerance for variance and how frequently you wish to see wins.</p><p><strong>Conclusion: Making Your Free Bets Work Harder</strong></p><p>Free bets are a valuable tool for any sports bettor, but their true potential is often misunderstood. By understanding the unique interplay between odds and RTP when your stake isn’t returned, you can move beyond simply picking a long shot and instead make data-driven decisions that significantly improve your long-term profitability. Aiming for that sweet spot in the odds range of 3.5 to 10.0 is a strategic approach that can make your free bets work much harder for you.</p><p><strong>A Crucial Reminder:</strong> Always remember, as my previous analysis and this one show, all calculated RTPs were below 100%. While individual wins are certainly possible and exciting, statistically, the house always has an edge in the long run.</p><p>If you want to check my code or re-run the numbers yourself — you can find everything I have done <a href="https://github.com/bpiskernik/free_bet_optimize">here</a>.</p><p>Cheers!</p><h3>On my behalf</h3><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25a27610d50d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Sports Betting Odds Impact Your Return to Player (RTP)]]></title>
            <link>https://medium.com/@b.piskernik/how-sports-betting-odds-impact-your-return-to-player-rtp-2bd02999bcf0?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bd02999bcf0</guid>
            <category><![CDATA[sports-betting]]></category>
            <category><![CDATA[football]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 13:12:19 GMT</pubDate>
            <atom:updated>2025-07-17T13:12:19.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IoxTSj3s-wsJ7f8CbpCgDw.png" /><figcaption>Image generated with Gemini Flash 2.5</figcaption></figure><p>Sports betting can be an exhilarating experience, offering the thrill of predicting outcomes and the potential for lucrative returns. But beneath the surface of exciting matchups and fluctuating odds lies a crucial concept for any serious bettor: Return to Player (RTP). In the world of online casinos, RTP is a widely understood metric, indicating the percentage of wagered money a game is expected to return to players over time. However, when it comes to sports betting, this concept often takes a backseat, obscured by the allure of high odds and potential windfalls.</p><p>This article aims to shed light on the relationship between odds and RTP in sports betting, based on a comprehensive analysis of historical football match data. By examining hundreds of thousands of past bets, I reveal a clear and consistent trend that every punter should be aware of.</p><p><strong>The Data Dive: What I Analyzed</strong></p><p>To conduct this investigation, I utilized publicly available historical football match data and odds from football-data.co.uk. My focus was exclusively on 3-way bets (Home Win, Draw, Away Win), a common and popular betting market. I included all available games from the dataset. For each game, I selected randomly just one bet from the three possible outcomes (Home Win, Draw, Away Win) to avoid dependencies. From all such possible combinations across all games, I sampled 1000 combinations. These sampled bets were then binned by odds in 0.2 increments for each provider. For each bin, I calculated the mean RTP. This process resulted in 1000 randomly sampled RTP means per odds bin and provider, which I used to fit a model that maps odds (in 0.2 steps) to RTP.</p><p><strong>Key Findings: A Downward Trend in RTP as Odds Increase</strong></p><p>My analysis revealed a compelling and consistent trend: <strong>as the odds for a particular outcome increase, the associated Return to Player (RTP) tends to decrease.</strong> This means that while higher odds promise larger payouts, the statistical likelihood of achieving those payouts, relative to your stake, diminishes.</p><p><strong>Visualizing the Landscape: Data Distribution by Provider</strong></p><p>Before delving deeper into the RTP trends, it’s insightful to understand the distribution of data points across different bookmakers in my sample. The first plot highlights the number of bets per provider, with <strong>William Hill, Bet365, and Interwetten</strong> emerging as having the most sampled data. This simply reflects the volume of data available for these providers in the public dataset, rather than their market dominance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gLldXUtzP1AdIBNzW8dnWA.png" /><figcaption><em>number of 3-way bets per provider in the football-data.co.uk data set</em></figcaption></figure><p><strong>The Core Revelation: Odds vs. RTP by Provider</strong></p><p>The second and arguably most critical visualization in my study consists of line charts, faceted by provider, illustrating the relationship between odds and RTP. Each line chart distinctly shows a <strong>clear downward trend in RTP as the odds get higher.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtkZag_ZtiHDvZZqf6-KYg.png" /><figcaption>relationship between odds and rtp by provider (a 4th degree polynomial was fitted)</figcaption></figure><p>This consistent pattern across multiple reputable bookmakers suggests that it’s not an isolated anomaly but rather a fundamental characteristic of how odds are priced in sports betting. The only exception observed was with “Sporting Odds,” where the number of sampled bets was very small, making it difficult to draw definitive conclusions from its limited data points.</p><p><strong>What Does This Mean for Bettors?</strong></p><p>The implications of these findings are significant for any sports bettor:</p><ul><li><strong>Higher Odds, Lower Value (Relatively):</strong> While the prospect of a massive payout from a long-shot bet is exciting, understand that the underlying value (RTP) for such bets is generally lower. Bookmakers build in a higher margin for these less probable outcomes.</li><li><strong>Balancing Risk and Reward:</strong> This analysis doesn’t suggest avoiding high-odds bets entirely. Rather, it emphasizes the importance of a balanced approach. Understanding that the statistical return diminishes with higher odds can help you make more informed decisions about your bankroll management and risk tolerance.</li><li><strong>Focus on Value, Not Just Payouts:</strong> Instead of being solely enticed by the potential payout, consider the inherent value of a bet. A bet with lower odds but a higher RTP might offer a better long-term return on your investment, even if individual wins are smaller.</li><li><strong>Bookmaker Comparisons Still Matter:</strong> While the trend is consistent across providers, there can still be subtle differences in their pricing strategies. Comparing odds across different bookmakers remains crucial to finding the best possible RTP for your chosen bet.</li></ul><p><strong>Conclusion: Bet Smarter, Not Just Bigger</strong></p><p>My analysis of thousands of historical football bets provides compelling evidence of an inverse relationship between odds and Return to Player in 3-way sports betting. As odds increase, the effective RTP tends to decrease. This insight is not meant to discourage high-odds betting but to equip bettors with a deeper understanding of the underlying mechanics. By considering RTP alongside potential payouts, you can make more strategic and informed betting decisions, ultimately contributing to a more sustainable and potentially profitable sports betting journey. Remember, the goal is to bet smarter, not just bigger.</p><p><strong>Always remember, as my analysis showed, all calculated RTPs were below 100%, indicating that while individual wins are possible, statistically, the house always has an edge in the long run.</strong></p><p>If you want to check my code or re-run the numbers yourself — you can find everything I have done <a href="https://github.com/bpiskernik/free_bet_optimize">here</a>.</p><p>Cheers!</p><h3>On my behalf</h3><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bd02999bcf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Climatological Index Days in Vienna from 1950 to 2023]]></title>
            <link>https://medium.com/@b.piskernik/climatological-index-days-in-vienna-from-1950-to-2023-ed2871cf6816?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed2871cf6816</guid>
            <category><![CDATA[climate-change]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[vienna]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 12:25:43 GMT</pubDate>
            <atom:updated>2025-06-06T12:30:31.132Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wPxfIrjGTFuw5PuRd5HIEQ.jpeg" /><figcaption>Image generated with Gemini Flash 2.5</figcaption></figure><p>I was recently reading an article about Sony’s new cooling wearable. The author argued that such devices will become more popular as climate change progresses. This, however, triggered another reader, who commented (loosely translated): “[…] [some swearing] […] [some more swearing] […] [this is all propaganda] [repeating some earlier swearing] […]. <strong>There have always been some hot days.</strong>”</p><p>And I thought to myself — well, that is true. But when I was younger, there weren’t that many. Perhaps the reader is younger, or do I recall things incorrectly?</p><p>So I did the only reasonable thing to do and checked if I could find actual numbers. Fortunately, this wasn’t too hard. Vienna, where I live, <a href="https://www.wien.gv.at/statistik/lebensraum/tabellen/eis-hitze-tage-zr.html">provides</a> the yearly count of climatological index days for the past 70 years.</p><p>These indices are</p><ul><li><em>Heat Days</em>: days with a maximum temperature of 30 °C or more</li><li><em>Summer Days</em>: days with a maximum temperature of 25 °C or more</li><li><em>Frost Days</em>: days with a minimum temperature of -1 °C or less</li><li><em>Ice Days</em>: days with a maximum temperature of 0 °C or less</li></ul><p>So, we have two levels of hot and cold days, respectively. Let’s see how the sum of the two types has progressed over time.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F8.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F8%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0787d5a75b424ceb2b0a830e39e0a559/href">https://medium.com/media/0787d5a75b424ceb2b0a830e39e0a559/href</a></iframe><p>The plot clearly indicates, despite fluctuations, that the number of cold days is decreasing, while warm days have become more frequent. But, I understand, that you don’t take my ‘inference by eye’ as granted. So, let’s take a slightly more scientific approach. To identify potential trends, I have fitted lines through the point clouds of the counts per index. For the fitting, I used linear regression, so that I can a.) nicely hit the middle of the clouds, b.) quantify the change per year, and c.) evaluate how likely the seen change would be if there isn’t actually a change in the levels and the variations are just random.</p><p>Let’s have a look at the resulting lines (note: the chart is interactive, so if you want to focus on one type of index, click on it in the legend).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F10.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F10%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/130fe1483eda67aa1d4d31871d5ad34f/href">https://medium.com/media/130fe1483eda67aa1d4d31871d5ad34f/href</a></iframe><p>Again, we can see a clear upward trend for the two warm indices and a corresponding downward trend for the cold ones. The probability of encountering such a clear trend, although there is none, just by chance, is smaller than <em>p</em> &lt;0.001 for all four indices. So, it seems pretty likely that warm days increased and cold days decreased in Vienna over the last 70 years. To put numbers on that. The regression yielded</p><ul><li>+ 0.32 heat days / year</li><li>+ 0.72 summer days / year</li><li>- 0.40 frost days / year</li><li>- 0.24 ice days / year</li></ul><p>Of course, those values should not be extrapolated into the future. Predictions are hard, especially about the future. However, I will consider getting a cooling wearable after all.</p><h3>Closing remarks</h3><p>This is just a quick glance at some limited, readily available, public data by someone who clearly is just dabbling with it. Still, it fits nicely into what climate scientists keep telling us. It is getting warmer, and one can obviously see that without needing to massage any complex data.</p><p>If you would like to review my numbers and code, please feel free to do so. You can find it <a href="https://github.com/bpiskernik/Climatological-Index-Days-Vienna">here</a>.</p><p>Cheers!</p><h3>On my behalf</h3><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed2871cf6816" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reap all the benefits of incremental dbt-models in BigQuery]]></title>
            <link>https://medium.com/@b.piskernik/reap-all-the-benefits-of-incremental-dbt-models-in-bigquery-ed884d4e3591?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed884d4e3591</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[data-transformation]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 16:49:55 GMT</pubDate>
            <atom:updated>2025-04-18T16:51:25.196Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6XHqwKeoG0LTzJ93421Fg.png" /><figcaption>image generated by ChatGPT</figcaption></figure><p>Incremental <strong>dbt models</strong> enable the processing of only new or updated data, eliminating the need to rebuild an entire table every time a model runs. They help improve efficiency and performance by appending or updating only the necessary rows in a table, reducing not only the run time but potentially also the costs, as less data needs to be processed. However, there is a tripping hazard when using it with BigQuery.</p><h3>The Problem</h3><p>I use them primarily when expansive transformations are in play; in this case, everything works as expected. But there is another use case — very large datasets (e.g., from streaming data), which are so big that querying them completely every dbt run, might become a cost factor. Unfortunately, in that case, you won’t get the efficiency benefits of incremental models with BigQuery (maybe this is also true for other warehouses, idk) if you just follow the dbt documentation to the letter.</p><p>Let’s have a look at the problematic part of the documentation.</p><pre>{{<br>    config(<br>        materialized=&#39;incremental&#39;<br>    )<br>}}<br><br>select<br>    *,<br>    my_slow_function(my_column)<br><br>from {{ ref(&#39;app_data_events&#39;) }}<br><br>{% if is_incremental() %}<br><br>where event_time &gt;= (select coalesce(max(event_time),&#39;1900-01-01&#39;) from {{ this }} )<br><br>{% endif %}</pre><p>Don’t get me wrong — this code works, and it will be faster than a non-incremental version of it because my_slow_function is only applied to the new entries since max(event_time)in this(my usual use case for incremental models). Still, the query will process the same amount of data in BigQuery as its nonincremental counterpart because the whole of ref(&#39;app_data_events&#39;) will be scanned and billed (except you opted for <em>pay per slot</em> instead of the regular <em>pay per byte processed</em>).</p><p>To avoid that, first of all ref(&#39;app_data_events&#39;) needs to be clustered by event_time. Clustering is BigQuery’s flavor of indexing, and since Google’s documentation on how to cluster a table is quite good, I will not go into any details. Instead, I will turn to the issue that <strong>all data will be processed even when </strong><strong>ref(&#39;app_data_events&#39;) is correctly clustered</strong>. The problem is that the subquery in the where-clause is too complex, and therefore, the optimized block pruning in BigQuery will not work. For more information on that, see, e.g., the <a href="https://cloud.google.com/bigquery/docs/querying-clustered-tables">docs</a> or this detailed <a href="https://www.googlecloudcommunity.com/gc/Data-Analytics/Why-a-full-table-scan-when-joining-a-clustered-column-to-another/m-p/749715/highlight/true#M5963">answer</a>.</p><h3>The solution</h3><p>Although the solution is straightforward in theory — <em>creating a variable for the event_time offset</em> — dbt offers some pitfalls in its implementation, so I will slowly build up to the complete solution.</p><p>Variables need to be declared before the actual model query. We can do so in a <a href="https://docs.getdbt.com/reference/resource-configs/sql_header">call set_sql_header(config)</a>block. Note: a <a href="https://docs.getdbt.com/reference/resource-configs/pre-hook-post-hook">prehook</a> would not work, because it would be a separate query, and the variable’s scope would not extend to the model query.</p><p>In a simpler world, this would look something like this. Let’s call the variable ts:</p><pre>{% call set_sql_header(config) %}<br><br>declare ts default (select coalesce(max(event_time), timestamp(&#39;1900-01-01&#39;)) from {{ this }} );<br><br>{% endcall %}<br><br>...<br><br>where event_time &gt;= ts<br><br>...</pre><p>Unfortunately, it is more complicated. There are two issues we need to address.</p><p>First, set_sql_header() cannot be wrapped in an if is_incremental() conditional (see known <a href="https://github.com/dbt-labs/dbt-core/issues/3264">issue</a>). Accordingly, it will be executed every run, even the first, when {{ this }} does not exist, yet. This will throw an error on the first run, which we need to catch. We can do it like that:</p><pre>{% call set_sql_header(config) %}<br><br>    declare ts default timestamp(&#39;1900-01-01&#39;);<br>    <br>    begin<br>        execute immediate &quot;select coalesce(max(event_time), timestamp(&#39;1900-01-01&#39;)) from {{ this }} limit 1&quot; <br>        <br>        into ts;    <br>    exception when error then<br>        --  no need to do something here<br>    end;<br><br>{% endcall %}</pre><p>With that, we are almost done, except for the second issue. The {{ this }} reference does not work correctly in the set_sql_header call (see <a href="https://github.com/dbt-labs/dbt-core/issues/2793">here</a>). So, unless all your data is in the same BQ dataset you need to hardcode the path to {{ this }}. The final solution will look something like this:</p><pre>{{<br>    config(<br>        materialized=&#39;incremental&#39;<br>    )<br>}}<br><br>{% call set_sql_header(config) %}<br><br>    declare ts default timestamp(&#39;1900-01-01&#39;);<br>    <br>    begin<br>        execute immediate &quot;select coalesce(max(event_time), timestamp(&#39;1900-01-01&#39;)) from `project`.`dataset`.`table` limit 1&quot; <br>        <br>        into ts;    <br>    exception when error then<br>        --  no need to do something here<br>    end;<br><br>{% endcall %}<br><br>select<br>    *,<br>    my_slow_function(my_column)<br><br>from {{ ref(&#39;app_data_events&#39;) }}<br><br>{% if is_incremental() %}<br><br>where event_time &gt;= ts<br><br>{% endif %}</pre><h3>Closing remarks</h3><p>I hope this guide helped you to save some money or at least some of your time. I have linked all the relevant issues that impede a more straightforward solution — you might want to check those first, as they may have been resolved in the meantime.</p><p>Cheers!</p><h3>On my behalf</h3><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed884d4e3591" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting fit(ter) solved my snoring issues]]></title>
            <link>https://medium.com/@b.piskernik/getting-fit-ter-solved-my-snoring-issues-7c6343cca92c?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c6343cca92c</guid>
            <category><![CDATA[snoring-treatment]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[snoring]]></category>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[data-stories]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Fri, 05 Apr 2024 09:35:39 GMT</pubDate>
            <atom:updated>2024-04-05T09:35:39.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jehZ1xHNZXCEB49s0zNP8g.jpeg" /><figcaption>generated with stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><h4>A data-focused case study</h4><p>I am a snorer. I have done it for many years. It is loud, and it annoys my wife … a lot. A protrusion splint reduced my snoring tremendously, but only after I got fitter did it stop (at least almost). This was unintended and unexpected, but quite happily so, so I would like to share my experience (with data).</p><h3>How it started</h3><p>I don’t know exactly when I started snoring. When I think back, my wife probably started complaining about it when she was pregnant with our first child. A period of conflict followed until I started tackling the issue. First, I tried a lot of cheap snoring aids from Amazon, but to no avail. A visit to the ENT finally brought some relief. Firstly, she informed me that I don’t have any medical issues and that my snoring is only a social problem. Secondly, she recommended trying a protrusion splint, which actually helped, and I use it to this day. Still, the snoring only got better, but it wasn’t gone. But my wife was happy enough (on most days), so I thought that this was as good as it gets.</p><h4>Weight was not an issue</h4><p>Interestingly, my ENT did not recommend weight loss, although if you research snoring, this is pretty much the first recommendation you will stumble upon. Ok, I was slimmer then, despite a bit of couvade syndrome (my wife wasn’t the only one who got a little belly during the pregnancy). But even until recently, I always discarded too much weight as not applicable to me because, yes, I got a full-fledged dad body over the following years, and I am a little bit overweight today. Still, for a guy in his forties, I believed myself to be pretty fit, at least in good shape, and probably fitter than the next guy. Part of that is undoubtedly delusional, male self-infatuation, but I still believe it could have been worse. Further, I did not gain that many pounds over the years; the change is more where they are located. Ultimately, this story is not about weight loss because I hardly lost any.</p><h4>How it changed</h4><p>Anyway, as I got older, I noticed that I sometimes needed new clothes because the old ones didn’t fit anymore, but while disturbing in my thirties, I was already used to it in my forties. So everything was fine until I did not fit into my suit anymore — the suit I had just bought for the ceremony of getting my doctorate because all my other suits did not fit me at that time anymore. Well, finishing my dissertation wasn’t that recent, but it still made me mad about myself and motivated me to get fit again.</p><p>This happened around the start of December 2023. In its wake, I cleaned up my diet and upped my sports quota to regain the body shape I once had. Both incrementally and in small steps because I aimed for a Modus operandi I could maintain for a long time. After all, besides my suit project, my main goals are fitness, health, and longevity. If you are interested in the details, please let me know, but it is only my idiosyncratic story, and I wouldn’t dare to frame it as the way to go for others.</p><p>Still, it kind of worked for me. Although I hardly lost any weight (between Dec 23 and Mar 24, it decreased by only two kilograms from 85 kg to 83 kg — my height is 173 cm, so yes, my BMI indicated overweight and still does), my abdominal circumference decreased by 6 cm from 93 to 87 cm in the same time, and I feel a whole lot fitter than before. Below, you can see a “during” (not a “before” because I am not in the habit of taking shirtless photos of myself, so I don’t have any) and an “after” photo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Og7V99Otect3ywO6IZupQ.png" /><figcaption>two photos taken six weeks apart during my “getting fit”-phase — not pre-photo-pump or flexing, just my dad bod in its 24/7 glory</figcaption></figure><p>As you can see, the change is a far cry from the body transformation we see and marvel about on social media. Further, I still rock a dad body and have not joined the sublime ranks of fitfluencers body greatness. But even this minor change in body composition from fat to muscle mass (this is how I would explain the discrepancy in weight and circumference change) had a massive impact on my snoring (remember, the protrusion splint only improved but did not solve the issue) and I can back it up with data.</p><h3>Visualization of the snoring data</h3><p>I always struggled with understanding my wife’s, let’s be civil and call it, displeasure with my snoring because I never heard it myself and, therefore, had problems recognizing the full extent of the issue. So, I wrote a mobile app to detect specific sounds, e.g., snoring, and collect stats about them. It is called <a href="https://moodpatterns.info/nighthark/index.html">Night Hark</a>, and I have used it myself since about the same time I decided to get fitter. This is also where I first noticed that my snoring decreased (which my wife confirmed later).</p><h4>Charts directly in the app</h4><p><a href="https://moodpatterns.info/nighthark/index.html">Night Hark</a> already has some basic visualization features, and those were the first to give me a hint that something is changing. The ‘trend’ charts were especially helpful. Those display two characteristics per night for the selected period: the sound volume in decibels relative to full scale [dBFS] and the duration in minutes. Before we get to the results, we need some info on dBFS to facilitate interpretation. Mobile phones use digital microphones, so they can only measure the sound pressure level relative to the maximum signal capacity of the microphone (= 0 dBFS). I don’t know how much that is for my phone (Pixel 6a), but my best guess would be to put it somewhere close to 100 dB. So, e.g., a value of -40 dBFS would mean 100–40=60 dB. Further, humans don’t hear equally well across the whole spectrum; therefore, I use the A-filtered version [dB(a)FS], which is tuned to the frequencies audible to us and provided by the app. With that, only one last piece of information is needed to interpret the values correctly: Loudness is not linear. An increase of 10 dB corresponds to a perceived doubling of loudness. So, e.g., -50 dBFS is double as loud as -60 dBFS.</p><p>Now that the metric is laid out, we can turn to the charts. The first is the <em>total trend chart</em>. It visualizes the mean sound volume (in blue) and duration (in red) of the complete sleep sessions. Although there is quite a lot of zig-zag, a slight downward trend in the sound volume is visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wSXXvvi44h7ori8MSt8Kxg.png" /><figcaption>Screenshot from Night Hark app: Trend-Chart Total</figcaption></figure><p>Of course, my snoring is only one of many factors affecting the mean sound volume throughout the night. We can look at the <em>snoring trend chart</em> to get a clearer picture of its contribution. This one shows only the data deemed “snoring” by the app. Again, we might see a slight downward trend in the sound volume (please notice that the overall level is about 10 dB higher than in the total chart), but more importantly, an apparent reduction in duration is noticeable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XGelCMkafvZiRRz9qO6nBg.png" /><figcaption>Screenshot from Night Hark app: Trend-Chart Snoring</figcaption></figure><h4>A more in-depth look at the data</h4><p>Only after that I asked my wife about it, and she confirmed what I had already seen in the charts. My snoring has decreased over time. But now, my interest was aroused, and I decided to look closer at the data. I exported all minute-by-minute values as a CSV file and visualized them in different ways, increasing the aggregation level with every chart.</p><p>But let’s start with some general characteristics to facilitate putting the charts into context. As mentioned, the data was collected with the app Night Hark on my Pixel 6a, which was lying on a nightstand beside my bed while I was sleeping. For the analysis, I use data collected between 2023–11–25 and 2024–03–14, comprising 75 nights and a total of 34,493 per-minute aggregates (the app&#39;s raw measurement unit is seconds, but to keep the used storage in check I set the app to keep only the minute aggregates for all but the seven most recent nights). Each per-minute data point includes, besides the timestamp, the maximum volume [dBFS/dB(a)FS] and the maximum <em>snoring score</em> within this minute. The snoring score ranges from 0 to 1, with higher values indicating more certainty that the app heard a snore. The app also provides similar scores for 500+ other sound categories, but today we will focus only on the volume and the snoring.</p><p>For the first visualization approach, I chose a <strong>strip chart</strong>, a chart type that did not require any aggregation and could reasonably display all 34k per-minute data points. Each minute is shown as on point with gradually changing colors for low and high values of sound volume and snoring score. The minutes of each night are sorted along those values and stacked on top of each other to create one colored strip per night. The color gradient of each strip tells us if it was a comparably quiet or a rather loud night.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*moweXB26Nf1BwBsMcgE8RQ.jpeg" /><figcaption>Strip charts of sound volume and snoring score</figcaption></figure><p>You probably notice that I don’t have data for all nights. Around the holidays, I had COVID, so I slept on the couch and couldn’t use my regular recording setup (there was no outlet to charge my phone). The other smaller gaps are primarily due to me forgetting to use the app (it wasn’t a habit then) and a few to one of our kids wanting to sleep in our bed, and I did not want to wake them by using my phone next to them. Apart from the gaps, you can see that the strips on the right (more recent) indicate quieter nights and less snoring than those on the left (earlier).</p><p>To get a clearer view of that, I aggregated the data by averaging per night so that each night is represented by a single data point. I charted the data in <strong>scatter plots</strong> and added a smoothing <a href="https://en.wikipedia.org/wiki/Local_regression"><strong>LOESS</strong></a><strong>-fit</strong> to highlight the general trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntPCiTIR7MbFUyzt_lkGGg.jpeg" /><figcaption>Scatterplot of mean values per night with LOESS-fit and its confidence band</figcaption></figure><p>You can see a noticeable decrease in mean volume. Also, my total sleep duration has fluctuated a little—I wasn’t aware of that and have no idea if that is meaningful. Chances are, this is just a fluke. My only hypothesis is that my sleep demand decreased as I got fitter, but in mid-February, I was so fit that I upped my game and increased my sports quota and, therefore, once again, needed more rest. I will keep an eye on that, and if I find a story worth telling, I will.</p><p>Anyway, this story is about snoring, so I zoomed in on the snoring part of the data (I filtered out all definitely not-snoring minutes before aggregating per night) and redid the scatter plots with the snoring-only data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tN0lBxlve2Hi5x9LFR8u8A.jpeg" /><figcaption>Scatterplot of mean values of the snoring per night with LOESS-fit and its confidence band</figcaption></figure><p>Now, it becomes pretty evident that my snoring has decreased in duration and sound volume over the given period. But by aggregating further, an even clearer picture is possible. So, I averaged all nights per month and displayed the means as <strong>bar plots</strong>. Please remember that I only have a few November nights, so it&#39;s better not to read too much into this bar. Further, you might wonder why the origin of<em> mean volume</em> is set at -90 dB(a)FS. This is due to -90 being the lower measurement bound of my phone (it cannot discern sounds more silent than -90 dB from total silence).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MgNPB649Nv0Qh9h6nXI4LA.jpeg" /><figcaption>Bar plots of monthly means of mean per night + 95% confidence intervals</figcaption></figure><p>For both duration and volume, the 95% confidence intervals of December and January do not overlap with those of February and March. For the duration, even February and March are distinct. Although one cannot conclude with certainty that they therefore differ significantly in a statistical sense (see, e.g., <a href="https://pubmed.ncbi.nlm.nih.gov/15740449/">Cumming &amp; Finch 2005</a> for an overview of inference by eye), it makes that seem very likely.</p><p>Granted, this is unsatisfying, so I also tested the hypothesis that the duration and volume of my snoring decreased during the observation period. To keep it as simple as possible, I used a simple linear regression and regressed the per-night averages on the measurement date. Implicitly, I made some very strong assumptions while doing so. Foremost that the measurements decreased linearly over time (meaning the measurement change per time unit is constant). Obviously, this wouldn’t fit the data well if I had started sampling earlier or sampled longer because before the observation period, the plateau was more or less stable (according to my wife), and after the latest decrease, there is not much more room for further reduction. In either case, drawing a straight line through the data (this is the visual representation of the regression) wouldn’t have done it justice. However, assuming linearity is a reasonable simplification since the observation period coincidentally matches the change period. You can inspect this claim (at least a bit) in the following plot, where I have drawn the regression lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sI3PkNjFQ-1Os-eD7agj8Q.jpeg" /><figcaption>Scatterplot of mean values of the snoring per night with fitted linear regression line</figcaption></figure><p>As expected, both lines have a distinct negative slope (they go downwards) that is statistically significantly different from zero (<em>p</em> &lt;&lt; 0.001 for both measures). To simplify the interpretation of the slopes, I have scaled the time-axis so that one unit is precisely one week. So the slopes tell us how much each measure decreased every week. The duration slope β(duration)=-6.5, meaning that each week, my snoring duration per night decreased by 6 minutes and 30 seconds. While the volume slope β(volume)=-0.29 indicates that the dwindling remaining snoring became 0.29 dB(a) more silent per week.</p><h3>Closing remarks</h3><p>As you have seen, a slight change in body composition remarkably impacted my snoring. When using a protrusion splint, I almost completely stopped snoring (I still don’t know if I would still snore without it, and if yes, how much — if this is a story you are interested in, please let me know). Although this snoring reduction wasn’t even intended, I might have considered getting fitter earlier if I had fathomed it prior. Of course, this is just a single case and might not be generalized well, but it might be worth a try if you are in a similar position — even if it does not work for your snoring, the worst case is you look a little better naked. Anyway, I am interested in your experiences and thoughts, so please let me know in the comments.</p><p>If you want to look at the data or the code to create the charts, you can find those in this <a href="https://github.com/MoodPatterns/article_getting_fitter_reduced_snoring">repo</a>.</p><p>Night Hark, the app I have used for the sound measurements, is available on <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.night_hark">iOS</a> and <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.night_hark">Android</a>. If you are interested in the app’s data, I have also used it in another of my works: <a href="https://medium.com/@b.piskernik/silent-new-years-eve-in-vienna-austria-cdb7315c3d56">Silent New Year’s Eve in Vienna</a>, in which it helped me identify and quantify the noise caused by fireworks.</p><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c6343cca92c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Minimize drop-out in longitudinal formr surveys]]></title>
            <link>https://medium.com/@b.piskernik/minimize-drop-out-in-longitudinal-formr-surveys-0f95a8d61c10?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f95a8d61c10</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[longitudinal-study]]></category>
            <category><![CDATA[surveys]]></category>
            <category><![CDATA[churn]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Sun, 11 Feb 2024 19:09:59 GMT</pubDate>
            <atom:updated>2025-04-18T16:30:46.791Z</atom:updated>
            <content:encoded><![CDATA[<h4>Reduce participant churn with automatic reminder emails</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ja8afwdjGDendmiI8_FvMg.png" /><figcaption>created with stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p><a href="https://formr.org/">formr</a> is a fantastic survey framework. It is free, open-source, and easily outclasses all commercial competitors regarding features and versatility. But even this excellent tool doesn’t solve the most challenging part of any survey, finding participants, or in longitudinal studies (our topic today), even more importantly, keeping participants active. This post will describe how I tackled this problem while being frugal with time and effort. If you want to skip my rambling and see code with minimal scaffolding, you can look at this <a href="https://github.com/bpiskernik/formr_antichurn_example">example R-notebook</a> instead.</p><h3>The starting point</h3><p>My solution is not a one-size-fits-all, but it shouldn’t be too hard to adjust it to your requirements. But let’s not get ahead of ourselves and start at the beginning.</p><p>Recently, we started a longitudinal study that runs per participant over several months, with one long survey in the beginning (which asks, among other things, for a contact email address) and a short survey every week (which needs to be filled out between Thursday and Wednesday of the following week). The starting date of the survey is staggered, so not all participants start in the same week. On the one hand, we are still recruiting to reach the number suggested by a power analysis. On the other hand, we started with only a few participants to see if everything runs smoothly and avoid ‘burning’ too many participants if something needs to be changed after all (similar to a pre-release in software-dev). Those early birds have already partaken for a few weeks; overall, everything looks good. However, like in many longitudinal studies, some are only irregularly active, and others stop partaking. To keep those cases at a minimum, until now, a colleague has looked over all results every week and contacted those who seemed at risk to keep them motivated. This worked reasonably well, and AFAIK is the typical way to deal with this problem. The only problem is that it does not scale.</p><p>With more and more participants starting, personally screening all results and contacting everyone manually is not feasible given a tight working hour budget. Also, it is unreasonable because it is highly repetitive and, therefore, an ideal candidate for automation. So, I sat down with my colleague Caroline Gahrmann, who knows much more about participant care than I do and discussed criteria to identify participants who should get an email to motivate them to continue participating. This is what we came up with:</p><ol><li>Inactive participants who have not participated in the last two weeks (not less, not more) should get a gentle reminder.</li><li>Inactive participants who have already triggered this condition in the past should get an even more engaging gentle reminder.</li></ol><p>This seemed easy enough to formalize as code, so I was ready to start the fun part.</p><h3>The fun part (aka coding)</h3><p>Since formr already uses R and provides an accompanying package, I will work with R and the provided package. If you want to avoid R — formr also has a REST-API, but be warned — it will not yield all the metadata (e.g., the fields expiredand endedare missing).</p><p>I used the following code snippets (or rather something very close to them) in an R-notebook, which will be run once a week. Besides the identification of churn-endangered participants and the sending of emails, it also displays the status quo. So, it is correct to call it only semi-automatic. If you want to make it fully automatic, skip the displaying part, put the rest in an R-script, and schedule it to run, e.g., via CronJob.</p><h4>Preparations</h4><p>First, we need to install the <a href="https://rubenarslan.github.io/formr/index.html">formr</a>-library, which is unavailable on CRAN (yet).</p><pre>install.packages(&quot;devtools&quot;)<br>devtools::install_github(&quot;rubenarslan/formr&quot;)</pre><p>Next, we load all the packages we will use.</p><pre>library(tidyverse)<br>library(dotenv)<br><br>library(formr)<br><br>library(kableExtra)<br><br># for automatic contact<br>library(blastula)<br>library(Microsoft365R)</pre><p>I use dotenv to keep some strings private from you. At least for the login credentials, you should also avoid putting them hardcoded into your code.</p><pre>load_dot_env(file = &quot;.env&quot;)<br><br># login <br>email &lt;- Sys.getenv(&quot;FORMR_EMAIL&quot;)<br>password &lt;- Sys.getenv(&quot;FORMR_PWD&quot;)<br><br># survey names<br>survey_start &lt;- Sys.getenv(&quot;SURVEY_START&quot;)<br>survey_weekly &lt;- Sys.getenv(&quot;SURVEY_WEEKLY&quot;)<br><br># field name of participant email in survey_start<br>surve_email_field &lt;- Sys.getenv(&quot;EMAIL_FIELD&quot;)<br><br># address used to send reminder email to participants<br>email_sender &lt;- Sys.getenv(&quot;EMAIL_SENDER&quot;)</pre><p>With this, we are ready to get the data.</p><h4>Get the data</h4><p>First, we need to connect to formr.</p><pre>formr_connect(<br>  email = email,<br>  password = password<br>)</pre><p>Next, we pull the data.</p><pre>df_start_raw &lt;- formr_raw_results(survey_start)<br>df_weekly_raw &lt;- formr_raw_results(survey_weekly)</pre><p>And finally, end the started formr session.</p><pre>formr_disconnect()</pre><p>Now that we have all the data, we must bring it into a more usable form.</p><h4>Slice &amp; dice the data</h4><p>First, we tend to df_start_raw, from which we only need the email addresses and session, formr’s participant identifier, to link the email address with the other data.</p><pre>df_email &lt;- df_start_raw %&gt;%<br>  select(all_of(c(&#39;session&#39;, surve_email_field))) %&gt;%<br>  drop_na() %&gt;%<br>  rename(<br>    &#39;email&#39; = surve_email_field<br>  )</pre><p>Next, we extract the needed data from df_weekly_raw. <br>We need:</p><ul><li>Again session the for the join with emails</li><li>The <strong>week</strong> derived from the created( our survey week starts on Thursday, so we need to shift the timestamp a little)</li><li>Whether the survey was <strong>answered</strong> (in this example we check if the survey has expired; in my real use case I looked if the survey was filled out till a specific question).</li></ul><pre># survey week starts at thu 17:00 and ends on wed<br># shift `created` to allow use of iso_week<br># use_time = created - 3 days &amp; 9 hours (-&gt; thu 15:00 - start early to have safety margin, survey week is shorter than 7 full days)<br><br>survey_week_shift &lt;- duration(hour = 9, day = 3)<br><br>df_weekly &lt;- df_weekly_raw %&gt;%<br>  mutate(<br>    created = ymd_hms(created) # convert to timestamp<br>    , week = year(created-survey_week_shift)*100 + isoweek(created-survey_week_shift)<br>    , answered = is.na(expired) <br>  ) %&gt;%<br>  arrange(session, week) %&gt;%<br>  # aggregate by week (there are reminders, but one answered is sufficient)<br>  group_by(<br>    session<br>    , week<br>  ) %&gt;%<br>  summarize(<br>    active = max(answered)<br>  ) %&gt;%<br>  # not all participants start simultaniously - align to their individual starting dates<br>  mutate(<br>    week_individual = row_number()<br>  )</pre><p>From df_weekly we can derive all the aggregated info we need. We start with the currently inactive weeks as the decision criterion to send an email.</p><pre>df_currently_inactive_weeks &lt;- df_weekly %&gt;%<br>  group_by(<br>    session<br>  ) %&gt;%<br>  mutate(<br>    d = abs(active-lag(active)) %&gt;% replace_na(0)<br>    , streak = cumsum(d)<br>  ) %&gt;%<br>  group_by(<br>    session<br>    , streak<br>  ) %&gt;%<br>  mutate(<br>    streak_duration = row_number()<br>  ) %&gt;%<br>  ungroup() %&gt;%<br>  group_by(<br>    session<br>  ) %&gt;%<br>  slice_tail() %&gt;%<br>  mutate(<br>    currently_inactive_weeks = ifelse(active == 1, 0, streak_duration)<br>  ) %&gt;%<br>  select(session, currently_inactive_weeks)</pre><p>Next, we compute the inactive streaks per participant because those who have been inactive in the past get a different email.</p><pre>df_severe &lt;- df_weekly %&gt;%<br>  group_by(<br>    session<br>  ) %&gt;%<br>  mutate(<br>    d = abs(active-lag(active)) %&gt;% replace_na(0)<br>    , streak = cumsum(d)<br>  ) %&gt;%<br>  group_by(<br>    session<br>    , streak<br>  ) %&gt;%<br>  mutate(<br>    streak_duration = row_number()<br>  ) %&gt;%<br>  ungroup() %&gt;%<br>  filter(<br>    (streak %% 2 == 1) | ((streak == 0) &amp; (active==0))  # = # inactive<br>    , streak_duration == 2<br>  ) %&gt;%<br>  group_by(session) %&gt;%<br>  summarize(<br>    inactive_streaks = n()<br>  )  %&gt;%<br>  right_join(<br>    df_weekly %&gt;%<br>      select(session) %&gt;%<br>      distinct()<br>  ) %&gt;%<br>  mutate(<br>    inactive_streaks = replace_na(inactive_streaks, 0)<br>  )%&gt;%<br>  mutate(<br>    severe = inactive_streaks &gt;= 2<br>  )</pre><p>Optionally, we get the participation duration per participant. This is only needed to sort the participants by duration when displaying the status quo. If you don’t want the display and instead fully automate everything, you can skip that.</p><pre>df_participation &lt;- df_weekly %&gt;%<br>  group_by(session) %&gt;%<br>  summarize(duration = max(week_individual)) %&gt;%<br>  arrange(desc(duration), session)</pre><p>Finally, we merge all these into a data frame representing the status quo. If you have skipped df_participation in the previous step, start with df_email instead.</p><pre>df_status &lt;- df_participation %&gt;%<br>  inner_join(df_email) %&gt;%<br>  inner_join(df_currently_inactive_weeks) %&gt;%<br>  mutate(<br>    remind = currently_inactive_weeks == 2<br>  ) %&gt;%<br>  inner_join(df_severe) %&gt;%<br>  inner_join(<br>    df_weekly %&gt;%<br>      pivot_wider(<br>        id_cols = session<br>        , names_from = week_individual<br>        , values_from = active<br>      )<br>  ) %&gt;%<br>  select(-c(&#39;session&#39;, &#39;duration&#39;, &#39;currently_inactive_weeks&#39;, &#39;inactive_streaks&#39;))</pre><h4>Display the status quo</h4><p>To make the status data look nice, we write a short helper function that renders it in an HTML table. If you use Rstudio with a dark theme, then you need to overwrite the print function of kableExtra or the text will not be legible (light font on a light background). You can look up how to do that in the <a href="https://github.com/bpiskernik/formr_antichurn_example">example R-notebook</a>.</p><pre>to_status_table &lt;- function(df){<br>  df %&gt;%<br>  mutate(<br>    remind = cell_spec(remind, background = ifelse(remind, &#39;darkred&#39;, &#39;seagreen&#39;), color = &#39;white&#39;)<br>    , severe = cell_spec(severe, background = ifelse(severe, &#39;darkred&#39;, &#39;seagreen&#39;), color = &#39;white&#39;)<br>  ) %&gt;%<br>  mutate_if(<br>    is.numeric, <br>    ~cell_spec(<br>      ., <br>      color = case_when(<br>        is.na(.) ~ &#39;grey&#39;,<br>        . == 1 ~ &#39;seagreen&#39;,<br>        . == 0 ~ &#39;darkred&#39;<br>      )<br>      , bold = !is.na(.))<br>    ) %&gt;%<br>  kbl(escape = F) %&gt;%<br>  kable_paper(bootstrap_options = &quot;striped&quot;, full_width = T, fixed_thead = T)<br>}</pre><p>When we use it on df_status we get a nice looking overview.</p><pre>df_status %&gt;%<br>  to_status_table()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dPEz-KtHb0_bMrABzRTWeA.png" /><figcaption>Abbreviated status quo table. Note: for privacy reasons, those are no real emails</figcaption></figure><p>When we hone in on those who will get a reminder email, the list is, fortunately, a lot shorter (I am using our real data as a base — with scrambled emails, of course).</p><pre>df_contact &lt;- df_status %&gt;%<br>  filter(remind)</pre><pre>df_contact %&gt;%<br>  to_status_table()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbwJeaRHEs-tDBNURt4GpQ.png" /><figcaption>Table of participants who will get a reminder email</figcaption></figure><p>This week, only two participants who have just started but never responded to the weekly survey will get a reminder email (the gentle one because severe is false).</p><h4>Send the reminder emails</h4><p>If you work for a university, chances are good that you have an MS Outlook business account. To use those with R, you need the <a href="https://cran.r-project.org/web/packages/Microsoft365R/index.html">Microsoft365R</a>-library. If you want to send the emails from another account without 2fa, you can skip the next step and send the emails directly with <a href="https://cran.r-project.org/web/packages/blastula/index.html">Blastula</a>.</p><p>If you use MS Outlook Business, you must grant permission on the first execution (the credentials will be saved locally). The following snippet will open Outlook in the browser, require you to log in, and give your permission. Therefore, even if you want to automate the entire process, you still need to run this part interactively at least once.</p><pre>outl &lt;- get_business_outlook()</pre><p>Next, we will create the email templates. The following examples are very basic, both technically and regarding the content. In a real use-case, be more creative in the wording, personalize (e.g., if you know the name of the participants — use it), and add a logo from your university … see <a href="https://cran.r-project.org/web/packages/blastula/index.html">Blastula</a> for the technical options (essentially, you can format them using markdown).</p><p>We start with the <em>gentle reminder …</em></p><pre>email_basic &lt;-<br>  compose_email(<br>    body = md(<br>      glue::glue(<br>&quot;<br>Dear Participant,<br><br>We hope this email finds you well. We&#39;re reaching out because we haven&#39;t seen your participation in our ongoing longitudinal study for a while now.<br><br>We truly appreciate your initial commitment to this important research, and we value every contribution you&#39;ve made so far. Your continued participation is crucial for us to gain valuable insights into life, the universe, and everything that exists.<br><br>We understand that life gets busy, and things might come up that prevent you from completing tasks. If there&#39;s any reason you haven&#39;t been able to participate recently, please let us know! We&#39;re happy to answer any questions you may have, address any concerns, or work out a schedule that works better for you.<br><br>Here are some ways you can get back involved:<br><br>* **Complete any outstanding tasks**: If you have any pending surveys, please let us know and we&#39;ll gladly resend the access links.<br>* **Let us know your availability**: If you&#39;re interested in continuing but need to adjust your participation schedule, please feel free to reply to this email with your preferences.<br>* **Provide feedback**: If you&#39;ve decided not to continue, we would still greatly appreciate your feedback on your experience with the study. Your insights will help us improve future research.<br>Remember, every contribution matters! By continuing your participation, you&#39;re helping us answer important questions that could benefit not less than the whole human kind.<br><br>Thank you for your time and consideration. We hope to hear from you soon!<br><br>Sincerely,<br><br>The Research Team<br>&quot;<br>      )<br>    )<br>  )</pre><p>… and also compose one for the more severe cases …</p><pre>email_severe &lt;-<br>  compose_email(<br>    body = md(<br>      glue::glue(<br>&quot;<br>Dear Participant,<br><br>We&#39;re reaching out because we haven&#39;t seen your participation in our ongoing longitudinal study for a while now, and your previous contributions have been irregular.<br><br>We deeply appreciate your willingness to be part of this important research, and we want to ensure it&#39;s still a good fit for you. Understanding your needs helps us improve the study experience for everyone.<br><br>Could you tell us a little more about:<br><br>* What made you initially sign up for the study?<br>* What have you enjoyed about participating so far?<br>* Have you encountered any challenges that prevented you from participating regularly?<br><br>Remember, there&#39;s no pressure to continue if the study no longer aligns with your time or interests. However, if there&#39;s anything we can do to make participation easier or more engaging, please don&#39;t hesitate to let us know.<br><br>Here are some options:<br><br>* **Adjust your participation schedule**: Tell us what frequency works best for you.<br>*  **Share your feedback**: Even if you decide not to continue, sharing your experience helps us improve future research.<br><br>Ultimately, we want to ensure this study stays valuable to both participants and our research goals. Thank you for your time and we look forward to hearing from you soon!<br><br>Sincerely,<br>The Research Team<br>&quot;<br>      )<br>    )<br>  )</pre><p>Let’s check how it will look on the participant’s screen.</p><pre>email_basic</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJrqCvl5jpAHav5w59ja8A.png" /><figcaption>Rendered gentle reminder email</figcaption></figure><p>I will skip displaying the email for severe cases for brevity reasons. Feel free to render it yourself.</p><p>Up next is creating the individual emails. We create a helper function to do so. In this case, it only takes two arguments (the email address and whether it is a severe case), but it should be easy enough to extend it to your needs (e.g., by adding a name, language, …).</p><pre>add_email &lt;- function(email, severe) {<br>  <br>  # ifelse &amp; case_when do not work for flow control due to output datatype<br>  mail &lt;- email_basic # default fallback<br>  <br>  if(severe) {<br>      mail &lt;- email_severe<br>  }<br>  <br><br>  return(<br>    outl$create_email(<br>      mail<br>      , subject=&quot;Checking in: Your continued participation matters in our study!&quot;<br>      , to=address<br>      )<br>    )<br>}</pre><p>With that, we can create a vector of the emails we plan to send.</p><pre>emails &lt;- df_contact %&gt;%<br>  mutate(<br>    em = pmap(list(email, severe), add_email)<br>  ) %&gt;%<br>  pull(em)</pre><p>Finally, everything left to do is to iterate over this vector and send the emails. We will slow this process down so that only one email per 5 seconds is sent.</p><pre>for(em in emails){<br>  em$send()<br>  Sys.sleep(5)<br>}</pre><p>Here, the (semi-) automatic identification of potential survey drop-outs and sending them reminder emails is finished. Next week, we only need to execute the notebook/script again and save a ton of time.</p><h3>Closing remarks</h3><p>Of course, our criteria for sending a reminder email are somewhat arbitrary. But those are a good starting point. Anyways, formr makes it easy (for you) to access your data and build your own logic on it.</p><p>I hope this short illustration of how we have dealt with the participant churn issue in longitudinal studies is helpful or inspirational for some of you. I would be interested in your opinion, so please let me know in the comments.</p><p>Still, participant churn is not the only problem in longitudinal studies. Those become especially tricky if participants are requiredremain anonymous, even to the researcher. To tackle this problem, I have written a little open-source <a href="https://moodpatterns.info/participantId/index.html">app</a> described in this <a href="https://medium.com/@b.piskernik/participant-ids-taken-seriously-579a47afc87f">post</a>. So if privacy in longitudinal studies is a concern for you, please take a look.</p><h3>On my own behalf</h3><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f95a8d61c10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Silent New Year’s Eve in Vienna (Austria)]]></title>
            <link>https://medium.com/@b.piskernik/silent-new-years-eve-in-vienna-austria-cdb7315c3d56?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdb7315c3d56</guid>
            <category><![CDATA[mobile-apps]]></category>
            <category><![CDATA[noise-pollution]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[vienna]]></category>
            <category><![CDATA[new-year]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 12:59:36 GMT</pubDate>
            <atom:updated>2024-02-10T13:15:44.245Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7ffGTmC14ANAKW8zDZi8A.png" /><figcaption>generated with stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>Are there still fireworks in a famously quiet, central residential area in Austria’s capital?</p><p>New Year’s Eve in Vienna used to sound like being thrown into a war zone — a staccato of explosions with sound volume close to or above the pain threshold for hours and hours and hours … But those days are gone. Over the last few years, the change of years became relatively silent in Austria’s capital. Officially, the main reason is that Vienna has forbidden all pyrotechnics above class F1 (anything children are legally allowed to use) within city borders. Further, supermarkets no longer sell fireworks, citizens are more concerned about the environmental and climate impact, and dog owners (Austrians cherish their furry family members) have become more vocal.</p><p>This is especially true for my residential area — the <em>Nordbahnhofviertel</em>. This rather new part of the city, although very central, is quiet as can be. It is traffic-calmed, has many driving bans, and sometimes you get the impression that there are more cargo bikes than cars. And, predominantly inhabited by young families, it is not a party hotspot by far.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.google.com%2Fmaps%2Fembed%2Fv1%2Fplace%3Fcenter%3D48.2280429%252C16.3741966%26key%3DAIzaSyD9HrlRuI1Ani0-MTZ7pvzxwxi4pgW0BCY%26zoom%3D14%26q%3DKrakauer%2BStr.%2C%2B1020%2BWien&amp;display_name=Google+Maps&amp;url=https%3A%2F%2Fwww.google.at%2Fmaps%2Fplace%2FKrakauer%2BStr.%2C%2B1020%2BWien%2F%4048.2280429%2C16.3741966%2C14z%2Fdata%3D%214m6%213m5%211s0x476d0701fbecdda5%3A0x825585d502b8a408%218m2%213d48.2264562%214d16.3954451%2116s%252Fg%252F1hc21j7h4%3Fentry%3Dttu&amp;image=http%3A%2F%2Fmaps-api-ssl.google.com%2Fmaps%2Fapi%2Fstaticmap%3Fcenter%3D48.2280429%2C16.3741966%26zoom%3D15%26size%3D250x250%26sensor%3Dfalse&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="600" height="450" frameborder="0" scrolling="no"><a href="https://medium.com/media/a34bc2a8daa438c353b1eeaba4c62ed6/href">https://medium.com/media/a34bc2a8daa438c353b1eeaba4c62ed6/href</a></iframe><p>Anyway, even there, fireworks and firecrackers still exist, and people either love or hate them. Depending on the side, the reported noise quantification fluctuates between Animal Crossing and Call of Duty scenarios. Unsatisfying as this is, I have decided to put a little more data into this discussion.</p><h3>The Measurement</h3><p>I have used the mobile app <a href="https://moodpatterns.info/nighthark/">Night Hark</a> to measure the sound volume during the night and to detect the sound of fireworks/firecrackers. Therefore, I have placed an iPhone 8 next to the closed window in my apartment on the third floor and let it record the night. I put it into my home office room with closed doors, so there might be some noise contamination from my family and me, but it shouldn’t be too bad. After all, I can code there without being disturbed by my kids playing Ninja in the living room shouting the name of Jutsus.</p><p>I will report the sound volume in decibels full scale. Since mobile phones use digital microphones, one only gets the sound pressure level relative to the maximum signal capacity of the microphone (= 0 dbfs). I don’t know how much that is for an iPhone, but my best guess would be to put it somewhere close to 100 dB. The app would also return an A-filtered measure, which is tuned to the hearing spectrum of humans, but since this is at least partly about animals and I have no clue if A-filtered would be appropriate, I stick with dbfs (if you know more about this, please let me know in the comments).</p><p>Before we get to the results, a last help for interpreting them: Loudness is not linear. An increase of 10 dB corresponds to a perceived doubling of loudness. So 60 dB is double as loud as 50 dB.</p><h3>The Results</h3><p>We can see in Fig. 1, which displays the max sound pressure level per minute, that there is a build-up till midnight when loudness jumps to its max value and stays there for around half an hour before ebbing down. During the build-up there seem to be two local maxima at around 19:00 and 21:00 — maybe those were fireworks for very small and small children who cannot stay awake till midnight. After 2 o’clock, it is practically quiet.</p><p>Further, the scale was never maxed out with 0 dbfs, so the phone could have been able to quantify even louder sounds. The loudest minute was 0:32 with -17.8 dbfs. If my guess of a max value of 100 dB is correct, this would correspond to 82.3 dB, or for reference, a motorcycle or a crying baby. Not quiet, but only an eighth of the loudness of a disco at 110 dB or a 32nd of the pain threshold at 130 dB.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Ebpiskernik%2F3.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F3%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/2324bf6e5c7e08556d32ae3075136029/href">https://medium.com/media/2324bf6e5c7e08556d32ae3075136029/href</a></iframe><p>Honing in on fireworks and firecrackers, I looked at the count of either fireworks or explosion classifications with a score greater or equal to .05. (Night Hark uses YAMNet, a neural network, that can classify sound snippets of 0.975 seconds into 500+ categories. Each sound category gets a score between 0 and 1, with greater values indicating a higher likelihood that the snippet belongs to the specific category). Since the sound behind the window is somewhat muffled and the time resolution is limited, this is no 1:1 representation of the actual number of bangs, but the proportions between time-frames should be valid.</p><p>In Fig. 2, we can again see a clear peak at midnight, a local maximum at 20:30, and a hard stop at 02:00.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplotly.com%2F%7Ebpiskernik%2F5.embed%3Fautosize%3Dtrue&amp;display_name=Plotly&amp;url=https%3A%2F%2Fchart-studio.plotly.com%2F%7Ebpiskernik%2F5%2F&amp;image=https%3A%2F%2Fchart-studio.plotly.com%2Fstatic%2Fwebapp%2Fimages%2Fplotly-logo.8d56a320dbb8.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=plotly" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/685f0511f2d075f095cf63aba89e2a6e/href">https://medium.com/media/685f0511f2d075f095cf63aba89e2a6e/href</a></iframe><h3>Closing remarks</h3><p>Whether this is a lot or quasi-nothing lies in the ear of the listener, but I am sure this is comparatively silent for New Year’s Eve in a metropolis. I am interested in your experiences and thoughts on that, so please let me know in the comments.</p><p>If you want to look at the data, you can find it <a href="https://www.kaggle.com/datasets/bpiskernik/new-years-eve-soundscape-in-viennese-apartment">here</a>.</p><p>Night Hark, the app I have used for the sound measurements, is available on <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.night_hark">iOS</a> and <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.night_hark">Android</a>.</p><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdb7315c3d56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Participant IDs taken seriously]]></title>
            <link>https://medium.com/@b.piskernik/participant-ids-taken-seriously-579a47afc87f?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/579a47afc87f</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[id]]></category>
            <category><![CDATA[anonymization]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 16:18:22 GMT</pubDate>
            <atom:updated>2024-02-10T13:13:51.849Z</atom:updated>
            <content:encoded><![CDATA[<h4>Giving a little love to the underappreciated workhorse of psychological research</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*yl94SZbI4gDTGOAbNSmFnA.png" /><figcaption>Icon of the <a href="https://moodpatterns.info/participantId">Participant Id</a> app.</figcaption></figure><p>This post is about why participant Ids should be anonymous, reproducible, and irreversible. And how I implemented those ideas in an open-source app for everybody to use. I write it primarily for my colleagues in psychological research but will provide enough context for anyone interested to follow along.</p><h3>Some context</h3><p>If you are already deep into the rabbit hole and have encountered various shortcomings of the typical participant Ids, then you can probably skip this section.</p><h4>What are participant Ids, and what are they used for?</h4><p>Usually, participant Ids are short alphanumeric sequences indicating to which participant within a study a given data set belongs. Their primary use is to link different measures of the same participant (from other measurement instruments or measurement time points) together. But they are also used to provide individualized feedback to the participants after the study if they want to know their results, delete data if a participant changes her mind about her participation, and perform similar tasks.</p><h4>This doesn’t sound like a hard problem — what can possibly go wrong?</h4><p>What makes participant IDs tricky is that they should be unique and, in many cases, anonymous. This pretty much rules out real names. Just assigning an incrementing number or a random code doesn’t work either. Both have the problem that the participant must remember which number or code is hers for post-measurement communication. The researcher would also need a non-anonymous mapping if not all measurements are taken in one go (which pretty much defies the whole purpose). Further, an incrementing number might not be totally anonymous. Participants are likely to correctly guess the numbers of other participants they might have met.</p><p>The typical workaround for this problem is to take the participant&#39;s personal information (e.g., name — in sophisticated cases of some relative, birthday, place of birth, address, …), apply some shortening algorithm, and use the resulting code. This can be easily illustrated by creating an exemplary id for me. We use the first two letters of my first name (IRL, more clever colleagues than me would ask for my grandpa&#39;s name instead), the city I live in, and my birth year. This yields BeVi1980 for <strong>Be</strong>rnhard, <strong>Vie</strong>nna, and, well, <strong>1980</strong>. Looks good? Unfortunately, not. This prototypical type of participant id is neither anonymous, unique, nor stable over time. Let’s delve a little into why these three points are problematic.</p><h4>Not anonymous?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHAqHLNMzcJogfrM_tgImQ.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>It is evident that anyone who knows the id generation algorithm and some basic facts about me would be able to re-identify me in the above-given example. This is also mostly true for all the other variants I have encountered (as a ‘methods’ guy who has issues saying no, those have been quite a lot). But does this really matter?</p><p>Well, it does. Many countries have privacy and data processing laws (like, e.g., EU’s GDPR) that are pretty strict, and storing PII (Personally Identifiable Data) comes with a bunch of obligations and restrictions. But even without going into the for me arcane art of jurisprudence, I believe I can make some valid points to support the need for anonymity.</p><p>There are ethical and scientific reasons why one would care about the anonymity of the participant’s data. On the moral side, we first should remember that psychologists often ask undoubtedly private questions. Sometimes those are even about things that are secret to the people closest to participants. If they are still willing to dare this leap of faith and share that information with us, then our obligation is to protect it as well as possible. But the typical participant id fails at that.</p><p>It wouldn’t be hard for anyone who knows some basic facts about the participant (e.g., a neighbor, a boss, …) to generate the proper id and require “his own” data from you, leaving you none the wiser (especially if the one responsible for the data has not personally met the actual participant — e.g., in online studies). But even without malevolent outside imposters, danger also lingers on the inside. E.g., recently, I discovered that one of my neighbors has participated in a study I have analyzed, and honestly, I was tempted to look him up (of course I didn’t).</p><p>This brings us to the data quality problem a not fully secure Id might bear. Psychological research in its current magnitude is only possible because of the free workforce psychology students are forced to provide. If they are not the participants, they are often asked to recruit participants, which usually happens in their close social vicinity (family members, friends, colleagues, …). In most cases, the students also profit from their data collection because it is often only the prelude for a subsequent thesis based on the collected data. This becomes a problem if participants don’t have faith in the anonymization. If they need to fear that someone they know has access to their data (in most cases, this shouldn’t be a real issue because students usually don’t get the ids but only the data they need to work with), then they might very well adjust their responses accordingly. This adds noise to any signal you are looking for.</p><p>But anonymity is not the only issue.</p><h4>Not unique?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROQF6rO95it0ObigSWyGZA.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>The exemplary id generation algorithm, which uses only the first two letters, provides more anonymity than the full name. Yes, it allows anyone who knows a participant to recreate her id, but a stranger just skimming over the ids would be unable to identify them. Even if an id matches someone they know, there is still plausible deniability. Hundreds, if not thousands, of others could end up with the same BeVi1980 as me. This might be a boon regarding privacy but can become a real problem regarding the original purpose of matching data. Collisions break the 1:1 mapping of the data chunks, and unambiguous matching is no longer possible.</p><p>Unfortunately, I have seen this happening quite frequently. I know of one study in which the first two letters of the first and the family name were used as ids, but since they had a sample shy of 300, there were several duplicates. Luckily, the study required quite a lot of interaction between participants and researchers. Hence, the participants were not anonymous, and the researcher solved the problem by attaching an incrementing number at the end of the id. I have seen many <em>2</em>s, some <em>3</em>s, and even one <em>4</em>. Another study I know of ended up less fortunate. It was an internet study (with multiple time points that needed matching) with no direct interaction between researchers and participants, so no post facto fixing was possible. This study used the first two letters of the first name and the birthplace, and some other data. It turned out that those could have been better. Quite a few first names started with <em>Ma</em> (e.g., Maria, Martina, Martha, Marion, Markus, Marcel, Martin, Manfred, …) in the target population, and there was one big city in the target area, so many were born there. Ultimately, there were several duplicate ids, and matching became a real challenge.</p><p>Once faced with this problem, most of us get wiser and use more complex algorithms to generate the participant ids. But this leads us directly to the third issue of typical ids.</p><h4>Not stable over time?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQFU2ToFbBOAumQU2lo0Hw.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>In the endeavor to avoid duplicates while keeping plausible deniability, many researchers stick to the “first two characters algorithm” but expand the range to what it is applied. Unfortunately, not many truly stable characteristics exist, and quite a few supposedly stable ones are not. Names and addresses fall into the latter category. Family names often change with marriage, and even first names switch from time to time, and all it takes for an address to change is a simple relocation. I have seen this happening in an online study, which used hometown and family name, among other characteristics, to generate their ids. Not only did they face the typical participant loss across the waves, but also an astonishing phenomenon. New ids suddenly appeared in later waves. This shouldn’t have been possible because one would only get an invite to a later wave if she had entered her email to a list in the previous wave, but still — there they were. So the best guess is that not the participants changed, but just some of their characteristics.</p><p>Of course, this is only an issue with longitudinal studies, but have you tried getting a cross-sectional study published recently?</p><p>This concludes my semi-anecdotal rant about what is wrong with typical participant ids. Next, I will present my vision of better participant ids.</p><h3>Properties of my ideal Participant Id</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXZJt642u50Kik0tK6kOxA.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>My ideal Participant Id would need to satisfy three key requirements. It must <em>anonymize </em>each participant without the risk of re-identification, the participant must be able to <em>reproduce the same Id</em> whenever needed, and the id should be <em>unique </em>to each participant. Besides those, a fourth factor is required to make an Id practical— the Id generation needs to be <em>easy and accepted by the participants</em>. But let’s look into all a little bit more closely because they all have some strings attached.</p><h4>Anonymize</h4><p>Ideally, there should be no way for anyone, but the participant herself, to find out who is behind an Id or reversely what Id a known person would have. That means not just plausible deniability but real anonymity.</p><p>To avoid general re-identification, the Id cannot consist of the typical PII fragments (e.g., the first two letters of the surname) that could be easily recognized (especially with the knowledge that a specific person was a participant). Further, it shouldn’t contain any information about the time of the generation (i.e., one shouldn’t be able to infer which Ids were generated on which day or in which order).</p><p>Lastly, even if one knows someone (like a neighbor, co-worker, family, or spouse), he should not be able to generate her Id and impersonate her. That also includes that partial knowledge should not allow generating parts of the Id so that partial matches could be filtered from a body of Ids.</p><h4><em>Reproduce the same Id</em></h4><p>Since people sometimes forget stuff, and writing secrets down always risks their exposure, the Id should be reproducible by the participant whenever needed. So, if an Id is generated from any information the participant provides, one must ensure that the same is always provided. Unfortunately, this problem is harder than expected at first glance. The issue is that fewer facts about each person are truly stable over time than one might assume. This is obvious for preferences or hair color, but even addresses, names, gender, and eye colors might change over time.</p><h4>Unique</h4><p>Except for our fingerprints and our genetic code, there are not too many characteristics that are truly unique to a person. Our names, birthdays, and hometowns definitely don’t fall into this category. So if an Id is not based on one of those rare attributes, it needs to combine a sufficient number of non-unique characteristics so that random collisions are at least very, very unlikely.</p><h4><em>Easy and accepted by the participants</em></h4><p>Many participants become wary when asked about certain information (if it does not fall in the scope of the study) like income, social security or tax number, sexual preferences, personal data, … — so those might be a no-go for any Id. The same is probably true for biometric markers like fingerprints, face topography, iris scans, or allele combinations. But those have the additional shortcoming that they are not easy to come by. Generating the Id should not be a challenge in itself (not even a hassle), and participants shouldn’t feel the need to consider if they truly want to answer anything truthfully or at all.</p><h3>How I implemented my ideal Participant Id</h3><p>Well, the header is a little bit too optimistic. The Participant Id I have implemented as an <a href="https://play.google.com/store/apps/details?id=info.moodpatterns.participant_id">Android</a>-, <a href="https://apps.apple.com/us/app/participant-id/id6459474801">iOS</a>-, and <a href="https://moodpatterns.github.io/ParticipantId/#/">Web</a> app does, unfortunately, not satisfy all requirements I have set. But let’s look at how I tried before evaluating how my implementation stacks up to the proclaimed ideal.</p><p>The app consists of a start screen, six questions, and a result screen. I will quickly guide you through all of those.</p><h4>Start screen</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ax5e_PHmA3IRTfExFyMGhQ.png" /><figcaption>screenshot of the web app’s start screen</figcaption></figure><p>This is what the participants see after starting the app. The main purpose is to inform the participant about this app and why they can trust it. Each of the four visible cards can be flipped to provide additional information.</p><p>A click on “CREATE A PARTICIPANT ID” starts the generation process and brings up the first question.</p><h4>Question 1</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M70Z084oXMp20BEBikvPeg.png" /><figcaption>screenshot of the 1st question in the web app</figcaption></figure><p>Question 1 is one of two free-format questions. Both accept any character, but only a cleaned version will be used to safeguard at least a little against differing writing styles. So if the character system has lower- and uppercase, then everything will be converted to lowercase, diacritics on Latin characters will be removed, as well as whitespace, emojis, and interpunctuation.</p><p>Since chances are that not everybody knows her first word, instructions are given on what to enter if that is the case.</p><p>For many participants, the answer will be a variant of mommy or daddy. But since each variant is a distinct word, and other frequent first words like, e.g., no, dog, cat, or car, exist, a fair amount of variability can be expected from this question.</p><h4>Question 2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbO528njb0J1rbftYF0PwA.png" /><figcaption>screenshot of the 2nd question in the web app</figcaption></figure><p>This is the second free-form question. In addition to instructions, if it cannot be answered, a short explanation of the question is given to ensure that it is correctly understood.</p><p>This is probably the question with the highest variability despite some names being more frequent than others.</p><h4>Question 3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KWwJpqqFzcdL7f799Y_n2g.png" /><figcaption>screenshot of the 3rd question in the web app</figcaption></figure><p>Question 3 asks about the participant’s birthday by selecting the year, month, and day. Again, instructions are provided if the question cannot be answered (I know a few people who don’t know their exact birthdays, and the ones noted in their legal documents are only guesstimates) or the participant does not want to answer.</p><h4>Question 4</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppUTapOtxzqxsjJXDOIfvg.png" /><figcaption>screenshot of the 4th question in the web app</figcaption></figure><p>Question 4 only asks about older siblings because the number of younger siblings might change for some participants.</p><h4>Question 5</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LaSNBdp5f_uHD1oPfFbvxw.png" /><figcaption>screenshot of the 5th question in the web app</figcaption></figure><p>The index and ring finger ratio is mainly associated with prenatal levels of the sex hormones testosterone and estrogen. It might change somewhat in the early years, but it should be stable for school children and onwards.</p><p>This might be a loaded question in some subpopulations (e.g., men who are overly concerned about their masculinity and know about the 2D:4D ratio), but I have decided to include it anyway. On the one side because I believe only a few are affected, and most of them will still consistently answer the question, and on the other, because there are not many good alternatives, and its variation is needed to support the uniqueness requirement.</p><h4>Question 6</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*buL3qm64C3t-N3aS4758zA.png" /><figcaption>screenshot of the 6th question in the web app</figcaption></figure><p>Question 6 will probably contribute the least variation of all questions because most (~90%) are right-handed.</p><p>But it should be easy to answer for most people (in rare cases, the dominant hand could change, but this shouldn’t happen too often in the target adult population), and even a little variation is better than none.</p><h4>Result screen</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AH9FMHWMR-cg9r71ii46Vw.png" /><figcaption>screenshot of the result screen in the web app</figcaption></figure><p>While answering the questions, participants can always go back to previous questions and change their answers. This is no longer possible once the result screen is reached. Instead, using the back functionality of the browser or device would return to the start screen and remove all answers so that participants can be sure that there is no trick to see their answers by going back.</p><p>On the result screen, only the final participant id in three different but interchangeable representations is visible. It is created by concatenating all answers and hashing the final string with the industry-standard encryption method <a href="https://en.wikipedia.org/wiki/MD5">MD5</a>. It converts the information into a unique alphanumeric string (= the Participant Id). Once encrypted, it is completely irreversible and, therefore, impossible to derive the original data from the Id.</p><p>Since the resulting 32-character long Id is rather hard to read, two other representations are also provided for the case that copy and paste is not an option. The first is a <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">BIP39</a> mnemonic. This means that the Id is converted into a list of 12 words, which is much easier to spell on the phone than the Id. This process is fully reversible, so you can always generate the other if you have either the Id or the mnemonic. Since BIP39 mnemonics are also used for Bitcoin wallets, online converters, and implementations in all relevant programming languages are available.</p><p>The second representation is the Id as a QR code. Any QR reader, e.g., those integrated into mobile phones’ camera apps, can reverse the QR code back into the Id. When interacting personally (not online) with a participant, this can be useful because the participant can create the Id on her own device, and the researcher just needs to scan it. So the participant does not need to trust any provided device, nobody needs to copy it, and no sending over the internet (which would be deanonymizing) is needed either.</p><h3>So, how does it stack up?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZokEn_Yo2h1aoJdB0ykCA.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>I have already spoilered that my app cannot satisfy all the requirements, and while I guided you through its description, you probably have spotted some of its weak points. Let’s compare them with those that I am aware of, and please let me know if I have missed some in the comments.</p><h4>Anonymize</h4><p>Well, this requirement definitely isn’t satisfied entirely. On the bright side, the MD5 encryption prevents any re-identification based solely on the Id. It does not leak any PII fragments or information about the creation date. Also, having partial information about a participant does not get you closer to her Id because if only a single bit is different, the whole Id will be completely different.</p><p>Unfortunately, it is not unthinkable that someone else besides the participant has all the information required and could therefore impersonate the participant. In fact, parents, spouses, siblings, and children are very likely to be able to. However, neighbors and colleagues are probably not.</p><p>The problem is that this could only be solved by using data privy to participants alone or only they have access to. Biometrics would fall in the latter category, but not everybody has those available, and further, I believe that many potential participants wouldn’t comply with giving, e.g., their fingerprint. But the first category is even harder because, yes, everybody has secrets, but they are not the same for everybody, so it is not straightforward to ask for them. Further, it is unclear if a participant would be willing to type in her secrets that nobody else knows. Of course, we could ask very personal questions that not too many other people are likely to know, but most likely, they would be intrusive (e.g., First name of the person you had your first sexual intercourse?), not stable over time (e.g., Favorite song by your second favorite band?), or both (e.g., How many moles do you have on your genitalia?). Finally, there would also be the option that the participant could use an innocuous “password” only she knows. The drawback of this variant is that it is either not secure, unique, or reproducible.</p><p>So, overall I believe that my proposition is a good compromise.</p><h4>Reproduce the same Id</h4><p>This boils down to whether the participants can and will give the same answer anytime they are asked. I believe the questions have very stable answers, but they are imperfect. E.g., One could learn in later years the maiden name of her mother, find out that she had an older brother all along, switch the dominant hand, or lose the index finger in an accident. All that and many more would change the answers and, therefore, the Id. But, these cases should be rare, and more importantly, a participant should be very aware of them. She should be able to “impersonate” her past self and easily respond with the previously correct answers.</p><h4>Unique</h4><p>Like the requirements before, this one is not fully met. On the one hand, collisions of the MD5 hash are possible. MD5 uses 128-bit and therefore has 2¹²⁸ (a really large number) states. However, any string of arbitrary length can be hashed with MD5, and those are even more. So different inputs could result in the same output, but in practice, that will not matter because the chances of an actual collision are very, very, very small.</p><p>Instead, if there are collisions, then they will be due to participants answering all questions exactly the same. We can roughly estimate how often that will happen within a fixed sample size. To do so, we first need to consider the relative frequency of the most frequent answer per question. Let’s assume 20% for q1 (probably a ‘mommy’-variant) and 1% for q1 (maybe ‘Smith’). Q3 is a bit tricky because it changes with the target age range. For simplicity&#39;s sake and to be conservative, let’s just assume we are only interested in people from a specific birth year. This puts q3 at (1/365)*100%. For q4 we will use 50%, for q5 60%, and for q6 90%. I will put this in some R-code to make it easier to follow along.</p><pre>q1 &lt;- 0.2<br>q2 &lt;- 0.01<br>q3 &lt;- 1/365<br>q4 &lt;- 0.5<br>q5 &lt;- 0.6<br>q6 &lt;- 0.9</pre><p>Next, we can combine those to get the probability (<em>p</em>) of a single participant answering every question with the most frequent response.</p><pre>p &lt;- q1*q2*q3*q4*q5*q6<br>p<br># [1] 1.479452e-06</pre><p>Consequently, <em>p</em>² is the chance of two people giving exactly those answers.</p><pre>p**2<br># [1] 2.188778e-12</pre><p>This is a pretty low probability, but as you might know from the birthday paradox (i.e., you only need a group of 23 people to have an above 50% chance of two people having the same birthday), the number of pairs matters, and grows rapidly with the total sample size. To be on the robust side, let’s assume a sample size of <em>N</em> = 1000 for our thought experiment (I know there are a few psychological studies with even greater <em>N</em>s, but frankly, they are rare, and I would thank the ghosts of Karl Popper and Wilhelm Wundt if I ever manage to get half of it in one of my studies). To get the number of all pairs in the sample, we need to calculate <a href="https://en.wikipedia.org/wiki/Combination"><em>n choose k</em></a><em> </em>with <em>n</em> = 1000 and <em>k</em> = 2.</p><pre>choose(1000,2)<br># [1] 499500</pre><p>With that, we can calculate the chance of two people within a sample of 1000 people giving exactly those answers.</p><pre>1-(1-p**2)**choose(1000,2)<br># [1] 1.093307e-06</pre><p>This seems comfortably unlikely, but this is just the probability of one specific set of answers. There are 364 others (the other days of the year) with exactly the same probability and an arbitrary number of less likely combinations (each one times 365, though). To get the arbitrary number somewhat under control, we will assume that the probability decreases from step to step by 10% and use only the first 1000 combinations (more would be meaningless because the result flattens out fast, and even an increase by a magnitude doesn’t change anything). Then we can calculate the weight of those with the following R code.</p><pre>c(365, rep(0.9,1000)) %&gt;%<br>  cumprod() %&gt;%<br>  sum()<br># [1] 3650</pre><p>Finally, we can calculate the chance of two people within a sample of 1000 people giving the same answers, violating the uniqueness requirement.</p><pre>1-(1-(p**2)*3650)**choose(1000,2)<br># [1] 0.003982574</pre><p>So, within the reasonable assumptions of our thought experiment, the chances of having an Id-collision within a sample of <em>N</em>=1000 are less than 0.4%. This means that, on average, in every 250 studies with <em>N</em>=1000 each, there will be one study with an Id-collision. Yes, it is not perfect, but within an acceptable margin in most cases.</p><h4>Easy and accepted by the participants</h4><p>I believe the questions are easy and not too intrusive, but granted — I am biased. Regarding acceptance, three points should help foster trust even for the most skeptical participants. 1.) it is open source, 2.) it works without network connectivity, and 3.) even if they cannot be convinced about the security and privacy of the Id generation — one will have a hard time re-identifying someone solely on the answers to the six questions.</p><p>Ultimately, this one is hard to answer without actually trying it out. If you do so, please let me know about your experiences.</p><h3>What would this look like in practice?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qPsjH9lf2wFCWiIFpnkZQQ.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>To make the usage of the Participant Id more tangible, let’s consider a few use cases.</p><h4>Participant in lab and multiple physical data sources</h4><p>This is probably a frequent scenario for the experimenters among you.</p><p>If the participant is not too suspicious, she can create the Id on a provided tablet. The Id is then sent to a label printer, and labels can be attached to each measurement of the participant. If the suspicion level is higher, the participant could be asked to create the Id on her device. A lab assistant can then scan the QR code and send the Id to the label printer. If the participant is not trusting at all, then more information about the Id needs to be provided. Especially about the fact that the encrypted data cannot be reverse-engineered. After that, she can be guided through an offline Id-generation (install the mobile app on her device — switch off the internet — create Id — uninstall the mobile app — switch on the internet again).</p><h4>Online assessment</h4><p>At the start of the assessment, the participant is asked to create an Id and copy and paste it into the form. The Id-generation can be either integrated (if you host it yourself — it is open source with the very permissive MIT license, so you can do with it more or less whatever you please), or you provide links to the web app and the mobile apps.</p><h4>Automatic individual feedback</h4><p>It would be very easy to come up with a dashboard displaying individual results once an Id is entered. Maybe in conjunction with sample aggregates which all too often pass as the typically promised feedback.</p><h4>Information by telephone</h4><p>For identification purposes, the participant can state her mnemonic. In typical sample sizes, not all twelve words should be required. Unambiguous matching is likely possible after the first three or four words.</p><h3>I’m sold. Other things I need to know?</h3><h4>How can I use Participant Id in my study?</h4><p>You can use my <a href="https://moodpatterns.info/participantId">prebuild version</a> or the <a href="https://github.com/MoodPatterns/participant_id">source code</a> to build your own (maybe adding some personal flavor like university insignia or lab emblem).</p><h4>Is Participant Id free?</h4><p>YES. It is completely free. Also, there are no ads or tracking in the prebuild version.</p><h4>How can I contribute?</h4><p>Especially translations are very welcome, but other non-breaking PRs to improve the app are also appreciated. See <a href="https://github.com/MoodPatterns/participant_id#contribution">here</a> for details.</p><h3>On my own behalf</h3><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><p>Please let me know if you actually use Participant Id in one of your studies. If it is alright for you, I would gladly link your study on the homepage of the app (if you don’t want that, please tell me anyway — I would love to hear that I did not waste my time).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=579a47afc87f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being (just) a fun dad does not equal being a good dad]]></title>
            <link>https://medium.com/@b.piskernik/being-just-a-fun-dad-does-not-equal-being-a-good-dad-6f8129a11337?source=rss-ccde92507c16------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f8129a11337</guid>
            <category><![CDATA[parenting]]></category>
            <category><![CDATA[attachment]]></category>
            <category><![CDATA[parenting-advice]]></category>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[fatherhood]]></category>
            <dc:creator><![CDATA[Bernhard Piskernik]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 17:44:12 GMT</pubDate>
            <atom:updated>2024-02-10T13:16:48.051Z</atom:updated>
            <content:encoded><![CDATA[<h4>A simple tip for being a better father</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vkjb9ySlk25cSdkldtA0nQ.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>I recently talked about being a father to one of my neighbors. He didn’t know that fatherhood was the key topic in my Psychology Ph.D. thesis, and he was somewhat surprised by what I had to tell him about being a good father from a scientific perspective — Having as much fun as possible with your kids does not build the foundation for a good relationship with them.</p><p>If this does not seem obvious to you, please give me a few minutes to summarise my contribution to a <a href="https://doi.org/10.1111/mono.12404">paper</a> to explain why I make this (maybe) counterintuitive claim.</p><h3>Being a good dad was well defined</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDlC0Yochv_3x6WWKzxl0Q.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>To be honest, I really should have put <em>good</em> in quotation marks. Because what good means differs between cultures, and I do not claim that my Western perspective is universal — because it is not (but maybe let us get into that more another time). What being in the role “dad” means is shaped by your society. Even within one culture, such a role is nothing static.</p><p>Interestingly, many believe there is this prototypical or even natural ideal of the good provider, whose main job is having a job and bringing home money. But in the greater scope of things, the reduction to this most restricted form of parenting is a rather new invention. It started with the industrial revolution, and its downfall began with the rise of feminism. So it is a role definition that lasted only for around 200 years.</p><h3>It’s more complicated today</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-rtbqqy01eAo-a9N_gFFA.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>Feminism’s call for gender equality and men’s estrangement from work success as the only goal in life returned men into the life of their families, actively interacting with their kids.</p><p>The definition of actively, however, varies wildly. In any case, it is a far cry away from gender equality in parenting. E.g., in Austria, where I am from, having children does not leave any dent in the number of weekly working hours for most men. I know a few countries where this is a little different, but overall it is more the norm than the exception in industrialized nations.</p><p>So the working hours stay the same but bringing home money is no longer sufficient. Nowadays, men are expected to do their share in the household and be there for their children. Given the little available time, this seems like a conundrum to many, especially as those are seen as opposing activities. There seem to be two different types of activities with kids: on one side, there are the chores (feeding, clothing, organizing, transporting, … them) that just need to be done, and on the other side, all the quality stuff (having fun, emotional talks, teaching something, …) that nurtures our children and strengthens our bond with them.</p><p>With the excuse of limited time and the fact that one of those is more fun, you probably don’t need to guess twice on which side many men fall. The mothers draw the short straw in the setup, and the men are allowed to shine. After 200 years of romanticizing the good provider role, even doing anything with the kids seems commendable, so many mothers agree to this deal. But are those fun dads good dads?</p><h3>Finally, let’s get to the science</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_HpsPhvE2n-curNG8NkfMA.png" /><figcaption>generated via stable diffusion by <a href="https://medium.com/u/ccde92507c16">Bernhard Piskernik</a></figcaption></figure><p>According to my research, they are at least not using their full potential and could nurture their kids even more. So let’s look at the study.</p><p>We examined 190 fathers’ direct engagement with children (1–5 yrs old) over one week using experience sampling. That means they had an app installed on their phones, which asked them randomly multiple times each day whether they were interacting with their children and, if yes, how specifically.</p><p>Further, the fathers did an interview, filled out multiple questionnaires, and, most importantly, were observed by two trained raters during direct interaction with their child. This observation was used for the Attachment-Q-sort, a standardized way to evaluate the attachment between parent and child. The reason why I emphasize this measure is that it has been shown that parent-child attachment is linked to a whole lot of things in the child’s later life (e.g., <em>positive self-image and self-esteem, autonomy, problem-solving skills, goal orientation, stability of romantic relationships and friendships, positive belief sets and outlook on life, coping strategies, emotional contro</em>l, … — to name a few)</p><p>Among other things we found out with this study, there is one result that this story is about. <strong>Fathers-child dyads that interacted in multiple different ways had also better attachment scores</strong>. Granted, it was a cross-sectional study, so no direct causation can be derived, but it is at least a strong indication that interacting with your child in multiple ways strengthens its attachment quality. And this is something you want.</p><p>This does not mean that playing with your child and having fun is bad — it is not; there are whole labs studying nothing but the benefits of that. But you might want to broaden your scope. Take over more of the care of work, have meals and reading time together, let the kids join you at grocery shopping, go to the doctor and the hairdresser together, cook together, and let the child help you with your chores and help the child with her’s in return. Or, to put it short: <strong>be a whole parent and not just a playmate. </strong>This will deepen your relationship, and you will profit from it.</p><h3>TL;DR</h3><p>So to sum it up: the simple trick to be a better father is to engage with your child in many different ways. Not all need to be fun. Chores and the like are also a facet of life, and the relationship between your child and you will profit if you share them.</p><p>This was only my fourth medium article and my first non-technical one. Feedback is very welcome.</p><p>If you appreciate this post, here are three things you can do to support my work:</p><p>1 — Give this story a CLAP 👏<br>2 — SUBSCRIBE to my upcoming stories<br>3 — <a href="https://www.buymeacoffee.com/bpiskernik">Buy me a coffee ☕</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f8129a11337" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>