Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

estimates () not working at all and compare.fits() not for lmer? #124

Open
LauritaInFrance opened this issue Nov 10, 2023 · 0 comments
Open

Comments

@LauritaInFrance
Copy link

LauritaInFrance commented Nov 10, 2023

Would love the help here. Is it common for others? problem in the code or the version of flexplot?

######https://www.youtube.com/watch?v=jXlzQm0vF5g
model = lmer(darkness ~ anger + emotional_bonds + (anger + emotional_bonds | dojo_id),data=jedi)
Message d'avis :
Dans checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge with max|grad| = 0.0144489 (tol = 0.002, component 1)
summary(model)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: darkness ~ anger + emotional_bonds + (anger + emotional_bonds |
dojo_id)
Data: jedi

REML criterion at convergence: 8789.8

Scaled residuals:
Min 1Q Median 3Q Max
-4.4329 -0.6265 0.0004 0.6542 3.8004

Random effects:
Groups Name Variance Std.Dev. Corr
dojo_id (Intercept) 6.90721 2.6282
anger 0.01302 0.1141 -0.62
emotional_bonds 0.02213 0.1488 -0.78 0.11
Residual 1.56222 1.2499
Number of obs: 2530, groups: dojo_id, 95

Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -0.84432 0.31358 90.63236 -2.693 0.00845 **
anger 0.37820 0.01492 88.79089 25.344 < 2e-16 ***
emotional_bonds 0.10897 0.01791 89.49654 6.085 2.83e-08 ***

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) anger
anger -0.638
emotnl_bnds -0.756 0.071
optimizer (nloptwrap) convergence code: 0 (OK)
Model failed to converge with max|grad| = 0.0144489 (tol = 0.002, component 1)

library(flexplot)
> estimates(model)
Erreur dans str2lang(x) : :1:15: ')' inattendu(e)
1: darkness~1+(1|)
^
###NOT WORKING ############### in none of the scripts i tried

visualize(model, plot="model")

####me playing around according to codes from https://github.com/dustinfife/flexplot
visualize(model)
flexplot(darkness1, data=jedi)
flexplot(darkness
emotional_bonds| anger , data=jedi, method="lm", se=F, bins=3)

####back to your visualizations
visualize(model, plot="model",

  •       formula=darkness~emotional_bonds+dojo_id| anger, sample=30)
    

It looks like you're trying to plot more than 6 colors/lines/symbols.
I gotta give it to you...you're ambitious. Alas, I can't do that, so I'm removing the colors/lines/symbols.
I hope we can still be friends.

visualize(model, plot="model",

  •       formula=darkness~emotional_bonds+dojo_id, sample=30)
    

Note: You didn't choose to plot anger so I am inputting the median

It looks like you're trying to plot more than 6 colors/lines/symbols.
I gotta give it to you...you're ambitious. Alas, I can't do that, so I'm removing the colors/lines/symbols.
I hope we can still be friends.

visualize(model, plot="model",

  •       formula=darkness~anger+dojo_id, sample=30)
    

Note: You didn't choose to plot emotional_bonds so I am inputting the median

It looks like you're trying to plot more than 6 colors/lines/symbols.
I gotta give it to you...you're ambitious. Alas, I can't do that, so I'm removing the colors/lines/symbols.
I hope we can still be friends.

###anger seems parallel lines to fixed-so maybe no random effect neeeded
reduced = lmer(darkness ~ emotional_bonds + anger + (emotional_bonds | dojo_id ), data=jedi)
Message d'avis :
Dans checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge with max|grad| = 0.0232594 (tol = 0.002, component 1)

**> compare.fits(darkness ~ anger | dojo_id,

  •          data=jedi,
    
  •          model1 = model,
    
  •          model2 = reduced,
    
  •          re=T,
    
  •          clusters=10)
    

Erreur dans model$model : $ operator not defined for this S4 class

###########NOT WORKING ############# compare fits does not work here for me but actually model comparison works,
#however not the same output as yours in the video, no p value or squared change
model.comparison(model,reduced)
$statistics
aic bic bayes.factor
model 8809.836 8868.196 118334497021
reduced 8878.337 8919.189 0

$predicted_differences
0% 25% 50% 75% 100%
0.000 0.028 0.091 0.230 2.062

####compare fits for a lm model instead of lmer is working though adopted from your github example
reduced2 = lm(darkness ~ emotional_bonds + anger, data=jedi)
model2 = lm(darkness ~ anger * emotional_bonds,data=jedi)
compare.fits(darkness~anger|emotional_bonds, data=jedi,model2,reduced2)**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant