Title: Incorporating Stability Information into Cross-Sectional Estimates
Version: 1.0.0
Description: The goal of 'stim' is to provide a function for estimating the Stability Informed Model. The Stability Informed Model integrates stability information (how much a variable correlates with itself in the future) into cross-sectional estimates. Wysocki and Rhemtulla (2022) https://psyarxiv.com/vg5as.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.2.2
Imports: lavaan, Ryacas, stats
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2023-01-20 22:37:37 UTC; annawy
Author: Anna Wysocki [aut, cre]
Maintainer: Anna Wysocki <awysocki@ucdavis.edu>
Repository: CRAN
Date/Publication: 2023-01-23 10:20:02 UTC

Internal function used to do symbolic matrix multiplication using the Ryacas R package

Description

Internal function used to do symbolic matrix multiplication using the Ryacas R package

Usage

symbMultiplication(x1, x2)

Arguments

x1

A Ryacas object.

x2

A Ryacas object.


Creates a character matrix which specifies which effects to estimate and which effects to constrain to a non-zero value

Description

Creates a character matrix which specifies which effects to estimate and which effects to constrain to a non-zero value

Usage

blueprint(effects, use)

Arguments

effects

A data frame that contains information on which cross-lagged effects to estimate or constrain to a value other than zero. Each row represents one effect. The effects object must have four columns: column 1 has the variable names for the predictors, column 2 has the variable names for the outcomes, column 3 has the names of the estimated effect or the value an unestimated effect should be constrained to, and column 4 has information on whether the effect should be estimated. This table can be created by using the effectTable function

use

A vector with the variable names that will be used in the stability-informed model

Value

   A character matrix

Create a parameter table

Description

Create a parameter table

Usage

effectTable(model)

Arguments

model

An object with the model description for the cross-sectional model in lavaan syntax

Value

A list with information on the cross-lagged paths and the residual covariances. The cross-lagged effect table has information on which cross-lagged effects to estimate and which to constrain. Each row represents one effect and specifies which variable is the predictor and outcome of the effect. The name column contains information on either the name of the estimated effect (e.g., CLxy) or what value the unestimated effect should be constrained to (e.g., .3). The residual covariance list has the lavaan syntax to specify that specific residuals should be allowed to covary, and a table with information on which variables should have covarying residuals and what the name of that residual covariance parameter should be.

Examples


#estimate effect from X to Y
#constrain effect from Y to X to .3
#allow X and Y's residuals to covary
model <- c('Y ~  X
            X ~ .3 * Y
            X ~~ Y')

effectTable(model)

Create lavaan syntax based on the blueprint matrix

Description

Create lavaan syntax based on the blueprint matrix

Usage

lavaanEq(blueprint, S)

Arguments

blueprint

A character matrix which specifies which effects to estimate and which effects to constrain to a non-zero value

S

Sample covariance matrix

Value

A character vector which contains the lavaan syntax to specify the latent variables, variances, and covariances


Outputs Lavaan Summary

Description

Outputs Lavaan Summary

Usage

lavaanSummary(x, subset = NULL)

Arguments

x

a stim Object

subset

Specify which model(s) you would like summarized. Default is to output all estimated models

Value

Lavaan summary table

Examples

model <- 'Y~X'
stability <- data.frame(X = c(.3, .4, .5), Y = c(.3, .5, .6))
dat <- data.frame(Y = rnorm(500, 0, 1), X = rnorm(500, 0, 1), Z = rnorm(500, 0, 1))

output <- stim(data = dat, model = model, stability = stability)

lavaanSummary(output, subset = c(1,2))

Get the model implied symbolic equations for the auto-regressive effects and the covariances between the phantom variables

Description

Get the model implied symbolic equations for the auto-regressive effects and the covariances between the phantom variables

Usage

modelImpliedEq(S, blueprint, stability, residualcov)

Arguments

S

Sample covariance matrix

blueprint

A character matrix that specifies which effects to estimate and which effects to constrain to a non-zero value

stability

A named object that contains stability information for each variable in the model.

residualcov

A list with both the lavaan syntax for the residual covariance and a dataframe with the variable names

Value

A list of 1) A character vector with the model implied equations for the autoregressive effects and the phantom variable covariances, and 2) the symbolic psi and covariance matrices that were used to get the model implied equations.


stim print function

Description

stim print function

Usage

## S3 method for class 'stim'
print(out)

Arguments

out

A stim object

Value

Overview of model


Creating a Result Table from a stim object

Description

Creating a Result Table from a stim object

Usage

resultTable(modelList)

Arguments

modelList

A list of SIModel inputs and outputs

Value

A result table


Estimate a Stability Informed Model

Description

Estimate a Stability Informed Model

Usage

stim(data = NULL, S = NULL, n = NULL, model, stability)

Arguments

data

A dataframe with the measured variables. Not needed if S is provided

S

A covariance matrix for the measured variables. Not needed if data is provided.

n

Number of observations. Not needed if data is provided.

model

An object with the cross-sectional model description in lavaan syntax

stability

An object that contains stability information for each variable in the model.

Value

An object of class stim

Examples


model <- 'Y~X'
stability <- data.frame(X = .3, Y = .3)
dat <- data.frame(Y = rnorm(500, 0, 1), X = rnorm(500, 0, 1))

stim(data = dat, model = model, stability = stability)

Summary method for stim objects

Description

Summarize a set of Stability Informed Models

Usage

## S3 method for class 'stim'
summary(object, ...)

Arguments

object

An object of class stim

...

Not used

Value

A print out containing the results for a set of Stability Informed Models

See Also

stim

Examples


model <- 'Y~X'
stability <- data.frame(X = .3, Y = .3)
dat <- data.frame(Y = rnorm(500, 0, 1), X = rnorm(500, 0, 1))

modelFit <- stim(data = dat, model = model, stability = stability)

summary(modelFit)



Create a symbolic covariance matrix

Description

Create a symbolic covariance matrix

Usage

symbMatrix(blueprint, residualcov)

Arguments

blueprint

A character matrix which specifies which effects to estimate and which effects to constrain to a non-zero value

residualcov

A list with both the lavaan syntax for the residual covariance and a dataframe with the variable names

Value

A list of character matrices: A symbolic covariance matrix and a symbolic psi matrix