3
votes

I have fitted a lmer model, and now I am trying to interpret the coefficients in terms of the real coefficients instead of scaled ones.

My top model is:

 lmer(logcptplus1~scale.t6+scale.logdepth+(1|location) + (1|Fyear),data=cpt, REML=TRUE)

so both the predictor variables are scaled, with one being the scaled log values. my response variable is not scaled and just logged.

to scale my predictor variables, I used the scale(data$column, center=TRUE,scale=TRUE) function in r.

The output for my model is: Fixed effects:

                Estimate Std. Error t value
  (int)         3.31363    0.15163  21.853
scale.t6       -0.34400    0.10540  -3.264
scale.logdepth -0.58199    0.06486  -8.973

so how can I obtain real estimates for my response variable from these coefficients that are scaled based on my scaled predictor variables?

NOTE: I understand how to unscale my predictor variables, just not how to unscale/transform the coefficients

Thanks

1

1 Answers

3
votes

The scale function does a z-transform of the data, which means it takes the original values, subtracts the mean, and then divides by the standard deviation.

to_scale <- 1:10
using_scale <- scale(to_scale, center = TRUE, scale = TRUE)
by_hand <- (to_scale - mean(to_scale))/sd(to_scale)
identical(as.numeric(using_scale), by_hand)
[1] TRUE

Therefore, to reverse the model coefficients all you need to do is multiply the coefficient by the standard deviation of the covariate and add the mean. The scale function holds onto the mean and sd for you. So, if we assume that your covariate values are the using_scale vector for the scale.t6 regression coefficient we can write a function to do the work for us.

get_real <- function(coef, scaled_covariate){

            # collect mean and standard deviation from scaled covariate
            mean_sd <- unlist(attributes(scaled_covariate)[-1])

            # reverse the z-transformation
             answer <- (coef * mean_sd[2]) + mean_sd[1]

            # this value will have a name, remove it
             names(answer) <- NULL

            # return unscaled coef
              return(answer)
}

get_real(-0.3440, using_scale)
[1] 4.458488

In other words, it is the same thing as unscaling your predictor variables because it is a monotonic transformation.