[R] Function Fstats and p value

Peter Ehlers ehlers at ucalgary.ca
Fri Feb 12 14:19:52 CET 2010

sebastien wrote:
> Hello,
> I used the function Fstats (in the package strucchange) and would like to
> transform the F probability given by Fstats in P value. This transformation
> can be made while making a plot, but I need to have the numerical P value
> which are ploted... and I can't find out how to do.
You can look inside the plot.Fstats function with


There you will find the equivalent of the following:

  k <- fs$nreg
  n <- fs$nobs
  x <- fs$Fstats
  pvals <- 1 - pf(x, k, (n - 2 * k))

which gives you the P-values.

  -Peter Ehlers

> Here a is an exemple, to plot the P value.
> let's take data as a array
> fs <-fstats(data ~ 1, from = 4, to = length(data)-4)
> plot(fs,pval=TRUE)
> Thank you for your help,
> Seb

More information about the R-help mailing list