[R-sig-ME] A question
Tom_Philippi at nps.gov
Tom_Philippi at nps.gov
Wed Feb 8 20:33:12 CET 2012
Sheida--
What you are drawing with your call to lines() is a connect-the-dots graph,
where you have a number of points with different values for weight at each
discrete value of month. The vertical bar at each month value is zigging
and zagging among all of your points at that value for month. The lines
from one month to the next are simply connecting the last value at one
month to the first at the next month. Why do you have so many points? I
suspect because you have multiple population-level predictions for
different values of BirthWeight.
What value of BirthWeight do you want your line to represent? Your graph
is only weight v month, but your second model is a response surface of
BirthWeight and month+month^2. Do you have perfectly balanced data (same
set of months for each subject)? Do you want to show a line of the
predictions for only the mean value of BirthWeight? For perhaps quantiles
of the BirthWeight distribution? For each individual value of BirthWeight
(which may or may not be each individual subject id)?
If you want to see what is going on, break apart your call to lines() by
making the fitted result a separate object:
Yfit <- fitted.lme(lme2,level=0)[order(month)]
head(Yfit)
nrow(Yfit)# probably 9 in your model without BirthWeight much larger in
model with BirthWeight
Lines(month[order(month)],Yfit[order(month)])
?fitted.lme explains the level= parameter: level=0 extracted
population-level fitted values, in your case I believe that level=1 would
give subject-level (id) fitted values (you can perform the experiment with
level=c(0:1) as in the example).
I hope that this helps steer you in the right direction.
Tom 2
ps: also, see:
fortunes::fortune(285)
about selecting a subject line more likely to attract responses from the
real gurus (not me) on this list.
-------------------------------------------
Tom Philippi, Ph.D.
Quantitative Ecologist
Inventory and Monitoring Program
National Park Service
c/o Cabrillo National Monument
1800 Cabrillo Memorial Dr
San Diego, CA 92106
(619) 523-4576
Tom_philippi at NPS.gov
http://science.nature.nps.gov/im/monitor
-------------------------------------------
sheida sarafzade
<shsarafzade at gmai
l.com> To
Sent by: r-sig-mixed-models at r-project.org
r-sig-mixed-model cc
s-bounces at r-proje shsarafzade <shsarafzade at gmail.com>
ct.org Subject
[R-sig-ME] A question
02/08/2012 08:43
PM ZE4B
Hello
I'm MSc. student in biostatistics and working on mixed effect models
I’m trying to add fitted line to scatter plot (x,y)
Here “weight” is dependent variable and “month” is time variable.
The program is:
Lme1<-Lme(weight~month+(month^2),data=DataSetName,random=~month|id)
When I use the code below:
Lines(month[order(month)],fitted.lme(lme1,level=0)[order(month)])
It draws a smooth line but when I add a covariate (like birth weight)
to my model as below:
Lme2<-lme(weight~BirthWeight+month+(month^2),data=DataSetName,random=~month|id)
And then write the code below:
Lines(month[order(month)],fitted.lme(lme2,level=0)[order(month)])
It doesn’t draw smooth line. the line is not smooth.
How can I fix this problem?
What is the role of term “level” in this code? And what are it’s option?
for more information please see attachment
Thanks a lot
_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list