[R] How to catch data from the different dataframes and lm problem?

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Fri Dec 28 09:55:43 CET 2007


> 1) I have a dataframe.  Based on “formulation” and “subject”, a
> dataframe is split into 4 dataframes.  The
> example is as follows.  Moreover, I want
> to calculate “test” value for these 4 dataframes.  My question is 
> that the “test” values not
> correct and I do not know where the problem is.
What does the variable "test" represent?  It isn't clear from your code 
what it means.  (Currently it looks like a cumulative rate of change of 
concentration with respect to time; are you really sure you want this?)

> 2) There are 12 “test” (y) values from 1).  Then, I want to model 
> the relationship
> between “concentration” (X) and “test” (Y) by fitting the linear 
regression,
> such lm(Y~X) and this is my target.  I
> think that if I can catch “test” (Y) values and “concentration” (X) 
> values into
> a dataframe, then I can carry out regression.  So, how to catch all 
> “test” values from
> different dataframes?  Or does anyone
> have better way to get this target?
Once you have all your "test" values, you probably want to perform a 
regression on all the data, in a single data frame, with "formulation" and 
"subject" as effects, e.g.
lm(test~concentration+formulation+subject, data=df)

If the subjects are drawn from a large population, it is better to 
represent them as random effects in a mixed effects model.
library(nlme)
lme(test~concentration+formulaion, data=df, random=~1|subject)

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.

Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.

Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.
------------------------------------------------------------------------

------------------------------------------------------------------------
This e-mail message has been scanned for Viruses and Content and cleared 
by NetIQ MailMarshal
------------------------------------------------------------------------


More information about the R-help mailing list