[R] Optimizing variables represented in a matrix
nataraj at orchidpharma.com
nataraj at orchidpharma.com
Fri Jun 1 06:50:25 CEST 2012
Thanks David and rest of people for replying to my problem posted here.
Basically this is my attempt to estimate the variables of a Gaussian random field model using maximum likelihood method. I have examples of using
"optim " command to optimize one or more variables in a function, the optim command is implemented in the package Stats4. I am following the manual "Maximum Likelihood Programming in R" by Marco R. Steenbergen.
The study that I am doing involves evaluating variables inside a matrix so I have to pass value to the function as matrix which also contains my variables to optimize. Unfortunately, the manual that I mentioned did not have any examples for my kind of problem.
So I hope if you can link my earlier post (forwarded hereunder) with this mail you can get what I am trying to achieve, please let me know if I am still not clear and I will try my best to explain it more. But please do reply.
Regards,
B.Nataraj
-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net]
Sent: Thursday, May 31, 2012 8:19 PM
To: Nataraj B (ORLL-Biotech)
Cc: r-help at r-project.org
Subject: Re: [R] Optimizing variables represented in a matrix
On May 31, 2012, at 7:37 AM, <nataraj at orchidpharma.com> <nataraj at orchidpharma.com
> wrote:
>
> Dear R-list members,
>
> I have a matrix with non-numeric variables in it and I have to
> optimize the variables of the matrix in a formula using optim
> routine of the stats4 package. I know the matrix can only take
> numeric data
Some of the things you think you know, are not so:
> exvec <- c('0.05V1+V2', '0.31V1', '0.05V1', '0.31V1', '0.3V1+V2',
'0.5V1', '0.05V1', '0.5V1', '0.1V1+V2')
> matrix(exvec, 3,3)
[,1] [,2] [,3]
[1,] "0.05V1+V2" "0.31V1" "0.05V1"
[2,] "0.31V1" "0.3V1+V2" "0.5V1"
[3,] "0.05V1" "0.5V1" "0.1V1+V2"
> and so I would like to know how to store non-numeric variables
> inside a matrix.
>
> Say for example: The 3X3 matrix is 0.05V1+V2 0.31V1
> 0.05V1
> 0.31V1 0.3V1+V2
> 0.5V1 0.05V1
> 0.5V1 0.1V1+V2
>
> The matrix is only for an example and the real matrix that I want to
> use is a 15X15 matrix ,here I would like to optimize the values of
> V1 and V2 using a formula.
Whether that plan makes sense seems problematic, but that wasn't your
question.
>
> Could you please help me how to go about to represent the matrix in R.
I'm guessing you have thoughts of evaluating these expressions. They
are not valid R expressions, however. You have some further study to do.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list