Skip to content

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

3 messages · Richard Cotton, Hsin-Ya Lee

#
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?)
regression,
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
------------------------------------------------------------------------
2 days later
#
Dear Richie:

1) I have a mistake in the code that ?A.split[[1]][["time"]][i]? should
replace with ?A.split[[j]][["time"]][i]?.  The ?test? value is ?auc? which
is a cumulative rate of change of concentration with respect to time.  

for (j in 1:length(A.split)){
test <- 0
for(i in 2:length(A.split[[j]][["time"]])){
    test[i] <- (A.split[[j]][["time"]][i] - A.split[[j]][["time"]][i-1]) *
(A.split[[j]][["concentration"]][i] - A.split[[j]][["concentration"]][i-1])*
0.5
    test[i]<-test[i]+test[i-1]
 }
output<-data.frame(A.split[[j]][["subject"]],A.split[[j]][["formulation"]],A.split[[j]][["time"]],A.split[[j]][["concentration"]],test)
colnames(output)<-list("subject","formulation","time","concentration","test")
show(output) 
}

subject formulation time   concentration(X) test(Y)
1       1           1    1           0.1  0.00
2       1           1    2          10.0  4.95
3       1           1    3          20.0  9.95
  subject formulation time concentration(X) test(Y)
1       1           2    1            20  0.0
2       1           2    2            25  2.5
3       1           2    3            60  20.0
  subject formulation time concentration(X) test(Y)
1       2           1    1           0.3  0.00
2       2           1    2           2.5  1.10
3       2           1    3           6.0  2.85
  subject formulation time concentration(X) test(Y)
1       2           2    1            35  0.0
2       2           2    2            40  2.5
3       2           2    3            45  5.0

2) Then, I want to pool all "concentration" (X) and pool all "test" (Y) to
perform a 
regression.  For example, I used the ?regression? function of Microsoft
Excel 2003 and intercept is -0.01894 and X is 0.185758.  I think that if I
can catch ?test? (Y) values and ?concentration? (X) values into a dataframe,
then I can use ?lm? to fit linear models.  So, how to catch all ?test?
values from different dataframes?  Or what should I do? 

Best regards,

Hsin-Ya Lee
#
Dear all:

I used lm to perform a regression in R and and intercept is -0.01894 and X
is 0.185758.  This is my target.  
Y<-(c(0,4.95,9.95,0,2.5,20,0,1.1,2.85,0,2.5,5))
X<-(c(0.1,10,20,20,25,60,0.6,2.5,6,35,40,45))
lm(Y~X)
anova(wnlm<-lm( Y~X))
summary(wnlm<-lm( Y~X))

I catch test (Y) values and concentration (X) values by myself.  Then, here
is my question.  How to ?auto-catch? test (Y) values and concentration (X)
values from the split dataframes?  Because I think that if I can catch
?test? (Y) values and ?concentration? (X) values into a dataframe, then I
can use ?lm? to fit linear models.  So, how to catch all ?test? values from
different dataframes?  Or what should I do? 

Best regards,

Hsin-Ya Lee