A summary.lm
object stores these values in a matrix
called 'coefficients'
. So the value you are after can be accessed with:
a2Pval <- summary(mg)$coefficients[2, 4]
Or, more generally/readably, coef(summary(mg))["a2","Pr(>|t|)"]
. See here for why this method is preferred.
More Related Contents:
- How to debug “contrasts can be applied only to factors with 2 or more levels” error?
- Linear Regression and group by in R
- Fitting a linear model with multiple LHS
- `lm` summary not display all factor levels
- How does predict.lm() compute confidence interval and prediction interval?
- Fast pairwise simple linear regression between variables in a data frame
- Linear Regression with a known fixed intercept in R
- R: lm() result differs when using `weights` argument and when using manually reweighted data
- How `poly()` generates orthogonal polynomials? How to understand the “coefs” returned?
- predict.lm() with an unknown factor level in test data
- Messy plot when plotting predictions of a polynomial regression using lm() in R
- how to debug “factor has new levels” error for linear model and prediction [duplicate]
- How to create a loop that will make regression models in R? [closed]
- Predict() – Maybe I’m not understanding it
- How to succinctly write a formula with many variables from a data frame?
- Getting Warning: ” ‘newdata’ had 1 row but variables found have 32 rows” on predict.lm
- Pass a vector of variables into lm() formula
- What does the capital letter “I” in R linear regression formula mean?
- Why is using update on a lm inside a grouped data.table losing its model data?
- Plot polynomial regression curve in R
- How do I create a “macro” for regressors in R?
- Stepwise regression using p-values to drop variables with nonsignificant p-values
- lme4::lmer reports “fixed-effect model matrix is rank deficient”, do I need a fix and how to?
- lm function in R does not give coefficients for all factor levels in categorical data
- get x-value given y-value: general root finding for linear / non-linear interpolation function
- Specifying formula in R with glm without explicit declaration of each covariate
- R error which says “Models were not all fitted to the same size of dataset”
- Linear model function lm() error: NA/NaN/Inf in foreign function call (arg 1)
- Add Regression Plane to 3d Scatter Plot in Plotly
- Double clustered standard errors for panel data