lsem
Signature/Parameters
class lsem
def __init__(self, formula, data, estimator = 'auto', ordinal = 'auto', ordinal_auto_ncat = 5, se = None, se_cluster = None, weights = None, silent = False, *args, **kws)
Interface to estimate linear structural equation models via lavaan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
formula
|
str
|
|
required |
data
|
DataFrame
|
Dataset containing all variables referenced in |
required |
estimator
|
str
|
The name of the estimator to use. If ‘auto’, it uses maximum likelihood (‘ML’) if estimating models with continuous outcomes an diagonally weighted least squares (‘DWLS’) if there are ordinal endogenous variables. For other options, see lavaan lavOptions documentation. |
'auto'
|
ordinal
|
str, list, or None
|
Used to indicate binary and ordinal endogenous variables in the data A string (list) must be the name(s) of the binary and ordinal endogenous variable(s). If ‘auto’: (Default), auto-detect the type and set the estimator type accordingly (see ‘estimator’) If None, use all variables as continuous. |
'auto'
|
ordinal_auto_ncat
|
int
|
Threshold for categorizing variables as ordinal when using
|
5
|
se
|
str, bool, or None
|
Specification for classical, robust, or bootstrap standard errors. Options: - None: use classical standard errors - “robust.huber.white”: standard errors are computed based on the ‘mlr’ (aka pseudo ML, Huber-White) approach. - “robust.sem”: conventional robust standard errors are computed. - “robust”: either “robust.sem” or”robust.huber.white” is used depending on the estimator, the mimic option, and whether the data are complete or not. - “boot” or “bootstrap”: bootstrap standard errors using standard bootstrapping |
None
|
se_cluster
|
str or None
|
Column name indicating clustering groups for standard errors. If |
None
|
weights
|
str or None
|
Optional column name specifying sampling weights. |
None
|
silent
|
bool
|
Suppress estimation progress messages when |
False
|
*args
|
Additional positional arguments passed directly to |
()
|
|
**kws
|
Additional keyword arguments passed directly to |
{}
|
Examples:
>>> df = tp.tibble({'X': [0, 1, 0], 'Y': [1.0, 2.3, 1.5]})
>>> model = lsem("Y ~ X", data=df, silent=True)
>>> round(model.est.fit['AIC'], 2)
0.0
Source code in causalinf/models.py
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |