Hi,
I was trying to have a graph whose axes are of the following type:
X axis: n and Y axis: var[U ((a,b) in suffix, and (n,d) in the power)].
U ((a,b) in suffix, and (n,d) in the power)- U^(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 code I used:
plot(n, hn$h_pg, ylab=expression(Var(U[2%,%1]^(n%,%0))-Var(U[1%,%1]^(n%,%0))),
xlab="n",type="l");
The expression() didn't work out for this case. Can anyone help me out.
Also due to the size of the expression in the Y axis, I want to shift the graph
in the R Graphics window, so that the Y labels are also fully visible. i
don't know such command which will shift the whole graph a little in the
Graphics window.
Thanks, in advance.
Shant
[[alternative HTML version deleted]]
On 02.06.2010 20:22, Shant Ch wrote:> > > Hi, > I was trying to have a graph whose axes are of the following type: > > X axis: n and Y axis: var[U ((a,b) in suffix, and (n,d) in the power)]. > > U ((a,b) in suffix, and (n,d) in the power)- U^(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 code I used: > > plot(n, hn$h_pg, ylab=expression(Var(U[2%,%1]^(n%,%0))-Var(U[1%,%1]^(n%,%0))), xlab="n",type="l");plot(1, 1, ylab = expression(var(U[list(a,b)]^(list(n,d)))), xlab = "n", type = "l") or if you want to replace a, b, d, and n by values, use: a <- 1 b <- 2 d <- 3 n <- 4 plot(1, 1, ylab = substitute(var(U[list(a,b)]^(list(n,d))), list(a=a, b=b, d=d, n=n)), xlab = "n", type = "l")> The expression() didn't work out for this case. Can anyone help me out. > > Also due to the size of the expression in the Y axis, I want to shift the graph in the R Graphics window, so that the Y labels are also fully visible. i don't know such command which will shift the whole graph a little in the Graphics window.Define other margins, see argument "mar" in ?par, e.g. par(mar=c(5,5,4,1)+.1) Uwe Ligges> 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.
Hi,
I was trying to solve for m such that,
choose(n-1,k-1)+choose(n-2,k-1)+...+choose(n-m+1,k-1) - ck=0
ck is calculated by the way given in the code. Now I solved for m using uniroot
but the error messages appeared.
n<-30
k=3
alpha<-0.05
nk<-choose(n,k);
ck<-(nk/2)+k*nk*qnorm(1-alpha)/(12*n) # computation of ck.
lhs<-function(z)
{
Smc=0;
fnk=0
for(y in 1:z)
{
fnk[y]<-choose((n-y+1),(k-1))
Smc=Smc+fnk[y]-ck
}
return(Smc);
}
In order to solve the equation first I tried to find out the point near which
lhs=0 using curve function.
curve(lhs,-70,-60)
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ
In addition: Warning message:
In 1:z : numerical expression has 101 elements: only the first used
Then I computed lhs function for every z one by one, I found that lhs changes
its sign between (-64,-63), so I used the following uniroot function.
uniroot(lhs(-64,-63))
Error in min(interval) : 'interval' is missing
Can anyone help me out? Thanks.
Shant
[[alternative HTML version deleted]]