Skip to content

Bivariate normal regression in R

3 messages · DHIMAN BHADRA, Dimitris Rizopoulos, Viechtbauer Wolfgang (STAT)

#
One possibility is function gls() from package nlme.

Best,
Dimitris
On 8/25/2011 8:22 PM, DHIMAN BHADRA wrote:

  
    
#
Another way would be to consider this as a path model and use the sem or lavaan package to fit this model. Here is an example:

x  <- rnorm(1000)
e1 <- rnorm(1000)
e2 <- e1 + rnorm(1000)
e1 <- e1 + rnorm(1000)
y1 <- 2 + 1*x + e1
y2 <- 4 + 2*x + e2

dat <- data.frame(x, y1, y2)

model <- 'y1 ~ x
          y2 ~ x'

fit <- sem(model, data=dat)
summary(fit)

However, note that you could just as well run two separate regressions:

summary(lm(y1 ~ x))
summary(lm(y2 ~ x))

The results are virtually identical. 

Best,

Wolfgang