[R] Computation efficiency with lme in looping

2007-08-31 Thread Gang Chen
I'm running a mixed-effects model with lme in a big for loop of 20,000 iterations. It would take from 20 to 100 hours to finish a typical analysis depending on the complexity of the model. However in the model Y = X*beta + Z*b + e X and Z are always the same for all the iterations, and the

[R] logic operation on an array

2007-08-28 Thread Gang Chen
I want to check whether all the components of a vector (or an array) are 0, and if they are I will skip the later computations. Of course I can create a loop to go through all the components. However is there an R function for this purpose more efficient than looping? Thanks a lot, Gang

Re: [R] within-subject factors in lme

2007-08-22 Thread Gang Chen
Hi Lorenz, I really appreciate your comments. If I understand correctly, you want to include the interactions between the random and fixed terms? Yes that is exactly I wanted to model. This is done like: model.lme - lme(Beta ~ Trust*Sex*Freq, random =

[R] within-subject factors in lme

2007-08-20 Thread Gang Chen
I'm trying to run a 3-way within-subject anova in lme with 3 fixed factors (Trust, Sex, and Freq), but get stuck with handling the random effects. As I want to include all the possible random effects in the model, it would be something more or less equivalent to using aov fit.aov -

[R] Memory problem

2007-08-09 Thread Gang Chen
I got a long list of error message repeating with the following 3 lines when running the loop at the end of this mail: R(580,0xa000ed88) malloc: *** vm_allocate(size=327680) failed (error code=3) R(580,0xa000ed88) malloc: *** error: can't allocate region R(580,0xa000ed88) malloc: *** set a

Re: [R] Memory problem

2007-08-09 Thread Gang Chen
the memory usage keep accumulating? Does each error message keep stored accumulatively in the buffer or something else? Or something is wrong with the way I'm using 'try'? Thanks, Gang On Aug 9, 2007, at 10:36 AM, Gang Chen wrote: I got a long list of error message repeating with the following

[R] fit.contrast - contrast testing with lme

2007-08-08 Thread Gang Chen
I need some help on contrast testing with lme. It seems fit.contrast in 'gmodels' package works fine for simple contrasting among levels of a factor such as fit.contrast(fit.lme, Trust, c(1,-1)) Estimate Std. Error t-value Pr(|t|) Trust c=( 1 -1 ) -0.001442638

Re: [R] Catch errors

2007-08-07 Thread Gang Chen
- operator: tag - 0 tryCatch(fit.lme - lme(Beta ~ Trust*Sex*Freq, random = ~1|Subj, Model), error=function(err) tag - 1) On Aug 6, 2007, at 6:55 PM, Seth Falcon wrote: Gang Chen [EMAIL PROTECTED] writes: I wanted something like this: tag - 0; tryCatch(fit.lme - lme(Beta ~ Trust*Sex

[R] Contrast testing with lme

2007-08-07 Thread Gang Chen
I'm trying to run a contrast with lme, but could not get it work: anova(lme(Beta ~ Trust*Sex*Freq, random = ~1|Subj, Model), L=c (TrustT:Sex:Freq=1, TrustU:Sex:Freq=-1)) Error in anova.lme(lme(Beta ~ Trust * Sex * Freq, random = ~1 | Subj, : Effects TrustT:Sex:Freq, TrustU:Sex:Freq

[R] Catch errors

2007-08-06 Thread Gang Chen
I run a linear mixed-effects model in a loop for (i in 1:N) { fit.lme - lme(Y ~ X1*X2, random = ~1|subj, Model[i]); } As the data in some iterations are all (or most) 0's, leading to the following error message from lme: Error in chol((value + t(value))/2) : the leading minor of order 1

[R] Catch errors

2007-08-06 Thread Gang Chen
I run a linear mixed-effects model in a loop for (i in 1:N) { fit.lme - lme(Y ~ X1*X2, random = ~1|subj, Model[i]); } As the data in some iterations are all (or most) 0's, leading to the following error message from lme: Error in chol((value + t(value))/2) : the leading minor of order 1

Re: [R] Catch errors

2007-08-06 Thread Gang Chen
with 'err' or just return 0 as above) --- Gang Chen [EMAIL PROTECTED] wrote: I run a linear mixed-effects model in a loop for (i in 1:N) { fit.lme - lme(Y ~ X1*X2, random = ~1|subj, Model[i]); } As the data in some iterations are all (or most) 0's, leading to the following error message

Re: [R] Catch errors

2007-08-06 Thread Gang Chen
, Stephen Tucker wrote: ?try or ?tryCatch http://www.maths.lth.se/help/R/ExceptionHandlingInR/ for example... tryCatch(lme(Y ~ X1*X2, random = ~1|subj, Model[i]), error=function(err) return(0)) (you can do something with 'err' or just return 0 as above) --- Gang Chen [EMAIL

[R] lme and aov

2007-08-03 Thread Gang Chen
I have a mixed balanced ANOVA design with a between-subject factor (Grp) and a within-subject factor (Rsp). When I tried the following two commands which I thought are equivalent, fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model); fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp,

Re: [R] lme and aov

2007-08-03 Thread Gang Chen
? Thanks, Gang On Aug 3, 2007, at 3:52 PM, Peter Dalgaard wrote: Gang Chen wrote: I have a mixed balanced ANOVA design with a between-subject factor (Grp) and a within-subject factor (Rsp). When I tried the following two commands which I thought are equivalent, fit.lme - lme(Beta ~ Grp

Re: [R] lme and aov

2007-08-03 Thread Gang Chen
corrected) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gang Chen Sent: Friday, August 03, 2007 4:01 PM To: Peter Dalgaard Cc: r-help@stat.math.ethz.ch Subject: Re: [R] lme and aov Thanks for the response! It is indeed a balanced design. The results

Re: [R] lme and aov

2007-08-03 Thread Gang Chen
Subj as factor. This is exactly the problem I had: Model$Subj was not a factor! Now they converge. A lesson well learned. Thanks a lot for the help, Gang On Aug 3, 2007, at 4:53 PM, Peter Dalgaard wrote: Gang Chen wrote: Thanks a lot for clarification! I just started to learn

Re: [R] Error message in lmer

2007-08-02 Thread Gang Chen
Thanks a lot for the response and explanation, Lorenz! It seems that I can run the analysis with 'lm' without treating subject as a random factor lm(Resp ~ Group*Cov, TestData) Thanks, Gang On Aug 2, 2007, at 5:09 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I do not think anyone has

[R] Access an entry after reading a table

2007-08-02 Thread Gang Chen
Sorry about this basic question. After reading a table, Model=read.table(ModelMat.txt, header=T) I want to get access to each entry in the table Model. However, if I do Model[1,1] I get the following, [1] A Levels: A B C My question is, how can I just get the entry A without the 2nd line

[R] Linear model without an intercept

2007-07-31 Thread Gang Chen
I would like to run a regression analysis without a constant (intercept) or a special one-way within-subject (repeated-measures) ANOVA. I'm not sure if the following command lines are correct or not: m1 - lme(Resp ~ Cond - 1, random = ~ Cond - 1 | Subj, TestData) or, m2 - lmer(Resp ~ Cond

[R] Error message in lmer

2007-07-30 Thread Gang Chen
I'm trying to run a simple one-way ANCOVA with the lmer function in R package lme4, but have encountered some conceptual problem. The data file MyData.txt is like this: Group Subj Cov Resp A 1 3.90 4.05 A2 4.05 4.25 A3 4.25 3.60 A4 3.60

[R] Using lmer with huge amount of data

2007-07-24 Thread Gang Chen
Based on the examples I've seen in using statistical analysis packages such as lmer, it seems that people usually tabulate all the input data into one file with the first line indicating the variable names (or labels), and then read the file inside R. However, in my case I can't do that

Re: [R] Using lmer with huge amount of data

2007-07-24 Thread Gang Chen
it in a loop? Thanks, Gang On Tue, 24 Jul 2007, Gang Chen wrote: Based on the examples I've seen in using statistical analysis packages such as lmer, it seems that people usually tabulate all the input data into one file with the first line indicating the variable names (or labels

[R] A simple question

2007-07-17 Thread Gang Chen
Hi all, I am a newbie of R, and have a very simple question. When I run the following t test result = t.test(weight ~ group) If I want to get the t value, I can do tvalue = result$statistic with tvalue being the following: t 1.191260 However, if I just want the number 1.191260, not the

Re: [R] A simple question

2007-07-17 Thread Gang Chen
Thank you very much! Gang On Jul 17, 2007, at 3:57 PM, Duncan Murdoch wrote: On 7/17/2007 3:36 PM, Gang Chen wrote: Hi all, I am a newbie of R, and have a very simple question. When I run the following t test result = t.test(weight ~ group) If I want to get the t value, I can do

[R] Invoke operating system command

2006-07-13 Thread Gang Chen
Hi all, How can I invoke an operating system command in R? I mean something like exclamation mark (!) inside Matlab. Thanks, Gang __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

[R] Package sem

2006-07-06 Thread Gang Chen
Hi, I am trying to run some path analysis with Dr. Fox's sem package. The number N in sem(ram, S, N) is supposed to be the total number of observations, right? However, in my situation the effective number of degrees of freedom for each observed variable is estimated by some

[R] Problem with package sem

2006-06-29 Thread Gang Chen
in library(sem) : 'sem' is not a valid package -- installed 2.0.0? Why is this? Thank you, Gang Chen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read