[R] Model vs. Observed for a lme() regression fit using two variables

CG Pettersson cg.pettersson at evp.slu.se
Thu Sep 7 21:49:18 CEST 2006

Hi Andrew,

Thanks a lot, That would give me what I want.
But using my own data and models resulted in this:

> plot(fitted(tcos31.c.cp, level=1), FCR.c$g.cp)
Error in xy.coords(x, y, xlabel, ylabel, log) :
        'x' and 'y' lengths differ

This is quite correct, as there are some missing values in the covariate
and I made the model using the 'na.action=na.omit' option.

I know there is a way of using the model to fix this, but haven´t been
able to get the code right during the afternoon.

How do I code this and where should I have looked?


On Thu, September 7, 2006 12:03 pm, Andrew Robinson said:
> Hi CG,
> I think that the best pair of summary plots are
> 1) the fitted values without random effects against the observed
>    response variable, and
> 2) fitted values with random effects against the observed response
>    variable.
> The first plot gives a summary of the overall quality of the fixed
> effects of the model, the second gives a summary of the overall
> quality of the fixed effects and random effects of the model.
> eg
> fm1 <- lme(distance ~ age, data = Orthodont)
> plot(fitted(fm1, level=0), Orthodont$distance)
> abline(0, 1, col="red")
> plot(fitted(fm1, level=1), Orthodont$distance)
> abline(0, 1, col="red")
> I hope that this helps.
> Andrew
> On Thu, Sep 07, 2006 at 11:35:40AM +0200, CG Pettersson wrote:
>> Dear all.
>> R 2.3.1, W2k.
>> I am working with a field trial series where, for the moment, I do
>> regressions using more than one covariate to explain the protein levels
>> in malting barley.
>> To do this I use lme() and a mixed call, structured by both experiment
>> (trial) and repetition in each experiment (block). Everything works
>> fine, resulting in nice working linear models using two covariates. But
>> how do I visualize this in an efficient and clear way?
>> What I want is something like the standard output from all multivariate
>> tools I have worked with (Observed vs. Predicted) with the least square
>> line in the middle. It is naturally possible to plot each covariate
>> separate, and also to use the 3d- sqatterplot in Rcmdr to plot both at
>> the same time, but I want a plain 2d plot.
>> Who has made a plotting method for this and where do I find it?
>> Or am I missing something obvious here, that this plot is easy to
>> achieve without any ready made methods?
>> Cheers
>> /CG
>> --
>> CG Pettersson, MSci, PhD Stud.
>> Swedish University of Agricultural Sciences (SLU)
>> Dept. of Crop Production Ecology. Box 7043.
>> SE-750 07 UPPSALA, Sweden.
>> +46 18 671428, +46 70 3306685
>> cg.pettersson at vpe.slu.se
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> --
> Andrew Robinson
> Department of Mathematics and Statistics            Tel: +61-3-8344-9763
> University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
> Email: a.robinson at ms.unimelb.edu.au         http://www.ms.unimelb.edu.au

CG Pettersson, MSci, PhD Stud.
Swedish University of Agricultural Sciences (SLU)
Dep. of Crop Production Ekology. Box 7043.
SE-750 07 Uppsala, Sweden
cg.pettersson at vpe.slu.se

More information about the R-help mailing list