# Re: [R] Multivariate OLS

From: r400 r400 <r_253309_at_yahoo.com>
Date: Tue 09 Jan 2007 - 12:02:29 GMT

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@googlemail.com> To: r400 r400 <r_253309@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@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@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

```--
=================================
David Barron
University of Oxford
Park End Street
Oxford OX1 1HP

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help