d_labes Hero Berlin, Germany, 20090401 15:00 Posting: # 3442 Views: 9,698 

Dear Bears, dear Rusers, dear all, recent I (The power to know is with me) had the opportunity to take a deeper look on to R and into the source code of bear. Since I am a novice in R I could not fully understand all the lot of code. But I argue that the 90% confidence interval is calculated in BANOVA.r (the part of bear which deals with the SAS GLM counterpart) but in a different manner. My interpretation of the code is: The MSE is taken from the lm() call, but point estimate is calculated by the ordinary means m_{T} and m_{R}. Any body out there: Am I right? If I am right: This is ok, as long as the design is balanced between sequences. but for unbalanced data there is a difference In SAS this is done usually via LSMeans or an ESTIMATE statement. Astonishing enough there seems no counterpart to LSMeans in R. After reading tons of Web pages it seems this another mine field like Type III sums of squares. But nevertheless there is the task to estimate the treatment effect with 90% confidence interval (from the parameter of the fitted model), i.e. from a counterpart of the ESTIMATE statement. Dear Bears have a look on to this page. Eventually this helps you. I don't understand it, because I am a novice . — Regards, Detlew 
ElMaestro Hero Denmark, 20090401 17:01 @ d_labes Posting: # 3445 Views: 8,737 

Dear DLabes, I could be wrong, but......... » My interpretation of the code is: The MSE is taken from the lm() call, but » point estimate is calculated by the ordinary means m_{T} and » m_{R}. » Any body out there: Am I right? Better let the authors answers here, but if you are right then Bear has a potential problem in the case of imbalance. But you could also ask yourself: Do I want to test if the means differ or do I want to test if the LSMeans differ? I once heard that some statisticians think that a diference in LSMeans should be tested with type III SS. After all LSMeans are means that are adjusted for all other effects, while type III SS for a factor X, corresponds to the variation caused by factor X given the presence of all other factors (thus 'single term deletions') which may be the as saying that a type III SS is the variation for factor X adjusted for the variation caused by everything else. So I may digress and ask: If type III SS provide tests for LSMeans, then which SS are appropriate for ordinary means? And why would the former be more relevant than the latter from a practical standpoint? » If I am right: This is ok, as long as the design is balanced between » sequences. but for unbalanced data there is a difference Certainly. » In SAS this is done usually via LSMeans or an ESTIMATE statement. » » Astonishing enough there seems no counterpart to LSMeans in R. After » reading tons of Web pages it seems this another mine field like Type III » sums of squares. It is quite easy to find websites with renowned statisticians who do not really believe that LSMeans are more relevant than ordinary normal oldfashioned boring means. The people who write R do it for a reason. For example some of them do not like SAS. Therefore they don't like LSMeans and type III SS. Therefore these things are not really implemented in R. It's just like getting tired of one type of random number generator and then coming up with a new one which has better attributes (better is in this regard completely in the eyes of the beholder). So can we extract LSMeans from an lm fit? No! Can we in stead extract the difference in LSMeans (test minus R) from an lm fit? Yes! And this is exactly what we need for the BE evaluation, because log(LSMean(T)/LSMean(R))=log(LSMean(T)log(LSMean(R)). As far as I know the reason has to do with differences in the way model matrices are specified in R and SAS. I was at some point thinking about asking a q about this here because I noticed that some model matrices in R are not full rank. Anyone with insight, please comment! » But nevertheless there is the task to estimate the treatment effect with » 90% confidence interval (from the parameter of the fitted model), i.e. » from a counterpart of the ESTIMATE statement. Extract the difference in LSMeans, then you have your estim T/R ratio. Extract the MSE, then you get your sigma. Calculate the 90% CI, leave from work early and enjoy the good weather. EM. 
yjlee168 Senior Kaohsiung, Taiwan, 20090401 18:38 @ ElMaestro Posting: # 3447 Views: 8,594 

Dear ElMaestro, » The people who write R do it for a reason. For example some of them do not » like SAS. Therefore they don't like LSMeans and type III SS.[...] You heard that, too. We have been quite frustrated when coding bear and tried to validate obtained results from bear with SAS counterparts. Do you remember that, when we announced bear v1.0, you once suggested that we should have Type III SS output in bear? Then we started getting more information about the differences between SAS and R. » So can we extract LSMeans from an lm fit? No! » Can we in stead extract the difference in LSMeans (test minus R) from an » lm fit? Yes! And this is exactly what we need for the BE evaluation, » because log(LSMean(T)/LSMean(R))=log(LSMean(T)log(LSMean(R))[...] Interesting points. Do you mean for unbalanced data or for all kinds here? I don't know this before. » As far as I know the reason has to do with differences in the way model » matrices are specified in R and SAS. I was at some point thinking about » asking a q about this here because I noticed that some model matrices in R » are not full rank. Anyone with insight, please comment! We maybe need to go to some UseR! Forums to find out. — All the best, Yungjin Lee bear v2.8.33: created by Hsinya Lee & Yungjin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) > here 
ElMaestro Hero Denmark, 20090401 19:28 (edited by ElMaestro on 20090402 05:56) @ yjlee168 Posting: # 3448 Views: 8,604 

Hi again, » » And this is exactly what we need for the BE evaluation, » » because log(LSMean(T)/LSMean(R))=log(LSMean(T)log(LSMean(R))[...]» » Interesting points. Do you mean for unbalanced data or for all kinds » here? I don't know this before. Yes, this is actually the easy part. If you use something like this: TotallyFantasticFit=lm(lnAUC~Subj+Seq+Per+Trt) Then you can get the difference in LSMeans via: summary(TotallyFantasticFit) Note that the sign of the treatment effect will be depending on the way the data have been garbled initially: It will be equal to either (LSMean(T)LSMean(R)) or to (LSMean(R)LSMean(T)) so be aware of the sign. The alternative way to do it is to simply calculate LSMeans by averaging over the sequences, see Chow & Liu's book. It is solely a matter of taste. Your end result (T/R ratio) will be the same regardless. And it will work for balanced as well as unbalanced datasets. EM. Edit 02.04.09: Error in my explanation of LSMean calculation. 
yjlee168 Senior Kaohsiung, Taiwan, 20090401 18:15 @ d_labes Posting: # 3446 Views: 8,695 

Dear D. Labes, Please allow me to quickly and briefly respond this message. » My interpretation of the code is: The MSE is taken from the lm() call, but » point estimate is calculated by the ordinary means m_{T} and m_{R}. » Any body out there: Am I right? Exactly. » If I am right: This is ok, as long as the design is balanced between » sequences. but for unbalanced data there is a difference We have discussed this back to previous versions. Indeed, we should use lme() (counterpart to SAS PROC MIXED) to analyze unbalanced data, not using lm() here. We forget to take care of this part so far. Many thanks for reminding us. We need to write a conditional statement when doing 2x2x2 crossover design to separate the analysis of unbalanced data using lme(). » Astonishing enough there seems no counterpart to LSMeans in R. After » reading tons of Web pages it seems this another mine field like Type III » sums of squares. Exactly, just like replied message by ElMaestro. In R, there is no counterpart to LSMeans. » But nevertheless there is the task to estimate the treatment effect with » 90% confidence interval (from the parameter of the fitted model), i.e. » from a counterpart of the ESTIMATE statement. In R, I think lme() should be able to solve the problem easily and nicely. We have previously validated the results done with lme() for unbalanced data compared with SAS PROC MIXED. We got the same. Unfortunately, we just forgot to implement this into bear at that moment. » Dear Bears have a look on to this page. » Eventually this helps you. I don't understand it, because I am » a novice . Thanks for your pointer. — All the best, Yungjin Lee bear v2.8.33: created by Hsinya Lee & Yungjin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) > here 
ElMaestro Hero Denmark, 20090401 19:47 @ yjlee168 Posting: # 3450 Views: 8,558 

Hi again again, » We have discussed this back to previous versions. Indeed, we should use » lme() (counterpart to SAS PROC MIXED) to analyze unbalanced data, not using » lm() here. We forget to take care of this part so far. Many thanks for » reminding us. We need to write a conditional statement when doing 2x2x2 » crossover design to separate the analysis of unbalanced data using lme(). I have come to realise* that one should be safe enough with lm for unbalanced data as long as we talk 2,2,2BE studies, but you might want to make sure to use LSMeans as indicated in the previous post rather than means (at least if your intention is to get SASlike results). As soon as we talk more complex designs and/or inclusion of subjects with missing period values a switch to a mixed muddle/REML is mandatory. To cut it all short: lme will always work for you, even with 2,2,2studies but from a computational viewpont lme for 2,2,2BE is somehow overkill. On a modern computer it takes a split second anyway and you never see he difference in terms of computational effort. EM. *: Didn't dlabes some time last year explain this? I remember I tried really hard to challenge lm with an unbalanced dataset to see if I could get it "wrong" with lm due to imbalance in a 2,2,2study, but I failed to do that. 
yjlee168 Senior Kaohsiung, Taiwan, 20090404 21:11 @ ElMaestro Posting: # 3467 Views: 8,604 

Dear ElMaestro, We have tried your method with lm() and it worked perfectly and was just exactly the same as the SAS output using balanced and unbalanced data. We also tried the method (this link) pointed by D. Labes, and it didn't work. We're still trying to find out why it didn't work. It could be due to that the dataset we used to test included a missing value. I will post the final result here later if necessary. Now I post the results obtained from your suggested method here with balanced and unbalanced dataset. Balanced dataset with bear Statistical analysis (ANOVA(lm)) Balanced dataset with SAS only showing Cmax here [...]Least Squares Means Unbalanced dataset using bear [...]
**************** Classical (Shortest) 90% C.I. for lnCmax **************** Unbalanced with SAS only showing Cmax here {...] » *: Didn't dlabes some time last year explain this? I remember I tried » really hard to challenge lm with an unbalanced dataset to see if I could » get it "wrong" with lm due to imbalance in a 2,2,2study, but I failed to » do that. Yes, you're right. Sorry about my poor memory. Thank you for your suggestions. — All the best, Yungjin Lee bear v2.8.33: created by Hsinya Lee & Yungjin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) > here 
ElMaestro Hero Denmark, 20090405 11:23 @ yjlee168 Posting: # 3472 Views: 8,469 

Hi, lm and lme should give you the same result for balanced and unbalanced 2,2,2anova and 90% CI. If you get dissimilar results then try to force lme to exclude subjects with a mising period. I think it is via setting the na.action to "na.omit" or "na.exclude" or something like that. Not sure, not able to test it right now. Alternatively, to be completely safe you could also simply cleanup the dataframe or dataset and remove the subject(s) in question. Depending on how you implement your derivation of LSMeans this might actually be a good option, avoiding perhaps some confusion. Best regards EM. 
yjlee168 Senior Kaohsiung, Taiwan, 20090406 05:50 @ ElMaestro Posting: # 3479 Views: 8,545 

Dear EM, » lm and lme should give you the same result for balanced and unbalanced » 2,2,2anova and 90% CI. Exactly. » If you get dissimilar results then try to force lme to exclude subjects » with a mising period. I think it is via setting the na.action to "na.omit" » or "na.exclude" or something like that. Not sure, not able to test it right » now.[...] We will try that later. Thank you so much. — All the best, Yungjin Lee bear v2.8.33: created by Hsinya Lee & Yungjin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) > here 
d_labes Hero Berlin, Germany, 20090407 06:46 @ yjlee168 Posting: # 3489 Views: 8,469 

Dear Yungyin, can you give details of the dataset? — Regards, Detlew 
yjlee168 Senior Kaohsiung, Taiwan, 20090407 11:44 @ d_labes Posting: # 3495 Views: 8,537 

Dear D. Labes, Sure. The dataset is real and is used for the balanced study. subj,trt,seq,prd,Cmax,AUC0t,AUC0INF,LnCmax,LnAUC0t,LnAUC0INF Since we don't any unbalanced dataset on hand, we simply delete the Subject #14 from the above balanced dataset to obtain the following unbalanced dataset. subj,trt,seq,prd,Cmax,AUC0t,AUC0INF,LnCmax,LnAUC0t,LnAUC0INF — All the best, Yungjin Lee bear v2.8.33: created by Hsinya Lee & Yungjin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) > here 
d_labes Hero Berlin, Germany, 20090406 08:49 @ yjlee168 Posting: # 3481 Views: 8,715 

Dear Yungjin, dear ElMaestro, sorry but I was a little short in time last week to share the discussion, which I have kicked off naively. Without delving into the details of your arguments/discussion contributions: The key is that we are fitting a linear model to our data, because we are interested in estimating the difference between our treatments/formulations in respect to some target parameters (AUC, Cmax or whatever, logtransformed or not). And this from our fitted model, with all the eventually existing cofactors included to account for their influence. As ElMaestro has pointed out, this can be done via the coefficients of the model (including a 90% confidence interval for the equivalence test) associated to the treatment. But this is only true if your have only two treatments/formulations of interest, because lm() or lme() estimate the first of the coefficients to zero. If your order of treatments is so that reference comes first, then TR is the value of the coefficient associated with test. If you consider a broader class of crossover designs with more treatments/formulations, f.i. 3x3 (three treatment, 3 period) or 4x4 crossover, you have to deal with the estimation of more then one contrast, which you cannot obtain from the confidence intervals of the coefficients itself. You have to estimate the difference between the coefficients of interest, with their variation and associated 90% confidence intervals. If you deal with that via LSMeans or not, is a matter of taste I think. If I understand the SAS ESTIMATE statement and the R counterpart described on the WEB site I pointed to above . All stuff in respect of LSMeans (coefficients to average over all other effects present in the model) vanishes, if you go to the LSMeans differences. The only task left is to estimate differences in the treatment associated model coefficients. Then the only task is to identify which piece of R will do the task for you. Or you must/can do it by yourself using the coefficients and the residual variance and associated df of the fitted model. BTW: @ElMaestro: Seems part of the R community is seeing SAS as "The dark side of the power (to know)". Seems every one needs some M$ (in german "Klein weich") to claim one self can do better. (this is not meant in respect to you personally, but a BTW to your answer to me above concerning Rusers and Rdevelopers) — Regards, Detlew 
yjlee168 Senior Kaohsiung, Taiwan, 20090407 12:05 @ d_labes Posting: # 3496 Views: 8,535 

Dear D. Labes, » If you consider a broader class of crossover designs with more » treatments/formulations, f.i. 3x3 (three treatment, 3 period) or 4x4 » [...] Indeed. » » If you deal with that via LSMeans or not, is a matter of taste I think. » If I understand the SAS ESTIMATE statement and the R counterpart described » on the WEB site I pointed to above . We've tried that without success. Some error messages occurred with tested dataset as posted previously. We're still working on it. — All the best, Yungjin Lee bear v2.8.33: created by Hsinya Lee & Yungjin Lee Kaohsiung, Taiwan http://pkpd.kmu.edu.tw/bear Download link (updated) > here 