EqParse: Equations Parser

Description Usage Arguments Value Syntax Operations par.label par.start Line breaks Comments Author(s) See Also Examples

View source: R/EqParse.R

Description

Parse equations and return a parameter table (par.table). The argument eq is a character string that specifies the associations between the variables. See Syntax, Operations, par.label, par.start, Line breaks, and Comments below.

Usage

1
EqParse(eq)

Arguments

eq

Character string. Equations. See Details.

Value

Returns a data.frame with the following columns

lhs

is the variable on the left-hand side,

rhs

is the variable on the right-hand side,

op

is the operation between lhs and rhs,

par.label

is the column of parameter label,

par.start

is the column of starting values for estimation if eq has a fifth colulmn, and

par.names

is the column of parameter label with NAs on fixed parameters.

Syntax

Each line should follow the syntax below

lhs <space> op <space> rhs <space> par.label <\n> or <;>

lhs

is the variable on the left-hand side,

rhs

is the variable on the right-hand side,

op

is the operation between lhs and rhs,

par.label

is the column of parameter label,

par.start

is the column of starting values for estimation (only for functions that require it), and

\n or ;

are line breaks. Each line should end with a line break.

Operations

The associations are defined by the following operations

by

left-hand side measured by right-hand side,

on

left-hand side regressed on right-hand side,

with

left-hand side covarying with right-hand side,

on 1

left-hand side regressed on 1 for mean structure.

par.label

Each parameter should be labeled. The par.label should be a number for fixed parameters and a character string for free parameters. Equality contraints can be imposed by using the same par.label.

par.start

Numerical values as starting values for estimation. Starting values for fixed parameters should be NA. Starting values should be identical for parameters constrained to be equal, that is, parameters with the same par.label.

Line breaks

The characters \n and ; can be used as line breaks. Each line should end with a line break.

Comments

Comments can be written after a hash (#) sign.

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other eq functions: Eq2Expectations(), Eq2RAM()

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
eq <- "
  # lhs op   rhs par.label
    e   by   y   1
    y   on   x   beta
    e   with e   sigmae2
    x   with x   sigmax2
    y   on   1   alpha
    x   on   1   mux
"
EqParse(eq)

eq <- "
  # lhs op   rhs value
    e   by   y   1
    y   on   x   1
    e   with e   1
    x   with x   0.25
    y   on   1   0
    x   on   1   0.50
"
EqParse(eq)

eq <- "
  # lhs op   rhs par.label par.start
    e   by   y   1         NA
    y   on   x   beta      0.00
    e   with e   sigmae2   1.25
    x   with x   sigmax2   0.25
    y   on   1   alpha     0.00
    x   on   1   mux       0.50
"
EqParse(eq)

# \n as line breaks------------------------------------------------

eq <- "
  e by y 1 NA \n y on x beta 0.00
  e with e sigmae2 1.25 \n x with x sigmax2 0.25
  y on 1 alpha 0.00 \n x on 1 mux 0.50
"
EqParse(eq)

# ; as line breaks------------------------------------------------

eq <- "
  e by y 1 NA; y on x beta 0.00
  e with e sigmae2 1.25; x with x sigmax2 0.25
  y on 1 alpha 0.00; x on 1 mux 0.50
"
EqParse(eq)

jeksterslab/ramR documentation built on March 14, 2021, 9:38 a.m.