[R] On p-values presented in the summary of Linear Models
Kevin E. Thorpe
kevin.thorpe at utoronto.ca
Fri Feb 8 02:30:17 CET 2013
On 02/07/2013 08:22 PM, Antonio Silva wrote:
> Dear list members
>
> I have a doubt on how p-values for t-statistics are calculated in the
> summary of Linear Models.
>
> Here goes an example:
>
> x <- rnorm(100,50,10)
> y <- rnorm(100,0,5)
> fit1<-lm(y~x)
> summary(fit1)
> summary(fit1)$coef[2] # b
> summary(fit1)$coef[4] # Std. Error
> summary(fit1)$coef[6] # t-statistic
> summary(fit1)$coef[8] # Pr(>|t|
> summary(fit1)$df [2] # degrees of freedom
>
> # t-statistic can be calculated as:
> t<-(summary(fit1)$coef[2])/summary(fit1)$coef[4]
> t # t-statistic
>
> # the critical value for t0.05(2)df can be obtained in a t distribuition
> table
> # http://www.math.unb.ca/~knight/utility/t-table.htm or with
> qt(0.975,summary(fit1)$df[2])
>
> # Two-sided p-value should be estimated with
> dt(t,summary(fit1)$df[2]) # isn't it?
>
The dt() function is giving you the value from the density function, not
the probability. Use pt() to obtain probabilities.
> But this value is different from summary(fit1)$coef[8]
>
> My question is: how to reach to the same p-value indicated in Pr(>|t|) or
> summary(fit1)$coef[8]?
>
> Thanks in advance,
>
> Antonio Olinto
>
> [[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.
>
>
--
Kevin E. Thorpe
Head of Biostatistics, Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016
More information about the R-help
mailing list