[R] Trouble setting up correlation structure in lme

2008-01-25 Thread Gang Chen
Hi, I'm trying to set up AR(1) as a correlation structure in modeling some data (attached file data.txt in text format) with lme, but have trouble getting it to work. Incent, Correctness, and Oppor are 3 categorical variables, Beta is a response variable, and Time is an equally-spaced variable wit

[R] Trouble receiving messages from the mailing list

2008-01-17 Thread Gang Chen
For some unknown reason I stopped receiving any messages from the R- help mailing list. See if this test gets through. Thanks, Gang __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] glht() and contrast() comparison

2008-01-11 Thread Gang Chen
With the example you provided, it seems both glht() and contrast() work fine. Based on my limited experience with contrast(), if you encounter such an error message you just mentioned, check > dat.lme$apVar You might see something like this [1] "Non-positive definite approximate variance

[R] Residual deviance in glm

2008-01-10 Thread Gang Chen
I'm running a categorical data analysis with a two-way design of nominal by ordinal structure like the Political Ideology Example (Table 9.5) in Agresti's book Categorical Data Analysis. The nominal variable is Method while the ordinal variable is Quality (Bad, Moderate, Good, Excellent). I

Re: [R] Create a new dataframe from an existing dataframe

2008-01-08 Thread Gang Chen
ts >> x.new <- x[, -1] # delete "A" >> x.new$FreqD <- counts # add new column >> # print out unique entries >> unique(x.new) >B C D FreqD > 1 B1 C1 D1 3 > 2 B2 C1 D1 3 > 4 B2 C2 D2 2 > 7 B1 C2 D2 2 >> > > > On

Re: [R] Create a new dataframe from an existing dataframe

2008-01-07 Thread Gang Chen
Sorry the new column in DF2 should be called FreqD instead of FreqA. How can I get DF2 with aggregate? Gang On Jan 7, 2008, at 2:38 PM, Gang Chen wrote: > Yes, I misstated it when I said that I would keep B and C. I want to > collapse column A, but count the frequency of D as a new col

Re: [R] Create a new dataframe from an existing dataframe

2008-01-07 Thread Gang Chen
C1 D243 B2 C2 D123 B2 C2 D243 Thanks, Gang On Jan 7, 2008, at 2:06 PM, Duncan Murdoch wrote: > On 1/7/2008 1:28 PM, Gang Chen wrote: >> I have a dataframe DF with 4 columns (variables) A, B, C, and D, >> and want to create a new dataframe DF2 by keeping B and C

Re: [R] glm for nominal X ordinal

2008-01-07 Thread Gang Chen
Thanks a lot! This is exactly what I wanted. Gang On Jan 5, 2008, at 2:20 PM, David Winsemius wrote: > Gang Chen <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > >> Suppose I have a two-way table of nominal category (party >> affiliation) X ordinal c

[R] Create a new dataframe from an existing dataframe

2008-01-07 Thread Gang Chen
I have a dataframe DF with 4 columns (variables) A, B, C, and D, and want to create a new dataframe DF2 by keeping B and C in DF but counting the frequency of D while collapsing A. I tried by(DF$D, list(DF$B, DF$C), FUN=summary) but this is not exactly what I want. What is a good way to do it

[R] glm for nominal X ordinal

2008-01-04 Thread Gang Chen
Suppose I have a two-way table of nominal category (party affiliation) X ordinal category (political ideology): party affiliation X (3 levels) - democratic, independent, and republic political ideology Y (3 levels) - liberal, moderate, and conservative The dependent variable is the frequency (o

Re: [R] How to deal with character(0)?

2007-11-15 Thread Gang Chen
Thanks a lot for all who've provided suggestions! Gang On Nov 15, 2007, at 5:09 PM, Duncan Murdoch wrote: > On 11/15/2007 4:54 PM, Gang Chen wrote: >> I want to identify whether a variable is character(0), but get >> lost. For example, if I have >> > dd&l

[R] How to deal with character(0)?

2007-11-15 Thread Gang Chen
I want to identify whether a variable is character(0), but get lost. For example, if I have > dd<-character(0) the following doesn't seem to serve as a good identifier: > dd==character(0) logical(0) So how to detect character(0)? Thanks, Gang __

[R] Getting mean in a dataframe

2007-11-13 Thread Gang Chen
Sorry to hijack this thread. I have a similar but slightly different situation. Using the original poster's example, how to elegantly get the mean of column V2 when column V1 is either A or C and F1 is 0? Thanks, Gang On Nov 13, 2007, at 5:30 AM, Petr PIKAL wrote: > Hi > > [EMAIL PROTECTED]

Re: [R] How to create an array of list?

2007-11-09 Thread Gang Chen
cc[n, ii, jj] > } > names(sublist) <- names(MyModel) > result[[n]][[ii]] <- sublist > } > } > str(result) # see what it looks like > > > > On Nov 8, 2007 6:31 PM, Gang Chen <[EMAIL PROTECTED]> wrote: >> Thanks again for th

Re: [R] How to create an array of list?

2007-11-08 Thread Gang Chen
eplacement, so to see what the alternatives are, can you give an > explicit example of what you would like as an outcome and then how you > intend to use it. > > On Nov 8, 2007 5:19 PM, Gang Chen <[EMAIL PROTECTED]> wrote: >> Thanks for the response! >> >> I want to create

Re: [R] How to create an array of list?

2007-11-08 Thread Gang Chen
gt; > On Nov 8, 2007 4:51 PM, Gang Chen <[EMAIL PROTECTED]> wrote: >> I have trouble creating an array of lists? For example, I want to do >> something like this >> >> clist <- array(data=NA, dim=c(7, 2, 3)); >> for (n in 1:7) { >>for (ii in 1:2) { >

[R] How to create an array of list?

2007-11-08 Thread Gang Chen
I have trouble creating an array of lists? For example, I want to do something like this clist <- array(data=NA, dim=c(7, 2, 3)); for (n in 1:7) { for (ii in 1:2) { for (jj in 1:3) { if (cc[n, ii, jj] == "0") { clist[n, ii, ][[jj]] <- list(levels (MyModel[,colnames(M

[R] Trouble in creating a list

2007-11-07 Thread Gang Chen
I want to create a list based on the information from a data.frame, Model. So I tried the following: MyList <- list(colnames(Model)[2] = levels(Model$(colnames(Model)[2]))) but it failed with an error: Error: unexpected '=' in "list(colnames(Model)[2] =" I have the following problems with th

Re: [R] How to test combined effects?

2007-11-02 Thread Gang Chen
actly a partial F test. So does it mean that this only tests the average effect of those 3 terms? If so, that would be slightly different from the partial F test I was looking for, no? Gang > -G > > > > On Oct 30, 2007, at 5:26PM , Gang Chen wrote: > >> Dieter, >> >

Re: [R] How to test combined effects?

2007-10-30 Thread Gang Chen
0', 'IQ:I (age^3) = 0')) Error in FUN(newX[, i], ...) : `param' has no names and does not match number of coefficients of model. Unable to construct coefficient vector Thanks, Gang On Oct 30, 2007, at 9:08 AM, Dieter Menne wrote: > Gang Chen mail.nih.gov> write

Re: [R] Converting a string

2007-10-30 Thread Gang Chen
> > Of course this is yet another case where Lumley's principle (at > least I > think it's his) holds: if you have to use eval(parse(...)) rethink -- > there's a better way. > > > Bert Gunter > Genentech Nonclinical Statistics > > > -Original

Re: [R] Converting a string

2007-10-29 Thread Gang Chen
into MyFunc to make it executable? Gang On Oct 29, 2007, at 5:42 PM, jim holtman wrote: > Can you provide an example of your input and what you expect the > output to be. You can always use 'as.numeric'. > > On 10/29/07, Gang Chen <[EMAIL PROTECTED]> wrote: >> This

[R] Converting a string

2007-10-29 Thread Gang Chen
This must be very simple, but I'm stuck. I have a command line in R defined as a variable of a string of characters. How can I convert the variable so that I can execute it in R? Really appreciate any help, Gang __ R-help@r-project.org mailing list

[R] How to test combined effects?

2007-10-29 Thread Gang Chen
Suppose I have a mixed-effects model where yij is the jth sample for the ith subject: yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) + beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ) +random intercepti + eij In R how can I get an F test against the nu

[R] How to coerce this?

2007-10-25 Thread Gang Chen
This is the command I want to execute with function contrast in contrast package: > contrast(MyObject, list(Trust="T"), list(Trust="U")); As the two arguments with 'list' are defined as a string of characters, contr: > str(contr) chr "list(Trust=\"T\"),list(Trust=\"U\")" I would like to

Re: [R] Trouble with R CMD INSTALL

2007-10-18 Thread Gang Chen
Hi Liviu, Thank you very much for the response! I knew that would work within R, but was just wondering why > R CMD INSTALL nlme does not work on the shell terminal. Any clue? Thanks, Gang On Oct 17, 2007, at 6:27 PM, Liviu Andronic wrote: > On 10/17/07, Gang Chen <[EMAIL

Re: [R] Trouble with R CMD INSTALL

2007-10-17 Thread Gang Chen
fine: > R CMD INSTALL lme4 Gang On Oct 17, 2007, at 1:29 PM, Liviu Andronic wrote: > On 10/17/07, Gang Chen <[EMAIL PROTECTED]> wrote: >> Why does R CMD INSTALL work for some packages (e.g., lme4) but not >> others (e.g., nlme)? > > If you don't provide any co

[R] Trouble with R CMD INSTALL

2007-10-17 Thread Gang Chen
Why does R CMD INSTALL work for some packages (e.g., lme4) but not others (e.g., nlme)? Thanks, Gang __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-gu

Re: [R] How to pass a string as an argument to a function?

2007-09-19 Thread Gang Chen
Yes, as.formula is the magic tool! Thanks a lot... Gang On Sep 19, 2007, at 2:00 PM, Vladimir Eremeev wrote: > > lme(as.formula(paste("y~",ww)),random=~1|subj,model) > > > Gang Chen-3 wrote: >> >> I want to pass a predefined string ww ("fa*fb+fc")

[R] How to pass a string as an argument to a function?

2007-09-19 Thread Gang Chen
I want to pass a predefined string ww ("fa*fb+fc") to function lme so that I can run > lme(y ~ fa*fb+fc, random = ~1|subj, model) I've tried something like > lme(y ~ paste(ww), random = ~1|subj, model) and > lme(y ~ sprintf(ww), random = ~1|subj, model) but both give me the following

<    1   2