[R] How to import simple java/mathematica expression to R
David Winsemius
dwinsemius at comcast.net
Sat Jul 24 05:34:24 CEST 2010
On Jul 23, 2010, at 10:29 PM, jim holtman wrote:
> Well, I took you equation and put the following at the start:
>
> Power <- function(x,y) x^y
> EE <- function(x) x
> alp <- 2
>
> x <- 9000000*Power(-0.2030178326474623 + 0.23024073983368956*(1 -
> alp) +
> 0.2807352820970084*(1 - alp)*(1 - alp*(1 + EE(1))) +
> 0.2145643524071315*(1 - alp)*
> Power(1 - alp*(1 + EE(1)),2) + 0.11519022530097237*(1 -
> alp)*Power(1 - alp*(1 + EE(1)),3) +
> 0.046127977611990736*(1 - alp)*Power(1 - alp*(1 + EE(1)),4) +
> 0.014279410543117517*(1 - alp)*
> Power(1 - alp*(1 + EE(1)),5) + 0.2145643524071315*(Power(1 -
> alp,2)*alp*(1 + EE(1)) +
> (1 - alp)*alp*(1 + EE(1))*(1 - alp*(1 + EE(1))) + Power(1 -
> alp,2)*alp*(1 + EE(2))) +
> 0.11519022530097237*(Power(1 - alp,2)*alp*(1 + EE(1))*(1 - alp*(1
> + EE(1))) +
> 2*(1 - alp)*alp*(1 + EE(1))*Power(1 - alp*(1 + EE(1)),2) +
> Power(1 - alp,2)*alp*(1 - alp*(1 + EE(1)))*(1 + EE(2))) +
> .....................
>
> since there appeared to be functions "Power" and "EE", and the
> variable 'alp'. This evaluated as-is to: 32157617213
>
> so what you have appears to be a legal equation that R can parse as
> is. There you can probably put it in a function and use one of the R
> routines to minimize it, It does not look like you will have any
> problem importing it to R; just have to make sure you have the
> appropriate functions defined.
It has some interesting properties with that identity definition of
EE(x). Local maxima at 1 and 0, "blows up" beyond -1 and 2, and
several local minima nearby:
Math.Fn <- function(alp) { <big-long-expression> }
plot( seq(-.3,1.5,by=0.01), Math.Fn(seq(-.3,1.5,by=0.01) ), cex=0.2)
--
David.
>
> On Fri, Jul 23, 2010 at 1:29 PM, Andrey Siver
> <andrey.siver at gmail.com> wrote:
>> Hello,
>>
>> 2010/7/23 jim holtman <jholtman at gmail.com>:
>>> It would be nice if you could post what the data looks like that you
>>> want to import. R can import any text file and then you have string
>>> manipulation that you can do to parse it. So the basic answer is
>>> probably yes, but we do need to understand the format of the data to
>>> give a more precise answer.
>>
>> I put the target expression to minimize (with some constrains) here:
>>
>> http://analytic-products4you.com/target.txt
>>
>> Is it possible to import it as a function to minimize?
>>
>>>
>>> What is the problem that you are trying to solve?
>>>
>>
>> We solve a problem for parameters estimation with ties.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list