[R] Simple question on a function

From: Serguei Kaniovski <kaniovsk_at_wifo.ac.at>
Date: Mon 02 Oct 2006 - 09:53:49 GMT

I would like to apply the following function to the rows of the matrix "mat", so that freq[1],...,freq[4] are the four elements of each row.




optim(c(0.1,0.1,0.1),obj,NULL,method="BFGS")$par }

mat<-matrix(c(0.4,0.1,0.1,0.4), byrow=TRUE, nrow=10, ncol=4)

1. How to do this using the "apply" function? 2. Can "opmit" be used directly, i.e. without needing to define the function "min_chi2"?
3. How to pass the vector of initial conditions (c(0.1,0.1,0.1)) as an argument to "apply"?

The output should be a 10x3 matrix containing 0.5 0.5 0.6 in each row.

Thanks a lot,


Austrian Institute of Economic Research (WIFO)

Name: Serguei Kaniovski			P.O.Box 91
Tel.: +43-1-7982601-231			Arsenal Objekt 20
Fax:  +43-1-7989386			1103 Vienna, Austria
Mail: Serguei.Kaniovski@wifo.ac.at


R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon Oct 02 19:58:08 2006

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 Mon 02 Oct 2006 - 13:30:07 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.