estimate.lvm.reduced: Estimate a latent variable model with linear predictors (LP)

Description Usage Arguments Examples

Description

Add columns corresponding to the LPs in the dataset (filled with 0) so that LPs are not treated as a latent variable

Usage

1
2
## S3 method for class 'lvm.reduced'
estimate(x, data, estimator = "gaussian", ...)

Arguments

x

lvm.reduced-object

data

data.frame

estimator

character

...

additional arguments to be passed to the low level functions

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
#### regression ####

## simulation
m <- lvm()
m <- regression(m,y='y1',x='x'%++%1:2)
m <- regression(m,y='y1',x='z'%++%1:5)

set.seed(10)
d <- sim(m,150)

## reduced model 1
mR1 <- lvm.reduced()
mR1 <- regression(mR1,y='y1',x='x'%++%1:2)
mR1 <- regression(mR1,y='y1',x='z'%++%1:5, reduce = TRUE)

## reduced model 2
mR2 <- reduce(m)

## check estimation
emGS <- estimate(m, d)
em1 <- estimate(m, d, estimator = "gaussian1")
emR1 <- estimate(mR1, d)
coef(emGS) - coef(em1)
coef(em1) - coef(emR1)[names(coef(em1))]

emR2 <- estimate(mR1, d)

#### latent variable model ####
m <- lvm()
m <- regression(m,y=c('y1','y2','y3','y4'),x='eta')
m <- regression(m,y=c('y2','y3'),x='x'%++%1:5)
latent(m) <- ~eta
m <- regression(m,y=c('y1','y2'),x='z'%++%1:2)
covariance(m) <- y2~y1

# simul
set.seed(10)
d <- sim(m,100)

# reduced model
mR1 <- reduce(m, endo = c("y2"))
mR2 <- reduce(m)

## estimation
em <- estimate(m,d)
emR <- estimate(mR1, data = d)
coef(em)
coef(emR)[names(coef(em))]

bozenne/lavaReduce documentation built on May 24, 2019, 3:05 a.m.