zero predictions from nnet function - R - r

I obtain 0 fitted values when using nnet function as below:
nnet(realized1~ann_t1+ann_t2+ann_t3, data=df2_input, size=2)
Output is
> str(nnet(realized1~ann_t1+ann_t2+ann_t3, data=df2_input, size=2))
# weights: 11
initial value 134.845214
final value 0.147077
converged
List of 18
$ n : num [1:3] 3 2 1
$ nunits : int 7
$ nconn : num [1:8] 0 0 0 0 0 4 8 11
$ conn : num [1:11] 0 1 2 3 0 1 2 3 0 4 ...
$ nsunits : int 7
$ decay : num 0
$ entropy : logi FALSE
$ softmax : logi FALSE
$ censored : logi FALSE
$ value : num 0.147
$ wts : num [1:11] 14.815 -69.862 0.244 -0.456 -5.638 ...
$ convergence : int 0
$ fitted.values: num [1:800, 1] 0 0 0 0 0 0 0 0 0 0 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:800] "1601" "1602" "1603" "1604" ...
.. ..$ : NULL
$ residuals : num [1:800, 1] 0.004267 0.000401 0.002404 0.022561 0.001354 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:800] "1601" "1602" "1603" "1604" ...
.. ..$ : NULL
$ call : language nnet.formula(formula = realized1 ~ ann_t1 + ann_t2 + ann_t3, data = df2_input, size = 2)
$ terms :Classes 'terms', 'formula' language realized1 ~ ann_t1 + ann_t2 + ann_t3
.. ..- attr(*, "variables")= language list(realized1, ann_t1, ann_t2, ann_t3)
.. ..- attr(*, "factors")= int [1:4, 1:3] 0 1 0 0 0 0 1 0 0 0 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:4] "realized1" "ann_t1" "ann_t2" "ann_t3"
.. .. .. ..$ : chr [1:3] "ann_t1" "ann_t2" "ann_t3"
.. ..- attr(*, "term.labels")= chr [1:3] "ann_t1" "ann_t2" "ann_t3"
.. ..- attr(*, "order")= int [1:3] 1 1 1
.. ..- attr(*, "intercept")= int 1
.. ..- attr(*, "response")= int 1
.. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. ..- attr(*, "predvars")= language list(realized1, ann_t1, ann_t2, ann_t3)
.. ..- attr(*, "dataClasses")= Named chr [1:4] "numeric" "numeric" "numeric" "numeric"
.. .. ..- attr(*, "names")= chr [1:4] "realized1" "ann_t1" "ann_t2" "ann_t3"
$ coefnames : chr [1:3] "ann_t1" "ann_t2" "ann_t3"
$ xlevels : Named list()
- attr(*, "class")= chr [1:2] "nnet.formula" "nnet"
Input data frame is as below:
> str(df2_input)
'data.frame': 800 obs. of 4 variables:
$ realized1: num 0.004267 0.000401 0.002404 0.022561 0.001354 ...
$ ann_t1 : num -4.4 -4.19 -4.3 -4.48 -4.6 ...
$ ann_t2 : num 0 -0.002996 -0.000298 -0.001964 -0.01963 ...
$ ann_t3 : num 0 -0.01662 0.00165 -0.01089 -0.10887 ...
Why do I get zero predictions and how can I fix it?
Thanks a lot.

Related

extract one element/data frame from a list of lists

I have a list of lists called cj1. Each list contains multiple data frames/elements. I want to extract the first element/data frame from each list in a separate list of data frames. The first rows in the first element of each list look like this
as.data.frame(cj1[[1]])
cj1[[1]]
..a15.pdf 1.27679608
..a17.pdf 1.05090176
..a18.pdf 1.51820192
..a15.pdf etc. is a rowname. If I use as.data.frame(cj1[1][1]), I get the same results, but the name of the column is the combination of all rownames and coeffients.
I'd like to make a list of all of these data frames. In the image below, the name of the element/data frame I am interested in is coefficients. In total there are 462 of them
To extract my desired list (results1) I tried:
results1<-sapply(cj1, function(x) as.data.frame(cj1[1][1]))
This renders a list with more than 15000 elements (same number as cj1), which is more than I would expect (462). In addition, when I access the elements, they are all the same: the coefficients data frame from list 1.
I also tried a for loop, which does not seem right to me, and not surprisingly does not work.
results1 <- c()
for (i in 1:462) {
results1[[i]] <- as.data.frame(cj1[[1]])
}
My original list:
str(cj1)
List of 15708
$ : Named num [1:22] 1.28 1.05 1.52 2.3 1.49 ...
..- attr(*, "names")= chr [1:22] "..a15.pdf" "..a17.pdf" "..a18.pdf" "..a21.pdf" ...
$ : Named num [1:92] -1.1 3.79 1.17 -1.12 -1.1 ...
..- attr(*, "names")= chr [1:92] "1" "2" "3" "4" ...
$ : Named num [1:92] 0.0909 0.2637 0.269 0.1049 0.095 ...
..- attr(*, "names")= chr [1:92] "1" "2" "3" "4" ...
$ : Named num [1:92] -0.327 -0.372 -1.394 -0.514 -1.373 ...
..- attr(*, "names")= chr [1:92] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
$ : num [1:22, 1:22] -1.45 0 0 0 0 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
.. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
$ : int 22
$ :List of 5
..$ qr : num [1:92, 1:22] -1.45 0 0 0 0 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:92] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
..$ rank : int 22
..$ qraux: num [1:22] 1 1 1 1 1 ...
..$ pivot: int [1:22] 1 2 3 4 5 6 7 8 9 10 ...
..$ tol : num 1e-11
..- attr(*, "class")= chr "qr"
$ :List of 12
..$ family : chr "binomial"
..$ link : chr "logit"
..$ linkfun :function (mu)
..$ linkinv :function (eta)
..$ variance :function (mu)
..$ dev.resids:function (y, mu, wt)
..$ aic :function (y, n, mu, wt, dev)
..$ mu.eta :function (eta)
..$ initialize: language { if (NCOL(y) == 1) { ...
..$ validmu :function (mu)
..$ valideta :function (eta)
..$ simulate :function (object, nsim)
..- attr(*, "class")= chr "family"
$ : Named num [1:92] -2.3 -1.03 -1 -2.14 -2.25 ...
..- attr(*, "names")= chr [1:92] "1" "2" "3" "4" ...
$ : num 87
$ : num 148
$ : num 148
$ : int 17
$ : Named num [1:92] 0.0826 0.1941 0.3933 0.1878 0.0859 ...
..- attr(*, "names")= chr [1:92] "1" "2" "3" "4" ...
$ : Named num [1:92] 1 1 2 2 1 1 2 1 2 2 ...
..- attr(*, "names")= chr [1:92] "1" "2" "3" "4" ...
$ : int 70
$ : int 92
$ : Named num [1:92] 0 1 0.5 0 0 0 0.5 1 0.5 0.5 ...
..- attr(*, "names")= chr [1:92] "1" "2" "3" "4" ...
$ : logi TRUE
$ : logi FALSE
$ :'data.frame': 92 obs. of 2 variables:
..$ Y: num [1:92, 1:2] 0 1 1 0 0 0 1 1 1 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "win1" "win2"
..$ X: num [1:92, 1:22] 0 0 0 0 0 0 0 0 0 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:92] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:22] "..a15.pdf" "..a17.pdf" "..a18.pdf" "..a21.pdf" ...
.. ..- attr(*, "assign")= int [1:22] 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "terms")=Classes 'terms', 'formula' language Y ~ X - 1
.. .. ..- attr(*, "variables")= language list(Y, X)
.. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : chr [1:2] "Y" "X"
.. .. .. .. ..$ : chr "X"
.. .. ..- attr(*, "term.labels")= chr "X"
.. .. ..- attr(*, "order")= int 1
.. .. ..- attr(*, "intercept")= int 0
.. .. ..- attr(*, "response")= int 1
.. .. ..- attr(*, ".Environment")=<environment: 0x000001b58a90fc78>
.. .. ..- attr(*, "predvars")= language list(Y, X)
.. .. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "nmatrix.22"
.. .. .. ..- attr(*, "names")= chr [1:2] "Y" "X"
$ : language BTm(outcome = cbind(win1, win2), player1 = player1, player2 = player2, data = x)
$ :Class 'formula' language ~..
.. ..- attr(*, ".Environment")=<environment: 0x000001b58a910420>
$ :Classes 'terms', 'formula' language Y ~ X - 1
.. ..- attr(*, "variables")= language list(Y, X)
.. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:2] "Y" "X"
.. .. .. ..$ : chr "X"
.. ..- attr(*, "term.labels")= chr "X"
.. ..- attr(*, "order")= int 1
.. ..- attr(*, "intercept")= int 0
.. ..- attr(*, "response")= int 1
.. ..- attr(*, ".Environment")=<environment: 0x000001b58a90fc78>
.. ..- attr(*, "predvars")= language list(Y, X)
.. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "nmatrix.22"
.. .. ..- attr(*, "names")= chr [1:2] "Y" "X"
$ :'data.frame': 92 obs. of 4 variables:
..$ player1: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 1 1 1 1 1 1 1 1 1 2 ...
..$ player2: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 5 8 9 12 13 15 16 19 20 3 ...
..$ win1 : num [1:92] 0 1 1 0 0 0 1 1 1 1 ...
..$ win2 : num [1:92] 1 0 1 2 1 1 1 0 1 1 ...
$ : NULL
$ :List of 3
..$ epsilon: num 1e-08
..$ maxit : num 25
..$ trace : logi FALSE
$ : chr "glm.fit"
$ : Named list()
$ : int [1:22] 1 1 1 1 1 1 1 1 1 1 ...
$ : chr ".."
$ :'data.frame': 92 obs. of 1 variable:
..$ ..: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 1 1 1 1 1 1 1 1 1 2 ...
$ :'data.frame': 92 obs. of 1 variable:
..$ ..: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 5 8 9 12 13 15 16 19 20 3 ...
$ : chr ".."
$ : Named num [1:22] 2.097 2.198 1.918 0.801 2.162 ...
..- attr(*, "names")= chr [1:22] "..a15.pdf" "..a17.pdf" "..a18.pdf" "..a21.pdf" ...
$ : Named num [1:94] -1.15 0.89 3.59 -1.14 -1.05 ...
..- attr(*, "names")= chr [1:94] "1" "2" "3" "4" ...
$ : Named num [1:94] 0.1281 0.3097 0.2786 0.1266 0.0516 ...
..- attr(*, "names")= chr [1:94] "1" "2" "3" "4" ...
$ : Named num [1:94] -0.522 -0.6154 -0.9306 0.0702 -1.3505 ...
..- attr(*, "names")= chr [1:94] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
$ : num [1:22, 1:22] -1.46 0 0 0 0 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
.. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
$ : int 22
$ :List of 5
..$ qr : num [1:94, 1:22] -1.46 0 0 0 0 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:94] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
..$ rank : int 22
..$ qraux: num [1:22] 1 1 1 1 1 ...
..$ pivot: int [1:22] 1 2 3 4 5 6 7 8 9 10 ...
..$ tol : num 1e-11
..- attr(*, "class")= chr "qr"
$ :List of 12
..$ family : chr "binomial"
..$ link : chr "logit"
..$ linkfun :function (mu)
..$ linkinv :function (eta)
..$ variance :function (mu)
..$ dev.resids:function (y, mu, wt)
..$ aic :function (y, n, mu, wt, dev)
..$ mu.eta :function (eta)
..$ initialize: language { if (NCOL(y) == 1) { ...
..$ validmu :function (mu)
..$ valideta :function (eta)
..$ simulate :function (object, nsim)
..- attr(*, "class")= chr "family"
$ : Named num [1:94] -1.918 -0.801 -0.951 -1.931 -2.911 ...
..- attr(*, "names")= chr [1:94] "1" "2" "3" "4" ...
$ : num 68
$ : num 131
$ : num 142
$ : int 18
$ : Named num [1:94] 0.1117 0.4276 0.201 0.1106 0.0979 ...
..- attr(*, "names")= chr [1:94] "1" "2" "3" "4" ...
$ : Named num [1:94] 1 2 1 1 2 1 1 2 3 2 ...
..- attr(*, "names")= chr [1:94] "1" "2" "3" "4" ...
$ : int 72
$ : int 94
$ : Named num [1:94] 0 0.5 1 0 0 ...
..- attr(*, "names")= chr [1:94] "1" "2" "3" "4" ...
$ : logi TRUE
$ : logi FALSE
$ :'data.frame': 94 obs. of 2 variables:
..$ Y: num [1:94, 1:2] 0 1 1 0 0 0 0 1 2 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "win1" "win2"
..$ X: num [1:94, 1:22] 0 0 0 0 0 0 0 0 0 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:94] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:22] "..a15.pdf" "..a17.pdf" "..a18.pdf" "..a21.pdf" ...
.. ..- attr(*, "assign")= int [1:22] 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "terms")=Classes 'terms', 'formula' language Y ~ X - 1
.. .. ..- attr(*, "variables")= language list(Y, X)
.. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : chr [1:2] "Y" "X"
.. .. .. .. ..$ : chr "X"
.. .. ..- attr(*, "term.labels")= chr "X"
.. .. ..- attr(*, "order")= int 1
.. .. ..- attr(*, "intercept")= int 0
.. .. ..- attr(*, "response")= int 1
.. .. ..- attr(*, ".Environment")=<environment: 0x000001b592c99120>
.. .. ..- attr(*, "predvars")= language list(Y, X)
.. .. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "nmatrix.22"
.. .. .. ..- attr(*, "names")= chr [1:2] "Y" "X"
$ : language BTm(outcome = cbind(win1, win2), player1 = player1, player2 = player2, data = x)
$ :Class 'formula' language ~..
.. ..- attr(*, ".Environment")=<environment: 0x000001b5877fb898>
$ :Classes 'terms', 'formula' language Y ~ X - 1
.. ..- attr(*, "variables")= language list(Y, X)
.. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:2] "Y" "X"
.. .. .. ..$ : chr "X"
.. ..- attr(*, "term.labels")= chr "X"
.. ..- attr(*, "order")= int 1
.. ..- attr(*, "intercept")= int 0
.. ..- attr(*, "response")= int 1
.. ..- attr(*, ".Environment")=<environment: 0x000001b592c99120>
.. ..- attr(*, "predvars")= language list(Y, X)
.. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "nmatrix.22"
.. .. ..- attr(*, "names")= chr [1:2] "Y" "X"
$ :'data.frame': 94 obs. of 4 variables:
..$ player1: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 1 1 1 1 1 1 1 1 1 2 ...
..$ player2: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 4 5 8 9 12 13 15 16 20 3 ...
..$ win1 : num [1:94] 0 1 1 0 0 0 0 1 2 1 ...
..$ win2 : num [1:94] 1 1 0 1 2 1 1 1 1 1 ...
$ : NULL
$ :List of 3
..$ epsilon: num 1e-08
..$ maxit : num 25
..$ trace : logi FALSE
$ : chr "glm.fit"
$ : Named list()
$ : int [1:22] 1 1 1 1 1 1 1 1 1 1 ...
$ : chr ".."
$ :'data.frame': 94 obs. of 1 variable:
..$ ..: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 1 1 1 1 1 1 1 1 1 2 ...
$ :'data.frame': 94 obs. of 1 variable:
..$ ..: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 4 5 8 9 12 13 15 16 20 3 ...
$ : chr ".."
$ : Named num [1:22] 1.9 1.85 1.56 1.69 1.09 ...
..- attr(*, "names")= chr [1:22] "..a15.pdf" "..a17.pdf" "..a18.pdf" "..a21.pdf" ...
$ : Named num [1:89] -1.19 3.77 -1.26 6.01 -1.14 ...
..- attr(*, "names")= chr [1:89] "1" "2" "3" "4" ...
$ : Named num [1:89] 0.156 0.265 0.205 0.166 0.124 ...
..- attr(*, "names")= chr [1:89] "1" "2" "3" "4" ...
$ : Named num [1:89] -0.82 -0.743 -0.889 -0.789 -0.878 ...
..- attr(*, "names")= chr [1:89] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
$ : num [1:22, 1:22] -1.55 0 0 0 0 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
.. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
$ : int 22
$ :List of 5
..$ qr : num [1:89, 1:22] -1.55 0 0 0 0 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:89] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:22] "X..a15.pdf" "X..a17.pdf" "X..a18.pdf" "X..a21.pdf" ...
..$ rank : int 22
..$ qraux: num [1:22] 1 1 1 1 1 ...
..$ pivot: int [1:22] 1 2 3 4 5 6 7 8 9 10 ...
..$ tol : num 1e-11
..- attr(*, "class")= chr "qr"
$ :List of 12
..$ family : chr "binomial"
..$ link : chr "logit"
..$ linkfun :function (mu)
..$ linkinv :function (eta)
..$ variance :function (mu)
..$ dev.resids:function (y, mu, wt)
..$ aic :function (y, n, mu, wt, dev)
..$ mu.eta :function (eta)
..$ initialize: language { if (NCOL(y) == 1) { ...
..$ validmu :function (mu)
..$ valideta :function (eta)
..$ simulate :function (object, nsim)
..- attr(*, "class")= chr "family"
$ : Named num [1:89] -1.69 -1.02 -1.35 -1.61 -1.95 ...
..- attr(*, "names")= chr [1:89] "1" "2" "3" "4" ...
$ : num 75.4
$ : num 139
$ : num 141
$ : int 18
$ : Named num [1:89] 0.132 0.195 0.163 0.139 0.218 ...
..- attr(*, "names")= chr [1:89] "1" "2" "3" "4" ...
$ : Named num [1:89] 1 1 1 1 2 1 2 2 3 3 ...
..- attr(*, "names")= chr [1:89] "1" "2" "3" "4" ...
$ : int 67
$ : int 89
$ : Named num [1:89] 0 1 0 1 0 ...
..- attr(*, "names")= chr [1:89] "1" "2" "3" "4" ...
$ : logi TRUE
$ : logi FALSE
$ :'data.frame': 89 obs. of 2 variables:
..$ Y: num [1:89, 1:2] 0 1 0 1 0 0 1 1 1 2 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "win1" "win2"
..$ X: num [1:89, 1:22] 0 0 0 0 0 0 0 0 0 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:89] "1" "2" "3" "4" ...
.. .. ..$ : chr [1:22] "..a15.pdf" "..a17.pdf" "..a18.pdf" "..a21.pdf" ...
.. ..- attr(*, "assign")= int [1:22] 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "terms")=Classes 'terms', 'formula' language Y ~ X - 1
.. .. ..- attr(*, "variables")= language list(Y, X)
.. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. ..$ : chr [1:2] "Y" "X"
.. .. .. .. ..$ : chr "X"
.. .. ..- attr(*, "term.labels")= chr "X"
.. .. ..- attr(*, "order")= int 1
.. .. ..- attr(*, "intercept")= int 0
.. .. ..- attr(*, "response")= int 1
.. .. ..- attr(*, ".Environment")=<environment: 0x000001b587c20440>
.. .. ..- attr(*, "predvars")= language list(Y, X)
.. .. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "nmatrix.22"
.. .. .. ..- attr(*, "names")= chr [1:2] "Y" "X"
$ : language BTm(outcome = cbind(win1, win2), player1 = player1, player2 = player2, data = x)
$ :Class 'formula' language ~..
.. ..- attr(*, ".Environment")=<environment: 0x000001b587c20b40>
$ :Classes 'terms', 'formula' language Y ~ X - 1
.. ..- attr(*, "variables")= language list(Y, X)
.. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:2] "Y" "X"
.. .. .. ..$ : chr "X"
.. ..- attr(*, "term.labels")= chr "X"
.. ..- attr(*, "order")= int 1
.. ..- attr(*, "intercept")= int 0
.. ..- attr(*, "response")= int 1
.. ..- attr(*, ".Environment")=<environment: 0x000001b587c20440>
.. ..- attr(*, "predvars")= language list(Y, X)
.. ..- attr(*, "dataClasses")= Named chr [1:2] "nmatrix.2" "nmatrix.22"
.. .. ..- attr(*, "names")= chr [1:2] "Y" "X"
$ :'data.frame': 89 obs. of 4 variables:
..$ player1: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 1 1 1 1 1 1 1 1 1 2 ...
..$ player2: Factor w/ 23 levels "a12TTT.pdf","a15.pdf",..: 5 8 9 10 12 13 15 16 20 3 ...
..$ win1 : num [1:89] 0 1 0 1 0 0 1 1 1 2 ...
..$ win2 : num [1:89] 1 0 1 0 2 1 1 1 2 1 ...
$ : NULL
$ :List of 3
..$ epsilon: num 1e-08
..$ maxit : num 25
..$ trace : logi FALSE
$ : chr "glm.fit"
$ : Named list()
$ : int [1:22] 1 1 1 1 1 1 1 1 1 1 ...
$ : chr ".."
[list output truncated]
- attr(*, "dim")= int [1:2] 34 462
- attr(*, "dimnames")=List of 2
..$ : chr [1:34] "coefficients" "residuals" "fitted.values" "effects" ...
..$ : NULL
Extract from dput
dput(cj1[c(1, 3, 8)])
list(c(..a15.pdf = 1.27679607834331, ..a17.pdf = 1.05090175857491,
..a18.pdf = 1.51820192474905, ..a21.pdf = 2.30296037386815, ..a2TTT.pdf = 1.48568731934637,
..a5.pdf = 0.493713103224402, ..B11.pdf = 1.02705905465749, ..B12.pdf = 0.999747360884078,
..B13.pdf = 2.40828101927852, ..B22.pdf = 0.695152132033603,
..B24.pdf = 2.1436001615064, ..B4.pdf = 2.25444037842867, ..B7.pdf = 0.909773940025014,
..B8.pdf = 1.14837173756827, `..cw10-1.pdf` = -1.36323271003293,
`..cw15-1TTT.pdf` = 0.341428535787024, `..cw17-1.pdf` = -0.786878348480425,
..cw18.pdf = 0.793720472787986, ..cw3.pdf = -1.57831038567642,
..cw4.pdf = 0.277733503122777, ..cw7_1TTT.pdf = -0.0364645818969112,
`..cw13-1.pdf` = -18.336668416705), c(`1` = 0.0908780807219899,
`2` = 0.263654664895121, `3` = 0.268991096134461, `4` = 0.104930779989728,
`5` = 0.0949671345831925, `6` = 0.240786617491842, `7` = 0.796284595482489,
`8` = 0.31137037055408, `9` = 0.82896509427021, `10` = 0.556234653434742,
`11` = 0.447966262353147, `12` = 0.562111772393927, `13` = 0.64144559057026,
`14` = 0.295919740681443, `15` = 0.590739226571063, `16` = 0.618473870745292,
`17` = 0.730874229815385, `18` = 0.385255456804764, `19` = 0.392984164719899,
`20` = 0.505960393621032, `21` = 0.512785811414426, `22` = 0.588011150512112,
`23` = 0.230846313945379, `24` = 0.917898796713428, `25` = 0.670284750854893,
`26` = 0.862685953007114, `27` = 0.99999999619736, `28` = 0.508127935292484,
`29` = 0.735846044750689, `30` = 0.620375626350015, `31` = 0.348554704521668,
`32` = 0.946921016898213, `33` = 0.909296911948067, `34` = 0.673593098928319,
`35` = 0.825586698787513, `36` = 0.78637523124224, `37` = 0.473694150487632,
`38` = 0.883420398016852, `39` = 0.999999998912766, `40` = 0.729477690591574,
`41` = 0.612688711990574, `42` = 0.341208618334042, `43` = 0.945262830874797,
`44` = 0.758460698474656, `45` = 0.769936700176506, `46` = 0.820855140443936,
`47` = 0.146699277115816, `48` = 0.397459740469979, `49` = 0.537997737731323,
`50` = 0.782550437769477, `51` = 0.888154125425794, `52` = 0.553785981995655,
`53` = 0.582223288022616, `54` = 0.226640083932377, `55` = 0.529287713363298,
`56` = 0.999999996105605, `57` = 0.196465439953117, `58` = 0.551325299580471,
`59` = 0.92943599314157, `60` = 0.738118436855869, `61` = 0.893836974671663,
`62` = 0.920176356697468, `63` = 0.99999999902145, `64` = 0.173748802751829,
`65` = 0.446549562485168, `66` = 0.388595549230014, `67` = 0.587520249127046,
`68` = 0.814879076916803, `69` = 0.4753778467418, `70` = 0.90665523878871,
`71` = 0.999999994572681, `72` = 0.730119396156374, `73` = 0.970881561088295,
`74` = 0.865979290569218, `75` = 0.898444979546349, `76` = 0.793256288161879,
`77` = 0.871357134749265, `78` = 0.811642757783275, `79` = 0.440631930364752,
`80` = 0.906616650865072, `81` = 0.845096998613173, `82` = 0.691457736894216,
`83` = 0.873829387141476, `84` = 0.587745042243573, `85` = 0.7658162723501,
`86` = 0.999999996550512, `87` = 0.755526305253868, `88` = 0.515918376716212,
`89` = 0.999999992269536, `90` = 0.999999976109623, `91` = 0.135164835661148,
`92` = 0.999999947284594), structure(list(family = "binomial",
link = "logit", linkfun = function (mu)
.Call(C_logit_link, mu), linkinv = function (eta)
.Call(C_logit_linkinv, eta), variance = function (mu)
mu * (1 - mu), dev.resids = function (y, mu, wt)
.Call(C_binomial_dev_resids, y, mu, wt), aic = function (y,
n, mu, wt, dev)
{
m <- if (any(n > 1))
n
else wt
-2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m *
y), round(m), mu, log = TRUE))
}, mu.eta = function (eta)
.Call(C_logit_mu_eta, eta), initialize = {
if (NCOL(y) == 1) {
if (is.factor(y))
y <- y != levels(y)[1L]
n <- rep.int(1, nobs)
y[weights == 0] <- 0
if (any(y < 0 | y > 1))
stop("y values must be 0 <= y <= 1")
mustart <- (weights * y + 0.5)/(weights + 1)
m <- weights * y
if ("binomial" == "binomial" && any(abs(m - round(m)) >
0.001))
warning(gettextf("non-integer #successes in a %s glm!",
"binomial"), domain = NA)
}
else if (NCOL(y) == 2) {
if ("binomial" == "binomial" && any(abs(y - round(y)) >
0.001))
warning(gettextf("non-integer counts in a %s glm!",
"binomial"), domain = NA)
n <- (y1 <- y[, 1L]) + y[, 2L]
y <- y1/n
if (any(n0 <- n == 0))
y[n0] <- 0
weights <- weights * n
mustart <- (n * y + 0.5)/(n + 1)
}
else stop(gettextf("for the '%s' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures",
"binomial"), domain = NA)
}, validmu = function (mu)
all(is.finite(mu)) && all(mu > 0 & mu < 1), valideta = function (eta)
TRUE, simulate = function (object, nsim)
{
ftd <- fitted(object)
n <- length(ftd)
ntot <- n * nsim
wts <- object$prior.weights
if (any(wts%%1 != 0))
stop("cannot simulate from non-integer prior.weights")
if (!is.null(m <- object$model)) {
y <- model.response(m)
if (is.factor(y)) {
yy <- factor(1 + rbinom(ntot, size = 1, prob = ftd),
labels = levels(y))
split(yy, rep(seq_len(nsim), each = n))
}
else if (is.matrix(y) && ncol(y) == 2) {
yy <- vector("list", nsim)
for (i in seq_len(nsim)) {
Y <- rbinom(n, size = wts, prob = ftd)
YY <- cbind(Y, wts - Y)
colnames(YY) <- colnames(y)
yy[[i]] <- YY
}
yy
}
else rbinom(ntot, size = wts, prob = ftd)/wts
}
else rbinom(ntot, size = wts, prob = ftd)/wts
}), class = "family"))
The dput output from above probably presents the rows 1,3,8 from V1 only i.e. coefficients, fitted values, family (see image here).
The desired output would be a list of data frames with the coefficients and their names (first row) in all of the columns presented in the image, i.e. V1:V462. When I extract the data from the first row and first column, the names are rownames. But I was not able to access coefficients in V2 etc. cj2[2][1] accessess the residuals (second row) in V1. cj2[1][2] gives null.
Illustration of the output
Data frame one
..a15.pdf 1.27679608
..a17.pdf 1.05090176
..a18.pdf 1.51820192 and so on for the 22 names that I have (i.e.a15.pdf)
Data frame 2
..a15.pdf 2.09668756
..a17.pdf 2.19826038.....etc for 22 names (if they are all included).
So basically I want the data that on the image appears to be in row one across all the columns.
So after messing around, the answer seems to be very simple: `results1<-cj1["coefficients",]. This creates the list that I want. Akrun, if you read this, thank you for your support.

Changing the data frame to not include the first column BUT including the treatments still. Working in R

I'm working with 6 stations that are currently the first column after the header column (bold) in my R console. I need to get it so that my stations/treatments are in the header column. I have done this with other data before and it's worked fine, but I get an error when working with this new csv file.
Code I'm using:
stations<-as.factor(Data$Sites)
Data2<-data.frame(Data[,-1], row.names=Data[,1]) #Data refers to my file name
Error I'm getting:
Error in data.frame(Data[, -1], row.names = Data[, 1]) :
'row.names' should specify one of the variables
Exampled of data where my code creates the error:
# A tibble: 6 × 5
Sites AB1 AB2 AB3 AB4
<chr> <int> <int> <int> <int>
1 NS1 0 0 1 2
2 S27 2 2 0 2
3 S28 3 0 5 3
4 NS29 0 6 7 0
5 NS31 3 0 1 0
6 S44 0 1 8 0
Please can anyone tell me either what's wrong with my existing code, or code that will do the same job.
Output of str(data):
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 6 obs. of 95 variables:
$ Sites : chr "NS1" "S27" "S28" "NS29" ...
$ AB1 : int 0 2 0 5 7 1
$ AB104 : int 2 0 0 31 0 0
$ AB105 : int 1 0 0 0 0 0
$ AB107 : int 1 0 0 0 0 0
$ AB110 : int 1 0 0 0 0 0
$ AB111 : int 1 0 0 0 0 0
$ AB113 : int 1 0 0 0 0 0
$ AB114 : int 1 0 0 0 0 0
$ AB115 : int 1 0 0 0 0 0
$ AB121 : int 0 30 0 166 94 4
$ AB128 : int 0 0 0 13 0 0
$ AB129 : int 0 0 0 13 1 0
$ AB131 : int 0 5 0 4 2 0
$ AB136 : int 0 1 0 4 3 0
$ AB137 : int 0 0 0 5 0 0
$ AB140 : int 0 0 0 12 0 0
$ AB141 : int 0 0 0 14 1 0
$ AB142 : int 0 0 0 2 0 0
$ AB143 : int 0 0 0 1 0 0
$ AB144 : int 0 0 0 3 1 0
$ AB145 : int 0 5 0 0 3 503
$ AB147 : int 0 7 1 0 0 10
$ AB148 : int 0 0 0 0 0 1
$ AB149 : int 0 0 0 0 0 2
$ AB150 : int 0 0 0 0 0 1
$ AB151 : int 0 0 0 0 0 5
$ AB152 : int 0 0 0 0 0 1
$ AB153 : int 0 0 0 0 0 1
$ AB154 : int 0 0 0 0 0 2
$ AB156 : int 0 0 0 0 1 1
$ AB16 : int 1 1 0 0 10 3
$ AB160 : int 0 0 0 0 2 0
$ AB164 : int 0 0 0 0 1 0
$ AB169 : int 2 0 0 31 0 0
$ AB17 : int 1 154 33 14388 1018 158
$ AB170 : int 0 0 0 0 0 1
$ AB171 : int 0 0 0 82 1 6
$ AB172 : int 0 4 0 2 0 0
$ AB174 : int 0 7 0 0 0 0
$ AB175 : int 0 1 0 0 0 0
$ AB18 : int 0 2 6 0 0 2
$ AB19 : int 3 54 83 0 25 18
$ AB2 : int 0 19 2 8 6 5
$ AB20 : int 0 0 1 0 3 2
$ AB21 : int 0 24 1 3 41 4
$ AB228 : int 0 1 0 0 0 0
$ AB24 : int 0 0 0 1 0 0
$ AB26 : int 0 3 11 2 1 0
$ AB27 : int 0 39 17 8 6 28
$ AB28 : int 2 49 41 1 94 43
$ AB30 : int 47 89 100 24 32 20
$ AB31 : int 0 3 2 1 1 2
$ AB32 : int 2 4 8 19 4 1
$ AB36 : int 0 0 1 1 0 1
$ AB38 : int 6 0 0 1 2 1
$ AB4 : int 0 0 0 0 1 0
$ AB41 : int 0 4 2 0 0 6
$ AB42 : int 1 1 0 2 0 0
$ AB43 : int 0 106 75 161 274 109
$ AB45 : int 0 0 0 1 4 2
$ AB48 : int 0 13 8 0 5 22
$ AB53 : int 0 0 14 0 0 0
$ AB54 : int 0 0 2 0 0 2
$ AB56 : int 0 0 0 1 0 1
$ AB57 : int 0 0 0 0 1 0
$ AB59 : int 0 1 1 1 0 0
$ AB60 : int 0 3 0 0 0 0
$ AB64 : int 0 0 1 0 0 0
$ AB65 : int 0 0 1 0 0 0
$ AB68 : int 0 0 1 0 0 0
$ AB69 : int 0 0 3 0 0 0
$ AB7 : int 4 9 2 21 16 6
$ AB70 : int 0 0 1 0 0 0
$ AB71 : int 0 0 7 0 0 0
$ AB72 : int 0 0 1 0 0 0
$ AB73 : int 0 0 2 0 0 0
$ AB74 : int 0 2 1 0 0 5
$ AB75 : int 0 0 1 0 0 0
$ AB76 : int 0 0 3 0 0 0
$ AB77 : int 16 0 2 0 2 3
$ AB78 : int 0 0 2 0 0 1
$ AB79 : int 0 0 8 0 0 0
$ AB80 : int 0 0 1 0 0 0
$ AB85 : int 0 0 1 0 0 4
$ AB86 : int 0 5 1 6 0 0
$ AB88 : int 0 0 1 0 1 0
$ AB90 : int 0 0 1 0 0 0
$ AB91 : int 0 0 1 0 0 0
$ AB92 : int 0 0 1 0 0 3
$ AB93 : int 0 0 1 0 0 0
$ AB98 : int 15 0 0 0 0 0
$ OTU231: int 2 37 114 3 9 55
$ OTU339: int 0 5 2 1 3 10
$ OTU347: int 0 499 123 0 0 14
- attr(*, "spec")=List of 2
..$ cols :List of 95
.. ..$ Sites : list()
.. .. ..- attr(*, "class")= chr "collector_character" "collector"
.. ..$ AB1 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB104 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB105 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB107 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB110 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB111 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB113 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB114 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB115 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB121 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB128 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB129 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB131 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB136 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB137 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB140 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB141 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB142 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB143 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB144 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB145 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB147 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB148 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB149 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB150 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB151 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB152 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB153 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB154 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB156 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB16 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB160 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB164 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB169 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB17 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB170 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB171 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB172 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB174 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB175 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB18 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB19 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB2 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB20 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB21 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB228 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB24 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB26 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB27 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB28 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB30 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB31 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB32 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB36 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB38 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB4 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB41 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB42 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB43 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB45 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB48 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB53 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB54 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB56 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB57 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB59 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB60 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB64 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB65 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB68 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB69 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB7 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB70 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB71 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB72 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB73 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB74 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB75 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB76 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB77 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB78 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB79 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB80 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB85 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB86 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB88 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB90 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB91 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB92 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB93 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ AB98 : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ OTU231: list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ OTU339: list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ OTU347: list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
..$ default: list()
.. ..- attr(*, "class")= chr "collector_guess" "collector"
..- attr(*, "class")= chr "col_spec"
Output of str(data[,1]):
chr [1:6] "NS1" "S27" "S28" "NS29" "NS31" "S44"
To prevent smashing stuff into the comments, the code
df <- read.table(header=TRUE, text=" Sites AB1 AB2 AB3 AB4
1 NS1 0 0 1 2
2 S27 2 2 0 2
3 S28 3 0 5 3
4 NS29 0 6 7 0
5 NS31 3 0 1 0
6 S44 0 1 8 0")
df2 <- data.frame(df[,-1], row.names=df[,1])
runs without error and produces
df2
AB1 AB2 AB3 AB4
NS1 0 0 1 2
S27 2 2 0 2
S28 3 0 5 3
NS29 0 6 7 0
NS31 3 0 1 0
S44 0 1 8 0
From your output, it looks like this should work. You might try being super-explicit:
df2 <- data.frame(as.data.frame(df[,-1]), row.names=as.character(df[,1]))
replacing df with the name of your data.frame as discussed in the comments.
Alternatively, in two lines
df2 <- as.data.frame(df[,-1])
row.names(df) <- as.character(df[,1])

How do I access individual objects of an anova summary?

I have an object,
> str(summary(A$aov[[2]]))
List of 1
$ :Classes ‘anova’ and 'data.frame': 4 obs. of 5 variables:
..$ Df : num [1:4] 1 1 1 26
..$ Sum Sq : num [1:4] 0.00966 0.01137 0.00458 1.13068
..$ Mean Sq: num [1:4] 0.00966 0.01137 0.00458 0.04349
..$ F value: num [1:4] 0.222 0.261 0.105 NA
..$ Pr(>F) : num [1:4] 0.641 0.614 0.748 NA
- attr(*, "class")= chr [1:2] "summary.aov" "listof"
however I can't seem to figure out how to access "Sum Sq"?
I tried the following already,
summary(A$aov[[2]])$'Sum Sq'
summary(A$aov[[2]])[2]
summary(A$aov[[2]])[2,]
Would be even great for learning if I can extract the Sum Sq values without the summary function. For example, typing
> A$aov[[2]]
Terms:
Adult_Group Sex Adult_Group:Sex Residuals
Sum of Squares 0.0096577 0.0113658 0.0045836 1.1306777
Deg. of Freedom 1 1 1 26
Residual standard error: 0.2085368
Estimated effects may be unbalanced
> str(A$aov[[2]])
List of 9
$ coefficients : Named num [1:3] -0.00757 -0.01057 -0.00746
..- attr(*, "names")= chr [1:3] "Adult_Group1" "Sex1" "Adult_Group1:Sex1"
$ residuals : Named num [1:29] 0.04596 -0.00541 0.41315 -0.24305 -0.06205 ...
..- attr(*, "names")= chr [1:29] "2" "3" "4" "5" ...
$ effects : Named num [1:29] 0.0983 -0.1066 -0.0677 -0.305 -0.0284 ...
..- attr(*, "names")= chr [1:29] "Adult_Group1" "Sex1" "Adult_Group1:Sex1" "" ...
$ rank : int 3
$ fitted.values: Named num [1:29] 4.16e-17 6.51e-17 4.51e-02 3.49e-02 -1.90e-02 ...
..- attr(*, "names")= chr [1:29] "2" "3" "4" "5" ...
$ assign : int [1:3] 1 2 4
$ qr :List of 5
..$ qr : num [1:29, 1:3] -9.30 -5.97e-17 -3.23e-01 -2.50e-01 1.36e-01 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:29] "2" "3" "4" "5" ...
.. .. ..$ : chr [1:3] "Adult_Group1" "Sex1" "Adult_Group1:Sex1"
.. ..- attr(*, "assign")= int [1:3] 1 2 4
..$ qraux: num [1:3] 1 1 1.28
..$ pivot: int [1:3] 1 2 3
..$ tol : num 1e-07
..$ rank : int 3
..- attr(*, "class")= chr "qr"
$ df.residual : int 26
$ terms :Classes 'terms', 'formula' language value ~ Adult_Group + Sex + Region + Adult_Group:Sex + Adult_Group:Region + Sex:Region + Adult_Group:Sex:Region
.. ..- attr(*, "variables")= language list(value, Adult_Group, Sex, Region)
.. ..- attr(*, "factors")= int [1:4, 1:7] 0 1 0 0 0 0 1 0 0 0 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:4] "value" "Adult_Group" "Sex" "Region"
.. .. .. ..$ : chr [1:7] "Adult_Group" "Sex" "Region" "Adult_Group:Sex" ...
.. ..- attr(*, "term.labels")= chr [1:7] "Adult_Group" "Sex" "Region" "Adult_Group:Sex" ...
.. ..- attr(*, "order")= int [1:7] 1 1 1 2 2 2 3
.. ..- attr(*, "intercept")= int 1
.. ..- attr(*, "response")= int 1
.. ..- attr(*, ".Environment")=<environment: 0x000000005c411db8>
- attr(*, "class")= chr [1:2] "aov" "lm"
So I guess from another level, how do I get extract Sum Sq from either,
summary(A$aov[[2]]) or A$aov[[2]]
Would be great to learn how do this since str confuses me.

Extracting results from a `lmermod` object

I would like to extract some results from a lmermod object
require(lme4)
(fm1 <- lmer(Yield ~ 1|Batch, Dyestuff))
This produces
Linear mixed model fit by REML ['lmerMod']
Formula: Yield ~ 1 | Batch
Data: Dyestuff
REML criterion at convergence: 319.6543
Random effects:
Groups Name Std.Dev.
Batch (Intercept) 42.00
Residual 49.51
Number of obs: 30, groups: Batch, 6
Fixed Effects:
(Intercept)
1527
In particular, I would like to extract the standard devations of the 2 random effects, ie 42.00 and 49.51. I guess there may be a built-in method to do this, but I couldn't find it quickly so I thought I should be able to find it by using str(fm1), which produces this:
Formal class 'lmerMod' [package "lme4"] with 13 slots
..# resp :Reference class 'lmerResp' [package "lme4"] with 9 fields
.. ..$ Ptr :<externalptr>
.. ..$ mu : num [1:30] 1510 1510 1510 1510 1510 ...
.. ..$ offset : num [1:30] 0 0 0 0 0 0 0 0 0 0 ...
.. ..$ sqrtXwt: num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ sqrtrwt: num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ weights: num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ wtres : num [1:30] 35.1 -69.9 -69.9 10.1 70.1 ...
.. ..$ y : num [1:30] 1545 1440 1440 1520 1580 ...
.. ..$ REML : int 1
.. ..and 26 methods, of which 14 are possibly relevant:
.. .. allInfo, copy#envRefClass, initialize, initialize#lmResp,
.. .. initializePtr, initializePtr#lmResp, objective, ptr, ptr#lmResp,
.. .. setOffset, setResp, setWeights, updateMu, wrss
..# Gp : int [1:2] 0 6
..# call : language lmer(formula = Yield ~ 1 | Batch, data = Dyestuff)
..# frame :'data.frame': 30 obs. of 2 variables:
.. ..$ Yield: num [1:30] 1545 1440 1440 1520 1580 ...
.. ..$ Batch: Factor w/ 6 levels "A","B","C","D",..: 1 1 1 1 1 2 2 2 2 2 ...
.. ..- attr(*, "terms")=Classes 'terms', 'formula' length 3 Yield ~ 1 + Batch
.. .. .. ..- attr(*, "variables")= language list(Yield, Batch)
.. .. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. ..$ : chr [1:2] "Yield" "Batch"
.. .. .. .. .. ..$ : chr "Batch"
.. .. .. ..- attr(*, "term.labels")= chr "Batch"
.. .. .. ..- attr(*, "order")= int 1
.. .. .. ..- attr(*, "intercept")= int 1
.. .. .. ..- attr(*, "response")= int 1
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. .. .. ..- attr(*, "predvars")= language list(Yield, Batch)
.. .. .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "factor"
.. .. .. .. ..- attr(*, "names")= chr [1:2] "Yield" "Batch"
.. .. .. ..- attr(*, "predvars.fixed")= language list(Yield)
.. ..- attr(*, "formula")=Class 'formula' length 3 Yield ~ 1 | Batch
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
..# flist :List of 1
.. ..$ Batch: Factor w/ 6 levels "A","B","C","D",..: 1 1 1 1 1 2 2 2 2 2 ...
.. ..- attr(*, "assign")= int 1
..# cnms :List of 1
.. ..$ Batch: chr "(Intercept)"
..# lower : num 0
..# theta : num 0.848
..# beta : num 1527
..# u : num [1:6] -20.755 0.461 33.669 -27.212 66.877 ...
..# devcomp:List of 2
.. ..$ cmp : Named num [1:10] 9.15 1.88 61495.41 9590.84 71086.25 ...
.. .. ..- attr(*, "names")= chr [1:10] "ldL2" "ldRX2" "wrss" "ussq" ...
.. ..$ dims: Named int [1:12] 30 30 1 29 1 6 1 1 0 1 ...
.. .. ..- attr(*, "names")= chr [1:12] "N" "n" "p" "nmp" ...
..# pp :Reference class 'merPredD' [package "lme4"] with 18 fields
.. ..$ Lambdat:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:6] 0 1 2 3 4 5
.. .. .. ..# p : int [1:7] 0 1 2 3 4 5 6
.. .. .. ..# Dim : int [1:2] 6 6
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:6] 0.848 0.848 0.848 0.848 0.848 ...
.. .. .. ..# factors : list()
.. ..$ LamtUt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:30] 0 0 0 0 0 1 1 1 1 1 ...
.. .. .. ..# p : int [1:31] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..# Dim : int [1:2] 6 30
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:30] 0.848 0.848 0.848 0.848 0.848 ...
.. .. .. ..# factors : list()
.. ..$ Lind : int [1:6] 1 1 1 1 1 1
.. ..$ Ptr :<externalptr>
.. ..$ RZX : num [1:6, 1] 1.98 1.98 1.98 1.98 1.98 ...
.. ..$ Ut :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:30] 0 0 0 0 0 1 1 1 1 1 ...
.. .. .. ..# p : int [1:31] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..# Dim : int [1:2] 6 30
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : chr [1:6] "A" "B" "C" "D" ...
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
.. .. .. ..# factors : list()
.. ..$ Utr : num [1:6] 6384 6481 6634 6354 6787 ...
.. ..$ V : num [1:30, 1] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ VtV : num [1, 1] 30
.. ..$ Vtr : num 45825
.. ..$ X : num [1:30, 1] 1 1 1 1 1 1 1 1 1 1 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:30] "1" "2" "3" "4" ...
.. .. .. ..$ : chr "(Intercept)"
.. .. ..- attr(*, "assign")= int 0
.. ..$ Xwts : num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ Zt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:30] 0 0 0 0 0 1 1 1 1 1 ...
.. .. .. ..# p : int [1:31] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..# Dim : int [1:2] 6 30
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : chr [1:6] "A" "B" "C" "D" ...
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
.. .. .. ..# factors : list()
.. ..$ beta0 : num 0
.. ..$ delb : num 1527
.. ..$ delu : num [1:6] -20.755 0.461 33.669 -27.212 66.877 ...
.. ..$ theta : num 0.848
.. ..$ u0 : num [1:6] 0 0 0 0 0 0
.. ..and 42 methods, of which 30 are possibly relevant:
.. .. b, beta, CcNumer, copy#envRefClass, initialize, initializePtr,
.. .. installPars, L, ldL2, ldRX2, linPred, P, ptr, RX, RXdiag, RXi,
.. .. setBeta0, setDelb, setDelu, setTheta, solve, solveU, sqrL, u, unsc,
.. .. updateDecomp, updateL, updateLamtUt, updateRes, updateXwts
..# optinfo:List of 7
.. ..$ optimizer: chr "bobyqa"
.. ..$ control :List of 1
.. .. ..$ iprint: int 0
.. ..$ derivs :List of 2
.. .. ..$ gradient: num 1.61e-07
.. .. ..$ Hessian : num [1, 1] 14.1
.. ..$ conv :List of 2
.. .. ..$ opt : int 0
.. .. ..$ lme4: list()
.. ..$ feval : int 16
.. ..$ warnings : list()
.. ..$ val : num 0.848
...but this leaves me none the wiser.
lme4 supplies VarCorr for extracting variance and correlation components:
varcor <- VarCorr(fm1)
as.data.frame(varcor)
# grp var1 var2 vcov sdcor
#1 Batch (Intercept) <NA> 1764.05 42.0006
#2 Residual <NA> <NA> 2451.25 49.5101

How to extract "fixed effect design matrix" from glmer model object

The call mF#X should return fixed effect design matrix (necessary for marginal and conditional R^2 in glmm).
However it does not work.
Is even such matrix listed in model structure?
I appreciate any suggestions.
str(mF)
Formal class 'glmerMod' [package "lme4"] with 13 slots
..# resp :Reference class 'glmResp' [package "lme4"] with 11 fields
.. ..$ Ptr :<externalptr>
.. ..$ mu : num [1:480] 0.168 0.356 0.168 0.356 0.284 ...
.. ..$ offset : num [1:480] 0 0 0 0 0 0 0 0 0 0 ...
.. ..$ sqrtXwt: num [1:480] 0.373 0.479 0.373 0.479 0.451 ...
.. ..$ sqrtrwt: num [1:480] 2.68 2.09 2.68 2.09 2.22 ...
.. ..$ weights: num [1:480] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ wtres : num [1:480] -0.449 -0.744 -0.449 1.344 -0.629 ...
.. ..$ y : num [1:480] 0 0 0 1 0 0 0 1 0 0 ...
.. ..$ eta : num [1:480] -1.603 -0.591 -1.603 -0.591 -0.927 ...
.. ..$ family :List of 11
.. .. ..$ family : chr "binomial"
.. .. ..$ link : chr "logit"
.. .. ..$ linkfun :function (mu)
.. .. ..$ linkinv :function (eta)
.. .. ..$ variance :function (mu)
.. .. ..$ dev.resids:function (y, mu, wt)
.. .. ..$ aic :function (y, n, mu, wt, dev)
.. .. ..$ mu.eta :function (eta)
.. .. ..$ validmu :function (mu)
.. .. ..$ valideta :function (eta)
.. .. ..$ simulate :function (object, nsim)
.. .. ..- attr(*, "class")= chr "family"
.. ..$ n : num [1:480] 1 1 1 1 1 1 1 1 1 1 ...
.. ..and 41 methods, of which 29 are possibly relevant:
.. .. aic, allInfo, allInfo#lmResp, copy#envRefClass, devResid, fam,
.. .. initialize, initialize#lmResp, initializePtr, Laplace, link, muEta, ptr,
.. .. ptr#lmResp, resDev, setOffset, setResp, setTheta, setWeights, sqrtWrkWt,
.. .. theta, updateMu, updateMu#lmResp, updateWts, variance, wrkResids,
.. .. wrkResp, wrss, wtWrkResp
..# Gp : int [1:3] 0 60 72
..# call : language lme4::glmer(formula = Colour ~ Treatment + Habitat + (1 | Population) + (1 | Container), data = Data, family = "binomial", control = structure(list( ...
..# frame :'data.frame': 480 obs. of 5 variables:
.. ..$ Colour : int [1:480] 0 0 0 1 0 0 0 1 0 0 ...
.. ..$ Treatment : Factor w/ 2 levels "Cont","Exp": 1 2 1 2 1 2 1 2 1 2 ...
.. ..$ Habitat : Factor w/ 2 levels "A","B": 1 1 1 1 2 2 2 2 1 1 ...
.. ..$ Population: int [1:480] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ Container : int [1:480] 2 2 2 2 2 2 2 2 4 4 ...
.. ..- attr(*, "terms")=Classes 'terms', 'formula' length 3 Colour ~ Treatment + Habitat + (1 + Population) + (1 + Container)
.. .. .. ..- attr(*, "variables")= language list(Colour, Treatment, Habitat, Population, Container)
.. .. .. ..- attr(*, "factors")= int [1:5, 1:4] 0 1 0 0 0 0 0 1 0 0 ...
.. .. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. ..$ : chr [1:5] "Colour" "Treatment" "Habitat" "Population" ...
.. .. .. .. .. ..$ : chr [1:4] "Treatment" "Habitat" "Population" "Container"
.. .. .. ..- attr(*, "term.labels")= chr [1:4] "Treatment" "Habitat" "Population" "Container"
.. .. .. ..- attr(*, "order")= int [1:4] 1 1 1 1
.. .. .. ..- attr(*, "intercept")= int 1
.. .. .. ..- attr(*, "response")= int 1
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. .. .. ..- attr(*, "predvars")= language list(Colour, Treatment, Habitat, Population, Container)
.. .. .. ..- attr(*, "dataClasses")= Named chr [1:5] "numeric" "factor" "factor" "numeric" ...
.. .. .. .. ..- attr(*, "names")= chr [1:5] "Colour" "Treatment" "Habitat" "Population" ...
.. .. .. ..- attr(*, "predvars.fixed")= language list(Colour, Treatment, Habitat)
.. ..- attr(*, "formula")=Class 'formula' length 3 Colour ~ Treatment + Habitat + (1 | Population) + (1 | Container)
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
..# flist :List of 2
.. ..$ Container : Factor w/ 60 levels "2","4","6","8",..: 1 1 1 1 1 1 1 1 2 2 ...
.. ..$ Population: Factor w/ 12 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
.. ..- attr(*, "assign")= int [1:2] 1 2
..# cnms :List of 2
.. ..$ Container : chr "(Intercept)"
.. ..$ Population: chr "(Intercept)"
..# lower : num [1:2] 0 0
..# theta : num [1:2] 0.0761 1.0537
..# beta : num [1:3] -1.251 1.012 0.676
..# u : num [1:72] -0.05 0.0254 -0.05 0.1008 -0.05 ...
..# devcomp:List of 2
.. ..$ cmp : Named num [1:11] 27.3 8.5 438.1 10.6 448.7 ...
.. .. ..- attr(*, "names")= chr [1:11] "ldL2" "ldRX2" "wrss" "ussq" ...
.. ..$ dims: Named int [1:14] 480 480 3 477 2 72 1 1 0 2 ...
.. .. ..- attr(*, "names")= chr [1:14] "N" "n" "p" "nmp" ...
..# pp :Reference class 'merPredD' [package "lme4"] with 18 fields
.. ..$ Lambdat:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:72] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..# p : int [1:73] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..# Dim : int [1:2] 72 72
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:72] 0.0761 0.0761 0.0761 0.0761 0.0761 ...
.. .. .. ..# factors : list()
.. ..$ LamtUt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:960] 0 60 0 60 0 60 0 60 0 60 ...
.. .. .. ..# p : int [1:481] 0 2 4 6 8 10 12 14 16 18 ...
.. .. .. ..# Dim : int [1:2] 72 480
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:960] 0.0284 0.3935 0.0365 0.5046 0.0284 ...
.. .. .. ..# factors : list()
.. ..$ Lind : int [1:72] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ Ptr :<externalptr>
.. ..$ RZX : num [1:72, 1:3] 0.124 0.125 0.124 0.125 0.124 ...
.. ..$ Ut :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:960] 0 60 0 60 0 60 0 60 0 60 ...
.. .. .. ..# p : int [1:481] 0 2 4 6 8 10 12 14 16 18 ...
.. .. .. ..# Dim : int [1:2] 72 480
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : chr [1:72] "2" "4" "6" "8" ...
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:960] 0.373 0.373 0.479 0.479 0.373 ...
.. .. .. ..# factors : list()
.. ..$ Utr : num [1:72] -0.094 -0.018 -0.094 0.058 -0.094 ...
.. ..$ V : num [1:480, 1:3] 0.373 0.479 0.373 0.479 0.451 ...
.. ..$ VtV : num [1:3, 1:3] 92.7 0 0 48.3 48.3 ...
.. ..$ Vtr : num [1:3] 15.738 0.879 3.455
.. ..$ X : num [1:480, 1:3] 1 1 1 1 1 1 1 1 1 1 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:480] "1" "2" "3" "4" ...
.. .. .. ..$ : chr [1:3] "(Intercept)" "TreatmentExp" "HabitatB"
.. .. ..- attr(*, "assign")= int [1:3] 0 1 2
.. .. ..- attr(*, "contrasts")=List of 2
.. .. .. ..$ Treatment: chr "contr.treatment"
.. .. .. ..$ Habitat : chr "contr.treatment"
.. ..$ Xwts : num [1:480] 0.373 0.479 0.373 0.479 0.451 ...
.. ..$ Zt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..# i : int [1:960] 0 60 0 60 0 60 0 60 0 60 ...
.. .. .. ..# p : int [1:481] 0 2 4 6 8 10 12 14 16 18 ...
.. .. .. ..# Dim : int [1:2] 72 480
.. .. .. ..# Dimnames:List of 2
.. .. .. .. ..$ : chr [1:72] "2" "4" "6" "8" ...
.. .. .. .. ..$ : NULL
.. .. .. ..# x : num [1:960] 1 1 1 1 1 1 1 1 1 1 ...
.. .. .. ..# factors : list()
.. ..$ beta0 : num [1:3] 0 0 0
.. ..$ delb : num [1:3] 0 0 0
.. ..$ delu : num [1:72] -0.05 0.0254 -0.05 0.1008 -0.05 ...
.. ..$ theta : num [1:2] 0.0761 1.0537
.. ..$ u0 : num [1:72] 0 0 0 0 0 0 0 0 0 0 ...
.. ..and 42 methods, of which 30 are possibly relevant:
.. .. b, beta, CcNumer, copy#envRefClass, initialize, initializePtr,
.. .. installPars, L, ldL2, ldRX2, linPred, P, ptr, RX, RXdiag, RXi, setBeta0,
.. .. setDelb, setDelu, setTheta, solve, solveU, sqrL, u, unsc, updateDecomp,
.. .. updateL, updateLamtUt, updateRes, updateXwts
..# optinfo:List of 7
.. ..$ optimizer: chr "Nelder_Mead"
.. ..$ control :List of 3
.. .. ..$ xst : num [1:5] 0.02 0.02 0.0721 0.0421 0.0418
.. .. ..$ xt : num [1:5] 1.00e-05 1.00e-05 3.60e-05 2.11e-05 2.09e-05
.. .. ..$ verbose: int 0
.. ..$ derivs :List of 2
.. .. ..$ gradient: num [1:5] 4.64e-05 9.60e-05 -6.73e-05 -6.46e-05 -1.26e-04
.. .. ..$ Hessian : num [1:5, 1:5] 2.644 -0.247 0.162 -1.023 -0.625 ...
.. ..$ conv :List of 2
.. .. ..$ opt : num 0
.. .. ..$ lme4: list()
.. ..$ feval : num 232
.. ..$ warnings : list()
.. ..$ val : num [1:5] 0.0761 1.0537 -1.2511 1.0118 0.676
You can use the function model.matrix to obtain the fixed-effects design matrix:
model.matrix(fit)
where fit is the object returned by glmer.

Resources