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,

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
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
=================================
David Barron
Said Business School
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
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Jan 10 10:38:39 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 00:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.