[R] Extract p-value from linear model

Peter Ehlers ehlers at ucalgary.ca
Thu Jan 7 15:35:05 CET 2010


  coef(summary(lm(..stuff..)))[,4]
or
  coef(summary(lm(..stuff..)))[,4,drop=FALSE]

  -Peter Ehlers

Trafim Vanishek wrote:
> Dear all,
> 
> I have the following question.
> Is it possible in R to call for the p-value directly in a model like this
> 
> a <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> b <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> 
> summary(lm(a~(b+0)))
> 
> or even in this
> a <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> b <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> 
> summary(lm(a~b))
> 
> to call the p-values directly for every estimated parameter.
> Thanks a lot for the help!
> 
> 	[[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.
> 
> 

-- 
Peter Ehlers
University of Calgary
403.202.3921



More information about the R-help mailing list