Re: [R] code for power and suffix for x,y labels in plot( ).

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Wed, 02 Jun 2010 09:15:40 -0700

On Tue, Jun 1, 2010 at 9:59 PM, Shant Ch <sha1one_at_yahoo.com> wrote:
> Hi
>
> I was trying to have a graph whose axes are X axis: m, Y axis: var[X ((a,b) in suffix, and (n,d) in the power)].
>
> X ((a,b) in suffix, and (n,d) in the power)-        X^(n,d) _ (a,b).
>
> Actually I require many plots involving different values of a,b,n,d, so need to keep this complicated notation.
> The expression() didn't work out for this case. Can anyone help me out.
> Thanks, in advance.
> Shant
>
>
>
>
>
>
> uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2, upper = 2, tol = 0.001 )
>
> While using this I am getting the following error. Can anyone please help me out.
> Error in uniroot(function(x) x * (3^x) * log(4) - x * log(4/3) - (3^x) +  :   f() values at end points not of opposite sign.

Here is your function:

temp.fun <- function(x) {
  value <- x*(3^x)*log(4)-x*log(4/3)-(3^x)+1   return(value)
}

look what happens when you do:

temp.fun(-2)
temp.fun(2)

in both cases, it returns a positive value. uniroot() requires "The function values at the endpoints must be of opposite signs (or zero)", hence the error. I believe your function has a lower bound of 0, which is obtained when the input is 0. So one option would be to change your argument to uniroot() so that lower=0. Although the results are not particularly interesting in this case.

uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = 0, upper = 2, tol = 0.001 )

HTH, Josh

>
> Thanks in advance.
>
> Shant
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org 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.
>

-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

______________________________________________
R-help_at_r-project.org 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 02 Jun 2010 - 16:17:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 16:40:26 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.

list of date sections of archive