Re: [R] Time-series analysis with treatment effects - statistical approach

2011-06-22 Thread Ravi Varadhan
If you have any specific features of the time series of soil moisture, you could either model that or directly estimate it and test for differences in the 4 treatments. If you do not have any such specific considerations, you might want to consider some nonparametric approaches such as function

Re: [R] numerical integration and 'non-finite function value' error

2011-06-22 Thread Ravi Varadhan
In the limit as x goes to infinity, the integrand x f(x) should go to 0 sufficiently fast in order for the integral to be finite. The error indicates that the integrand becomes infinite for large x. Check to ensure that the integrand is correctly specified. I don't understand how you can repla

Re: [R] Latin Hypercube Sampling with a condition

2011-06-02 Thread Ravi Varadhan
I am not sure, but this thread from a couple of months ago might be relevant (and useful): https://stat.ethz.ch/pipermail/r-help/2011-March/273423.html Ravi. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of Rob Carnell [car

Re: [R] Value of 'pi'

2011-05-31 Thread Ravi Varadhan
ay 31, 2011 4:41 PM To: Ravi Varadhan Cc: Bentley Coffey; Vincy Pyne; r-help@r-project.org Subject: Re: [R] Value of 'pi' On Wed, Jun 1, 2011 at 2:12 AM, Ravi Varadhan wrote: > > I have also heard (courtesy: John Nash) that `pi' is the ratio of actual time > it takes t

Re: [R] Value of 'pi'

2011-05-31 Thread Ravi Varadhan
It is the same thing (simply multiply the polynomial by the LCM and you have a polynomial with integer coefficients). --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins

Re: [R] Value of 'pi'

2011-05-31 Thread Ravi Varadhan
plete your thesis to the anticipated time. I have also heard that March 14 is the official `pi' day in the US (probably not in Indiana!). Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology Sch

Re: [R] Value of 'pi'

2011-05-30 Thread Ravi Varadhan
Here is the wiki entry on the "Indiana Pi Bill" http://en.wikipedia.org/wiki/Indiana_Pi_Bill Ravi. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of bill.venab...@csiro.au [bill.venab...@csiro.au] Sent: Monday, May 30, 2011 2:

Re: [R] Fitting spline using Pspline

2011-05-29 Thread Ravi Varadhan
Yes, you are right that the results of smooth.spline are slightly worse than that of sm.spline. The Doppler function is "tricky". At small `x' values, it oscillates rapidly. Hence it is not surprising that the smoothers do not do as well. Here is a noisy version of your Doppler function.

Re: [R] Fitting spline using Pspline

2011-05-29 Thread Ravi Varadhan
Use the smooth.spline() function in "stats" package. This is more stable. ?smooth.spline Ravi. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of guy33 [david.res...@magd.ox.ac.uk] Sent: Sunday, May 29, 2011 1:30 PM To: r-hel

Re: [R] finding derivative of a data series in R

2011-05-27 Thread Ravi Varadhan
t;x", ylab="First derivative") yexact <- -0.2 * 2*pi * cos(2*pi*x) * exp(-0.2 * sin(2*pi*x)) lines(x, yexact, col=2) # Similarly, you can also look at the smoothed second derivative Hope this is helpful, Ravi. --- Ravi Var

Re: [R] Problem with Princurve

2011-05-23 Thread Ravi Varadhan
Why does this not find a better solution? > x <- seq(0,2*pi, length=1000) > x <- cbind(x/(2*pi), sin(x)) > fit1 <- principal.curve(x, plot = TRUE, trace = TRUE, maxit = 100, + start = cbind(sort(x[,1]), rep(1, nrow(x Starting curve---distance^2: 1499.5 Iteration 1---distance^2: 3.114789 Itera

Re: [R] maximum likelihood convergence reproducing Anderson Blundell 1982 Econometrica R vs Stata

2011-05-21 Thread Ravi Varadhan
t know what is wrong with bobyqa in this example. In short, even with scaling and exact gradients, this optimization problem is recalcitrant. Best, Ravi. ____ From: Mike Marchywka [marchy...@hotmail.com] Sent: Thursday, May 12, 2011 8:30 AM To: Ravi Varadhan; pda.

Re: [R] Maximization of a loglikelihood function with double sums

2011-05-14 Thread Ravi Varadhan
It should not be very hard to find information on optimization. Have you tried any of the search facilities in R? ?optim # comes with `base' library(optimx) # you need to install this first from CRAN Ravi. From: r-help-boun...@r-project.org [r-help-boun

Re: [R] SQP with Constraints

2011-05-09 Thread Ravi Varadhan
Look at the solve.QP() function in the "quadprog" package. Ravi. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of vioravis [viora...@gmail.com] Sent: Monday, May 09, 2011 10:46 PM To: r-help@r-project.org Subject: [R] SQP wi

Re: [R] Syntax for iter.max in rms

2011-05-08 Thread Ravi Varadhan
The option `iter.max' should be an element of the Control list. If you read the help file carefully, you would have noticed this. So, try this: f <- bj(Surv(ftime, stroke) ~ rcs(age,5) + hospital, link='identity', control=list(iter.max=200), x=TRUE, y=TRUE) Identity link is challenging to fit

Re: [R] help!! warning:only the first element has been used

2011-05-07 Thread Ravi Varadhan
x <- 1:5 rev(cumprod(rev(x))) > rev(cumprod(rev(x))) [1] 120 120 60 20 5 > Ravi. From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of pwldk [pw...@hotmail.com] Sent: Saturday, May 07, 2011 12:37 PM To: r-help@r-project.org Su

Re: [R] maximum likelihood convergence reproducing Anderson Blundell 1982 Econometrica R vs Stata

2011-05-07 Thread Ravi Varadhan
There is something strange in this problem. I think the log-likelihood is incorrect. See the results below from "optimx". You can get much larger log-likelihood values than for the exact solution that Peter provided. ## model 18 lnl <- function(theta,y1, y2, x1, x2, x3) { n <- length(y1)

Re: [R] How to fit a random data into Beta distribution?

2011-05-05 Thread Ravi Varadhan
Beta is not as general as you think. Its support is limited to [0,1], but you are trying to fit data that lies outside of its support. Please read about the beta distribution from a basic stats/prob book. Ravi. From: r-help-boun...@r-project.org [r-he

Re: [R] nls problem with R

2011-05-04 Thread Ravi Varadhan
. --- 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-help-boun...@r-project.org [mailto:r-help-boun...@r

Re: [R] help with the maxBHHH routine

2011-05-03 Thread Ravi Varadhan
maxBHHH is *not* an in-built R function. It is in a distributed package called "maxLik". Always tell us which package is being used so that it is easier for us to help you. The error message says that the gradient function is returning a 10 x 2 matrix, whereas you say that you have 1000's of

Re: [R] adaptIntegrate - how to pass additional parameters to the integrand

2011-05-03 Thread Ravi Varadhan
Ok, I get it. require(cubature) f <- function(x, a) cos(2*pi*x*a) # a simple test function # this works a <- 0.2 adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2) # but this doesn't work rm(a) adaptIntegrate(function(x, argA=a) f(x, a=argA), lower=0, upper=2, a=0.2) Ravi. __

Re: [R] fitting distributions using fitdistr (MASS)

2011-05-03 Thread Ravi Varadhan
Your simulation example is bad. You cannot fit a beta distribution to a data that is not in [0,1], leave alone negative data. x <- runif(1007) fitdistr(x, "beta", start=list(shape1=0.5, shape2=0.5)) But try this instead: x <- runif(100, 1, 27) fitdistr(x, "beta", start=list(shape1=0.5, shap

Re: [R] easy way to do a 2-D fit to an array of data?

2011-05-02 Thread Ravi Varadhan
Hi Carl, Here is another slightly different (not necessarily the easiest) approach that uses a profiling technique. An advantage is that you get the maximum location directly. n <- 20 x <- sort(rnorm(n)) y <- sort(rnorm(n)) xy <- expand.grid(x, y) zfn <- function(x) 0.5 - 2.2 * (x[1] - 0.5)

Re: [R] easy way to do a 2-D fit to an array of data?

2011-05-02 Thread Ravi Varadhan
You may want to consider spatial::surf.ls Or, a simplistic approach where you fit a model such as using `lm': E[Z | x, y] = a + b(x - x0)^2 + c(y - y0)^2 where (x0, y0) is the location of maximum. Ravi. From: r-help-boun...@r-project.org [r-help-boun.

Re: [R] strange fluctuations in system.time with kernapply

2011-05-02 Thread Ravi Varadhan
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-help-boun...@r-project.org [mailto:r

Re: [R] how to generate a normal distribution with mean=1, min=0.2, max=0.8

2011-04-28 Thread Ravi Varadhan
Surely you must be joking, Mr. Jianfeng. --- 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

Re: [R] matrix of higher order differences

2011-04-27 Thread Ravi Varadhan
the Wronskian, but was just wondering whether it is an established matrix that is some kind of an *ian* like Hermitian, Jacobian, Hessian, Wronskian, Laplacian, ... Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of

Re: [R] matrix of higher order differences

2011-04-27 Thread Ravi Varadhan
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-help-boun...@r

Re: [R] Multi-dimensional non-linear fitting - advice on best method?

2011-04-24 Thread Ravi Varadhan
Julian, You have not specified your problem fully. What is the nature of f? Is f a scalar function or is it a vector function (2-dim)? Here are some examples showing different possibilities: (1) y1 = f + e1 = a + b*exp(-c*x) + e1; y2 = f + e2 = a + b*exp(-c*x) + e2; (e1, e2) ~ bivariate norm

Re: [R] Matching a vector with a matrix row

2011-04-24 Thread Ravi Varadhan
I gave a solution previously with integer elements. It also works well for real numbers. rowMatch <- function(A,B) { # Rows in A that match the rows in B # The row indexes correspond to A f <- function(...) paste(..., sep=":") if(!is.matrix(B)) B <- matrix(B, 1, length(B)) a <- do.cal

Re: [R] Matching a vector with a matrix row

2011-04-22 Thread Ravi Varadhan
Here is one solution: rowmatch <- function(A,B) { # Rows in A that match the rows in B f <- function(...) paste(..., sep=":") if(!is.matrix(B)) B <- matrix(B, 1, length(B)) a <- do.call("f", as.data.frame(A)) b <- do.call("f", as.data.frame(B)) match(b, a) } A <- matrix(1:1000

Re: [R] question regarding qmvnorm

2011-04-20 Thread Ravi Varadhan
If you had told us what the error message was, my job would have been easier. But, at least you provied the code, so it was not hard for me to see where the problem was. There is a problem with the strategy used by `qmvnorm' to locate the initial interval in which the quantile is supposed to l

Re: [R] How to generate a correlation matrix with restrictions on its eigenvalues

2011-04-15 Thread Ravi Varadhan
Generate random numbers from a multinomial. ?rmultinom # The following will generate n multinomial vectors each of size m rmultinom(n, size=m, prob=m^(-1/8)) # you need to specify probabilities appropriately Ravi. From: r-help-boun...@r-project.org [r-he

Re: [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-14 Thread Ravi Varadhan
Bill's code is insanely fast! f2 <- function(x, y) length(y) - findInterval(-x, rev(-sort(y))) n1 <- 1e07 n2 <- 10^c(1,2,3,4,5,6,7) tt <- rep(NA, 7) x <- rnorm(n1) for (i in 1:length(n2)){ y <- runif(n2[i]) tt[i] <- system.time(a1 <- f2(x, y))[3] } > tt [1] 0.70 0.86 1.03 1.28 1.54 4.99

Re: [R] integration

2011-04-11 Thread Ravi Varadhan
It does. See `lower' and `upper' arguments. Why are y and z not known? Say, you want the marginal of x, i.e. integrate over x. Now, y and z are fixed. You fix them at different values, but they are known. Ravi. --- Ravi Vara

Re: [R] integration

2011-04-08 Thread Ravi Varadhan
?integrate From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of cindy Guo [cindy.g...@gmail.com] Sent: Friday, April 08, 2011 9:21 PM To: r-help@r-project.org Subject: [R] integration Hi, All, I have a density function with 3 v

Re: [R] optim and optimize are not finding the right parameter

2011-03-30 Thread Ravi Varadhan
Try this: pred <- pred/1e06 DV <- DV/1e03 opt1 <- optim(fn=my.function, par=1.0) opt2 <- optim(fn=my.function, par=1.0, method="BFGS") opt3 <- optim(fn=my.function, par=1.0, method="L-BFGS-B", lower=0, upper=1) opt1 opt2 opt3 Ravi. -

Re: [R] Integration with variable bounds

2011-03-29 Thread Ravi Varadhan
ct. 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: Ravi Varad

Re: [R] Integration with variable bounds

2011-03-29 Thread Ravi Varadhan
You get 0 because you did not specify lower and upper bounds that define the hyper-rectangle; therefore, the default is used which is (0,1)^4. Specify the proper lower and upper bounds. Ravi. Ravi Varadhan, Ph.D. Assistant

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Ravi Varadhan
TRUE) rtrg.1 <- cbind(pmin(tmp[,1], tmp[,2]), abs(tmp[,1] - tmp[,2]),1 - pmax(tmp[,1], tmp[,2])) }) all.equal(rtrg, rtrg.1) Now, how can we use vis.test to test differences between these? Best, Ravi. ____ Ravi Varadhan, Ph.D. Assi

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Ravi Varadhan
t;- runif(3) rtrg2[i, ] <- tmp/sum(tmp) } par(mfrow=c(2,1)) triplot(rtrg) # Looks more uniformly distributed triplot(rtrg2, col=2) # Corners are sparsely populated Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of

Re: [R] Creating 3 vectors that sum to 1

2011-03-29 Thread Ravi Varadhan
The following one-liner generates uniformly distributed 3-tuples that sum to 1: diff(c(0, sort(runif(2)), 1)) More, generally you can generate n-tuples that sum to unity as: diff(c(0, sort(runif(n-1)), 1)) Ravi. Ravi

Re: [R] Integration with variable bounds

2011-03-29 Thread Ravi Varadhan
mp; u1 <= z2) & (u2 > 4 & u2 <= z2) ff <- ifelse (reg.nonzero, u1*(z1-u1)*u2*(z2-u2)*exp(-0.027*(12-z2)), 0) return(ff) } Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontolo

Re: [R] pmt

2011-03-27 Thread Ravi Varadhan
That is essentially zero, because you are so far out in the left tail of the distribution. So, you can ignore the negative sign and treat it as zero. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric

Re: [R] a question on R optimization functions

2011-03-25 Thread Ravi Varadhan
Ben, I am a huge fan of the old-fashioned and low-tech `cat'; it is good to know that I am not alone in this! Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Ho

Re: [R] a question on R optimization functions

2011-03-25 Thread Ravi Varadhan
You might want to use `trace' and/or other debugging options to better understand when and why this happens. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Med

Re: [R] R helps win competitions

2011-03-23 Thread Ravi Varadhan
R prediction experts. Thanks & 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: rvarad...@jhmi.edu -Original M

Re: [R] < ABOUT Rdonlp2 package >

2011-03-23 Thread Ravi Varadhan
This is no longer on CRAN. Try one of the other constrained optimization packages: "Rsolnp" or "alabama" Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Me

Re: [R] BFGS and Neldear-Mead

2011-03-21 Thread Ravi Varadhan
o accomplish this. 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-help-boun...@r-project.org [mailto:r-help-

Re: [R] Part of a density plot

2011-03-19 Thread Ravi Varadhan
Take a look at pvladens() function in "bootruin" package. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-

Re: [R] BFGS and Neldear-Mead

2011-03-18 Thread Ravi Varadhan
iple optima, you can get different answers from properly converged iterations. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email

Re: [R] Problem with nls.lm function of minpack.lm package.

2011-03-15 Thread Ravi Varadhan
s. 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: Yann PĂ©riar

Re: [R] using pre-calculated coefficients and LP in coxph()?

2011-03-13 Thread Ravi Varadhan
t;Mean relative difference: 1.463598" The results from `offset' are correct, i.e. lp2 can be readily verified to be equal to 0.05 * (age - ph.karno). I don't know how lp1 is computed. Ravi. Ravi Varadhan, P

Re: [R] Hello!

2011-02-27 Thread Ravi Varadhan
nging criticisms. Mark, by reacting to the comments in a personal manner, I am afraid that you are the loser. Best, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Med

Re: [R] BFGS versus L-BFGS-B

2011-02-25 Thread Ravi Varadhan
separation using a minorization inequality, and hence the problem simplifies greatly. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502

Re: [R] How to flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
Dear Bill - your solution works beautifully. Thank you very much. David - thank you as well for your solution. It also works. Best regards, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and

Re: [R] How to flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
Nope - that does not work. The value of last.warning is not reset after the initial NULL. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins

Re: [R] How to flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
May be I could do: for (i in 1:nsim) { last.warning <- NULL # do model fitting if(!is.null(last.warning)) # discard simulation result } I think this might work. Any other ideas? Ravi. ____ Ravi Varadhan, Ph.D. Assist

[R] How to flag those iterations which yield a warning?

2011-02-18 Thread Ravi Varadhan
etect warnings. Any pointers would be appreciated. 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: r

Re: [R] Optimization Question

2011-02-14 Thread Ravi Varadhan
c(0.1, 0.1, 2.5),control=list(trace=TRUE)) 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.e

Re: [R] Optimization Question

2011-02-14 Thread Ravi Varadhan
e changes, you might want to try optimizing using "optimx" package, as it will try various optimization tools. Hopefully, some of them will be successful. If you send the data test$A, we might be able to help you better. Hope this helps, Ravi. -

Re: [R] A question on Duplicating

2011-02-09 Thread Ravi Varadhan
?duplicated This will identify common locations where duplications occur: duplicated(a) & duplicated(b) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hop

Re: [R] Removing Outliers Function

2011-02-08 Thread Ravi Varadhan
u plotted the amount of learning on the Y-axis and time on the X-axis, a steep learning curve means that one learns very quickly, but this is just the opposite of what is actually meant. Best, Ravi. ____ Ravi Varadhan, Ph.D.

Re: [R] fast optimization routines in R

2011-02-07 Thread Ravi Varadhan
ntrol option as `all.methods=TRUE' to get all the algorithms. 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] Help with integrating R and c/c++

2011-02-06 Thread Ravi Varadhan
uld be the "optimx" package, which unifies a large number of optimiaztion tools under one umbrella. Hope this helps, Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology Scho

Re: [R] Matching patients

2011-02-01 Thread Ravi Varadhan
Look at the "optmatch" package. ____ 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] Positive Definite Matrix

2011-01-30 Thread Ravi Varadhan
of the matrix, (A + t(A))/2. 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: rvarad...@jhmi.edu - Original Message - From: Spencer Graves Date: Sunday,

Re: [R] nlminb doesn't converge and produce a warning

2011-01-21 Thread Ravi Varadhan
timization algorithm of your choice without having to worry about the names of the control parameters. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University

Re: [R] Integration in R

2011-01-10 Thread Ravi Varadhan
You are missing basic algebra skills! You had: myfunc<- function(x) {0.25*(9*x^4 + 6*x^2 + 1)} This should be: myfunc<- function(x) {0.25*(9*x^4 - 6*x^2 + 1)} Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Ger

Re: [R] Waaaayy off topic...Statistical methods, pub bias, scientific validity

2011-01-07 Thread Ravi Varadhan
"Conclusion: try to be/become a good scientist: with a high prevalence of good ideas." Or, I would say: "try to publish only good and mature ideas". Gauss said it best "pauca sed matura" or "few, but ripe." Ravi. ---

Re: [R] Waaaayy off topic...Statistical methods, pub bias, scientific validity

2011-01-07 Thread Ravi Varadhan
. --- 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: Spencer Graves [mailto:spencer.gra...@structuremonitoring.com] Sent

Re: [R] Waaaayy off topic...Statistical methods, pub bias, scientific validity

2011-01-07 Thread Ravi Varadhan
in an open learning environment. Unless, we can achieve this we cannot solve the problems of publication bias and inefficient and sub-optimal use of data. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and G

Re: [R] Solution to differential equation

2010-12-17 Thread Ravi Varadhan
such that the solution is bounded as t goes to infinity. 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..

Re: [R] Solution to differential equation

2010-12-17 Thread Ravi Varadhan
e solution at any given `t' in one shot, rather than having to march through time from t=t0 to t=t. Numerical time-marching schemes make more sense for systems of nonlinear ODEs. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Divisi

Re: [R] Solution to differential equation

2010-12-17 Thread Ravi Varadhan
pe this is helpful, 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-help-boun...@r-pr

Re: [R] Solution to differential equation

2010-12-16 Thread Ravi Varadhan
incomplete beta function would not work, which is why I had to develop the power series approach. Let me know how this works for you. Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology

Re: [R] Solution to differential equation

2010-12-16 Thread Ravi Varadhan
lt;- 0.5 k2 <- 1.5 Rm <- 2 R0 <- 0.2 system.time(y <- sapply(t, function(t) logistic.soln(t, k1, k2, Rm, R0))) plot(t, y, type="l") Hoep this helps, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geria

Re: [R] Solution to differential equation

2010-12-15 Thread Ravi Varadhan
and then integrate each term of the expansion. However, this is not very helpful as I don't know what this series converges to. May be I am missing something simple here? Any ideas? Ravi. ------- Ravi Varadhan, Ph.D. Assistant Professor, Division

Re: [R] More elegant magnitude method

2010-12-07 Thread Ravi Varadhan
I would prefer: round(log10(x)) 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

Re: [R] How to formulate constraint like abs(x) = y in constrOptim (or other)

2010-12-06 Thread Ravi Varadhan
Hi Benjamin, If you just had abs(x_i) < c_i, it will reduce to linear inequalities, but your constraint cannot be reduced to that. You might try "alabama" or "Rsolnp" packages. Ravi. --- Ravi Varadhan, Ph.D. Assistant

Re: [R] Optimize multiple variable sets

2010-12-06 Thread Ravi Varadhan
-optimize(f,int=c(-10,10), tol=1.e-07)$min } # results all.equal(results, -colSums(data)/2) Hope this helps, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins

Re: [R] "Nash Equilibrium"

2010-12-04 Thread Ravi Varadhan
alues)? 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: Chris

Re: [R] "Nash Equilibrium"

2010-12-03 Thread Ravi Varadhan
No, Spencer. Nash-Sutcliff efficiency is due to John E. Nash. It is unrelated to game theory. The well-known Nash equilibrium in game theory is due to John Forbes Nash, Jr. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of

Re: [R] "Nash Equilibrium"

2010-12-03 Thread Ravi Varadhan
I think Christophe Dutang is writing a package for generalized Nash Equilibria models called "GNE". I am cc'ing him here. I don't know if there are other packages out there. Christophe would know. Ravi. --- Ravi Varad

Re: [R] Integral of PDF

2010-12-03 Thread Ravi Varadhan
al interval [0, x], and see if this procedure can be improved. 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:

Re: [R] Integral of PDF

2010-12-03 Thread Ravi Varadhan
. --- 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-help-boun...@r-project.org [mailto:r-help-boun...@r

Re: [R] Integral of PDF

2010-12-02 Thread Ravi Varadhan
tegrate'. 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-help-boun...@r-project.org [mai

Re: [R] Outlier statistics question

2010-11-30 Thread Ravi Varadhan
It is, perhaps, more apt to call the tests of outliers as "tests of outright liars". "Lies, damned lies, and tests of outliers" Ravi. ____ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medi

Re: [R] non-linear fourth-order differential equations

2010-11-29 Thread Ravi Varadhan
en initial values). 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-h

Re: [R] question about constraint minimization

2010-11-23 Thread Ravi Varadhan
, 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-help-boun...@r

Re: [R] how to calculate derivative

2010-11-22 Thread Ravi Varadhan
atives from the smooth 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

Re: [R] question about constraint minimization

2010-11-22 Thread Ravi Varadhan
`spg' in "BB" may be useful. 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 -Origin

Re: [R] saddle points in optim

2010-11-07 Thread Ravi Varadhan
surmise. 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: Jonathan Phillips <994p.

Re: [R] saddle points in optim

2010-11-07 Thread Ravi Varadhan
elps, 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: Jonathan Phillips <994p...@gmail.com&

Re: [R] Constrained Regression

2010-10-31 Thread Ravi Varadhan
be a bit tricky. 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 Me

Re: [R] Setting constraints in the glm package

2010-10-26 Thread Ravi Varadhan
the profile likelihood in terms of a. We then maximize this over `a' . We can use, for example, `optimize' to accomplish this. This is not contrived. I have encountered this situation in a project. Ravi. ____ Ravi Va

Re: [R] Optimize parameters of ODE Problem which is solved numeric

2010-10-25 Thread Ravi Varadhan
Hi Michael, You do not need a numerical solver for this. This is a linear system of ODEs and it admits closed form solutions. The solution is given as: Y(t) = c_1 * v_1 * exp(k_1 * t) + ... + c_4 * v_4 * exp(k_4 * t) where k_1, ..., k_4 are the eigenvalues (can be real or complex) and v_1, ...

Re: [R] Help: Maximum likelihood estimation

2010-10-24 Thread Ravi Varadhan
Can you provide a reproducible code? 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] how do I make a correlation matrix positive definite?

2010-10-22 Thread Ravi Varadhan
I responded to another question that asked the exact same question. So, I will repeat my answer here: Nick Higham (2002) discusses algorithms for this. One of the algorithms discussed in the paper is implemented in the "Matrix" package as `nearPD' function. library(Matrix) ?nearPD Ravi.

Re: [R] Help: Maximum likelihood estimation

2010-10-22 Thread Ravi Varadhan
I am not surprised that you are running into difficulties with this model estimation, since you are treating a constrained optimization problem as unconstrained one. It is not so easy to set constraints on the covariance matrix (i.e. positive definiteness). The is the beauty of the EM algorithm i

<    1   2   3   4   5   6   7   >