Displaying 20 results from an estimated 100 matches similar to: "derivatives in R"
2012 Jul 11
2
nls problem: singular gradient
Why fails nls with "singular gradient" here?
I post a minimal example on the bottom and would be very
happy if someone could help me.
Kind regards,
###########
# define some constants
smallc <- 0.0001
t <- seq(0,1,0.001)
t0 <- 0.5
tau1 <- 0.02
# generate yy(t)
yy <- 1/2 * ( 1- tanh((t - t0)/smallc) * exp(-t / tau1) ) + rnorm(length(t))*0.01
# show the curve
2012 Aug 01
1
optim() for ordered logit model with parallel regression assumption
Dear R listers,
I am learning the MLE utility optim() in R to program ordered logit
models just as an exercise. See below I have three independent
variables, x1, x2, and x3. Y is coded as ordinal from 1 to 4. Y is not
yet a factor variable here. The ordered logit model satisfies the
parallel regression assumption. The following codes can run through,
but results were totally different from what I
2017 Mar 19
2
outer not applying a constant function
Hi,
the function outer can not apply a constant function as in the last line of the following example:
> xg <- 1:4
> yg <- 1:4
> fxyg <- outer(xg, yg, function(x,y) x*y)
> fconstg <- outer(xg, yg, function(x,y) 1.0)
Error in outer(xg, yg, function(x, y) 1) :
dims [product 16] do not match the length of object [1]
Of course there are simpler ways to construct a constant
1998 Apr 27
1
R-beta: vectors in dataframe?
I have a file:
x y z
0.025 0.025 1.65775
0.025 0.050 1.62602
0.025 0.075 1.63683
0.025 0.100 1.91847
0.025 0.125 2.00913
0.025 0.150 1.82222
0.025 0.175 1.70901
0.025 0.200 1.39759
0.025 0.225 1.39089
0.025 0.250 1.04762
If I read the file like this:
data<-read.table("file.dat")
How do I access the vectors x,y,z that are inside the dataframe data? I
studied Venables and
2017 Mar 20
1
outer not applying a constant function
> Or is this a bad idea?
I don't like the proposal. I have seen code like the following (in
fact, I have written such code, where I had forgotten a function was
not vectorized) where the error would have been discovered much later
if outer() didn't catch it.
> outer(1:3, 11:13, sum)
Error in outer(1:3, 11:13, sum) :
dims [product 9] do not match the length of object [1]
2007 Nov 07
1
thumbnailer/swfdec-thumbnailer.c
thumbnailer/swfdec-thumbnailer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit a31d0686b78df2da96b9d8d1e3220e63978bba30
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Nov 7 20:02:04 2007 +0100
s/swfdec_player_get_image_size/swfdec_player_get_default_size/
diff --git a/thumbnailer/swfdec-thumbnailer.c b/thumbnailer/swfdec-thumbnailer.c
index
2009 Nov 02
1
need help in using Hessian matrix
Hi
I need to find the Hessian matrix for a complicated function from a certain
kind of data but i keep getting this error
Error in f1 - f2 : non-numeric argument to binary operator
the data is given by
U<-runif(n)
Us<-sort(U)
tau1<- 2
F1tau<- pgamma((tau1/theta1),shape,1)
N1<-sum(Us<F1tau)
X1<- Us[1:N1]
2010 Nov 30
1
confidence interval for logistic joinpoint regression from package ljr
I?m trying to run a logistic joinpoint regression utilising the ljr package. I?ve been using the forward selection technique to get the number of knots for the analysis, but I?m uncertain as to my results and the interpretation. The documentation is rather brief ( in the package and the stats in medicine article is quite technical) and without any good examples. At the moment I?m thinking
1)find
2005 Jul 20
1
predict.lm - standard error of predicted means?
Simple question.
For a simple linear regression, I obtained the "standard error of
predicted means", for both a confidence and prediction interval:
x<-1:15
y<-x + rnorm(n=15)
model<-lm(y~x)
predict.lm(model,newdata=data.frame(x=c(10,20)),se.fit=T,interval="confidence")$se.fit
1 2
0.2708064 0.7254615
2010 Jul 22
1
class
Hello,
### I created two classes "A" and "B". "A" is the superclass of "B".
setClass("A", representation(s1="numeric"),prototype=prototype(s1=8))
setClass("B",contains="A",representation(s2="character"),prototype=list(s2="hi"))
myA=new("A")
myB=new("B")
#### I created
2009 Nov 01
2
intigrate function and absolute error
Hi
Can we get the result of an intigration without the absolute error?
for example
f1<-function(x1){(1/gamma(alpha))*x1^(alpha-1)*exp(-x1)*log(x1)}
I1<-integrate(f1, 0, (max(cc)-tau1+(theta2/theta1)*tau1)/theta2)
I1
0.08007414 with absolute error < 7.2e-05
I need the answer 0.08007414 withou the other part(with absolute error
<7.2e-05)
how can we do that?
thank you and take care
2005 Apr 04
5
a question about box counting
Hi,
I have a set of x,y data points and each data point lies between (0,0)
and (1,1). Of this set I have selected all those that lie in the lower
triangle (of the plot of these points).
What I would like to do is to divide the region (0,0) to (1,1) into
cells of say, side = 0.01 and then count the number of cells that
contain a point.
My first approach is to generate the coordinates of these
2010 Jun 23
1
A question about R2Winbugs
Dear R users:
I was trying to fit a HMM with mixture of Gaussian into the dataset, and I
tried to implement it by R2Winbugs. But I got the following errer.
*
Error in FUN(X[[1L]], ...) :
.C(..): 'type' must be "real" for this format*
Does anybody know what's the problem? Does R2Winbugs accept some matrix as
inits? I would really appreciate your help. Thank you very much.
2013 Feb 12
3
improving/speeding up a very large, slow simulation
Dear R help;
I'll preface this by saying that the example I've provided below is pretty
long, turgid, and otherwise a deep dive into a series of functions I wrote
for a simulation study. It is, however, reproducible and self-contained.
I'm trying to do my first simulation study that's quite big, and so I'll
say that the output of this simulation as I'd like it to be is
2010 Aug 02
2
Dealing with a lot of parameters in a function
Hi all,
I'm trying to define and log-likelihood function to work with MLE.
There will be parameters like mu_i, sigma_i, tau_i, ro_i, for i between
1 to 24. Instead of listing all the parameters, one by one in the
function definition, is there a neat way to do it in R ? The example is
as follows:
ll<- function(mu1=-0.5,b=1.2,tau_1=0.5,sigma_1=0.5,ro_1=0.7)
{ if (tau1>0 &&
2008 Feb 06
1
how to plot an user-defined function
Dear R-users,
Suppose I have defined a likelihood function as ll(tau), how can I plot this
likelihood function by calling it by plot?
I want to do it like this:
ll <- function(tau)
{
w <- 1 / (s^2 + tau^2)
mu <- sum(theta * w) / sum(w)
-1/2*sum((theta-mu)^2*w -log(w))
}
plot(ll, 0, 2)
But have the following error:
Error in xy.coords(x, y, xlabel, ylabel, log) :
2008 Apr 04
1
Problems with Unit Root testing using ur.df function
Hi All,
I'm new to R and am trying to run a unit root test on the vector "y" (a time
series of inflation (i.e. changes in the Consumer Price Index quarter on
quarter)).
I've run the Augmented-Dickey-Fuller Test below (R's URCA package). It gives
me an error that it cannot find the function ur.df unless I comment out the
third last line of code (see below).
I try to call
2012 Dec 06
1
Fuction Error
I'm calling a list of symbols and then using a function to build a data
frame from that symbol list. It works great until I introduce this index
symbol from yahoo '^GSPC'. When and index symbol is introduced I get and
error which is below.
> Data <- symbolFrame(symbols)
Error in get(S) : object '^GSPC' not found
Since R does not like the ^ in front of a name it
2004 Mar 11
4
Summary: do.call and environments
To use the modify the solution from Tony and I
so that you can pass the name of the function, rather
than the function itself, like this:
x <- 7
fx <- function(y) print(x*y)
f <- function(fun, x) {
fun <- get(fun)
environment(fun) <- environment()
do.call("fun",list(3))
}
f("fx",2)
---
Date: Thu, 11 Mar 2004 08:22:45 +0100
From:
2006 May 01
4
efficiency in merging two data frames
I have two data sets about lots of companies' stock
and fiscal data. One is monthly data with about
144,000 lines, and the other is quaterly with about
56,000. Each data set takes different company code.
I need to merge these two together. I read both ask
cvs. And the other file with corresponding firm code.
Now I have three data sets. return$PERMNO,
account$GVKEY. id is the data frames