[R] R-square n p-value

Justin Rhodes jrhodes at stat.psych.uiuc.edu
Mon Sep 5 00:39:18 CEST 2005


Dear Peter,

This is exactly what I needed.  The "input" is 
coming from the Mouse Phenome Project database 
(http://aretha.jax.org/pub-cgi/phenome/mpdcgi?rtn=docs/home) 
which only gives pearson's correlations r, and 
n.  Thank you very much.  I have used this R-help 
resource twice now recently and it is incredibly 
helpful and fast.  Thanks again.  It is much appreciated.

cc Dirk

Best,

Justin




At 03:43 AM 9/4/2005, Peter Dalgaard wrote:
>Dirk Eddelbuettel <edd at debian.org> writes:
>
> > On 3 September 2005 at 17:59, Justin Rhodes wrote:
> > | Dear R-help,
> > |
> > | Can someone please help me discover what function or code will give
> > | me a p-value from the input: 1) R-square statistic from a simple
> > | linear regression, and 2) sample size, n
> > |
> > | This would be greatly appreciated.  I need this because I am using a
> > | database that gives me R-square and sample size for multiple
> > | comparisons, and I wish to determine the false discovery rate using
> > | q-value.  Thanks again,
> >
> > Do
> >       > example(lm)                   # just to get an lm object
> >       > str(summary(lm.D9))           # to examine summary of an object
> >
> > and you'll see that the object returned from summary has the two common R^2
> > measures, as well as things like residuals from which can compute n quite
> > easily -- which you could obviously also from 
> your regressors and regressand.
> >
> >       > length(summary(lm.D9)$residuals)
>
>I think the problem was somewhat different: The *input* is coming from
>some sort of (closed-source or otherwise impenetrable) database which
>only gives out n and R^2, right?
>
>Now R^2 = SSDmodel/(SSDmodel+SSDres) and F =
>DFres/DFmodel*SSDmodel/SSDres, i.e.
>
>   1/R^2 = 1 + 1/F*DFmodel/DFres
>
>or
>
>   F = 1/(1/R^2 - 1)*DFres/DFmodel = R^2/(1-R^2)*DFres/DFmodel
>
>which can be looked up "in the F-table" using
>
>   pf(F, 1, N-2, lower.tail=FALSE)
>
>(provided we have a 1 DF model)
>
>Actually, R^2 itself has a beta distribution and you could use pbeta
>directly, but then you'd need to figure out (or recall) what the
>relation between the DF and the shape parameters of the beta
>distribution are. By my reckoning, this should do it:
>
>   pbeta(Rsq, 1/2, (N-2)/2, lower.tail=FALSE)
>
>"Proof":
>
>....
>Residual standard error: 1.143 on 8 degrees of freedom
>Multiple R-Squared: 0.0004207,  Adjusted R-squared: -0.1245
>F-statistic: 0.003367 on 1 and 8 DF,  p-value: 0.9552
>
> > pbeta(0.0004207, 1/2, 8/2, lower=F)
>[1] 0.9551511
>
>
>--
>    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
>~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907

Justin S. Rhodes
Assistant Professor of Psychology
Affiliate, Institute for Genomic Biology and Neuroscience Program
University of Illinois at Urbana-Champaign
405 N Mathews Ave, Urbana, Il, 61801
Tel. 217-265-0021 Fax 217-244-5876
Website: http://s.psych.uiuc.edu/people/showprofile.php?id=545




More information about the R-help mailing list