strengejacke / ggeffects

Estimated Marginal Means and Marginal Effects from Regression Models for ggplot2
https://strengejacke.github.io/ggeffects
Other
544 stars 35 forks source link

Problems with predictions from "robustbase" package ("hypothesis_test") #530

Closed josefranciscolopezgil closed 4 months ago

josefranciscolopezgil commented 4 months ago

Hi all,

I am attaching the problem I am encountering. With the "predict_response" function, everything is fine. The problem is when I use the "hypothesis_test" function. Previously, there was no problem when performing this analysis, but I don't know what happens. This happens to me since I upgraded R and RStudio. I have tried to install the latest version of "ggeffects" but it doesn't work either. Here is the code:

library(tidyverse) library(robustbase) Model0 <- lmrob(HRQoL ~ Categorical_R_24h + Immigrant_status + Age + Sex +

  • SES_status2 + Excess_weight + HEI_score, data = ENSE_2017,
  • setting="KS2014") tidy(Model0)

A tibble: 11 × 5

term estimate std.error statistic p.value

1 (Intercept) 88.4 1.93 45.8 0 2 Categorical_R_24hOne recommendation 0.599 0.653 0.918 0.359 3 Categorical_R_24hTwo recommendations 1.98 0.654 3.02 0.00251 4 Categorical_R_24hAll three recommendations 3.23 0.773 4.18 0.0000302 5 Immigrant_statusForeign-born -1.64 0.875 -1.87 0.0611 6 Age -0.331 0.0939 -3.52 0.000437 7 SexGirls 0.536 0.365 1.47 0.142 8 SES_status2Medium SES 0.516 0.417 1.24 0.216 9 SES_status2High SES 1.45 0.489 2.96 0.00312 10 Excess_weightExcess weight -0.129 0.380 -0.340 0.734 11 HEI_score 0.0246 0.0201 1.23 0.220 > library(ggeffects) > Model0_prediction <- predict_response(Model0, terms="Categorical_R_24h") > print(Model0_prediction) # Predicted values of HRQoL Categorical_R_24h | Predicted | 95% CI ---------------------------------------------------- No recommendation | 86.44 | 85.12, 87.77 One recommendation | 87.04 | 86.17, 87.91 Two recommendations | 88.42 | 87.56, 89.28 All three recommendations | 89.68 | 88.51, 90.84 Adjusted for: * Immigrant_status = Native-born * Age = 11.18 * Sex = Boys * SES_status2 = Low SES * Excess_weight = No excess weight * HEI_score = 69.03 **> hypothesis_test(Model0_prediction) Error in (function (object, at, cov.reduce = mean, cov.keep = get_emm_option("cov.keep"), : Can't handle an object of class “lmrob” Use help("models", package = "emmeans") for information on supported model** The "plot" function also works fine. Thoughts? Thank you so much in advance. Regards,
josefranciscolopezgil commented 4 months ago

It is already working. Thank you.