I have a data frame with n=18 participants. There are 90 observations across 3 IVs and 1 binary DV (see below for shortened example).
data <- data.frame(age = c(21, 30, 25, 41, 29, 33),IQ=c(60,70,80,90,100,200),SAT=(2400,2200,1400,1550,1470,1300), sex = factor(c(1, 2, 1, 2, 1, 2), labels = c("Female", "Male")))
I've already done a logistic glm regression using the entire sample. This was the code used:
model2<-glm(Sex~Age+IQ+SAT,family=binomial(link="logit"))
summary(model2)
I want to compute the beta coefficients for each participant-- Age, IQ, and SAT scores to predict Sex. I should have 18 coefficients to plot. Thanks in advance!!
broom
andtidyverse
. If you use only one observation all coefs will beNA
:data %>% mutate(id=1:n()) %>% group_by(id) %>% do(fitmod = tidy(glm(sex~age+IQ+SAT,family=binomial(link="logit"), data = .))) %>% unnest(fitmod)
– Ducklibrary(tidyverse)
andlibrary(broom)
? – Duck