Edson Tirelli
Edson Tirelli

Reputation: 3901

Selecting variables in a multivariate regression in R

I am quite new to R and I am having trouble figuring out how to select variables in a multivariate linear regression in R.

Pretend I have the following formulas:

P = aX + bY
Q = cZ + bY

I have a data frame with column P, Q, X, Y, Z and I need to find a, b and c.

If I do a simple multivariate regression:

result <- lm( cbind( P, Q ) ~ X + Y + Z - 1 )

It calculates a coefficient for "c" on P's regression and for "a" on Q's regression.

If I calculate the regressions individually then "b" will be different in each regression.

How can I select the variables to consider in a multivariate regression?

Thank you, Edson

Upvotes: 3

Views: 1103

Answers (1)

lebatsnok
lebatsnok

Reputation: 6479

P = aX + bY; Q = cZ + bY

in lavaan you could do it by adding an equality constraint i.e giving two parameters the same custom name

P ~ X + b*Y
Q ~ Z + b*Y

See also http://lavaan.ugent.be/tutorial/syntax2.html

Upvotes: 1

Related Questions