Home > Software design >  Is there a way to print a certain part of the summary of a model?
Is there a way to print a certain part of the summary of a model?

Time:06-27

I wish to print a part of my summary when reviewing my model (more to save space and for a clearer output), if there anyway to do this? All want is the variance table as circled below

enter image description here

model used;

pupils_test_model = lmer(IQ ~ ses   (1 | Class), 
                    data = pupils) 

CodePudding user response:

If all you want is to get those lines, you could just use capture.output and then select the relevant lines.

temp = capture.output(summary(model))
Start = grep("Random effects", temp)
End   = grep("Number of obs", temp)
print(unname(temp[Start:End]))

[1] "Random effects:"                                  
[2] " Groups       Name        Variance Std.Dev. Corr "
[3] " Petal.Length (Intercept) 2.16667  1.4720        "
[4] "              Petal.Width 0.62156  0.7884   -0.91"
[5] " Residual                 0.08241  0.2871        "
[6] "Number of obs: 150, groups:  Petal.Length, 43"  
  •  Tags:  
  • r
  • Related