[R] adding overall constraint in optim()

2018-05-05 Thread Ravi Varadhan
Hi, You can use the projectLinear argument in BB::spg to optimize with linear equality/inequality constraints. Here is how you implement the constraint that all parameters sum to 1. require(BB) spg(par=p0, fn=myFn, project="projectLinear", projectArgs=list(A=matrix(1, 1, length(p0)), b=1,

Re: [R] adding overall constraint in optim()

2018-05-05 Thread Ravi Varadhan
vect)), b=1, meq=1))) Ravi ____ From: Ravi Varadhan Sent: Saturday, May 5, 2018 12:31 PM To: m.ash...@enduringinvestments.com; r-help@r-project.org Subject: adding overall constraint in optim() Hi, You can use the projectLinear argument in BB::spg to optimize with linear

[R] Subject: glm and stepAIC selects too many effects

2017-06-06 Thread Ravi Varadhan
If AIC is giving you a model that is too large, then use BIC (log(n) as the penalty for adding a term in the model). This will yield a more parsimonious model. Now, if you ask me which is the better option, I have to refer you to the huge literature on model selection. Best, Ravi [[

Re: [R] Subject: glm and stepAIC selects too many effects

2017-06-06 Thread Ravi Varadhan
More principled would be to use a lasso-type approach, which combines selection and estimation in one fell swoop! Ravi From: Ravi Varadhan Sent: Tuesday, June 6, 2017 10:16 AM To: r-help@r-project.org Subject: Subject: [R] glm and stepAIC selects too many

[R] Linear Regressions with non-negativity constraint

2016-05-23 Thread Ravi Varadhan
Hi, Take a look at the package "ic.infer" by Ulrike Gromping. https://www.jstatsoft.org/article/view/v033i10 Best, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor, Department of Oncology Division of Biostatistics & Bionformatics

Re: [R] Haplo.glm error: Failed to converge during EM-glm loop

2016-06-14 Thread Ravi Varadhan
verge when you set a small tolerance for convergence. You may fiddle with the control options for EM algorithm and see if you can get convergence. If not, you should contact the package authors. Hope this is helpful, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Pr

[R] Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Ravi Varadhan
Hi, Ramanujan supposedly discovered that the number, 163, has this interesting property that exp(sqrt(163)*pi), which is obviously a transcendental number, is real close to an integer (close to 10^(-12)). If I compute this using the Wolfram alpha engine, I get: 262537412640768743.25

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread Ravi Varadhan
matters in Rmpfr. Even if it does, the answer you get is still wrong as you showed. Thanks, Ravi -Original Message- From: Richard M. Heiberger [mailto:r...@temple.edu] Sent: Thursday, July 02, 2015 6:30 PM To: Aditya Singh Cc: Ravi Varadhan; r-help Subject: Re: [R] : Ramanujan and the

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread Ravi Varadhan
120), then all the constants, 163, pi, are automatically of 120 bits precision. Is this easy to do? Best, Ravi From: David Winsemius Sent: Friday, July 3, 2015 2:06 PM To: John Nash Cc: r-help; Ravi Varadhan Subject: Re: [R] : Ramanujan and the accuracy o

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Ravi Varadhan
What about numeric constants, like `163'? eval(Pre(exp(sqrt(163)*pi), 120))does not work. Thanks, Ravi From: David Winsemius Sent: Saturday, July 4, 2015 1:12 PM To: Duncan Murdoch Cc: r-help; John Nash; Ravi Varadhan Subject: Re: [R] : Rama

[R] Subject: short-sale constraint with nonpositive-definite matrix in portfolio optimization

2014-12-21 Thread Ravi Varadhan
Hi, You can try a projected gradient approach, which is implemented in the spg() function in the "BB" package. You have to provide a projection function which will take an infeasible matrix as input and will give a feasible (i.e. positive-definite) matrix as output. This kind of matrix projecti

Re: [R] R 3.1.2 mle2() function on Windows 7 Error and multiple solutions

2015-01-15 Thread Ravi Varadhan
Hi, I tried your problem with optimx package. I found a better solution than that found by mle2. ?library(optimx) # the objective function needs to be re-written LL2 <- function(par,y) { lambda <- par[1] alpha <- par[2] beta <- par[3] R = Nweibull(y,lambda,alpha,beta) -sum(log(R)) }

Re: [R] R 3.1.2 mle2() function on Windows 7 Error and multiple solutions

2015-01-15 Thread Ravi Varadhan
lems and it is quite difficult to know a priori which one would be the best for "my" problem. Thus, the benchmarking capability provided by optimx is a powerful feature. Ravi From: Ben Bolker Sent: Thursday, January 15, 2015 9:29 AM To: Rav

[R] Re-order levels of a categorical (factor) variable

2015-01-21 Thread Ravi Varadhan
Hi, I have a fairly elementary problem that I am unable to figure out. I have a continuous variable, Y, repeatedly measured at multiple times, T. The variable T is however is coded as a factor variable having these levels: c("Presurgery", "Day 30", "Day 60", "Day 180", "Day 365"). When I plot

Re: [R] Re-order levels of a categorical (factor) variable

2015-01-22 Thread Ravi Varadhan
Thursday, January 22, 2015 10:29 AM To: Bert Gunter Cc: William Dunlap; r-help@r-project.org; Ravi Varadhan Subject: Re: [R] Re-order levels of a categorical (factor) variable >>>>> Bert Gunter >>>>> on Wed, 21 Jan 2015 18:52:12 -0800 writes: > Bill/Rav

[R] Unable to use `eval(parse(text))' in nlme::lme

2015-02-08 Thread Ravi Varadhan
Hi, I would like to run lme() on a number of response variables in a dataframe in an automatic manner. Bu, when I use eval(parse(text=yname)) to denote the LHS of the formula in lme(), I get the following error message: > require(nlme) > mod2 <- with(subset(labdata2, Transplant_type!=0 &

Re: [R] Unable to use `eval(parse(text))' in nlme::lme

2015-02-09 Thread Ravi Varadhan
) dd <- subset(labdata2, Transplant_type!=0 & time >0) lme(ff, random=~1|Patient, data=dd, correlation=corAR1(), na.action=na.omit) Best, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor Department of Oncology Division of Biostatistics & Bionfor

Re: [R] Unable to use `eval(parse(text))' in nlme::lme

2015-02-14 Thread Ravi Varadhan
Yes, this is a very important point. Thank you, Bill. Best, Ravi From: William Dunlap Sent: Friday, February 13, 2015 4:56 PM To: Ravi Varadhan Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Unable to use `eval(parse(text))' in nlme::lme > ff <-

Re: [R] multiple parameter optimization with optim()

2015-02-21 Thread Ravi Varadhan
Harold, Obviously the bottleneck is your objective function fn(). I have speeded up your function by a factor of about 2.4 by using `outer' instead of sapply. I think it can be speeded much more. I couldn't figure it out without spending a lot of time. I am sure someone on this list-serv

[R] Fast matrix multiplication

2018-08-10 Thread Ravi Varadhan
Hi, I would like to compute: A %*% B %*% t(A) A is a mxn matrix and B is an nxn symmetric, positive-definite matrix, where m is large relative to n (e.g., m=50,000 and n=100). Here is a sample code. M <- 1 N <- 100 A <- matrix(rnorm(M*N), M, N) B <- crossprod(matrix(rnorm(N*N), N

Re: [R] Fast matrix multiplication

2018-08-13 Thread Ravi Varadhan
Hi Ista, Thank you for the response. I use Windows. Is there a pre-compiled version of openBLAS for windows that would make it easy for me to use it? Thanks, Ravi -Original Message- From: Ista Zahn Sent: Friday, August 10, 2018 12:20 PM To: Ravi Varadhan Cc: r-help@r-project.org

Re: [R] Fast matrix multiplication

2018-08-14 Thread Ravi Varadhan
Does Microsoft open R come with pre-compiled BLAS that is optimized for matrix computations? Thanks, Ravi -Original Message- From: Ista Zahn Sent: Monday, August 13, 2018 3:18 PM To: Ravi Varadhan Cc: r-help@r-project.org Subject: Re: [R] Fast matrix multiplication On Mon, Aug 13

[R] lsqlin in pracma

2015-08-29 Thread Ravi Varadhan
In solve.QP(), you don't need to expand the equality into two inequalities. It can DIRECTLY handle the equality constraints. The first `meq' rows of the constraint matrix are equality constraints. Here is the excerpt from the documentation. meq the first meq constraints are treated as equali

Re: [R] optimizing with non-linear constraints

2015-09-30 Thread Ravi Varadhan
nction(x, LAI) { h <- rep(NA, 2) h[1] <- LAI^x[2] / x[3] + x[1] h[2] <- 1 - x[1] - LAI^x[2] / x[3] h } Please take a look at the help page. If it is still not clear, you can contact me offline. Best, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Profess

Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Ravi Varadhan
2015 3:37 AM To: Ravi Varadhan Cc: 'r-help@r-project.org' Subject: Re: optimizing with non-linear constraints Ravi Varadhan writes: > Hi Rainer, > It is very simple to specify the constraints (linear or nonlinear) in > "alabama" . They are specified in a function

Re: [R] Bug in auglag?

2015-10-06 Thread Ravi Varadhan
esday, October 6, 2015 9:20 AM To: Ravi Varadhan Cc: 'r-help@r-project.org' Subject: Bug in auglag? Hi Ravi, I would like come back to your offer. I have a problem which possibly is caused by a bug or by something I don't understand: My function to be minimised is executed even when an

[R] Linear regression with a rounded response variable

2015-10-21 Thread Ravi Varadhan
ered. Any suggestions? Thank you, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor, Department of Oncology Division of Biostatistics & Bionformatics Sidney Kimmel Comprehensive Cancer Center Johns Hopkins University 550 N. Broadway, Suite -E Baltimore

Re: [R] Linear regression with a rounded response variable

2015-10-22 Thread Ravi Varadhan
: Ravi Varadhan; r-help@r-project.org Subject: Re: [R] Linear regression with a rounded response variable > On 21 Oct 2015, at 19:57 , Charles C. Berry wrote: > > On Wed, 21 Oct 2015, Ravi Varadhan wrote: > >> [snippage] > > If half the subjects have a value of 5 second

[R] How to get variable name while doing series of regressions in an automated manner?

2015-10-27 Thread Ravi Varadhan
HS? In addition, is there a better paradigm for doing these type of series of regressions in an automatic fashion? Thank you very much, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor, Department of Oncology Division of Biostatistics & Bi

Re: [R] How to get variable name while doing series of regressions in an automated manner?

2015-10-27 Thread Ravi Varadhan
ail.com] Sent: Tuesday, October 27, 2015 1:50 PM To: Ravi Varadhan Cc: r-help@r-project.org Subject: Re: [R] How to get variable name while doing series of regressions in an automated manner? Marc,Ravi: I may misunderstand, but I think Marc's solution labels the list components but not nece

Re: [R] About error: L-BFGS-B needs finite values of 'fn'

2015-11-11 Thread Ravi Varadhan
t can still happen). I would strongly suggest that when you are doing simulations, you should encapsulate the parameter estimation inside a `try' or `tryCatch' statement so that when there is an error, the simulation keeps going rather than crashing out. See the attached code. Best, Ravi

Re: [R] About error: L-BFGS-B needs finite values of 'fn'

2015-11-11 Thread Ravi Varadhan
It seems like there is substantial finite-sample bias in the MLEs. Either that or there is some error in your procedure. See attached code. Ravi From: Ravi Varadhan Sent: Wednesday, November 11, 2015 2:33 PM To: 'denizozo...@gazi.edu.tr' ; r-help@r-project.org Cc: 'profj

[R] Cautioning optim() users about "Nelder-Mead" default - (originally) Optim instability

2015-11-15 Thread Ravi Varadhan
Hi, While I agree with the comments about paying attention to parameter scaling, a major issue here is that the default optimization algorithm, Nelder-Mead, is not very good. It is unfortunate that the optim implementation chose this as the "default" algorithm. I have several instances wher

Re: [R] Cautioning optim() users about "Nelder-Mead" default - (originally) Optim instability

2015-11-15 Thread Ravi Varadhan
mentations of Nelder-Mead. Best regards, Ravi From: ProfJCNash Sent: Sunday, November 15, 2015 12:21 PM To: Ravi Varadhan; 'r-help@r-project.org'; lorenzo.ise...@gmail.com Cc: b...@xs4all.nl; Gabor Grothendieck Subject: Re: Cautioning optim() user

[R] grep/regexp

2015-12-01 Thread Ravi Varadhan
_percent_of_CD4" and "Fr_II_percent_of_CD4". How can I use grep() to do this? More generally, are there any good online resources with examples like this for the use of grep() and regexp() in R? I didn't find the help pages for these very user-friendly. Thank you very

Re: [R] Solve an equation including integral

2016-01-08 Thread Ravi Varadhan
05) Hope this is helpful, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor, Department of Oncology Division of Biostatistics & Bionformatics Sidney Kimmel Comprehensive Cancer Center Johns Hopkins University 550 N. Broadway, Suite -E Baltimore, MD

Re: [R] Solve an equation including integral

2016-01-08 Thread Ravi Varadhan
te(fun, -Inf, t, nu=nu, exi=exi)$value return(res) } uniroot(myroot, c(-2, 2), nu=2, exi=0.5, alpha=.05) Ravi From: Ravi Varadhan Sent: Friday, January 08, 2016 11:29 AM To: r-help@r-project.org; 'sstol...@gmail.com' Subject: Re: Solve an equation including integral I think t

[R] Looking for a data set - Teratology data of Chen and Kodell (1989)

2016-02-18 Thread Ravi Varadhan
. Does anyone know of this or worked with this data set? If so, can someone share it with me? Thank you very much. Best, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor, Department of Oncology Division of Biostatistics & Bionformatics Sidney Ki

Re: [R] help in maximum likelihood

2016-03-02 Thread Ravi Varadhan
6, 63, 59, 62, 60) # note: there is no need to have the choose(n, y) term in the likelihood fn <- function(p) sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))) ) out <- nlm(fn, p = c(-50,20), hessian = TRUE) out eigen(out$hessian) Hope this is helpful, Ravi Ravi Varadhan, Ph.D.

Re: [R] help in maximum likelihood

2016-03-04 Thread Ravi Varadhan
Standard error = sqrt(diag(solve(opt$hessian))) Ravi From: Alaa Sindi [mailto:alaasi...@icloud.com] Sent: Wednesday, March 02, 2016 3:22 PM To: Ravi Varadhan Cc: r-help@r-project.org Subject: Re: help in maximum likelihood Thank you very much prof. Ravi, That was very helpful. Is there a way

Re: [R] How to solve systems of nonlinear equations in R?

2008-07-21 Thread Ravi Varadhan
Also take a look at the package "BB" for solving nonlinear systems. Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Berend Hasselman Sent: Saturday, July 19, 2008 7:45 AM To: r-help@r-project.org Subject: Re: [R] How to solve systems of nonlinear eq

Re: [R] re cursive root finding

2008-08-08 Thread Ravi Varadhan
Hi, Here is one way you can locate the peaks and troughs of a smoothed function estimate (using the example data from smooth.spline() demo): ##-- example from smooth.spline() y18 <- c(1:3,5,4,7:3,2*(2:5),rep(10,4)) xx <- seq(1,length(y18), len=201) s2 <- smooth.spline(y18) # GCV d1 <- pred

Re: [R] Constrained Optimization

2008-08-08 Thread Ravi Varadhan
Hessian may not even exist in a constrained optimization problem, for example, when the solution is on the boundary of the feasible region. If your solution is on the interior, you can use the hessian() function in "numDeriv" package. Ravi. -Original Message- From: [EMAIL PROTECTED] [mai

Re: [R] Between the values

2008-08-12 Thread Ravi Varadhan
Hi Shubaa, Here is one way to do this: is.between <- function(x, a, b) { x > a & x < b } set.seed(123) x <- rnorm(5) is.between(x, -1, 1) > is.between(x, -1, 1) [1] TRUE TRUE FALSE TRUE TRUE > Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behal

Re: [R] Between the values

2008-08-12 Thread Ravi Varadhan
: Tuesday, August 12, 2008 9:46 AM To: Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [R] Between the values Thanks Ravi... But was just wond

Re: [R] nonlinear constrained optimization

2008-08-19 Thread Ravi Varadhan
Hi, The "Tango project" website (from Brazil) has some R functions to implement Algencan. I haven't used it, but I would be interested to hear others' experience if someone has already used it or will be using it. Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTE

Re: [R] how can i get hessian matrix at "constrOptim"

2008-08-19 Thread Ravi Varadhan
Hi, Hessian for a consttarined problem can be tricky, when the converged parameter vector lies on the boundary, i.e. when one or more of the constraints are active at convergence. This can be handled by reparametrization when the constraints are linear, but is difficult otherwise. Ravi. -

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread Ravi Varadhan
k for all theta such that abs(theta) < -pi/2. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (

Re: [R] Problem with Integrate for NEF-HS distribution

2008-08-26 Thread Ravi Varadhan
d(-800) Do you see the problem? Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-261

Re: [R] Integrate a 1-variable function with 1 parameter (Jose L. Romero)

2008-08-27 Thread Ravi Varadhan
) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.

Re: [R] Ratio of gammas

2008-08-27 Thread Ravi Varadhan
This will work: exp( lgamma(nu/2) - lgamma((nu+1)/2) ) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins

Re: [R] Integrate a 1-variable function with 1 parameter (Jose L.Romero)

2008-08-28 Thread Ravi Varadhan
s2=ans2) # both answers are identical Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMA

Re: [R] Solutions of equation systems

2009-08-15 Thread Ravi Varadhan
| is minumum d <- svd(A) x.min <- c(d$v %*% diag(1/d$d, length(d$d)) %*% t(d$u) %*% b) # min-norm solution Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontolo

Re: [R] Confidence interval on parameters from optim function

2009-08-19 Thread Ravi Varadhan
Hi Emmanuel, You can obtain standard error estimate from the Hessian matrix evaluated at the optimum as: sqrt(diag(solve(ans$hessian))), where `ans' is the object returned by `optim'. However, `optim' does not return the Hessian matrix by default. So, you need to specify `hessian = TRUE' when you

Re: [R] Confidence interval on parameters from optim function

2009-08-19 Thread Ravi Varadhan
Emmanuel, I didn't answer your second question. You can use the `try' function to capture errors and keep proceeding through simulations without crashing out: ?try If `L-BFGS-B' does not work well, you could try the `spg' function in the "BB" package. Ravi. -Original Message- From:

Re: [R] Statistical question about logistic regression simulation

2009-08-26 Thread Ravi Varadhan
so that the binomial model can be estimated. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-

Re: [R] how to generate a random correlation matrix with restrictions

2009-08-28 Thread Ravi Varadhan
6) RtR <- R %*% t(R) Q <- cov2cor(RtR) But this does not have the property that the correlations are uniformly distributed. Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric M

Re: [R] how to generate a random correlation matrix with restrictions

2009-08-29 Thread Ravi Varadhan
lt;- matrix(rnorm(N*N), N, N) A <- amat %*% t(amat) # A is PD Best, Ravi ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619

Re: [R] Rdonlp2 package question

2009-09-03 Thread Ravi Varadhan
e. Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Richard Valliant Date: Thursday

Re: [R] Rdonlp2 package question

2009-09-03 Thread Ravi Varadhan
s. Fortunately, you do not have any nonlinear equality constraints, which it does not handle. If you are interested, I can share this function with you. Just curious - how big is H? How successful were you with Rdonlp2? Ravi. ____

Re: [R] function to solve equations

2009-09-10 Thread Ravi Varadhan
You don't need an equation solver. This is basic algebra. The solution is: X = (log(prob) - log(1 - prob) + 3.33) / 0.0102 Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and H

Re: [R] constrOptim parameters

2009-09-11 Thread Ravi Varadhan
It should be a matrix with dimension, Ni x p, where Ni is the number of inequality constraints and p is the number of parameters. So, in your case it should be a 2N x N matrix. Read the help carefully. Ravi. ---- --- R

Re: [R] Strange question/result about SVM

2009-09-14 Thread Ravi Varadhan
lated issues. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage:

Re: [R] Maximum Likelihood Est. regarding the degree of freedom of a multivariate skew-t copula

2009-09-23 Thread Ravi Varadhan
mize' instead. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.

Re: [R] using mle2 for multinomial model optimization

2010-02-12 Thread Ravi Varadhan
Use "Nelder-Mead" as the method in optim. This will give you the correct solution. m1 <- mle2(mfun, start=svec, vecpar=TRUE, fixed=svec[1:(l-1)], method="Nelder") Hope this is helpful, Ravi. ____ Ravi Va

Re: [R] Code working but too slow, any idea for how to speed it up ?(no loop in it)

2010-02-12 Thread Ravi Varadhan
First of all, please send a reproducible code. Your code is wrong and it does not execute: naming a function called "function" is a bad idea. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Me

Re: [R] non-linear contrained optimization

2010-02-18 Thread Ravi Varadhan
. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People

Re: [R] significance of coefficients in Constrained regression

2010-02-24 Thread Ravi Varadhan
. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu

Re: [R] Normal distribution (Lillie.test())

2010-02-25 Thread Ravi Varadhan
May be you should have said: "Normality tests are standard farce in a host of statistical texts." Ravi. ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatri

[R] Which system.time() component to use?

2010-02-27 Thread Ravi Varadhan
r CPU. Should I use the sum of user and system CPU or is the total elapsed time a better measure? I would appreciate UseR's feedback on this. Thanks very much. Best, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Divis

Re: [R] Which system.time() component to use?

2010-02-27 Thread Ravi Varadhan
Thanks, Gabor. Your reply is helpful, but it still doesn't answer whether I should use the sum of the first two components of system.time (user + system CPU) or only the first one (user CPU). Ravi. ____ Ravi Varadhan,

Re: [R] Which system.time() component to use?

2010-02-28 Thread Ravi Varadhan
CPU is not that different from the total elapsed time. Best regards, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619

Re: [R] Advice wanted on using optim with both continuous and discrete par arguments...

2010-03-01 Thread Ravi Varadhan
a large dispersion and then decreasing it towards zero. You could use extrapolation to extrapolate to the limit as \sigma goes to zero. Of course, you will then round-off the solution at the end. Does this make sense? Ravi. _____

Re: [R] Advice wanted on using optim with both continuous and discrete par arguments...

2010-03-01 Thread Ravi Varadhan
I know that Matlab can solve this problem, but I didn't mention it in my previous email since OP had asked for "native to R" solutions. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatr

Re: [R] cluster with mahalanobis distance

2010-03-03 Thread Ravi Varadhan
obis lived)! Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From

[R] Improved Nelder-Mead algorithm and Matlab's fminsearch. Was: Hi

2010-03-05 Thread Ravi Varadhan
will soon release it as a package (I have been saying this for several months now!), but I can send it to you if you are interested. Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medi

Re: [R] Nonparametric generalization of ANOVA

2010-03-05 Thread Ravi Varadhan
so like to urge the R-gurus to ignore such postings. Best, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rva

[R] How to parse the arguments from a function call and evaluate them in a dataframe?

2010-03-05 Thread Ravi Varadhan
here a simple way to accomplish this? Thanks very much, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu ___

Re: [R] is there an inverse method for table()?

2010-03-09 Thread Ravi Varadhan
z <- rep(x, each = y) Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.

Re: [R] is there an inverse method for table()?

2010-03-09 Thread Ravi Varadhan
Sorry, I mean to say: z <- rep(x, y) Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.

Re: [R] penalized maximum likelihood estimation and logistf

2010-03-09 Thread Ravi Varadhan
ted. Consequently, the steplength `delta' for the Newton method cannot be determined. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns H

Re: [R] penalized maximum likelihood estimation and logistf

2010-03-09 Thread Ravi Varadhan
al instead of profile likelihood based CI. Here is how you can do it: sd.logr <- logistf(AgeRange ~ I(Age - mean(Age)), pl=FALSE, data=sd) # this computes Wald C.I. summary(sd.logr) Hope this helps, Ravi. ____ Ravi V

Re: [R] help about solving two equations

2010-03-10 Thread Ravi Varadhan
<- dfsane(par=c(1,1), fn=fn, s=s) ans$par # solutions for p and q You can then loop through for each row of s1 and s2 and solve it to get corresponding p and q. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of

Re: [R] Comparing matrices

2010-03-11 Thread Ravi Varadhan
Look at: identical(pop, pop2) # if you want to do "exact" comparison Or all.equal(pop, pop2, tolerance=1.e-10) # if you want to allow for some small noise Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Es

Re: [R] help about solving two equations

2010-03-11 Thread Ravi Varadhan
You have to install it from CRAN before you can load it into your session. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619

Re: [R] help about solving two equations

2010-03-12 Thread Ravi Varadhan
1:nr) { ans <- dfsane(par=c(1,1), fn=fn, s=smat[i, ], control=list(trace=FALSE)) soln[i, ] <- ans$par } soln # your solution Hope this helps, Ravi. -Original Message- From: Shaoqiong Zhao [mailto:zh...@uwm.edu] Sent: Friday, March 12, 2010 5:20 PM To: Ravi Varadhan Cc: r-help@r-

Re: [R] Constrained non linear regression using ML

2010-03-16 Thread Ravi Varadhan
I have an algorithm that can perform nonlinear optimization, with linear/nonlinear, equality and/or inequality constraints. From your description, it seems like this algorithm would work for your problem. Contact me if you are interested and I will send you the code. Ravi. -Original Message-

Re: [R] crr - computationally singular

2009-06-25 Thread Ravi Varadhan
will see the problem. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614

Re: [R] Error: system is computationally singular: reciprocal conditionnumber

2009-06-25 Thread Ravi Varadhan
want to use Moore-Penrose inverse, also known as generalized inverse or pseudoinverse to overcome this problem. This approach uses singular-value decomposition (SVD). Take a look at the "corpcor" package. Ravi. -----

Re: [R] crr - computationally singular

2009-06-26 Thread Ravi Varadhan
onal_pages/Varadhan.h tml -Original Message- From: Laura Bonnett [mailto:l.j.bonn...@googlemail.com] Sent: Friday, June 26, 2009 6:22 AM To: Ravi Varadhan Cc: r-help@r-project.org Subject: Re: [R] crr -

Re: [R] Error: system is computationally singular: reciprocal condition number

2009-06-28 Thread Ravi Varadhan
It is a basic linear algebra issue and has nothing to do with statistics I told you what your problem is and also how to solve it. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and

Re: [R] ERROR: system is computationally singular: reciprocal condition number = 4.90109e-18

2009-06-28 Thread Ravi Varadhan
Hi, You are being rude to those who are trying to help you by ignoring their suggestions and by sending useless, irrelevant information. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and

Re: [R] Difficulty in calculating MLE through NLM

2009-07-01 Thread Ravi Varadhan
rested. Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message -

Re: [R] Iteratively Reweighted Least Squares of nonlinear regression

2009-07-01 Thread Ravi Varadhan
You are describing a "generalized nonlinear least-squares" estimation procedure. This is implemented in the gnls() function in "nlme" package. ?gnls Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, D

Re: [R] Difficulty in calculating MLE through NLM

2009-07-02 Thread Ravi Varadhan
ere. Ravi. ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhea

[R] lokern package

2009-07-02 Thread Ravi Varadhan
s it possible to have a similar feature in glkerns? Thanks for any suggestions. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology

Re: [R] matching rows in matrices

2009-07-02 Thread Ravi Varadhan
down in r-help archives. Hope this helps, Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.e

Re: [R] lokern package

2009-07-02 Thread Ravi Varadhan
alls each time in R and Fortran. While the savings may not be huge for a single function smoothing, it might be substantial for large numbers of time-series. Best regards, Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant

Re: [R] constrained optimisation in R.

2009-07-02 Thread Ravi Varadhan
onstraints you really have. Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://ww

Re: [R] constrained optimisation in R.

2009-07-02 Thread Ravi Varadhan
. You would use different starting values for lamda1 and lambda2, if the scales of the 2 constraints are very different. If not, you use a single lambda. Hope this helps, Ravi. ---- --- Ravi Varadhan, Ph.D. Assis

  1   2   3   4   5   6   7   >