estimate_NERM: Estimate nested error regression model (NERM)

Description Usage Arguments Value Examples

View source: R/estimate_NERM.R

Description

Estimate NERM, store fixed and random parameters and variances

Usage

1
estimate_NERM(X, y, clusterID, X_cluster = NULL)

Arguments

X

Matrix with covariates for fixed effects

y

Vector of responses

clusterID

Vector with cluster labels

X_cluster

Matrix with cluster level covariates for fixed effects. Default: NULL.

Value

List with parameters:

fit_model_fixed

Estimated model using fixed effects

fit_model_mixed

Estimated model using fixed and random effects

sig_u

Variance parameter of random effects

sig_e

Variance parameter of errors

beta

Fixed effects (regression parameters)

u

Random effects

mu

Mixed effects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
n = 10
m_i = 5
m_total = 50

clusterID = rep(1:5, n)
p = 10
beta = rep(2, p)
u_i = rnorm(n, 0, 2)
u_i_aug = rep(u_i, each = m_i)
X = matrix(rnorm(m_total * p), m_total, p)
y = X%*%beta + u_i_aug + rnorm(m_total, 0, 1)
fit_nerm <- estimate_NERM(X = X, y = y,
                          clusterID = clusterID,
                          X_cluster = NULL)

KatarzynaReluga/postcAIC documentation built on Jan. 25, 2022, 12:33 a.m.