predCurves {R2MLwiN}R Documentation

Draws predicted curves (lines) using estimates from the fixed part of a fitted model.

Description

This function draws predicted curves (lines) against an explanatory variable for each category of a categorical variable.

Usage

predCurves(
  object,
  indata = NULL,
  xname,
  group = NULL,
  legend = TRUE,
  legend.space = "top",
  legend.ncol = 2,
  ...
)

Arguments

object

Either an mlwinfitIGLS-class or mlwinfitMCMC-class object.

indata

A data.frame object containing the data. If not specified, data is extracted from the object.

xname

The name of variable to be plotted.

group

A character string or a sequence of length equivalent to rows of data to plot. group = NULL by default.

legend

A logical value indicating whether a legend for group is to be added.

legend.space

A character string specifies one of the four sides, which can be one of 'top', 'bottom', 'left' and 'right'. Default, legend.space = 'top'.

legend.ncol

An integer specifies a number of columns, possibly divided into blocks, each containing some rows. Default, legend.ncol = 2.

...

Other arguments to be passed to xyplot.

Author(s)

Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol.

See Also

predLines

Examples


## Not run: 
library(R2MLwiN)
# NOTE: if MLwiN not saved in location R2MLwiN defaults to, specify path via:
# options(MLwiN_path = 'path/to/MLwiN vX.XX/')
# If using R2MLwiN via WINE, the path may look like this:
# options(MLwiN_path = '/home/USERNAME/.wine/drive_c/Program Files (x86)/MLwiN vX.XX/')

## Read alevchem data
data(alevchem, package = "R2MLwiN")

alevchem$gcseav <- alevchem$gcse_tot/alevchem$gcse_no - 6
# Avoids warning when fitting factor as continuous response:
alevchem$a_point_num <- as.numeric(alevchem$a_point)

## Example: A-level Chemistry
(mymodel <- runMLwiN(a_point_num ~ 1 + gcseav + I(gcseav^2) + I(gcseav^3)
                     + gender + (1 | pupil), estoptions = list(EstM = 1,  resi.store = TRUE),
                     data = alevchem))
                     
predCurves(mymodel, xname = "gcseav", group = "genderfemale")

## End(Not run)


[Package R2MLwiN version 0.8-9 Index]