| Title: | Heteroskedasticity and Proxy-Based IV Methods |
|---|---|
| Description: | Tools for identifying structural shocks using heteroskedasticity- and proxy-based instrumental variable (IV) methods in event-study settings. Supports local projection impulse response estimation of Jorda (2005) <doi:10.1257/0002828053828518>, generalised weak instrument testing of Lewis and Mertens (2025) <doi:10.1093/restud/rdaf103>, recursive heteroskedasticity-IV identification of Burri and Kaufmann (2026b) <doi:10.1016/j.econlet.2026.113091>, and Kalman-filter shock extraction of Burri and Kaufmann (2026a). |
| Authors: | Daniel Kaufmann [aut, cre, cph], Marc Burri [aut], Valentin Grob [aut] |
| Maintainer: | Daniel Kaufmann <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-07-09 14:23:53 UTC |
| Source: | https://github.com/dankaufmann/hetiv |
Recursively computes IRFs given an impact matrix and VAR coefficient array. Optionally cumulates responses for selected variables.
computeirf(Psi, Phi, H, cum)computeirf(Psi, Phi, H, cum)
Psi |
Impact matrix, dimension |
Phi |
Array of VAR coefficient matrices, dimension |
H |
Horizon (number of periods) for which to compute IRFs. |
cum |
Logical scalar or logical vector of length |
An array:
Array of impulse responses, dimension H x N x R. Row names
are labelled 0 to H-1.
Psi <- matrix(c(1, 0.5), nrow = 2) Phi <- array(0, dim = c(2, 2, 1)) Phi[, , 1] <- matrix(c(0.4, 0.1, 0, 0.3), 2, 2) computeirf(Psi = Psi, Phi = Phi, H = 4, cum = FALSE)Psi <- matrix(c(1, 0.5), nrow = 2) Phi <- array(0, dim = c(2, 2, 1)) Phi[, , 1] <- matrix(c(0.4, 0.1, 0, 0.3), 2, 2) computeirf(Psi = Psi, Phi = Phi, H = 4, cum = FALSE)
Fills missing values (NA) in every column of a data frame using linear
interpolation, up to a maximum of gap consecutive missing observations.
Gaps longer than gap are left as NA.
filllinear(DF, gap)filllinear(DF, gap)
DF |
A data frame or matrix with numeric columns. |
gap |
Integer. Maximum number of consecutive |
The data frame DF with short gaps linearly interpolated.
filllinear(data.frame(x = c(1, NA, 3), y = c(2, NA, 4)), gap = 1)filllinear(data.frame(x = c(1, NA, 3), y = c(2, NA, 4)), gap = 1)
Computes the first difference of a numeric vector or time series,
i.e. x_t - x_{t-1}. Gaps in dates are ignored; the difference is always
taken with respect to the immediately preceding observation.
firstdiff(TS)firstdiff(TS)
TS |
A numeric vector or time series. |
A numeric vector of the same length as TS, with NA in the
first position.
firstdiff(c(1, 3, 6))firstdiff(c(1, 3, 6))
Tests for weak instruments with multiple endogenous regressors using the generalised minimum eigenvalue statistic of Lewis and Mertens (2025). The test is robust to heteroskedasticity and autocorrelation and nests the classical Stock-Yogo (2005) test as a special case. The function is a direct port from the Matlab codes by Lewis and Mertens (2025)
gweakivtest( y, Y, X, Z, cov_type = "EHW", alfa = 0.05, tau = 0.1, points = 1000L, target = "beta", crit = "abs", seed = 12345L )gweakivtest( y, Y, X, Z, cov_type = "EHW", alfa = 0.05, tau = 0.1, points = 1000L, target = "beta", crit = "abs", seed = 12345L )
y |
Regressand (T x 1 numeric vector or matrix). |
Y |
Endogenous regressors (T x N numeric matrix). |
X |
Exogenous regressors (T x Nx numeric matrix). A constant column is
added automatically if one is absent or if |
Z |
Instruments (T x K numeric matrix). Requires K >= N. |
cov_type |
HAR covariance estimator: |
alfa |
Nominal significance level (default |
tau |
Bias tolerance: maximum acceptable relative (or absolute, see
|
points |
Number of random starting points for the Stiefel manifold
optimisation used to compute the sharp critical value when K > N + 1
(default |
target |
Either |
crit |
Bias criterion: |
seed |
Integer seed used for the random Stiefel starting points when
computing the sharp critical value. The default is fixed for reproducible
critical values and the caller's RNG state is restored afterwards. Use
|
A named list with the following elements:
nobsNumber of complete observations used.
beta_2SLS2SLS point estimate(s).
targetDescription of the targeted parameter.
criterionBias criterion used ("abs" or "rel").
gmin_generalizedGeneralised minimum eigenvalue test statistic (Lewis-Mertens).
gmin_generalized_critical_valueSharp critical value via Stiefel optimisation.
gmin_generalized_critical_value_simplifiedConservative simplified critical value (closed-form bound).
stock_yogo_test_statisticStock-Yogo test statistic under the Nagar approximation.
stock_yogo_critical_value_nagarStock-Yogo critical value under the Nagar approximation.
Lazarus, E., Lewis, D. J., Stock, J. H. and Watson, M. W. (2018). HAR inference: recommendations for practice. Journal of Business & Economic Statistics, 36(4), 541-559.
Lewis, D. J. and Mertens, K. (2025). A robust test for weak instruments for 2SLS with multiple endogenous regressors. Review of Economic Studies, DOI: 10.1093/restud/rdaf103.
Stock, J. H. and Yogo, M. (2005). Testing for weak instruments in linear IV regression. In D. W. K. Andrews and J. H. Stock (Eds.), Identification and inference for econometric models: essays in honor of Thomas Rothenberg, pp. 80-108. Cambridge University Press.
set.seed(1) n <- 80 Z <- matrix(rnorm(n), ncol = 1) X <- matrix(1, n, 1) Y <- 0.8 * Z + rnorm(n) y <- 1.5 * Y + rnorm(n) gweakivtest(y = y, Y = Y, X = X, Z = Z, points = 1)set.seed(1) n <- 80 Z <- matrix(rnorm(n), ncol = 1) X <- matrix(1, n, 1) Y <- 0.8 * Z + rnorm(n) y <- 1.5 * Y + rnorm(n) gweakivtest(y = y, Y = Y, X = X, Z = Z, points = 1)
Estimates impulse response functions (IRFs) using recursive heteroskedasticity-IV identification (Rigobon, 2003; Rigobon and Sack, 2004; Lewis, 2022; Burri and Kaufmann, 2026a, 2026b) combined with local projections (Jorda, 2005). Identification exploits the difference in variance between policy event days and control days to construct instruments for the endogenous variables.
hetiv( y, O, X = NULL, Ind, P, H, E = 1, norm = 1, interact = FALSE, cum = FALSE, Hstep = 1, cov_type = "HC0", details = FALSE )hetiv( y, O, X = NULL, Ind, P, H, E = 1, norm = 1, interact = FALSE, cum = FALSE, Hstep = 1, cov_type = "HC0", details = FALSE )
y |
Numeric matrix of stationary outcome variables (T x N). The effect on the first variable in each dimension is normalized to unity at horizon 0. These variables are also used to construct heteroskedasticity-based instruments and for recursive ordering to identify multiple dimensions. |
O |
Numeric matrix of information set variables (T x M). May be
identical to |
X |
Numeric matrix of deterministic variables (T x K). For example, time trend, seasonal dummies or other deterministic controls. Included as is (no lags). A constant is included by default. |
Ind |
Integer vector of length T, event indicator:
|
P |
Integer. Maximum lag order for the information set. Set to |
H |
Integer. Maximum horizon (in periods) up to which IRFs are estimated. |
E |
Integer. Number of shock dimensions to identify via recursive ordering. |
norm |
Numeric scalar. Normalize the impact response of the first
variable to a specific value. Set to |
interact |
Logical. If |
cum |
Logical vector of length N. For each variable in |
Hstep |
Integer. Step size between horizons. The default |
cov_type |
Covariance estimator for local-projection standard errors:
|
details |
Logical. If |
For E > 1, identification is recursive and order-dependent: the
column order of y defines both the shock ordering and the normalization
variable for each shock dimension.
A named list with the following elements:
irfArray (H x N x E) of estimated impulse responses.
seArray (H x N x E) of local-projection standard errors.
IVResList of ivreg model objects, one per horizon, variable,
and shock dimension.
ObsData frame with observation counts: Tp (policy days),
Tc (control days), To (contaminated days), Tt (total used).
MethodCharacter string "Heteroscedasticity-IV".
etData frame of OLS residuals on event days (used for covariance estimation and shock extraction).
SigCovariance matrix of residuals on event days (used for shock extraction).
SigRCovariance matrix of residuals on control days, or NA
if unavailable (used for shock extraction).
PsiImpact matrix (N x E), equal to irf[1, , ]. By the
package's indexing convention HSeries starts at 1, so the first LP
uses lead(y, 0) (the contemporaneous value) and is labelled horizon
0; irf[1, , ] is therefore always the impact response.
WeakDataData frame of endogenous variables and instruments for the Lewis-Mertens (2025) weak instrument test.
Burri, M. and D. Kaufmann (2026a). Measuring monetary policy shocks. IRENE Working Papers 24-03, IRENE Institute of Economic Research, University of Neuchatel.
Burri, M. and D. Kaufmann (2026b). Multiple monetary policy shocks from daily data: A heteroskedasticity IV approach. Economics Letters, 268, 113091. doi:10.1016/j.econlet.2026.113091
Jorda, O. (2005). Estimation and inference of impulse responses by local projections. American Economic Review, 95(1), 161-182.
Lewis, D. J. (2022). Robust inference in models identified via heteroskedasticity. Review of Economics and Statistics, 104(3), 510-524.
Lewis, D. J. and Mertens, K. (2025). A robust test for weak instruments for 2SLS with multiple endogenous regressors. Review of Economic Studies, DOI: 10.1093/restud/rdaf103
Montiel Olea, J. L., M. Plagborg-Moller, E. Qian, and C. K. Wolf (2025). Local projections or VARs? A primer for macroeconomists. NBER Working Paper No. 33871.
Rigobon, R. (2003). Identification through heteroskedasticity. Review of Economics and Statistics, 85(4), 777-792.
Rigobon, R. and Sack, B. (2004). The impact of monetary policy on asset prices. Journal of Monetary Economics, 51(8), 1553-1575.
set.seed(1) y <- matrix(rnorm(80), ncol = 2) Ind <- rep(0L, nrow(y)) Ind[seq(5, nrow(y), by = 5)] <- 1L res <- hetiv(y = y, O = y, Ind = Ind, P = 1, H = 3, details = TRUE) dim(res$irf)set.seed(1) y <- matrix(rnorm(80), ncol = 2) Ind <- rep(0L, nrow(y)) Ind[seq(5, nrow(y), by = 5)] <- 1L res <- hetiv(y = y, O = y, Ind = Ind, P = 1, H = 3, details = TRUE) dim(res$irf)
Extracts structural shocks from reduced-form residuals using the Kalman
filter formula. Given the impact matrix Psi and the covariance matrices
of residuals on event and control days, the function recovers the latent
shocks for each observation. Optionally rescales shocks to unit variance.
kfpredict(Sig, SigR, Psi, et, tol = sqrt(.Machine$double.eps), scale = TRUE)kfpredict(Sig, SigR, Psi, et, tol = sqrt(.Machine$double.eps), scale = TRUE)
Sig |
Numeric matrix (N x N). Covariance matrix of reduced-form
residuals on policy event days (e.g. |
SigR |
Numeric matrix (N x N). Covariance matrix of reduced-form
residuals on control (non-event) days. Used to back out the implied
shock variances when |
Psi |
Numeric matrix (N x E). Impact matrix, i.e. the contemporaneous
responses of all N variables to the E structural shocks (e.g. |
et |
Numeric matrix or data frame (T x N). Reduced-form residuals on
event days (e.g. |
tol |
Numeric scalar. Tolerance for the generalized inverse
( |
scale |
Logical. If |
A numeric matrix (T x E) of extracted structural shocks, with the
same number of rows as et and one column per shock dimension.
Burri, M. and Kaufmann, D. (2026a). Measuring monetary policy shocks. IRENE Working Papers 24-03, IRENE Institute of Economic Research, University of Neuchatel.
Sig <- diag(2) SigR <- diag(c(0.5, 0.5)) Psi <- matrix(c(1, 0.5), nrow = 2) et <- matrix(rnorm(20), ncol = 2) kfpredict(Sig = Sig, SigR = SigR, Psi = Psi, et = et)Sig <- diag(2) SigR <- diag(c(0.5, 0.5)) Psi <- matrix(c(1, 0.5), nrow = 2) et <- matrix(rnorm(20), ncol = 2) kfpredict(Sig = Sig, SigR = SigR, Psi = Psi, et = et)
Computes the first log-difference of a numeric vector or time series,
i.e. log(x_t) - log(x_{t-1}). Gaps in dates are ignored; the difference
is always taken with respect to the immediately preceding observation.
logdiff(TS)logdiff(TS)
TS |
A numeric vector or time series. |
A numeric vector of the same length as TS, with NA in the
first position.
logdiff(c(1, 2, 4))logdiff(c(1, 2, 4))
Standardizes a numeric vector to zero mean and unit standard deviation (z-score normalization), ignoring missing values.
normalize(x)normalize(x)
x |
A numeric vector or time series. |
A numeric vector of the same length as x, with mean 0 and
standard deviation 1.
normalize(c(1, 2, 3, 4, 5))normalize(c(1, 2, 3, 4, 5))
Produces a panel of IRF plots comparing two sets of impulse responses.
Each panel shows the point estimates and confidence bands
at level ci for both approaches. Returns a list of ggplot objects
(one per variable-shock combination) that can be arranged with e.g.
cowplot::plot_grid().
plot2irf(IRF1, IRF1se, IRF2, IRF2se, HTick, Labels, ci = 0.9)plot2irf(IRF1, IRF1se, IRF2, IRF2se, HTick, Labels, ci = 0.9)
IRF1 |
Array (H x N x E) of impulse responses for the first approach. Dimnames on the first dimension must be the horizon labels (numeric). |
IRF1se |
Array (H x N x E) of standard errors for the first approach (set to 0 to suppress confidence intervals). |
IRF2 |
Array (H x N x E) of impulse responses for the second approach. |
IRF2se |
Array (H x N x E) of standard errors for the second approach (set to 0 to suppress confidence intervals). |
HTick |
Integer. Step size for x-axis tick marks. |
Labels |
Character vector of length N. Variable names used as panel titles. |
ci |
Numeric scalar in (0, 1). Confidence level for the shaded bands.
Defaults to |
A list of ggplot objects, one per variable-shock combination,
ordered by shock (outer loop) then variable (inner loop).
irf1 <- array(c(1, 0.5, 0.2, 0.1), dim = c(4, 1, 1)) dimnames(irf1)[[1]] <- 0:3 irf2 <- irf1 * 0.8 se <- array(0.1, dim = dim(irf1), dimnames = dimnames(irf1)) plot2irf(irf1, se, irf2, se * 0, HTick = 1, Labels = "Output")irf1 <- array(c(1, 0.5, 0.2, 0.1), dim = c(4, 1, 1)) dimnames(irf1)[[1]] <- 0:3 irf2 <- irf1 * 0.8 se <- array(0.1, dim = dim(irf1), dimnames = dimnames(irf1)) plot2irf(irf1, se, irf2, se * 0, HTick = 1, Labels = "Output")
Produces a panel of IRF plots for a single set of impulse responses,
with optional confidence bands. Returns a list of ggplot
objects (one per variable-shock combination) that can be arranged with
e.g. cowplot::plot_grid().
plotirf(IRFest, IRFse = NULL, HTick, Labels, ci = c(0.9, 0.95))plotirf(IRFest, IRFse = NULL, HTick, Labels, ci = c(0.9, 0.95))
IRFest |
Array (H x N x E) of impulse response point estimates. Dimnames on the first dimension must be the horizon labels (numeric). |
IRFse |
Array (H x N x E) of standard errors, or |
HTick |
Integer. Step size for x-axis tick marks. |
Labels |
Character vector of length N. Variable names used as panel titles. |
ci |
Numeric vector of confidence levels in (0, 1). One shaded band is
drawn per level, with wider bands rendered at lower opacity. Defaults to
|
A list of ggplot objects, one per variable-shock combination,
ordered by shock (outer loop) then variable (inner loop).
irf <- array(c(1, 0.5, 0.2, 0.1), dim = c(4, 1, 1)) dimnames(irf)[[1]] <- 0:3 se <- array(0.1, dim = dim(irf), dimnames = dimnames(irf)) plotirf(irf, se, HTick = 1, Labels = "Output")irf <- array(c(1, 0.5, 0.2, 0.1), dim = c(4, 1, 1)) dimnames(irf)[[1]] <- 0:3 se <- array(0.1, dim = dim(irf), dimnames = dimnames(irf)) plotirf(irf, se, HTick = 1, Labels = "Output")
Produces a panel of p-value plots across IRF horizons, with optional
horizontal reference lines at user-supplied significance levels. Returns a
list of ggplot objects (one per variable-shock combination) that can be
arranged with e.g. cowplot::plot_grid().
plotpval(pvals, HTick, Labels, sigLevels = c(0.05, 0.1))plotpval(pvals, HTick, Labels, sigLevels = c(0.05, 0.1))
pvals |
Array (H x N x E) of p-values. Dimnames on the first dimension must be the horizon labels (numeric). |
HTick |
Integer. Step size for x-axis tick marks. |
Labels |
Character vector of length N. Variable names used as panel titles. |
sigLevels |
Numeric vector of significance levels at which to draw
horizontal reference lines. The first value is drawn as a solid line, the
second as dashed, and any further values as dotted. Defaults to
|
A list of ggplot objects, one per variable-shock combination,
ordered by shock (outer loop) then variable (inner loop).
pvals <- array(c(0.2, 0.08, 0.04), dim = c(3, 1, 1)) dimnames(pvals)[[1]] <- 0:2 plotpval(pvals, HTick = 1, Labels = "Output")pvals <- array(c(0.2, 0.08, 0.04), dim = c(3, 1, 1)) dimnames(pvals)[[1]] <- 0:2 plotpval(pvals, HTick = 1, Labels = "Output")
Estimates impulse response functions (IRFs) using user-provided external
instruments (proxies) combined with local projections (Jorda, 2005). The
proxy variables serve directly as instruments for the endogenous shock
variables. Optionally imposes recursive zero restrictions across shock
dimensions and supports deterministic controls following the same
conventions as hetiv().
proxyiv( y, O, Z, X = NULL, Ind, P, H, E = 1, norm = 1, cum = FALSE, Hstep = 1, cov_type = "HC0", recursive = FALSE, details = FALSE )proxyiv( y, O, Z, X = NULL, Ind, P, H, E = 1, norm = 1, cum = FALSE, Hstep = 1, cov_type = "HC0", recursive = FALSE, details = FALSE )
y |
Numeric matrix of stationary outcome variables (T x N). The effect
on the first variable in each dimension is normalized to |
O |
Numeric matrix of information set variables (T x M). May be
identical to |
Z |
Numeric matrix of external instruments (T x E). Column |
X |
Numeric matrix of deterministic variables (T x K), or |
Ind |
Integer vector of length T, event indicator:
|
P |
Integer. Maximum lag order for the information set. Set to |
H |
Integer. Maximum horizon (in periods) up to which IRFs are estimated. |
E |
Integer. Number of shock dimensions to identify. Default |
norm |
Numeric scalar. Normalize the impact response of the first
variable to this value. Set to |
cum |
Logical scalar or vector of length N. If |
Hstep |
Integer. Step size between horizons. The default |
cov_type |
Covariance estimator for local-projection standard errors:
|
recursive |
Logical. If |
details |
Logical. If |
For E > 1, identification can be order-dependent: the column order
of y defines the endogenous shock variables and normalizations, the
column order of Z assigns proxies to shock dimensions, and
recursive = TRUE imposes restrictions in that order.
A named list. Always contains:
irfArray (H x N x E) of estimated impulse responses.
seArray (H x N x E) of local-projection standard errors.
MethodCharacter string "Proxy-IV".
With details = TRUE, additionally contains:
IVResList of ivreg model objects, one per horizon, variable,
and shock dimension.
OLSResList of OLS model objects used for residual-based covariance estimation, one per outcome variable.
ObsData frame with observation counts: Tp (policy days),
Tc (control days), To (contaminated days), Tt (labelled event or
control days), and Tiv (complete observations available to the IV
regression at the impact horizon).
etData frame of OLS residuals on event days.
SigCovariance matrix of residuals on event days.
SigRCovariance matrix of residuals on control days, or NA
if unavailable.
PsiImpact matrix (N x E), equal to irf[1, , ]. By the
package's indexing convention HSeries starts at 1, so the first LP
uses lead(y, 0) (the contemporaneous value) and is labelled horizon
0; irf[1, , ] is therefore always the impact response.
WeakDataData frame of endogenous variables and instruments for the Lewis-Mertens (2025) weak instrument test.
Jorda, O. (2005). Estimation and inference of impulse responses by local projections. American Economic Review, 95(1), 161-182.
Lewis, D. J. and Mertens, K. (2025). A robust test for weak instruments for 2SLS with multiple endogenous regressors. Review of Economic Studies, DOI: 10.1093/restud/rdaf103
Mertens, K. and Ravn, M. O. (2013). The dynamic effects of personal and corporate income tax changes in the United States. American Economic Review, 103(4), 1212-1247.
Montiel Olea, J. L., M. Plagborg-Moller, E. Qian, and C. K. Wolf (2025). Local projections or VARs? A primer for macroeconomists. NBER Working Paper No. 33871.
Stock, J. H. and Watson, M. W. (2018). Identification and estimation of dynamic causal effects in macroeconomics using external instruments. Economic Journal, 128(610), 917-948.
set.seed(1) y <- matrix(rnorm(80), ncol = 2) Ind <- rep(0L, nrow(y)) Ind[seq(5, nrow(y), by = 5)] <- 1L Z <- matrix(Ind * y[, 1] + rnorm(nrow(y)), ncol = 1) res <- proxyiv( y = y, O = y, Z = Z, Ind = Ind, P = 1, H = 3, details = TRUE ) dim(res$irf)set.seed(1) y <- matrix(rnorm(80), ncol = 2) Ind <- rep(0L, nrow(y)) Ind[seq(5, nrow(y), by = 5)] <- 1L Z <- matrix(Ind * y[, 1] + rnorm(nrow(y)), ncol = 1) res <- proxyiv( y = y, O = y, Z = Z, Ind = Ind, P = 1, H = 3, details = TRUE ) dim(res$irf)
Simulates data from a VAR(P) model with two types of structural shocks:
regular shocks (always present) and event shocks (occurring every Nevn
periods). The shock distribution can be normal, Student-t, or GARCH(1,1).
simulatedata(Phi, SigE, PsiE, PsiR, Nobs, Nbin, N, R, E, Nevn, P, eDist, seed)simulatedata(Phi, SigE, PsiE, PsiR, Nobs, Nbin, N, R, E, Nevn, P, eDist, seed)
Phi |
Array of VAR coefficient matrices, dimension |
SigE |
Variance of the event shocks. This applies to all E shocks. |
PsiE |
Impact matrix for event shocks, dimension |
PsiR |
Impact matrix for regular shocks, dimension |
Nobs |
Number of observations to retain after burn-in. The returned
data have exactly |
Nbin |
Number of burn-in observations. These are simulated to initialise the VAR but are discarded before returning. |
N |
Number of variables in the VAR. |
R |
Number of regular shocks. |
E |
Number of event shocks. For GARCH shock distributions
( |
Nevn |
Event frequency: an event shock occurs every |
P |
VAR lag order. |
eDist |
Shock distribution. Use |
seed |
Integer seed passed to |
A named list with components:
Simulated VAR data, dimension Nobs x N (burn-in discarded).
Event indicator matrix, dimension Nobs x 1.
Simulated regular shocks, dimension Nobs x R.
Simulated event shocks, dimension Nobs x E.
Composite structural shocks, dimension Nobs x N.
VAR coefficient array (returned unchanged).
Event shock impact matrix (returned unchanged).
Regular shock impact matrix (returned unchanged).
Event shock variance (returned unchanged).
N <- 2 Phi <- array(0, dim = c(N, N, 1)) Phi[, , 1] <- diag(c(0.4, 0.2)) simulatedata( Phi = Phi, SigE = 2, PsiE = matrix(c(1, 0.5), N, 1), PsiR = diag(N), Nobs = 20, Nbin = 5, N = N, R = N, E = 1, Nevn = 5, P = 1, eDist = 0, seed = 1 )N <- 2 Phi <- array(0, dim = c(N, N, 1)) Phi[, , 1] <- diag(c(0.4, 0.2)) simulatedata( Phi = Phi, SigE = 2, PsiE = matrix(c(1, 0.5), N, 1), PsiR = diag(N), Nobs = 20, Nbin = 5, N = N, R = N, E = 1, Nevn = 5, P = 1, eDist = 0, seed = 1 )