Learn R Programming

lessR (version 2.9.3)

Nest: Nest the Values of an Integer or Factor Variable

Description

Abbreviation: nt

A nested model has a subset of predictor variables from the corresponding full model. Compare a nested linear model with a full model to evaluate the effectiveness of the predictor variables deleted from the full model to define the nested model.

Usage

Nest(y, nested.model, full.model, method=c("ls", "logit"), data=mydata)

nt(...)

Arguments

y
Response variable.
nested.model
Predictor variables in the nested model.
full.model
Predictor variables in the full model.
method
Do a least squares analysis, the default, or a logit analysis.
data
The name of the data frame from which to create the subset, which is mydata by default.
...
The specified arguments.

Details

Use the standard R function anova function to compare a nested model with a corresponding full model. By default, compare models estimated with ordinary least squares from the R function lm, or compare models estimated with logistic regression from the R function glm with family="binomial". For the logistic analysis, the anova analysis is with test="Chisq".

To insure that the same data are analyzed for both models, the fit for the full model is first obtained. Then the data frame that is returned by this analysis is input into the analysis for the nested model. This guarantees that any cases with missing data values missing for the full analysis will have been deleted for the nested analysis. Otherwise rows of data could be retained for the nested analysis that were dropped for the full analysis because of missing data values for the deleted predictor variables. This method also guarantees that cases are not deleted because data was missing on variables not included in full analysis.

See Also

anova, lm, glm.

Examples

Run this code
mydata <- Read("Reading", format="lessR")


# compare least-squares models
mydata <- Read("Reading", format="lessR")
Nest(Reading, c(Absent), c(Verbal,Absent,Income))

# compare logistic models
mydata <- Read("BodyMeas", format="lessR")
Nest(Gender, c(Weight, Hips, Hand, Shoe),
      c(Height, Weight, Waist, Hips, Chest, Hand, Shoe), method="logit")

Run the code above in your browser using DataLab