Loading JSON Data in Swift UI

SwiftUI, Apple’s innovative UI toolkit, has transformed the way developers create user interfaces for iOS, macOS, and beyond. One of the fundamental tasks in app development is handling data, and JSON (JavaScript Object Notation) is a widely-used format for data interchange. In this blog post, we’ll delve into the essentials of loading JSON data in SwiftUI. We’ll start by exploring how to load JSON data directly as a String—useful for quick tests or when dealing with small data payloads. Then, we’ll advance to loading JSON from a file, which is a common scenario for apps that consume complex data structures or large datasets.

Read More

Adjusting for "bad controls"

In every statistical analysis, the selection of covariates in regression models is akin to navigating a labyrinth. One common heuristic advises controlling for as many variables as possible, under the presumption that it yields more conservative tests of hypotheses. However, this approach is not without pitfalls. Adding wrong or extraneous variables can distort results, introducing spurious effects and even reversing the signs of actual causal relationships. In the following, I will provide an example of how this can happen.

Read More

Treatment Effects

In the realm of healthcare, education, and policy-making, understanding the effects of treatments and interventions is paramount. However, discerning causality from mere correlation can be challenging. In this blog post, I invite you on a journey to unravel the complexities of estimating the true impact of interventions. From exploring randomized controlled trials to delving into the intricacies of confounding variables, join me as we navigate through the fascinating world of causal inference and uncover the methods and insights essential for evidence-based decision-making.

Read More

Comparing the seaborn objects interface with ggplot2

The Seaborn objects interface, introduced in version 0.12.0, is a new system based on the Grammar of Graphics, similar to R’s ggplot2. It offers a more consistent and flexible API, comprising a collection of composable classes for transforming and plotting data. This interface allows for end-to-end plot specification and customization without dropping down to the matplotlib level, making it suitable for more complex plots with multiple layers and mark types. While the interface is still experimental and incomplete, it provides a modular and Pythonic API that is informed by ggplot2’s design philosophy. In this post, I replicate the plots from the ggplot2 book using the seaborn objects interface.

Read More

Comparing dplyr with polars

Data manipulation is one of the most common and essential tasks in data analysis. Whether you are working with tabular data, time series, spatial data, or any other kind of data, you need to be able to perform operations such as filtering, grouping, aggregating, joining, reshaping, and more. In the R world, the dplyr package is one of the most popular and powerful tools for data manipulation. It provides a consistent and expressive syntax based on the tidyverse principles, which make it easy to write readable and maintainable code. Many other packages extend its functionality, allowing you to work with large and diverse data sources.

Read More