p<-summary(glm(...))$coefficients[2,4]?
Didn't realize summary(..)$coefficients returns a matrix.
Thanks a lot!
In R, you can do "summary(glm(y ~ x))" and it displays the results of the glm including the intercept, slope and the p-values for the intercept and the slope. But how can you programmatically retrieve the p-value for the slope? For instance, I would like to do something like the following:
rst <- glm(y ~ x)
rst$pvalue
Or, alternatively, a perl package with the desired capability. I've checked out Statistics::LineFit, however it can only return rSquared but not p-value
Save the output of the summary() and the coefficients slot contains the p value in the third column of that matrix.
I would do p<-summary(glm(...))$coefficients[2,3]
rst <- glm(y ~ x)
rst$pvalue
library(broom)
t.rst <- tidy(rst)
t.rst[,"p.value"]
Another method is to use perl Statistics::LineFit to get the tStatistics, and use Statistics::Distributions::tprob(dof, t-stat) to get the p-value.
Log in to answer this question.