[R-sig-ME] Scaling Issues

Salvador SANCHEZ COLON @@|v@dor@@nchezco|on @end|ng |rom prod|gy@net@mx
Sun Jul 21 18:17:11 CEST 2019

Hi Stephanie,

The base R function "scale" with default arguments (as in this case) first centers the columns in the df (substracting the column's mean from each entry) and then scales each of them by dividing them by its standard deviation.

I think the rest of the code is used only for getting the number of columns (numcols) in the df; assigning the scaled values to a new, updated df (dfs), etc.

I hope this helps. Best regards,


En Dom, 21 Jul, 2019 en 10:38, Stephanie Rivest <srive046 using uottawa.ca> escribió:

To: r-sig-mixed-models using r-project.org

My name is Stephanie Rivest and I've emailed this list in the past asking
questions about glmer models. I'm sorry if this is a repetitive question
that has perhaps been asked in the past, but I have not yet been able to
find an explanation on the web.

I'm using lme4 (glmer.nb) to fit a mixed effects model with the negative
binomial family. I have 173 data points, 8 independent parameters, and 1
random effect. My model is having difficulty converging and I think part of
the problem may be scaling (given the type of warnings that I get). I've
done some research on the subject and have found a couple links (
discussing what to do. In these web links, B. Bolker suggests the following
code to centre and scale predictors...

B. Bolker's Code:

numcols <- grep("^c\\.",names(df))
dfs <- df
dfs[,numcols] <- scale(dfs[,numcols])
m4 <- update(m1,data=dfs)

My questions is, what is this code doing!? When I look at the new df, it
seems completely identical to the old df, like nothing has changed. And
yet, when I fit the model with the new df, the warnings mostly go away
suggesting that whatever I did seemed to work. I would really like to
understand what is actually going on in the code above. Have all columns
been changed? Or only certain ones? Have scales actually been changed? If
so, in what way? Do they need to be backtransformed in order for me to do
my model interpretation at the end?

Thank you so much for your time,

Stephanie Rivest
Ph.D. Candidate | Candidate au Doctorat
Dept. of Biology | Dép. de Biologie
University of Ottawa | Université d'Ottawa

[[alternative HTML version deleted]]

R-sig-mixed-models using r-project.org mailing list
	[[alternative HTML version deleted]]

More information about the R-sig-mixed-models mailing list