Sorry if I was too vague to describe what was wrong. Here is a new
explanation of what I am trying to perform.
I am basically working on a random regression model that has this following
form:
Yij=U+sd(U)+(B+sd(B))*Xij + Eij  where U and B are the mean population
intercept and slope respectively and sd(U) and sd(B) the deviations of
those means.
I am actually interested in those deviations and I would like to obtain
their estimators; Vi (=estimator of sd(U)) and Vs (estimator of sd(B)),
which should vary between 0 and 1. I indeed want to quantify the
between-individual variability in both intercept and slope of my population.
Papers such as this one (Simple means to improve the interpretability of
regression coefficients, Holger Schielzeth 2010), advise to centre and
standardize the input variables of your model.

I thus tried to standardize my model in two ways:
1)  lm.beta function from the QuantPsych package.
Here is what I wrote in the R script:
>model<-lmer(logfreq_vig~logdensity+logbiomasstrue+(1|Idtag),na.action=na.omit,
data=tabimpala)
>lm.beta(model)
and I got this message:
Error in summary(MOD)$coef : $ operator is invalid for atomic vectors
I don't know what does this mean but it might simply not work as I used the
lmer function and not a lm function. The script that you gave me may thus
be more adequate indeed...

2) scale function
Here is what I wrote:
>logdensity_scale<-scale(tabimpala$logdensity,center=TRUE,scale=TRUE)
>summary(logdensity_scale)
>logitprop_vig_scale<-scale(tabimpala$logitprop_vig)
>summary(logitprop_vig_scale)
>logbiomasstrue_scale<-scale(tabimpala$logbiomasstrue)
>summary(logbiomasstrue_scale)
The standardization worked for the 2 first variables but did not for the
last one (logitbiomasstrue_scale). Here is the r message I got for this
variable:
Error in array(x, c(length(x), 1L), if (!is.null(names(x)))
list(names(x),:attempt to change an attribute in NULL
 I did not understand as all three variables are continuous.

I am thus wondering what would be the best way to standardize my model to
obtain both Vi and Vs and how to do it in R.
The second thing that I would like to do is to obtain the CI of Vi and Vs.
Any idea on the adequate package to do so?

I hope that my message is more comprehensive this time.

  Thanks again for your time

Tommy




2013/6/24 Ben Bolker <bbolker@gmail.com>

> tommy gaillard <tommy.gaillard40@...> writes:
>
> >
> >  Dear all,
> >
> >  I am currently trying to quantify between-individual differences in
> > intercept and slope of vigilance behavior.
> >  Here is my model:
> > model<-lmer(logfreq_vig~logdensity+logbiomasstrue+(1|Idtag),
> > na.action=na.omit, data=tabimpala)
> >
> > I would need to obtain the value of Vi (estimator of the intercept
> > deviation) and Vs (=estimator of the slope deviation)
> >  with their Confidence
> > Interval.
> >    I have tried the scale function and the lm.beta function
> > to standardize
> > the variables but it is not working...
> >   Does someone would have an idea to obtain those values?
>
>   You should probably tell us what package the lm.beta function is
> from ... sos::findFn() tells me that there are two in contributed packages
> (QuantPsyc and scaleCoef). scaleCoef has been archived ...
>
>
> Looking at what QuantPsyc::lm.beta actually does:
>
> lm.beta <- function (MOD)  {
>     b <- summary(MOD)$coef[-1, 1]
>     sx <- sapply(MOD$model[-1], sd)
>     sy <- sapply(MOD$model[1], sd)
>     beta <- b * sx/sy
>     return(beta)
> }
>
> The lme4 equivalent steps would be:
>
> library(lme4)
> fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
> b <- fixef(fm1)[-1]     ## get coefficients except intercept
> mf <- model.frame(fm1)  ## pull out original data
> sx <- sapply(mf[names(b)],sd)  ## calc sd of input variables
> sy <- sd(mf[[1]])              ## sd of response
> b*sx/sy
>
> Note that this is a bit fragile (as is the original lm.beta()): it assumes
>
> * the model has an intercept
> * all the predictors are continuous responses (no factors,
>   interactions, etc etc)
> * the response is stored as the first column of the model frame
>
> It might be worth writing a more robust version of this at some point.
>
>   It's good to give reproducible examples of what you want to do
> (and specify what's not working -- don't just say "it's not working")
>
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



-- 
*Tommy Gaillard
Etudiant stagiaire CNRS*
Université de Dijon
Master 2 Recherche
Tel: 06-71-81-94-66
Email: tommy.gaillard40@gmail.com

	[[alternative HTML version deleted]]

