I am trying to fit a very simple logistic regression model on a data, and then try and get an easystats text report:
library(tidyverse)
library(easystats)
Data <- structure(list(`12_month_remission` = c(0, 1, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0,
1), Sex = structure(c(2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L,
1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), levels = c("Female", "Male"), class = "factor")), row.names = c(NA,
-50L), class = c("tbl_df", "tbl", "data.frame"))
glm(`12_month_remission` ~ Sex, family = "binomial", data = Data) %>%
report::report()
And its coming up with:
Error in eval(predvars, data, env) : object '12_month_remission' not found Error: Unable to refit the model with standardized data.
Try instead to standardize the data (standardize(data)) and refit the model manually.
I know the model fit works, as if I just run the script without the report() I get an output. It doesnt make sense to Z-normalise data.. because there is no data that can be standardized? What am I missing?
It is about a matter of name in 12_month_remission
. The easiest way to solve it is changing the name and it'll run
Data %>%
rename(remission_12_months = "12_month_remission") %>%
glm(remission_12_months ~ Sex, family = binomial, data = .) %>%
report::report()
We fitted a logistic model (estimated using ML) to predict remission_12_months with Sex (formula: remission_12_months ~ Sex). The model's
explanatory power is weak (Tjur's R2 = 0.13). The model's intercept, corresponding to Sex = Female, is at 0.07 (95% CI [-0.69, 0.84], p =
0.847). Within this model:
- The effect of Sex [Male] is statistically significant and negative (beta = -1.63, 95% CI [-3.06, -0.38], p = 0.015; Std. beta = -1.63, 95% CI
[-3.06, -0.38])
Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values
were computed using a Wald z-distribution approximation.