forsearch_lm {forsearch} | R Documentation |
Create Statistics Of Forward Search in a Linear Model Database
Description
Prepares summary statistics at each stage of forward search for subsequent plotting. Forward search is conducted in two steps: Step 1 to identify minimal set of observations to estimate unknown parameters, and Step 2 to add one observation at each stage such that observations in the set are best fitting at that stage.
Usage
forsearch_lm(formula, data, initial.sample=1000, n.obs.per.level = 1,
skip.step1 = NULL, unblinded = TRUE, begin.diagnose = 100,
verbose = TRUE)
Arguments
formula |
Fixed effects formula as described in help(lm). The only permitted operators are +, : , and * . Terms must be found in data or as constructed by I(xxx) where xxx is found in data |
data |
Name of database |
initial.sample |
Number of observations in Step 1 of forward search |
n.obs.per.level |
Number of observations per level of (possibly crossed) factor levels.Set to rank of X'X if model contains constructed variables such as I(x^3), for example in polynomial regression |
skip.step1 |
NULL or a vector of integers for observations to be included in Step 1 |
unblinded |
TRUE causes printing of presumed analysis structure |
begin.diagnose |
Numeric. Indicates where in code to begin printing diagnostics. 0 prints all; 100 prints none |
verbose |
TRUE causes function identifier to display before and after run |
Details
Step 2 is determined by the results of Step 1, which itself is random. So, it is possible to reproduce the entire run by using the skip.step1 argument.
Value
LIST
Rows in stage |
Observation numbers of rows included at each stage |
Standardized residuals |
Matrix of errors at each stage |
Number of model parameters |
Rank of model |
Sigma |
Estimate of random error at final stage; used to standardize all residuals |
Fixed parameter estimates |
Vector of parameter estimates at each stage |
s^2 |
Estimate of random error at each stage |
Leverage |
Matrix of leverage of each observation at each stage |
Modified Cook distance |
Estimate of sum of squared changes in parameter estimates at each stage |
Call |
Call to this function |
Author(s)
William R. Fairweather
References
Atkinson, A and M Riani. Robust Diagnostic Regression Analysis, Springer, New York, 2000.
Examples
# Multiple regression
Observation <- 1:16
y <- runif(16)
x1 <- runif(16)
x2 <- runif(16)
x3 <- runif(16)
lmtest1 <- data.frame(Observation,y,x1,x2,x3)
forsearch_lm(formula=y~x1+x2+x3, data=lmtest1, initial.sample=200,begin.diagnose=100)
## Not run:
# Analysis of variance
Observation <- 1:30
y <- runif(30)
AN1 <- as.factor(c(rep("A1",5),rep("A2",5),rep("A3",5)))
AN1 <- c(AN1,AN1)
AN2 <- as.factor(c(rep("B1",15),rep("B2",15)))
lmtest2 <- data.frame(Observation,y,AN1,AN2)
forsearch_lm(formula=y~AN1*AN2, data=lmtest2, initial.sample=200,begin.diagnose=100)
# Analysis of covariance
Observation <- 1:60
y <- runif(60)
AN1 <- as.factor(c(rep("A1",10),rep("A2",10),rep("A3",10)))
AN1 <- c(AN1,AN1)
AN2 <- as.factor(c(rep("B1",30),rep("B2",30)))
COV <- runif(60)
lmtest3 <- data.frame(Observation,y,AN1,AN2,COV)
forsearch_lm(formula=y~AN1*AN2+COV, data=lmtest3, initial.sample=200,begin.diagnose=100)
# Polynomial regression
C1 <- 7*runif(60) + 1
y <- 4 + C1 - 6*C1^2 + 9*C1^3 + rnorm(60)
Observation <- 1:60
dfpoly <- data.frame(Observation,C1,y)
forsearch_lm(formula = y ~ C1 + I(C1^2) + I(C1^3), data = dfpoly, initial.sample = 200,
begin.diagnose=100)
## End(Not run)