lme4::lmer summary object contains double object with string

vanao veneri

take the following model as an example

library('lme4')
foo <- lmer(cty ~ hwy + (1|model), data=mpg, REML=F)

Now we can retreive the LogLikelihood of the model

sum.foo <- summary(foo)
LL <- sum.foo[["logLik"]]
LL
'log Lik.' -343 (df=4)
typeof(LL)
[1] "double"

Question: how can all this information be stored in a double object? There seems to be at least two strings in there, i.e. "log Lik." and "(df=4)". Is there a way to retreive the value of df from this object?

LyzandeR

LL is really just a number (with attributes). The line you see when you print LL is created by the print.logLik function as you can see below:

getAnywhere(print.logLik)
A single object matching ‘print.logLik’ was found
It was found in the following places
  registered S3 method for print from namespace stats
  namespace:stats
with value

function (x, digits = getOption("digits"), ...) 
{
    cat("'log Lik.' ", paste(format(c(x), digits = digits), collapse = ", "), 
        " (df=", format(attr(x, "df")), ")\n", sep = "")
    invisible(x)
}

This is what gets called when you run LL but LL is really only one number (numeric vector of length 1). The cat function is what prints the 'log Lik.' -343 (df=4) that you see on your console.

In order to get the df value you could do (as it can also be seen from the function above):

format(attr(LL[['logLik']], "df"))

See an example (from lmer 's documentation):

fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
a <- summary(fm1)# (with its own print method)

> a[['logLik']]
'log Lik.' -871.8141 (df=6)
> format(attr(a[['logLik']], "df"))
[1] "6"

And as per @BenBolker mentions in the comment format only converts it into character.

> attr(a[['logLik']], "df")
[1] 6

Is probably better.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

lme4::lmer summary object contains double object with string

From Dev

Error : object ‘sigma’ is not exported by 'namespace:lme4'

From Dev

Getting standard errors for lme4 object with texreg

From Dev

Error : object ‘sigma’ is not exported by 'namespace:lme4'

From Dev

Adjusting object@pp$X in lme4

From Dev

Separating a JSON string that contains object

From Dev

convert array that contains object to string

From Dev

Java List.contains object with double with tolerance

From Dev

obscure warning lme4 using lmer in optwrap

From Dev

obscure warning lme4 using lmer in optwrap

From Dev

Get a clean summary of nlme.lme() or lme4.lmer() in RPy

From Dev

Get a clean summary of nlme.lme() or lme4.lmer() in RPy

From Dev

Check if object contains an property matching a string

From Dev

How to check a variable contains JSON object or string?

From Java

Liquid: check if object contains certain string

From Dev

Check if a json object contains a specific string with php

From Dev

Check if any object property contains string

From Dev

compare an object whether it contains a string or an int

From Dev

Return array from object if contains string jquery

From Dev

Check if a list contains a string. Contains asks for a class object

From Dev

Keras model.summary() object to string

From Dev

lsmeans and difflsmeans return no output for lmer object

From Dev

How to check for double quotes in a string object

From Dev

Jackson double serialized json string to Java object

From Dev

assigning a string to an object without double quotes

From Dev

Trying to replace a String with a Double in an Object Array

From Dev

Trying to replace a String with a Double in an Object Array

From Dev

Unable to parse underneath double string with Object Mapper

From Dev

How to extract fixed effects part of summary from lme4?

Related Related

  1. 1

    lme4::lmer summary object contains double object with string

  2. 2

    Error : object ‘sigma’ is not exported by 'namespace:lme4'

  3. 3

    Getting standard errors for lme4 object with texreg

  4. 4

    Error : object ‘sigma’ is not exported by 'namespace:lme4'

  5. 5

    Adjusting object@pp$X in lme4

  6. 6

    Separating a JSON string that contains object

  7. 7

    convert array that contains object to string

  8. 8

    Java List.contains object with double with tolerance

  9. 9

    obscure warning lme4 using lmer in optwrap

  10. 10

    obscure warning lme4 using lmer in optwrap

  11. 11

    Get a clean summary of nlme.lme() or lme4.lmer() in RPy

  12. 12

    Get a clean summary of nlme.lme() or lme4.lmer() in RPy

  13. 13

    Check if object contains an property matching a string

  14. 14

    How to check a variable contains JSON object or string?

  15. 15

    Liquid: check if object contains certain string

  16. 16

    Check if a json object contains a specific string with php

  17. 17

    Check if any object property contains string

  18. 18

    compare an object whether it contains a string or an int

  19. 19

    Return array from object if contains string jquery

  20. 20

    Check if a list contains a string. Contains asks for a class object

  21. 21

    Keras model.summary() object to string

  22. 22

    lsmeans and difflsmeans return no output for lmer object

  23. 23

    How to check for double quotes in a string object

  24. 24

    Jackson double serialized json string to Java object

  25. 25

    assigning a string to an object without double quotes

  26. 26

    Trying to replace a String with a Double in an Object Array

  27. 27

    Trying to replace a String with a Double in an Object Array

  28. 28

    Unable to parse underneath double string with Object Mapper

  29. 29

    How to extract fixed effects part of summary from lme4?

HotTag

Archive