2023-07-14

Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid 'nsmall' argument

When I run the negative binomial model with the function below, I get the above error code when I try to the following code.

model<- glm.nb(upvotes ~ Answer_Rate + Score + offset(log(patient_days)) + factor(Post_ID) - 1, control = glm.control(maxit = 500), data = na.omit(mock_data))

summary(model)

# Create the dataframe with NA values
df <- data.frame(
  Post_ID = c(3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18),
  Creation_Year = c(2002, 2003, 2004, 2005, 2008, 2009, 2012, 2013, 2015, 2016, 2021, 2022, 2023, 2027, 2030, 2037),
  Last_Activity_Year = c(rep(2022, 16)),
  Views = c(3868, 2390, 1727, 5456, 2667, 2623, 1084, 2963, 5228, 1833, 1945, 2038, 3856, 3170, 5626, 2058),
  Upvotes = c(364, 654, 151, 246, 341, 82, 0, 270, 569, 184, 291, 265, 366, 439, 628, 293),
  Downvotes = c(63, 40, 54, 44, 90, 75, 36, 105, 157, 55, 79, 79, 93, 119, 103, 94),
  Answer_Count = c(66, 41, 34, 27, 24, 11, 22, 35, 85, 19, 49, 108, 63, 99, 70, 74),
  Score = c(42064, 24958, 18124, 32560, 36219, 27458, 11496, 46426, 60378, 28678, 34798, 32836, 42100, 62402, 54574, 28638),
  View_Rate = c(3.116946, 3.013748, 3.00667, 2.503681, 3.325894, 2.838673, 3.050738, 3.018707, 3.118339, 3.030976, 3.152526, 3.086555, 3.161453, 3.121305, 2.781192, 3.152503),
  Comment_Count = c(0.228, 0.259, NA, 0.215, 0.113, NA, 0.096, 0.035, 0.25, 0.003, 0.337, NA, 0.147, 0.103, NA, 0.203),
  Answer_Rate = c(21.1, NA, 19.7, 18.1, 19.6, 14.8, 12.2, 15.0, 15.3, 16.5, NA, 14.3, 19.8, NA, 17.6, 17.7),
  Favorite_Rate = c(8.65348, 26.204023, 8.331494, 7.555283, 9.414948, NA, 0.0, 5.815707, 9.423962, NA, 8.36255, 8.070411, NA, 7.035031, 11.507311, 10.231161),
  Average_Answer_Rate = c(1.497718, NA, 2.979475, 1.351351, 2.484884, 2.731444, 3.131524, 2.261664, NA, 1.917846, 2.270245, 2.405896, NA, 1.90699, 1.887346, NA),
  Answer_Accept_Rate = c(1.5690377, 1.6427598, 1.8759656, NA, 0.6626356, 0.4006118, NA, 0.7538879, 1.4077975, NA, 1.4081269, 3.289073, 1.4964371, 1.5864876, NA, 2.5839793)
)

I tried to create a new data frame using na.omit in case either of my predictor variables were missing. The same error returned.

The model seems to provide an adequate output with p-value, though I get the error on the summary line code.

Packages for the Markdown:

library(tidyverse)
library(lubridate)
library(janitor)
library(knitr)
library(kableExtra)
library(lme4)
library(gtsummary)
library(data.table)
library(ggalluvial)
library(alluvial)
library(geepack)
library(conflicted)
library(MASS)
library(car)
library(lmtest)
library(vcd)
library(AER)
library(pscl)

conflicts_prefer(gtsummary::select)
conflicts_prefer(dplyr::filter)


No comments:

Post a Comment