Hi Everyone!!
I standardized my input variables (ds.scale) before glmm adjustments but in the final plot, I have a problem with the real-world scale of my variables and the predicted values by model (m_6). In my plot:
I´d like the original scale of my temp and storage variables represented in my better model (m_6). What is the correct approach for this? Do not standardise my input variables, despite I lot of warmings? Some data transformation at the end? I make:
#Packages
library(lme4)
library(ggplot2)
library(ggeffects)
library(tidyverse)
library(bbmle)
library(broom)
#Open my dataset
myds<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/ds.desenvol.csv")
str(myds)
# 'data.frame': 400 obs. of 4 variables:
# $ temp : num 0 0 0 0 0 0 0 0 0 0 ...
# $ storage : int 5 5 5 5 5 5 5 5 5 5 ...
# $ rep : chr "r1" "r2" "r3" "r4" ...
# $ development: int 0 23 22 27 24 25 24 22 0 22 ...
# Storage (days) is temporally correlated with temperature then mixed model
ds.scale<- myds %>%
mutate(across(c(temp, storage), ~ drop(scale(.))))
# Models creation Poisson/Negative binomial
m_1 <- glmer(development ~ temp + storage +
(1 | storage ), data = ds.scale,
family = "poisson")
m_2 <- glmer(development ~ poly(temp,2) + storage +
(1 | storage ), data = ds.scale,
family = "poisson")
m_3 <- glmer(development ~ poly(temp,2) + poly(storage,2) +
(1 | storage ), data = ds.scale,
family = "poisson")
m_4 <- glmer.nb(development ~ temp + storage +
(1 | storage ), data = ds.scale)
m_5 <- glmer.nb(development ~ poly(temp,2) + storage +
(1 | storage ), data = ds.scale)
m_6 <- glmer.nb(development ~ poly(temp,2) + poly(storage,2) +
(1 | storage ), data = ds.scale)
modList <- tibble::lst(m_1,m_2,m_3,m_4,m_5,m_6)
bbmle::AICtab(modList)
# dAIC df
# m_6 0.0 7
# m_3 1.0 6
# m_5 3.3 6
# m_2 5.0 5
# m_4 17.9 5
# m_1 21.0 4
# Plot the results for my better model (m_6)
mydf <- ggpredict(m_6, terms = c("temp [all]", "storage[all]"))
# For temp
ggplot(mydf, aes(x, predicted)) +
geom_point(data=myds, aes(temp, development), alpha = 0.5) +
geom_line() +
labs(x = "temp", y = "development")
# For storage
ggplot(mydf, aes(x, predicted)) +
geom_point(data=myds, aes(storage, development), alpha = 0.5) +
geom_line() +
labs(x = "storage", y = "development")
# -------------------------------------------------------------------------------------------
Please, any help with it?