Displaying 20 results from an estimated 8000 matches similar to: "How to capture console output in a numeric format"
2009 Apr 22
3
Help using spg optimization in BB package
i'm trying to use the BB package to minimize the sum of the squared
deviations for 2 vectors. The only thing am having trouble with is defining
the project constraint. I got the upper and lower bounds to work but i am
not sure how to create a constraint that the sum of x must be 1. Any help
would be greatly appreciated.
--
View this message in context:
2007 Apr 23
4
Estimates at each iteration of optim()?
I am trying to maximise a complicated loglikelihood function with the "optim" command. Is there some way to get to know the estiamtes at each iteration? When I put "control=list(trace=TRUE)" as an option in "optim", I just got the initial and final values of the loglikelihood, number of iterations and whether the routine has converged or not. I need to know the
2009 Apr 29
2
Optim and hessian
Hi, my name is Marcel R. Lopes. My problem is,
I made a code to calculate the estimates of a Cox model with random effects.
Used to optimize the R command for this. The estimates were calculated
correctly, but the Hessian matrix does not have good values. The same thing
was done in SAS and gave good results for the Hessian Matrix. Where is the
problem in R? As the Hessian is calculated?. How
2009 Nov 18
1
bug in '...' of constrOptim (PR#14071)
Dear all,
There appears to be a bug in how constrOptim handles ... arguments that
are suppose to be passed to optim, according to the documentation. This
means you can't get the hessian to be returned, for example (so this is
a real problem, and not just a question of mistaken documentation).
Looking at the code, it appears that a call to the user-defined f
includes the ..., when the ...
2009 Aug 02
1
Inaccurate complex arithmetic of R (Matlab is accurate)
Dear All,
Hans Borchers and I have been trying to compute "exact" derivatives in R using the idea of complex-step derivatives that Hans has proposed. This is a really, really cool idea. It gives "exact" derivatives with only a minimal effort (same as that involved in computing first-order forward-difference derivative).
Unfortunately, we cannot implement this in R as the
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
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
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
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.
2007 Jun 20
4
finding roots of multivariate equation
Hello,
I want to find the roots of an equation in two variables. I am aware of the
uniroot function, which can do this for a function with a single variable (as I
understand it...) but cannot find a function that does this for an equation
with more than one variable. I am looking for something implementing similar
to a Newton-Raphson algorithm.
Thanks.
--
Bill Shipley
North American Editor for
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
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
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 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)
2007 Feb 01
3
Need help writing a faster code
Hi,
I apologize for this repeat posting, which I first posted yesterday. I would
appreciate any hints on solving this problem:
I have two matrices A (m x 2) and B (n x 2), where m and n are large
integers (on the order of 10^4). I am looking for an efficient way to
create another matrix, W (m x n), which can be defined as follows:
for (i in 1:m){
for (j in 1:n) {
W[i,j] <-
2010 Jul 23
5
UseR! 2010 - my impressions
Dear UseRs!,
Everything about UseR! 2010 was terrific! I really mean "everything" - the tutorials, invited talks, kaleidoscope sessions, focus sessions, breakfast, snacks, lunch, conference dinner, shuttle services, and the participants. The organization was fabulous. NIST were gracious hosts, and provided top notch facilities. The rousing speech by Antonio Possolo, who is the chief
2008 Mar 12
3
Types of quadrature
Dear R-users
I would like to integrate something like \int_k^\infty (1 - F(x)) dx, where F(.) is a cumulative distribution function. As mentioned in the "integrate" help-page: integrate(dnorm,0,20000) ## fails on many systems. This does not happen for an adaptive Simpson or Lobatto quadrature (cf. Matlab). Even though I am hardly familiar with numerical integration the implementation
2012 Oct 16
2
Creating Optimization Constraints
Good afternoon,
In the code below, I have a set of functions (m1,m2,m3,s1,s2, and s3) which represent response surface designs for the mean and variance for three response variables, followed by an objective function that uses the "Big M" method to minimize variance (that is, push s1, s2, and s3 as close to 0 as possible) and hit targets for each of the three means (which are 0, 10,
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 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