Re: [R] a question about lm on t-test.

2011-08-18 Thread Daniel Malter
I should have written "the standard errors of the coefficients are the SQUARE ROOT of the diagonal entries of the variance-covariance matrix," as I programmed it in the code. Daniel Malter wrote: > > Pick up a book or the like on ordinary least squares regression, which is > what lm() in its pla

Re: [R] a question about lm on t-test.

2011-08-18 Thread Eik Vettorazzi
That is a speciality of your model - it is actually an ANOVA-model (with 2 groups). Even so the variance of the intercept is estimated from the whole sample, not only for group==1 (thats why the statistics and p-values differ) - and that analysis is equivalent to a t-test with common variance (aka

Re: [R] a question about lm on t-test.

2011-08-18 Thread Daniel Malter
Pick up a book or the like on ordinary least squares regression, which is what lm() in its plain vanilla application does. The t-value is the estimated coefficient divided by the standard error. The standard errors of the coefficients are the diagonal entries of the variance-covariance matrix. x<

Re: [R] a question about lm on t-test.

2011-08-17 Thread Lao Meng
Well,since the intercept is the same as mean of group1,I take it for granted that the 1-sample ttest must test based on group==1... If the intercept is estimated from the whole sample,why does the intercept is the same as mean of group1? 2011/8/17 Eik Vettorazzi > Hi Lao, > thats not the sam

Re: [R] a question about lm on t-test.

2011-08-17 Thread Eik Vettorazzi
Hi Lao, thats not the same test. The concept of linear regression applies here (and you might take any introductory at your hand to refresh that concept). The intercept is estimated from the whole sample not just group==1, dfs are 20-2, not sum(group==1)-1! best regards Am 17.08.2011 09:57, schri

Re: [R] a question about lm on t-test.

2011-08-17 Thread Lao Meng
Thanks Eik. As to your words:"The intercept in lm is tested against 0 (one sample t-test)" So, I perform the following test: t.test(extra[group==1],mu=0) Since goup1 is regarded as reference,I do the 1-sample ttest based on group1's mean vs 0. But the result: t value= 1.3257 p-value = 0.2176 And

Re: [R] a question about lm on t-test.

2011-08-16 Thread Eik Vettorazzi
Hi, you may have noticed, that your t-test and lm had not the same p-values for the difference in means, which is calculated for group2 when you use treatment contrasts and that is what R does by default (see ?contr.treatment). This is because R uses Welsh test by default. Pros and cons are beyond

Re: [R] a question about lm on t-test.

2011-08-15 Thread Lao Meng
In my first email,I wrote: summary(lm(extra~group)) Maybe the same as your "summary.lm" 2011/8/16 Jeff Newmiller > ** Sorry, I missed the nature of the data. > > As to your original question, perhaps typing "summary.lm" at the R prompt > can enlighten you? > > ---

Re: [R] a question about lm on t-test.

2011-08-15 Thread Jeff Newmiller
Sorry, I missed the nature of the data. As to your original question, perhaps typing "summary.lm" at the R prompt can enlighten you? --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go... Live: OO#.

Re: [R] a question about lm on t-test.

2011-08-15 Thread Lao Meng
The mean of group1 is 0.75,just the same as intercept. Acturally,R treated group1 as reference,so intercept is just group1. 2011/8/16 Jeff Newmiller > Why would you assert that the mean is the same as the intercept? For data > clustered far from the y axis this seems clearly unlikely to be tru

Re: [R] a question about lm on t-test.

2011-08-15 Thread Jeff Newmiller
Why would you assert that the mean is the same as the intercept? For data clustered far from the y axis this seems clearly unlikely to be true. --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go...

[R] a question about lm on t-test.

2011-08-15 Thread Lao Meng
Hi all: I have a question about lm on t-test. data(sleep) I wanna perform t-test to test the difference between the 2 groups: I can use: t.test(extra~group) The t.test result shows that:t = -1.8608; mean1=0.75,mean2=2.33 But I still wanna use: summary(lm(extra~group)) Intercept=0.75,which is