lm.holdout | R Documentation |
Repeatedly remove the observation whose removal will move a model term most strongly to zero, until it is either no longer significant or has changed its sign.
lm.holdout(
model,
goal = c("nsig", "flip"),
terms = NULL,
alpha = 0.05,
verbose = FALSE
)
## S3 method for class 'lm.holdout'
print(x, ...)
## S3 method for class 'lm.holdout'
plot(x, ...)
model |
A |
goal |
Objective of observation removal: "nsig" (no longer significant) or "flip" (change of sign). |
terms |
Names of model terms to compute holdout statistics for.
When |
alpha |
Maximum p value for significance (only relevant when aiming to make value insignificant). |
verbose |
Should the function generate verbose output? Defaults to |
x |
A |
... |
Additional plotting parameters for |
Datapoints to exclude are found with the function [stats::lm.influence()]
.
The plot function displays a scatterplot of each predictor with the dependent variable, with the excluded datapoints colored differently.
A list, containing
holdouts
: a data.frame
where each row is a predictor; as for the columns:
h
- the number of observations needed to reach the goal
h.prop
- the percentage of excludable observations that were excluded to reach the goal
final.beta
- the final beta value of the predictor after exclusions
final.p
- the final p value of the predictor after exclusions
exclusion.matrix
model
Sercan Kahveci
Sigma <- diag(1,nrow=3)
Sigma[1,-1] <- Sigma[-1,1]<- -.5
fakedata <- MASS::mvrnorm(n=1000,mu=c(0,0,0),Sigma=Sigma,empirical=TRUE)
fakedata <- as.data.frame(fakedata)
lmmod <- lm(V1~V2*V3,data=fakedata)
lmmod.h <- lm.holdout(lmmod,goal="nsig")
print(lmmod.h)
lmmod.h2 <- lm.holdout(lmmod,goal="flip")
print(lmmod.h2)
plot(lmmod.h)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.