Juli Nagel
@juli-nagel.bsky.social
180 followers 130 following 83 posts
PhD student (psychology, neurobiology) researching reward, memory and sleep. Way too passionate about R. Otherwise interested in gaming, western riding and climbing. Mum.
Posts Media Videos Starter Packs
juli-nagel.bsky.social
Caveat: tabulate() only works for single vectors, so you can't replace sth like table(1:4, c("a", "a", "b", "b")).
Bonus points: You easily get 0 counts if you expect numbers from 1:nbins, i.e.:

> tabulate(c(3, 1, 3, 3, 3), nbins = 4)
[1] 1 0 4 0

2/2
juli-nagel.bsky.social
IF YOU CAN, REPLACE TABLE() WITH TABULATE() IN YOUR #rstats CODE!

data <- sample(1:3, 100, replace = TRUE)
microbenchmark::microbenchmark(table(data), tabulate(data), times = 10000)

I'm almost angry at how much faster this is, and why I was today years old when I learned this 🤬
1/2
juli-nagel.bsky.social
This is extremely exciting!
(But also with the release party being on October 3rd, a missed opportunity to use a "The Life of a Showgirl" reference.)
juli-nagel.bsky.social
Is this ... a very early preregistration?
juli-nagel.bsky.social
I also learned a fair deal of Spanish in school (read Don Quijote and all), but couldn't even do small talk nowadays. That happens, and it's normal (albeit sad). I fell into the "What?! But EVERYBODY should know THIS!" trap in the past, but learned that it's a very unhelpful trap to fall into.
2/2
juli-nagel.bsky.social
Sure, I've learned this in school. I'm a nerdy nerd with degrees in psychology, working as a scientist, well-trained in statistics (not so much physics). When I see these videos, all I remember is that it's not surprising that this happens, but I wouldn't be able to explain it properly.
1/2
juli-nagel.bsky.social
To be fair, I've had occasional situations like these with students BEFORE the rise of LLMs ...
juli-nagel.bsky.social
Line 1: warning("Hey, thought about restarting R before running this script? Btw, you might wanna set up a clean project for this, cause, you know, if you still use setwd(), Jenny Bryan will personally set your computer on fire. And do you know about dependency management? Sorry if you already do!")
juli-nagel.bsky.social
Don't know why the zebra paper won, though? It's been tested in horses before (Caro et al.); the horse community has been using blankets with zebra stripes for years. Sure, we desparetly need more replications, but why the Ig Nobel prize for a conceptual replication?
www.science.org/content/arti...
Zebra stripes confuse biting flies, causing them to abort their landings
Coat pattern helps zebras and horses evade dangerous insects
www.science.org
juli-nagel.bsky.social
Had the opposite experience lately. Daycare warned me: "In case tells any stories about today ... don't be confused ... he was very excited about the document shredder."
Unfortunately, he DIDN'T mention it, so I will never know why they were so worried what weird things he might say.
juli-nagel.bsky.social
Wooooooow, where is this?! 😱
juli-nagel.bsky.social
"So I leap from the gallows and I levitate down your street
Crash the party like a record scratch as I scream
'Who's afraid of little old me?'
You should be"
juli-nagel.bsky.social
(Disclaimer: Of course, results will vary if the data are not balanced, or are funky in any other way, but in this simple case, mixed model/t-test estimates and p-values will be identical.)
juli-nagel.bsky.social
t_test <- t.test(t1, t2, paired = TRUE)
mm <- lmer(value ~ time + (1 | id), data = data)
mm_summary <- summary(mm)

# estimates
abs(mm_summary$coefficients["timet2", "Estimate"])
abs(t_test$estimate)

# pval
mm_summary$coefficients["timet2", "Pr(>|t|)"]
t_test$p.value

2/2
juli-nagel.bsky.social
And here's a paired t-test versus a mixed model with a random intercept in R:

library(lmerTest)

n <- 1000
t1 <- rnorm(n)
t2 <- t1 + rnorm(n)

data <-
data.frame(
id = paste0("ID-", 1:n),
t1 = t1,
t2 = t2
)

data <-
data %>%
pivot_longer(c(t1, t2), names_to = "time")

1/2
juli-nagel.bsky.social
I once had a student telling me that she hates t-tests, but prefers linear mixed models. Boy, did I have news for her ...
juli-nagel.bsky.social
"Nagel" ist German for "nail", which is why this is the first GIF to pop up, once again reminding me how lucky I was to be able to assimilate my husband's last name.
juli-nagel.bsky.social
I am very proud of my Bluesky feed, which combines magic Quarto plugins with "The Life of a Showgirl" references.
emilhvitfeldt.bsky.social
Excited to share my newest quarto revealjs plugin: imagemover

Easily reposition and resize images directly in your quarto revealjs slides for a much smoother slidecrafting experience

github.com/EmilHvitfeld...
#quarto
juli-nagel.bsky.social
Joke aside, we recently discussed in our journal club about how there's no nominal rate of successful replication, i.e., the replication rates we're seeing might be just what to expect. I don't buy that, BUT there's an interesting discussion here about base rates of theories being correct etc. etc.
juli-nagel.bsky.social
I think it says a lot about how dominant RStudio is as an IDE that people frequently mistake it for the actual programming language. Sure, many don't even think about the difference between a language and an IDE, but you'd never see someone write "we used Spyder for data analysis" (I hope).
juli-nagel.bsky.social
I can see past the questionable artistic choices if they can also give me the data normalized by the overall consumption of each food item.
Reposted by Juli Nagel
skjerns.de
preprint alert 🚨
1/ Can we accurately detect sequential replay in humans using Temporally Delayed Linear Modelling (#TDLM)? In our recent study, we could not find any replay and decided to dig deeper by running a hybrid simulation with surprising results. Link to preprint & details below 👇