Displaying 20 results from an estimated 600 matches similar to: "deriv, loop"
2007 Oct 14
1
Extending deriv3()
Hello,
I was wondering if the functions deriv3(), deriv() etc. could be extended
to handle psigamma() and its special cases (digamma(), trigamma()
etc.). From the error message it seems that 'psigamma' needs to be
added to the derivatives table.
This might be easy since psigamma() has a deriv argument.
Additionally, this error message is also obtained when requesting for
the Hessian of
2010 Jan 04
1
polygamma or Hurwitz zeta function
Hi,
Is there any R library that is capable of handling polygamma function
(Hurwitz zeta function also works)? I am aware of digamma(0 and trigamma(),
but could not find more advanced versions.
I'd appreciate any help.
Hakan Demirtas
2006 Nov 18
1
deriv when one term is indexed
Hi,
I'm fitting a standard nonlinear model to the luminances measured
from the red, green and blue guns of a TV display, using nls.
The call is:
dd.nls <- nls(Lum ~ Blev + beta[Gun] * GL^gamm,
data = dd, start = st)
where st was initally estimated using optim()
st
$Blev
[1] -0.06551802
$beta
[1] 1.509686e-05 4.555250e-05 7.322720e-06
$gamm
[1] 2.511870
This works fine but I
2003 May 09
2
Data-mining using R
Is it possible to use R as a data-mining tool? Here's the problem I've
got. I have a couple of data sets consisting of results from a cDNA
microarray experiment - the details about the biology don't really matter here, the
same theory applies for any other data-mining task (that's why I thought it'd
be more appropriate to post this on r-user). Each of these datasets consists
2006 Oct 30
1
psigamma derivative
Hello,
I am trying to find a hessian matrix that
involves log(gamma(1/p)) second derivative, p being one of the parameters
of the function. I am using a function "deriv" with the hessian=TRUE
option, but psigamma is not on the list of derivative functions.
I know that it is possible to use 'psigamma(p,deriv)', but it doesn't work
with 1/p. Does anybody can help with this?
2004 May 14
1
covariates in lm
Dear R list,
I have been trying to do a linear model, extracting the effect of a
covariate.... and the results do not match, when I do it with other programs
(e.g. minitab).... so it is obvious that I was doing something wrong.
Whan I do it with minitab, I have this results: (sector is a factor and depth
is the covariate):
Source DF Seq SS Adj SS Adj MS F P
2018 Jan 04
3
silent recycling in logical indexing
Hmm.
Chuck: I don't see how this example represents
incomplete/incommensurate recycling. Doesn't TRUE replicate from
length-1 to length-3 in this case (mat[c(TRUE,FALSE),2] would be an
example of incomplete recycling)?
William: clever, but maybe too clever unless you really need the
speed? (The clever way is 8 times faster in the following case ...)
x <- rep(1,1e6)
2001 Oct 05
1
nls() fit to a lorentzian - can I specify partials?
First, thanks to all who helped me with my question about rescaling axes
on the fly. Using unlist() and range() to set the axis ranges in advance
worked well. I've since plotted about 300 datasets with relative ease.
Now I'm trying to fit a lossy oscillator resonance to (the square root of)
a lorentzian (testframe$y is oscillator amplitude, testframe$x is drive
frequency):
lorentz
2006 Oct 27
2
all.names() and all.vars(): sorting order of functions' return vector
Dear list-subscriber,
in the process of writing a general code snippet to extract coefficients
in an expression (in the example below: 0.5 and -0.7), I stumbled over
the following peculiar (at least peculiar to me:-) ) sorting behaviour
of the function all.names():
> expr1 <- expression(x3 = 0.5 * x1 - 0.7 * x2)
> all.names(expr1)
[1] "-" "*" "x1"
2006 Jul 18
2
I think this is a bug
Hello!
I work with:
R : Copyright 2006, The R Foundation for
Statistical Computing
Version 2.3.1 (2006-06-01)
On Windows XP Professional (Version 2002) SP2
I think there is a bug in the conditional
execution if (expr1) {expr2} else {expr3}
If I try:
"if (expr1) expr2 else expr3"
it works well but when I put the expression expr2
and expr3 between {} I receive an error message
2009 Jun 03
2
code for double sum
Hi R-users,
I wrote a code to evaluate double sum as follows:
ff2 <- function(bb,eta,z,k)
{ r <- length(z)
for (i in 1:r)
{ sm1 <- sum((z[i]*bb/2)*(psigamma((0:k)+eta+1,deriv=0)/(factorial(0:k)*gamma((0:k)+eta+1))))
sm2 <- sum((besselI(z[i]*bb,eta)*log(z[i]*bb/2) - sm1)/besselI(z[i]*bb,eta))
sm2
}
ff2(bb,eta,z,10)
but it gave me the following message:
>
2014 May 01
3
How to test if an object/argument is "parse tree" - without evaluating it?
This may have been asked before, but is there an elegant way to check
whether an variable/argument passed to a function is a "parse tree"
for an (unevaluated) expression or not, *without* evaluating it if
not?
Currently, I do various rather ad hoc eval()+substitute() tricks for
this that most likely only work under certain circumstances. Ideally,
I'm looking for a isParseTree()
2002 Aug 10
0
?subexpressions, D, deriv
Hi all,
I am not used to using the computer to do calculus and have up to
now done my differentiation "by hand" , calling on skills I learned
many years ago and some standard cheat sheets.
My interest at present is in getting the second derivative of a
gaussian, which I did by hand and results in a somewhat messy
result involving terms in sigma^5 .. I have done some spot checks
2009 Dec 09
4
equivalent of ifelse
Hi,
Is there any equivalent for ifelse (except if (cond) expr1 else expr2) which takes an atomic element as argument but returns vector since ifelse returns an object of the same length as its argument?
x = c(1,2,3)
y = c(4,5,6,7)
z = 3
ifelse(z <= 3,x,y)
would return x and not 1
thanks
2011 Aug 28
1
read.table: deciding automatically between two colClasses values
Hello,
I have a function for reading a data-frame from a file, which contains
E = read.table(file = filename,
header = T,
colClasses = c(rep("integer",6),"numeric","integer",rep("numeric",8)),
...)
Now a small variation arose, where
colClasses =
2013 Feb 04
2
Modifying a function programmatically
Dear list
# I have a function
ff <- function(a,b=2,c=4){a+b+c}
# which I programmatically want to modify to a more specialized function in which a is replaced by 1
ff1 <- function(b=2,c=4){1+b+c}
# I do as follows:
vals <- list(a=1)
(expr1 <- as.expression(body(ff)))
expression({
a + b + c
})
(expr2 <- do.call("substitute", list(expr1[[1]], vals)))
{
1 +
2023 Jan 11
1
return value of {....}
I am more than a little puzzled by your question.
In the construct {expr1; expr2; expr3} all of the
expressions expr1, expr2, and expr3 are evaluated,
in that order. That's what curly braces are FOR.
When you want some expressions evaluated in a
specific order, that's why and when you use curly
braces. If that's not what you want, don't use them.
Complaining about it is like
2001 May 28
0
bugs in deriv(*, *, function.arg = ) (PR#953)
Also, this should have gone in R-bugs quite a while ago :
------- start of forwarded message -------
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: R-core@stat.math.ethz.ch
Subject: PROTECT() bugs in deriv(*, *, function.arg = )
Date: Mon, 16 Apr 2001 21:02:10 +0200
In R versions 0.50 and 0.64.2 ,
the following worked
> deriv(expression(sin(cos(x) * y)),
2011 Apr 14
1
if (cond) expr1 expr2 ??
hi , this can be done easily if (cond) expr
ex:
> for (i in 1: 4)+ {+ if(i==2) print("a")+ if(i==2) print("b")+ }
output : [1] "a"[1] "b"
but i want this
if (cond) expr1 expr 2
i tried this :
> for (i in 1: 4)+ {+ if(i==2) (print("b") && print("a"))+ }
output : [1] "b"Error in print("b") &&
2002 Oct 17
2
Trigamma function
Hey, all
Do you how to calculate the trigamma function, that is
d**2(log(gamma(x))) / dx**2.
The second-order derivative of log(Gamma(x))?
I cannot find it in the R package, and somebody knows who or where to get
such one?
Thanks.
Fred
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html