# [R] Multivariate OLS

r400 r400 r_253309 at yahoo.com
Tue Jan 9 13:02:29 CET 2007

```Dear David,

Thank you very much for this reply. But unfortunately it is not that I want. In my equation 'a' is a vector with length 2, 'b' and 'c' are matrix with row and columns 2. It is like Vector Autoregressive model, but there is some difference between that model and my model. Is there any suggestion?

Thanks and regards,

----- Original Message ----
From: David Barron <mothsailor at googlemail.com>
To: r400 r400 <r_253309 at yahoo.com>
Sent: Tuesday, January 9, 2007 3:15:27 PM
Subject: Re: [R] Multivariate OLS

I don't understand the problem; why can't you use lm with a data
frame?  Is something like this what you are after?

dat <- data.frame(y=rnorm(100),x=rnorm(100,5))
dif1 <- diff(dat[,1])
dif2 <- diff(dat[,1],lag=2)

lm(y ~ dif1[-1] + dif2, data=dat[-(1:2),])

On 08/01/07, r400 r400 <r_253309 at yahoo.com> wrote:
> Dear all R users,
>
> Suppose I have a VECTOR of time series y[t] consists of 2000 data point. For example suppose I have data frame which has two columns. First column represents a time series of exchange rate for 2000 days. And the second column represents the price of a commodity for the same period. Now I want to fit a OLS regression like that,
>
> y[t] = a + b*delta[y[t-1]] + c*delta[y[t-2]] + epsilon[t]
>
> as y[t] is not a vector rather a data frame containing two columns I could not use lm() function. Can anyone give me any idea how to do that in R?
>
> Thanks and regards,
> jon
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

--
=================================
David Barron