'Getting error $ operator not defined for this S4 class when findings mean of residuals [duplicate]
heyy i have a problem with getting the the below error. I am new to R and not sure how to resolve this!!
I am trying to find the mean of residuals in a multi-linear regression model (testing for the assumptions)
My code is
mean(model1$residuals)
where model1 is
model1 = lmer(corruption ~ Gini.Index + GDP + Democracy.Index + Political.Terror.Index + Economic.Freedom + Regime + respondentage +
respondentgender + Education_Completed + Employment + European.Integration + (1 | country), NewD, REML = FALSE)
When i run the code for mean i get error--- error in evaluating the argument 'x' in selecting a method for function 'mean': $ operator not defined for this S4 class
Does anyone know what to do???
Solution 1:[1]
This is because lmer does not return a value of class "lm" as lm does. The return value of lmer (with which I am not familiar) has many slots. Slots in S4 classes are accessed using @. I suggest you try
str(model1)
and find the variable you need to access, e.g. like this
model1@resp$mu
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
