0

I am a beginner using R. I use the package "lmer" and write the code to do multilevel analysis in R below. But, there is no result of variance which should be shown up. How should I revise it? Thank you.

model_0 <- lmer( medicine ~ 1 + (1 | community), data=df, REML = FALSE)

I am sorry, it was very unkind sentence. Thank you for giving your suggestions and advice. And I could got variance from the code `summary(model_0)`, not just writing `model_0`. It was really beginner's problem... Thank you for trying to figure out, Camille & Ben Bolker !

[code]

write.csv(df,"df.csv")
df <- read.csv("df.csv", header = T, sep = ",", as.is = T, na.strings=".")

library(dplyr)
library(tableone)
library(lme4)

#outcome:   medicine
##Model_0  null
model_0 <- `lmer`( medicine ~ 1 + (1 | community), data=df, REML = FALSE)
summary(model0)

[Result]

Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: medicine ~ 1 + (1 | community)
   Data: df

     AIC      BIC   logLik deviance df.resid 
  2400.0   2407.8  -1197.0   2394.0       97 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.4732 -0.5024 -0.1183  0.5035  2.5060 

Random effects:
 Groups    Name        Variance  Std.Dev.
 community (Intercept) 9.020e+08 30033   
 Residual              1.109e+09 33300   
Number of obs: 100, groups:  community, 20

Fixed effects:
             Estimate Std. Error        df t value Pr(>|t|)    
(Intercept) 388914.00    8100.66     19.85   48.01   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  • 1
    Alas, your question is too unclear to answer. `summary(model_0)` or `VarCorr(model_0)` will print the random-effects variance, if that's what you're looking for ... – Ben Bolker May 27 '21 at 13:33
  • [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. We can't run your code without any data, and we can't see what the output is that you're trying to debug – camille May 27 '21 at 16:32
  • Thank you, Camille and Ben Bolker, for answering this question. just writing "model_0" couldn't lead the result with variance. Ben Bolker's adveive, writing "summary(model_0)" perfectly displayed the variance and p-value of fixed effect model. I appreciate so much. – R_biginner May 28 '21 at 00:07

0 Answers0