lav_partable: lavaan partable functions

lav_partableR Documentation

lavaan partable functions

Description

Utility functions related to the parameter table (partable)

Usage

# extract information from a parameter table
lav_partable_df(partable)
lav_partable_ndat(partable)
lav_partable_npar(partable)
lav_partable_attributes(partable, pta = NULL)

# generate parameter labels
lav_partable_labels(partable, blocks = c("group", "level"), 
                    group.equal = "", group.partial = "", type = "user")

# generate parameter table for specific models
lav_partable_independence(lavobject = NULL, lavdata = NULL,
    lavpta = NULL, lavoptions = NULL, lavsamplestats = NULL,
    lavh1 = NULL,
    sample.cov = NULL, sample.mean = NULL, sample.slopes = NULL,
    sample.th = NULL, sample.th.idx = NULL,
    sample.cov.x = NULL, sample.mean.x = NULL)

lav_partable_unrestricted(lavobject = NULL, lavdata = NULL, 
    lavpta = NULL, lavoptions = NULL, lavsamplestats = NULL, 
    lavh1 = NULL,
    sample.cov = NULL, sample.mean = NULL, sample.slopes = NULL, 
    sample.th = NULL, sample.th.idx = NULL,
    sample.cov.x = NULL, sample.mean.x = NULL) 

lav_partable_from_lm(object, est = FALSE, label = FALSE, 
    as.data.frame. = FALSE)

# complete a parameter table only containing a few columns (lhs,op,rhs)
lav_partable_complete(partable = NULL, start = TRUE)

# merge two parameter tables
lav_partable_merge(pt1 = NULL, pt2 = NULL, remove.duplicated = FALSE, 
    fromLast = FALSE, warn = TRUE)

# add a single parameter to an existing parameter table
lav_partable_add(partable = NULL, add = list())

Arguments

partable

A parameter table. See lavParTable for more information.

blocks

Character vector. Which columns in the parameter table should be taken to distinguish between different blocks of parameters (and hence be given different labels)? If "blocks" includes "group", a suffix ".g" and the group number (or group label) is added for the parameters of all but the first group. If "blocks" includes "level", a suffix ".l" and the level number is added for the parameters of all but the first level. If "blocks" includes, say "foo", a suffix ".foo" and the corresponding value of "foo" is added to all parameters.

group.equal

The same options can be used here as in the fitting functions. Parameters that are constrained to be equal across groups will be given the same label.

group.partial

A vector of character strings containing the labels of the parameters which should be free in all groups.

type

Character string. Can be either ‘user’ or ‘free’ to select all entries or only the free parameters from the parameter table respectively.

lavobject

An object of class ‘lavaan’. If this argument is provided, it should be the only argument. All the values for the other arguments are extracted from this object.

lavdata

An object of class ‘lavData’. The Data slot from a lavaan object.

lavoptions

A named list. The Options lsot from a lavaan object.

lavsamplestats

An object of class ‘lavSampleStats’. The SampleStats slot from a lavaan object.

lavh1

A named list. The h1 slot from a lavaan object.

lavpta

The pta (parameter table attributes) slot from a lavaan object.

sample.cov

Optional list of numeric matrices. Each list element contains a sample variance-covariance matrix for this group. If provided, these values will be used as starting values.

sample.mean

Optional list of numeric vectors. Each list element contains a sample mean vector for this group. If provided, these values will be used as starting values.

sample.slopes

Optional list of numeric matrices. Each list element contains the sample slopes for this group (only used when conditional.x = TRUE). If provided, these values will be used as starting values.

sample.th

Optional list of numeric vectors. Each list element contains a vector of sample thresholds for this group. If provided (and also sample.th.idx is provided), these values will be used as starting values.

sample.th.idx

Optional list of integers. Each list contains the threshold indices for this group.

sample.cov.x

Optional list of numeric matrices. Each list element contains a sample variance-covariance matrix for the exogenous variables for this group (only used when conditional.x = TRUE). If provided, these values will be used as starting values.

sample.mean.x

Optional list of numeric vectors. Each list element contains a sample mean vector for the exogenous variables for this group (only used when conditional.x = TRUE). If provided, these values will be used as starting values.

est

Logical. If TRUE, include the fitted estimates in the parameter table.

label

Logical. If TRUE, include parameter labels in the parameter table.

as.data.frame.

Logical. If TRUE, return the parameter table as a data.frame.

object

An object of class lm.

start

Logical. If TRUE, include a start column, based on the simple method for generating starting values.

pta

A list containing parameter attributes.

pt1

A parameter table.

pt2

A parameter table.

remove.duplicated

Logical. If TRUE, remove duplicated elements when merging two parameter tables.

fromLast

Logical. If TRUE, duplicated elements are considered from the bottom of the merged parameter table.

warn

Logical. If TRUE, a warning is produced when duplicated elements are found, when merging two parameter tables.

add

A named list. A single row of a parameter table as a named list.

Examples

# generate syntax for an independence model
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- cfa(HS.model, data=HolzingerSwineford1939)
lav <- lav_partable_independence(fit)
as.data.frame(lav, stringsAsFactors = FALSE)


# how many free parameters?
lav_partable_npar(lav)

# how many sample statistics?
lav_partable_ndat(lav)

lavaan documentation built on Sept. 27, 2024, 9:07 a.m.