On 01-Nov-08 20:59:29, RON70 wrote: > Still no reply. Is my question not understandable at all? > RON70 wrote: >> I am wondering how R calculate p-value for a test. Does R do some >> "Approximate" integration on the p.d.f of null distribution? >> How I can see the code for this particular calculation? >> >> Your help will be highly appreciated. >> Regards,
How R calculates a P-value depends on the analysis being done, but it will use a standard method. For example, a t-test (standard frm, not Welch)will assume a normal diretribution for the deviations from the mean (or means, for a two-sample test, with the same variance for each group); will calculate the T-statistic, and will calculate the exact (to within numerical accuracy) for this T-value from the distribution of t on the correct number of degrees of freedom. In the case of fitting a linear model with normally distributed errors (using lm()), the P-value for each coefficient will be based on the "z" value (value of coefficient divided by the standard error), referred to a t distribution with appropriate degrees of freedom. Again, an exact P-value. Similarly, for an analysis of variance, the F-statistic will be calculated in the standard way, and the P-value will be obtained by reference to the F distribution with appropriate degrees of freedom. Again exact, to within numerical accuracy. For some other kinds of analysis, standard (often large-sample chi-squared approximations, in some cases to the distribution of a likelihood ratio) methods will be used, and the resulting P-value will be approximate to within th accuracy of the approximating distribution. This kind of thing occurs for example in fitting generalised linear models using glm(). These P-values are approximate, but the approximations are standard. There is as much variety in all this as in the variety of standard methods for obtaining a test statistic and in using tractable approximations to the distribution of the test statistic. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 01-Nov-08 Time: 21:56:14 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@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.