Displaying 20 results from an estimated 5000 matches similar to: "Gradients in optimx"
2011 Aug 29
3
gradient function in OPTIMX
Dear R users
When I use OPTIM with BFGS, I've got a significant result without an error
message. However, when I use OPTIMX with BFGS( or spg), I've got the
following an error message.
----------------------------------------------------------------------------------------------------
> optimx(par=theta0, fn=obj.fy, gr=gr.fy, method="BFGS",
>
2011 Aug 26
2
How to generate a random variate that is correlated with a given right-censored random variate?
Hi,
I have a right-censored (positive) random variable (e.g. failure times subject to right censoring) that is observed for N subjects: Y_i, I = 1, 2, ..., N. Note that Y_i = min(T_i, C_i), where T_i is the true failure time and C_i is the censored time. Let us assume that C_i is independent of T_i. Now, I would like to generate another random variable U_i, I = 1, 2, ..., N, which is
2012 Apr 19
4
Column(row)wise minimum and maximum
Hi,
Currently, the "base" has colSums, colMeans. It seems that it would be useful to extend this to also include colMin, colMax (of course, rowMin and rowMax, as well) in order to facilitate faster computations for large vectors (compared to using apply). Has this been considered before? Please forgive me if this has already been discussed before.
Thanks,
Ravi
Ravi Varadhan, Ph.D.
2012 Apr 03
1
A contour plot question - vis.gam () function in "mgcv"
Hi,
Please see the attached contour plot (I am sorry about the big file). This was created using the vis.gam() function in "mgcv" package. However, my question is somewhat broader.
In generating this figure, I first created the contours using vis.gam() and then I plotted the points. These point are plotted on top of the contours so that some of the contour lines are only partially
2004 Dec 03
3
Computing the minimal polynomial or, at least, its degree
Hi,
I would like to know whether there exist algorithms to compute the
coefficients or, at least, the degree of the minimal polynomial of a square
matrix A (over the field of complex numbers)? I don't know whether this
would require symbolic computation. If not, has any of the algorithms been
implemented in R?
Thanks very much,
Ravi.
P.S. Just for the sake of completeness, a
2011 Jun 24
4
How to capture console output in a numeric format
Hi,
I would like to know how to capture the console output from running an algorithm for further analysis. I can capture this using capture.output() but that yields a character vector. I would like to extract the actual numeric values. Here is an example of what I am trying to do.
fr <- function(x) { ## Rosenbrock Banana function
on.exit(print(f))
x1 <- x[1]
x2 <- x[2]
2005 Apr 20
3
Keeping factors with zero occurrences in "table" output
Dear R group,
I have a data frame which contains data on preferences on 7 items (ranks 1
through 7) listed by each participant. I would like to tabulate this in a
7x7 table where the rows would be the items and the columns would be the
number of times that item received a particular rank.
I tried doing this by creating a matrix by "rbind"ing each vector obtained
using
2005 Nov 21
4
Can't figure out warning message
Hi,
I apologize for the previous posting, where the message was not formatted
properly. Here is a better version:
I have written the following function to check whether a vector has elements
satisfying monotonicity.
is.monotone <- function(vec, increase=T){
ans <- TRUE
vec.nomis <- vec[!is.na(vec)]
if (increase & any(diff(vec.nomis,1) < 0, na.rm=T)) ans <- FALSE
2013 Jan 30
1
starting values in glm(..., family = binomial(link =log))
Try this:
Age_log_model = glm(Arthrose ~ Alter, data=x, start=c(-1, 0), family=quasibinomial(link = log))
Ravi
Ravi Varadhan, Ph.D.
Assistant Professor
The Center on Aging and Health
Division of Geriatric Medicine & Gerontology
Johns Hopkins University
rvaradhan@jhmi.edu<mailto:rvaradhan@jhmi.edu>
410-502-2619
[[alternative HTML version deleted]]
2011 Sep 28
1
Download statistics for a package
Hi,
How can I get information on how many times a particular package has been downloaded from CRAN?
Thanks,
Ravi.
-------------------------------------------------------
Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University
Ph. (410) 502-2619
email: rvaradhan@jhmi.edu<mailto:rvaradhan@jhmi.edu>
[[alternative
2006 Nov 14
2
Matrix-vector multiplication without loops
Hi,
I am trying to do the following computation:
p <- rep(0, n)
coef <- runif(K+1)
U <- matrix(runif(n*(2*K+1)), n, 2*K+1)
for (i in 0:K){
for (j in 0:K){
p <- p + coef[i+1]* coef[j+1] * U[,i+j+1]
} }
I would appreciate any suggestions on how to perform this computation
efficiently without the "for" loops?
Thank
2011 Feb 18
2
How to flag those iterations which yield a warning?
Hi,
I am running a simulation study with the survival::coxph. Some of the simulations result in problematic fits due to flat partial likelihood. So, you get the warning message:
Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights, ... :
Loglik converged before variable 2 ; beta may be infinite.
How can I keep track of the simulations which yield any kind of
2006 Sep 29
2
X-axis labels in histograms drawn by the "truehist" function
Hi,
I have a simple problem that I would appreciate getting some tips. I am
using the "truehist" function within an "apply" call to plot multiple
histograms. I can't figure out how to get truehist to use the column names
of the matrix as the labels for the x-axis of the histograms.
Here is a simple example:
X <- matrix(runif(4000),ncol=4)
colnames(X)
2006 Nov 29
2
How to solve differential equations with a delay (time lag)?
Hi,
I would like to solve a system of coupled ordinary differential equations,
where there is a delay (time lag) term. I would like to use the "lsoda"
function "odesolve" package. However, I am not sure how to specify the
delay term using the syntax allowed by odesolve.
Here is an example of the kind of problem that I am trying to solve:
> library(odesolve)
2009 Jul 01
2
Difficulty in calculating MLE through NLM
Hi R-friends,
Attached is the SAS XPORT file that I have imported into R using following code
library(foreign)
mydata<-read.xport("C:\\ctf.xpt")
print(mydata)
I am trying to maximize logL in order to find Maximum Likelihood Estimate (MLE) of 5 parameters (alpha1, beta1, alpha2, beta2, p) using NLM function in R as follows.
# Defining Log likelihood - In the function it is noted as
2008 Apr 09
4
Skipping specified rows in scan or read.table
Hi,
I have a data file, certain lines of which are character fields. I would
like to skip these rows, and read the data file as a numeric data frame. I
know that I can skip lines at the beginning with read.table and scan, but is
there a way to skip a specified sequence of lines (e.g., 1, 2, 10, 11, 19,
20, 28, 29, etc.) ?
If I read the entire data file, and then delete the character
2010 Feb 28
1
Which system.time() component to use?
Hi,
The `system.time(expr)' command provide 3 different times for evaluating the expression `expr'; the first two are user and system CPUs and the third one is total elapsed time. Suppose I want to compare two different computational procedures for performing the same task, which component of `system.time' is most meaningful in the sense that it most accurately reflects the
2017 Dec 31
1
Order of methods for optimx
Dear R-er,
For a non-linear optimisation, I used optim() with BFGS method but it
stopped regularly before to reach a true mimimum. It was not a problem
with limit of iterations, just a local minimum. I was able sometimes to
reach better minimum using several rounds of optim().
Then I moved to optimx() to do the different optim rounds automatically
using "Nelder-Mead" and
2006 Oct 27
2
Multivariate regression
Hi,
Suppose I have a multivariate response Y (n x k) obtained at a set of
predictors X (n x p). I would like to perform a linear regression taking
into consideration the covariance structure of Y within each unit - this
would be represented by a specified matrix V (k x k), assumed to be the same
across units. How do I use "lm" to do this?
One approach that I was thinking of
2012 Nov 04
1
Struggeling with nlminb...
Hallo together,
I am trying to estimate parameters by means of QMLE using the nlminb
optimizer for a tree-structured GARCH model. I face two problems.
First, the optimizer returns error[8] false convergence if I estimate the
functions below. I have estimated the model at first with nlm without any
problems, but then I needed to add some constraints so i choose nlminb.