Articles by R on Sam Portnow's Blog

Random Effects Model From Scratch

January 3, 2021 | R on Sam Portnow's Blog

Random Effects Model by Hand I use random effects models (aka mixed-effects models aka multi-level models aka hierarchical linear models) frequently in my research. Although I understood the intuition behind them for a long time, I was lost on the mechanics, so I decided to finally sit down and try ... [Read more...]

SEM From Scratch

December 12, 2020 | R on Sam Portnow's Blog

A Structural Equation Model from Scratch In this post, I will build a latent variable Structural Equation Model (SEM) from scratch. Latent variable models are useful for reducing many observations into a single variable. For example, let’s say there a battery of questionnaires that assess depressive symptoms, and those ... [Read more...]

Earnings of Immigrants

August 14, 2020 | R on Sam Portnow's Blog

Introduction For this post, I want to look at the earnings of immigrants by the year that they immigrate to the United States. I want to to this because I am interested in looking to see if the earnings of immigrants are declining over time. I hear a constant debate ...
[Read more...]

Exploring Police Misconduct Data

July 30, 2020 | R on Sam Portnow's Blog

Introduction On July 26, 2020, Propublica released a dataset on police discipline records. I wanted to get a look at the data and do some exploratory analysis.
library(tidyverse)
## ── Attaching packages ──────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.3     ✓ dplyr   1.0.0
## ✓ tidyr   1.1.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.5.0
## Warning: package 'ggplot2' was built under R version 3.6.2
## Warning: package 'tibble' was built under R version 3.6.2
## Warning: package 'tidyr' was built under R version 3.6.2
## Warning: package 'purrr' was built under R version 3.6.2
## Warning: package 'dplyr' was built under R version 3.6.2
## ── Conflicts ─────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(gt)
## Warning: package 'gt' was built under R version 3.6.2
library(here)
## here() starts at /Users/samportnow/sam-portnow-website
library(fs)
## Warning: package 'fs' was built under R version 3.6.2
library(skimr)
## Warning: package 'skimr' was built under R version 3.6.2
library(janitor)
## Warning: package 'janitor' was built under R version 3.6.2
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
Read in Data
data = read_csv(here::here('content', 'post_data', 'allegations_20200726939.csv'))
{{...
[Read more...]

Getting Your Comparison Groups Right

September 6, 2019 | R on Sam Portnow's Blog

Often, when presented with evidence of racism, or the existence of racism, critics will say neither exists, at least not in a meaningful way because many immigrant groups have higher household incomes than White Americans. These critics often point to the median household income of Nigerian Americans are irrefutable proof ...
[Read more...]

Examining Racial Income Disparities

August 31, 2019 | R on Sam Portnow's Blog

Exploring Explanations Of the Black-White wealth gap The black-white wealth gap is nearly 15:1; the mean of black household wealth is $138,200; for white houesholds it is $933,700. A frequent explanation has been single-parent families in the Black community (1, 2 3) or culture (1, 2, 3, 4, 5) Fortunately, we can test these claims. I am going to use the ...
[Read more...]

Stanford NLP Tips

June 10, 2019 | R on Sam Portnow's Blog

Tips on Standford NLP There are several pacakges in R that use the Stanford CoreNLP Software (e.g. cleanNLP, coreNLP). These packages are great for using CoreNLP, but for large projects they are slowww. For a recent project, I had to employ Named E... [Read more...]

IRT From Scratch

June 1, 2019 | R on Sam Portnow's Blog

Programming an IRT, 2Pl Model from Scratch (So You Don’t Have to) I recently had a client that was looking to build a 2PL model from scratch. The 2PL describes the process through which someone gets a correct or incorrect response on a test. More ... [Read more...]

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)