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

Daniel Malter daniel at umd.edu
Thu Aug 18 10:43:24 CEST 2011


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 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<-rnorm(100)
> y<-2+x+rnorm(100)
> reg<-lm(y~x)
> summary(reg)$coefficients
> sqrt(diag(vcov(reg)))
> 
> See also: http://en.wikipedia.org/wiki/Ordinary_least_squares
> 
> HTH,
> Daniel
> 
> 
> Lao Meng wrote:
>> 
>> 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 mean1,just the same as t.test.
>> group2=1.58 means the difference of the 2 groups,so
>> mean2=1.58+0.75=2.33,just the same as t.test.
>> And some parameters of group2(t value,Pr) are the same as t.test,since
>> group2 is the difference of the 2 groups.
>> 
>> My question is:
>> How the "t value" of Intercept(group1 acturally) is calculated?
>> 
>> 
>> Thanks a lot.
>> 
>> My best
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at 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-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 

--
View this message in context: http://r.789695.n4.nabble.com/a-question-about-lm-on-t-test-tp3746371p3752068.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list