3

I am doing a hypothesis test to test to see if my model is significant and I want to extract the p-value.

So I know that you do summary(mymodel)$fstatistic[1]) to find the test statistic.

and you can do summary(mymodel)$coeff[2,4] to find the p-value, but this only works for simple linear regression since the p values are the same for t and f test.

I want to get the p-value by itself without any libraries. Can it be done? I can't seem to find an answer for this..

Thanks in advance.

Aystealthy
  • 169
  • 1
  • 16
  • 1
    its not actaullt returned, but printed using the `stats:::print.summary.lm` method. So calculate manually (as in the print method) ie `fs = s$fstatistic ; pf(fs["value"], fs["numdf"], fs["dendf"], lower=FALSE)` – user20650 Feb 24 '18 at 23:33
  • I'm still not sure what line of code I need to type to output the p-value that is not like a function? if that makes sense – Aystealthy Feb 25 '18 at 00:50
  • nvm I figured it out, thanks. – Aystealthy Feb 25 '18 at 00:56
  • 1
    yes, it makes sense. You can't just grab a number fro the results of the `summary` object, as it is only generated in the `print`ing of the summary (ie see `stats:::print.summary.lm` ). So you need to calculate it using the f-statistic, and degrees of freedom (all of which are retuned by `summary`) – user20650 Feb 25 '18 at 00:57
  • 1
    f = summary(mymodel)$fstatistic, p = pf(f[1], f[2], f[3], lower.tail = FALSE), p – Aystealthy Feb 25 '18 at 00:58

0 Answers0