[R] "Special" LS estimation problem

megh megh700004 at yahoo.com
Sat Aug 22 15:58:13 CEST 2009


I found no fruitful suggestions as yet, therefore I have devised a simple
mechanism for that. 

Here I can modify my model as : Y = X*a + error, X = (X1, X2), a = t(a1, a2)

Now I can apply the standard LS procedure, to estimate a. Here is my code :

Y <- replicate(10, matrix(rnorm(2),2), simplify = F)
X1 <- replicate(10, matrix(rnorm(4),2), simplify = F)
X2 <- replicate(10, matrix(rnorm(4),2), simplify = F)

X <- lapply(1:10, function(i) cbind(X1[[i]], X2[[i]]))

temp1 <- Reduce("cbind", lapply(X, "t")); temp2 <- Reduce("rbind", X); temp3
<- Reduce("rbind", Y)

a <- solve(temp1%*%temp2) %*% (temp1%*%temp3); a


Can I go ahead with this procedure? Somebody please validate this?

Thanks



megh wrote:
> 
> Hi, I have following kind of model : Y = X1 * a1 + X2 * a2 + error
> 
> Here sampled data for Y, X1, X2 are like that :
> 
> Y <- replicate(10, matrix(rnorm(2),2), simplify = F)
> X1 <- replicate(10, matrix(rnorm(4),2), simplify = F)
> X2 <- replicate(10, matrix(rnorm(4),2), simplify = F)
> 
> My goal is to calculate LS estimates of vectors "a1" and "a2". Can anyone
> please guide me how to do that in R? Is there any special function to
> handle this kind of problem?
> 
> Thanks
> 

-- 
View this message in context: http://www.nabble.com/%22Special%22-LS-estimation-problem-tp25083103p25094080.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list