# [R-sig-ME] Power Analysis for Linear Mixed Model with Covariates

Steve Walker steve.walker at utoronto.ca
Sat Apr 19 00:44:09 CEST 2014

```On 2014-04-18, 6:21 PM, Gerasimos Fergadiotis wrote:
> Ben,
>
> Thank you for the link. It is very helpful as it can serve as a map for achieving my goal.
> Based on my (limited) understanding of Linear Mixed Models, the core of your simulation is a model of that looks at fixed effects of two treatments while accounting for random effects at the individual level (intercept only) and at the observation level (intercept only). Random effects are not dependent and a slope is not included in the model.
>
> I started modifying the code to tailor it to my design. The first modification I wanted to do was build a model for a continuous dependent variable which would be otherwise similar to the one you have. I changed and ran the following code:
>
> expdat <- expand.grid(kid = factor(1:30), Time = factor(1:4), Treat = c("XTx", "BAU"))
> expdat\$obs <- factor(seq(nrow(expdat)))
>
> set.seed(101)
> nsim <- 20
> beta <- c(100, -7)
> theta <- c(15, 15)
>
> ss <- simulate(~Treat + (1 | kid) + (1| Time), nsim = nsim, family = gaussian, weights = rep(25, nrow(expdat)), newdata = expdat, newparams = list(theta = theta, beta = beta))
>
> I received the following error message:
>
> In setParams(object, newparams) :
>    some parameters not specified in setParams()
>
> Assuming beta includes the intercept and fixed effect for treatment, it is not clear to me how theta should be specified and further what the implications are after choosing Family = gaussian (weights?).
>
> Any thoughts?

You need to specify the residual scale parameter, sigma.  So that would
be something like:

newparams = list(theta = theta, beta = beta, sigma = 1))

Also, I _think_ you need to also include a response variable in your
newdata.

Cheers,
Steve

>
> Thank you,
> Gerasimos
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Assistant Professor
> Speech & Hearing Sciences
> 724 SW Harrison St., RM 84B
> Portland State University
> Portland, Oregon 97201
> Phone: 503.725.2217
> Fax: 503.725.9171
> Web page: http://aaldresearch.wix.com/aald
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>>
>> Message: 3
>> Date: Fri, 18 Apr 2014 00:27:03 -0400
>> From: Ben Bolker <bbolker at gmail.com>
>> To: r-sig-mixed-models at r-project.org
>> Subject: Re: [R-sig-ME] Power Analysis for Linear Mixed Model with
>> 	Covariates
>> Message-ID: <5350A997.3080702 at gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> On 14-04-17 11:40 PM, Gerasimos Fergadiotis wrote:
>>> Hello,
>>>
>>> I was wondering if someone could point me to the right direction to
>>> conduct a power analysis for a design that includes (Levels): One
>>> Within Subjects Factor (Time(4)), Two Between Subject Factors
>>> (Treatment(2), Dosage(2)), one covariate (Language Skill at Baseline
>>> (4)). Random Effects for Intercept and Slope are typically seen in
>>> similar studies so I would like to include them as well. I spent some
>>> time with PASS 13 but it will not allow me to incorporate the
>>> covariate so I turned to R. Any ideas, thoughts, suggestions would be
>>> greatly appreciated.
>>
>>
>> Is http://rpubs.com/bbolker/11703  at all helpful?
>>
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> R-sig-mixed-models mailing list
>> R-sig-mixed-models at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>>
>> End of R-sig-mixed-models Digest, Vol 88, Issue 19
>> **************************************************
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>

```