av.frame: Create data frame for added variable plot

Description Usage Arguments Examples

View source: R/fun.R

Description

av.frame( model, variable) returns a data frame with model.frame(model) augmented by y.res and x.res, the residuals for an added variable plot

The purpose of this function is to facilitate OLS av.plots for mixed models.

Usage

1
av.frame(model, ...)

Arguments

model
...

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
       library(nlme)
       library(lattice)
       hs <- read.csv( 'http://www.math.yorku.ca/~georges/Data/hs.csv')

       # Mixed model where ses and Sex are Level 1 and Sector is Level 2

       fit.mm <- lme( mathach ~ ses * Sex * Sector, hs, random = ~ 1+ses| school)

       # for diagnostics fit an OLS model using only level 1 variables interacting
       # with the id variable

       fit.ols <- lm( mathach ~ (ses * Sex ) * factor(school), hs)
       xyplot( y.res ~ x.res | factor(school), cbind(av.frame(fit.ols, 'ses:Sex'),hs), sub = 'ses:Sex')
       xyplot( y.res ~ x.res | factor(school), cbind(av.frame(fit.ols, '^Sex'),hs), sub = 'Sex')
       xyplot( y.res ~ x.res | factor(school), cbind(av.frame(fit.ols, '^ses$|^ses:f'),hs), sub = 'ses')


       Note : y.res is the residual from fitting the response on
              the model matrix for fit.ols omitting any column
              whose names is matched (as a regular expression)
              by 'effect'
              x.res is the residual of the first column of the
              model matrix that is matched by 'effect' on the
              same matrix used for y.res.
       Caution: To make sure that the correct columns were
              matched, the list of matched columns that are omitted
              is printed.

## The function is currently defined as
function (model, ...) 
{
    UseMethod("av.frame")
  }

gmonette/spida documentation built on May 17, 2019, 7:25 a.m.