Re: [R] How to code the factor for ANOVA

2017-06-25 Thread Bert Gunter
You really really need to go through one of the many R (web) tutorials where this is discussed in detail. Or see the Intro to R tutorial that ships with R. This is not the proper venue for learning how R handles linear models and how its formula interface works. A terse treatment can be found in

[R] How to code the factor for ANOVA

2017-06-25 Thread Jinsong Zhao
Hi there, I have a experimental design related question. I have done a experiment with 3 factors. The design matrix is similar to: data.frame(Factor.1 = rep(rep(0:2, each = 3),3), Factor.2 = rep(c("U","S","N"), 9), Factor.3 = rep(0:2, each = 9)) Factor.1 Factor.2 Factor.3 1 0

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-22 Thread Rolf Turner
I tried your suggestion on the toy example that was posted by David Carlson a while back: set.seed(42) x - 1:15 y - x/(1+x) + rnorm(15,0,0.02) I found that I had to: (a) Wrap the 1/x inside I(). (b) Set the offset term to be rep(1,length(x)). Bottom line: fit - glm(y ~

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-21 Thread Ben Bolker
Rolf Turner rolf.turner at xtra.co.nz writes: On 21/08/13 11:23, Ye Lin wrote: T hanks for your insights Rolf! The model I want to fit is y=x/a+x with no intercept, so I transformed it to 1/y=1+a/x as they are the same. For crying out loud, they are ***NOT*** the same. The equations

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-21 Thread Ben Bolker
On 13-08-21 05:17 PM, Rolf Turner wrote: Thott about this a bit more and have now decided that I don't understand after all. Doesn't glm(1/y~x,family=gaussian(link=inverse)) fit the model 1/y ~ N(1/(a+bx), sigma^2) whereas what the OP wanted was y ~

[R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Ye Lin
Hey All, I wanna to fit a model y~x/(a+x) to my data, here is the code I use now: lm((1/y-1)~I(1/x)+0, data=b) and it will return the coefficient which is value of a however, if I use the code above, I am not able to draw a curve the presents this equation. How can I do this? Thanks for your

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread David Carlson
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ye Lin Sent: Tuesday, August 20, 2013 4:40 PM To: R help Subject: [R] how to code y~x/(x+a) in lm() function Hey All, I wanna to fit a model y~x/(a+x) to my data, here is the code I use now: lm((1

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Rolf Turner
(1) It is not acceptable to use wanna in written English. You should say I want to fit a model . (2) The model you have fitted is *not* equivalent to the model you first state. If you write y ~ x/(a+x) you are tacitly implying that y = x/(a+x) + E where the errors E are

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Ye Lin
T hanks for your insights Rolf! The model I want to fit is y=x/a+x with no intercept, so I transformed it to 1/y=1+a/x as they are the same. but i will look up nls() and see how to fit the model without transformation. On Tue, Aug 20, 2013 at 2:45 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote:

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Rolf Turner
On 21/08/13 11:23, Ye Lin wrote: T hanks for your insights Rolf! The model I want to fit is y=x/a+x with no intercept, so I transformed it to 1/y=1+a/x as they are the same. For crying out loud, they are ***NOT*** the same. The equations y = x/(a+x) and 1/y = 1 + a/x are indeed

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Bert Gunter
Rolf: Thanks for this. It nicely illustrates what to me is a fundamental problem: For many scientists, it is not math (stats) that is the stumbling block, but rather the failure to understand how variability (noise) affects the experimental/observational process. One does tend to get more

Re: [R] How to Code Random Nested Variables within Two-way Fixed Model in lmer or lme

2011-09-30 Thread Helios de Rosario
Dave, your situation is clearer now. You wrote (see the full context at the end of the message): From this, you will see that I have 4 control sites and 7 treatment sites that are measured each week. All 13 locations have different names, and Location is a random varaible. Is Location

[R] How to Code Random Nested Variables within Two-way Fixed Model in lmer or lme

2011-09-29 Thread Dave Robichaud
Hi All, I am frustrated by mixed-effects model! I have searched the web for hours, and found lots on the nested anova, but nothing useful on my specific case, which is: a random factor (C) is nested within one of the fixed-factors (A), and a second fixed factor (B) is crossed with the first

Re: [R] How to Code Random Nested Variables within Two-way Fixed Model in lmer or lme

2011-09-29 Thread Helios de Rosario
Dear Dave, there are some inconsistencies in your explanation of the problem. You said your variables are: CO is a continuous response variable, Week is a fixed categorical factor, Habitat is a fixed categorical factor, and Location is a random categorical factor nested within Habitat.

Re: [R] How to Code Random Nested Variables within Two-way Fixed Model in lmer or lme

2011-09-29 Thread Dave Robichaud
Hi again, Thank you very much for taking the time to respond to my question. I am sorry that my explanation was confusing. Please allow me to try to clarify. First, please ignore my attempts to define a lmer model. By putting forward my best first guess, which was clearly wrong, I have

[R] how to code a restriction matrix with the following restrictions

2011-04-14 Thread sébastien saegesser
Dear list members, I need to fit a regression with two inequality constraints. I look up in the literature and R archive and found some ways to do it, for example using the ic.infer package. However I do not know how to write in R my constraints. In the package help, it is told that I

[R] how to code a restriction matrix with the following restrictions

2011-04-14 Thread sébastien saegesser
Dear list members, I need to fit a regression with two inequality constraints. I look up in the literature and R archive and found some ways to do it, for example using the ic.infer package. However I do not know how to write in R my constraints. In the package help, it is told that

[R] how to code it??

2010-07-28 Thread Raghu
Hi I have say a large vector of 3500 digits. Initially the digits are 0s and 1s. I need to check for a rule to change some of the 0s to -1s in this vector. But once I change a 0 to -1 then I need to start applying the rule to change the next 0 only after I see the next 1 in the vector. Say for

Re: [R] how to code it??

2010-07-28 Thread Matt Shotwell
If I take your meaning correctly, you want something like this. x - c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, + 1) easy - function(x) { + state - 0 + for (i in 1:length(x)) { + if (x[i] == 0) + x[i] - state + state - 0 + if (x[i] ==

Re: [R] how to code it??

2010-07-28 Thread Henrique Dallazuanna
You've tried: diff(c(0, x)) ? On Wed, Jul 28, 2010 at 3:10 PM, Raghu r.raghura...@gmail.com wrote: Hi I have say a large vector of 3500 digits. Initially the digits are 0s and 1s. I need to check for a rule to change some of the 0s to -1s in this vector. But once I change a 0 to -1 then I

Re: [R] how to code it??

2010-07-28 Thread Gabor Grothendieck
On Wed, Jul 28, 2010 at 2:10 PM, Raghu r.raghura...@gmail.com wrote: Hi I have say a large vector of 3500 digits. Initially the digits are 0s and 1s. I need to check for a rule to change some of the 0s to -1s in this vector. But once I change a 0 to -1 then I need to start applying the rule

Re: [R] how to code it??

2010-07-28 Thread raghu
Thanks Henrique. On Wed, Jul 28, 2010 at 9:20 PM, Henrique Dallazuanna [via R] ml-node+2305552-1908682012-309...@n4.nabble.comml-node%2b2305552-1908682012-309...@n4.nabble.com wrote: You've tried: diff(c(0, x)) ? On Wed, Jul 28, 2010 at 3:10 PM, Raghu [hidden

Re: [R] how to code it??

2010-07-28 Thread Raghu
Thanks Matt, I will try putting the other rule into this. On Wed, Jul 28, 2010 at 9:06 PM, Matt Shotwell shotw...@musc.edu wrote: If I take your meaning correctly, you want something like this. x - c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, + 1) easy - function(x) { +

Re: [R] how to code it??

2010-07-28 Thread raghu
Thanks Gabor. On Wed, Jul 28, 2010 at 9:24 PM, Gabor Grothendieck [via R] ml-node+2305561-610338075-309...@n4.nabble.comml-node%2b2305561-610338075-309...@n4.nabble.com wrote: On Wed, Jul 28, 2010 at 2:10 PM, Raghu [hidden email]http://user/SendEmail.jtp?type=nodenode=2305561i=0 wrote:

Re: [R] how to code it??

2010-07-28 Thread Jonathan Christensen
On Wed, Jul 28, 2010 at 2:18 PM, Henrique Dallazuanna www...@gmail.comwrote: You've tried: diff(c(0, x)) ? This is clever, but not quite what he's asking for--it converts a sequence of 1's into a 1 followed by zeroes. Jonathan On Wed, Jul 28, 2010 at 3:10 PM, Raghu

[R] How to code mixed model with nested factors in lmer

2010-06-11 Thread ZHAO, HUIYAN [AG/1005]
Hi, I have coding question on mixed model in R. I am using R2.11.0 in windows. I have an experiment with 2 fixed effect factors - A and B. The levels of B are within the levels of A factor. The model is very similar to a split plot design except the nesting relationship between the 2 fixed

[R] How to code repeated measures interaction in lmer?

2010-05-06 Thread René Mayer
Dear Everybody: I want to test an interaction of two repeated measures in lmer() I've response times (Y) from N subjects with two within-subject-factors. aov(Y ~ A*B + Error(subjects/A*B), ...) shows an insigificant interaction p(A:B) = .35 now lmer() lm1 = lmer(Y ~ 1+A+B+(1+A*B|subjects),