How to specify to_predict

22 views
Skip to first unread message

pixbuf

unread,
Feb 24, 2012, 5:45:39 PM2/24/12
to ez4r
Hello, I'm a new user of ez. I have a linear mixed model like this:
math ~ I(age - 11) + I((age - 11)^2) + old4gr + (I(age - 11) +
I((age - 11)^2) | sid)
I want predicted math scores for students at age 15 (age-11=4). I
figured I could create a data frame that looked like this:
1 4 16 0
1 4 16 1
and so on. Will this work? What I can't figure out is how to specify
the column names.

Also, I wanted to check that the random effects will be included in
the prediction. I think what I want is something like this:

(if new.data is a data frame like the one above)
new.data %*% c(intercept+random.effect[1],
fixed.effect[2]+random.effect[2], fixed.effect[3]+random.effect[3])

Is this what ezPredict would do?

Thanks in advance.

pixbuf

unread,
Feb 24, 2012, 7:07:41 PM2/24/12
to ez4r
I goofed with the matrix multiplication. What I want to do is, given
the matrix new.data (100x4), and the matrix of coefficients, also
100x4, something like this:
for (i in 1:100) {
new.data[i, ] %*% t(coefficients[i,])
}

There should be a more efficient way to represent this, but it's
beyond me.

Mike Lawrence

unread,
Feb 24, 2012, 7:42:28 PM2/24/12
to ez...@googlegroups.com
On Fri, Feb 24, 2012 at 6:45 PM, pixbuf <pix...@gmail.com> wrote:
> Also, I wanted to check that the random effects will be included in
> the prediction. I think what I want is something like this:

Sorry, ezPredict only includes variance associated with the fixed
effects. The R-SIG-Mixed FAQ (http://glmm.wikidot.com/faq) has code
demonstrating how to obtain predictions that include both fixed
effects and random effects variances.

Reply all
Reply to author
Forward
0 new messages