[R] Multidimensional quadrature using "integrate"

2002-12-17 Thread Ravi Varadhan
Hi: I was wondering if someone could give me some examples of how to use the "integrate" function to perform multi-dimensional quadrature? I have a posterior density (up to a constant), for which I'd like to evaluate the normalizing constant. thanks for any help, Ravi. __

Re: [R] laplace transform

2003-09-05 Thread Ravi Varadhan
Hi: I have written a Fortran program based on the Gaver-Stehfest algorithm, which uses only real numbers (as opposed to the more powerful methods using complex numbers). However, this can't be used in R since the function specifying the inverse of the Laplace transform must also be written in

Re: [R] calculating arc length using R?

2003-11-14 Thread Ravi Varadhan
Hi: If your curve is in a 2-dim plane, then you can use the following formula (in Tex notation): \int_a^b \sqrt{1 + (\frac{df}{dx})^2} dx So you need to take the derivative of your function first, and then compute the integral of (1 + deriv^2) from a to b. Here is a simple code to find the ar

Re: [R] calculating arc length using R?

2003-11-14 Thread Ravi Varadhan
Hi: If your curve is in a 2-dim plane, then you can use the following formula (in Tex notation): \int_a^b \sqrt{1 + (\frac{df}{dx})^2} dx So you need to take the derivative of your function first, and then compute the integral of sqrt(1 + deriv^2) from a to b. Here is a simple code to find th

[R] TISEAN and nonlinear time series

2003-11-20 Thread Ravi Varadhan
Hi: Has anyone linked TISEAN, which is a nonlinear time series analysis package developed by Schreiber et al., with R? If not, are there similar tools based on the phase-space representation of an observed time series? thanks, Ravi. __ [EMAIL PROTE

Re: [R] Random Numbers

2003-12-16 Thread Ravi Varadhan
Take a look at the help for "RNGkind" as follows: ?RNGkind Ravi. - Original Message - From: Silvia Perez Martin <[EMAIL PROTECTED]> Date: Tuesday, December 16, 2003 12:45 pm Subject: [R] Random Numbers > Hello > > I´m a student from Spain. I couldn´t find something about R and I > wa

[R] Software/algorithms for competing risks analysis

2003-12-20 Thread Ravi Varadhan
Dear R group: I am compiling a list of available algorithms/macros/software for performing the following types of competing risks analyses: (1) cumulative (crude) incidence regression (2) Gray's K-sample log-rank test for cmulative incidence (3) multi-state models (4) dependent competing risks mo

[R] na.action in model.frame

2003-06-06 Thread Ravi Varadhan
Dear Group: I am trying to create a model frame from a formula for the model as follows: formula <- y ~ x1 + x2 + x3 X <- model.frame(form=formula,data=mydata) I have some missing values in some the variables, but I want them to be included in my model frame and to be indicated as "NA". Is the

Re: [R] dynamics of functions

2003-06-06 Thread Ravi Varadhan
Here is a recursive function. iterate <- function(f, n, x){ if(n==0) return(x) iterate(f, n-1, f(x)) } iterate(function(x) 1/(1+x), 10, 1) Best, Ravi. - Original Message - From: Tobias Verbeke <[EMAIL PROTECTED]> Date: Thursday, June 5, 2003 12:04 pm Subject: Re: [R] dynamics of func

[R] Normal deviate generation - Marsaglia's ziggurat method

2003-05-31 Thread Ravi Varadhan
Hi: I was wondering why Marsaglia's new ziggurat method for generating deviates from the standard normal distribution has not been implemented in the R base package. I know that it is available in SuppDists pacakage of Bob Wheeler, as "rziggurat". According my timing tests, it is about 6 to 7

Re: [R] Help - Curvature measures of nonlinearity

2003-06-03 Thread Ravi Varadhan
How about "rms.curv" function in the MASS library? Ravi. - Original Message - From: Ivone Figueiredo <[EMAIL PROTECTED]> Date: Monday, June 2, 2003 4:40 am Subject: [R] Help - Curvature measures of nonlinearity > Dear colleagues, > > Von Bertalanffy model is commonly adjust to data on

Re: [R] Summary for mode of a data set

2003-06-23 Thread Ravi Varadhan
Dear Spencer: In the following example, your code doesn't pick up the local mode at 5. > x2 <- c(1,1,2,3,3,3,3,5,5,5) > modes(x2) [1] 1 3 In this example, it gives a mode at 7, which is incorrect. > x2 <- c(1,1,2,3,3,3,3,5,5,5,6,7) > modes(x2) [1] 1 3 7 Ravi. - Original Message - Fro

Re: [R] logLik.lm()

2003-06-27 Thread Ravi Varadhan
Hi: This is not a typical R posting, but I was quite surprised to read Prof. Ripley's comment about the inappropriate use of AIC to compare "non-nested" models. As he says, While it is indeed true that Akaike's (1973) develops AIC for nested models, i.e. models which can be obtained by variou

[R] SVD and spectral decompositions of a hermitian matrix

2003-07-03 Thread Ravi Varadhan
Hi: I create a hermitian matrix and then perform its singular value decomposition. But when I put it back, I don't get the original hermitian matrix. I am having the same problem with spectral value decomposition as well. I am using R 1.7.0 on Windows. Here is my code: X <- matrix(rnorm(16)

Re: [R] SVD and spectral decompositions of a hermitian matrix

2003-07-03 Thread Ravi Varadhan
Re: [R] SVD and spectral decompositions of a hermitian matrix > On Thu, 3 Jul 2003, Ravi Varadhan wrote: > > > I create a hermitian matrix > > You didn't succeed, if you meant Hermitian. > > > and then perform its singular value > > decomposition. But when

[R] A problem with using the "outer" function

2003-07-09 Thread Ravi Varadhan
Hi: I am using R 1.7.0 on Windows. I am having trouble getting "outer" to work on one of my functions. Here is a simple example illustrating my problem: > b1 <- c(1.2,2.3) > b2 <- c(0.5,0.6) > x <- c(3e+01, 1e+02, 3e+02, 5e+02, 1e+03, 1e+04, 1e+05, 1e+06) > y <- c(2,4,2,5,2,3,1,1) > n <- c(5,

Re: RE: [R] Why two chisq.test p values differ when the contingency

2003-07-15 Thread Ravi Varadhan
Hi Tao: The P-values for 2x2 table are generated based on a random (discrete uniform distribution) sampling of all possible 2x2 tables, conditioning on the observed margin totals. If one of the cells is extremely small, as in your case, you get a big difference in P-values. Suppose, you change

Re: [R] Is there a bug in qr(..,LAPACK=T)

2003-07-16 Thread Ravi Varadhan
As the help page for "qr" says, LAPACK does not attempt to detect linear dependencies or rank deficiencies, so you should not use the value of "rank" obtained with argument, LAPACK = TRUE. Computing the rank of a matrix using finite precision is difficult, as the example on the help page for "

Re: [R] inverse prediction and Poisson regression

2003-07-25 Thread Ravi Varadhan
Vincent: Here is a simple solution using Prof. Bates' non-linear least squares algorithm: Best, Ravi. > Phytopath <- data.frame(x=c(0, 0.03, 0.1), y=c(28, 21, 11)) > Phyto.nls <- nls(y ~ Ymax/(1 + x/x50),data=Phytopath,start=list (Ymax=20.0,x50=0.01),trace=T) 404.3058 : 20.00 0.01 15.76932

Re: [R] inverse prediction and Poisson regression

2003-07-25 Thread Ravi Varadhan
Thanks Peter, for the wonderful illustration of various model-fitting options for the non-linear models. Thinking about your comment that the "variance stabilizing" transform does better than the weighted non-linear least-squars - I am interpreting this to mean that the residual sum of squares

Re: [R] numericDeriv

2004-05-03 Thread Ravi Varadhan
Hi All: Along the lines of this thread, I was wondering about the usefulness of putting together a package for numerical differentiation, to perform tasks such as gradient, jacobian, and hessian calculations for exact functions, as well as for noisy functions (via some type of smoothing). Base

[R] Finding indices where

2004-05-19 Thread Ravi Varadhan
Hi: Suppose I have the following vector: > x <- c(1,4:8,11,13:14,17,19,23:28,35:38) > x [1] 1 4 5 6 7 8 11 13 14 17 19 23 24 25 26 27 28 35 36 37 38 > and I would like to pick out the first and last indices of all the consecutive "runs" of integers, where the length of a run is no smal

[R] Quadruple precision in R

2004-06-14 Thread Ravi Varadhan
Hi: Is it possible to perform computations in quadruple precision (more generally, with more digits in the floating-point arithmetic than that allowed by double precision) in R? thanks, Ravi. [[alternative HTML version deleted]] __ [EMAI

[R] counting the occurrences of vectors

2004-07-03 Thread Ravi Varadhan
Hi: I have two matrices, A and B, where A is n x k, and B is m x k, where n >> m >> k. Is there a computationally fast way to count the number of times each row (a k-vector) of B occurs in A? Thanks for any suggestions. Best, Ravi. [[alternative HTML version deleted]] ___

RE: [R] counting the occurrences of vectors

2004-07-04 Thread Ravi Varadhan
g the occurrences of vectors Ravi Varadhan jhsph.edu> writes: > Hi: > > I have two matrices, A and B, where A is n x k, and B is m x k, where n >> m >> k. Is there a computationally fast way to > count the number of times each row (a k-vector) of B occurs in A? Than

[R] Generalized least squares using "gnls" function

2004-01-14 Thread Ravi Varadhan
Hi: I have data from an assay in the form of two vectors, one is response and the other is a predictor. When I attempt to fit a 5 parameter logistic model with "nls", I get converged parameter estimates. I also get the same answers with "gnls" without specifying the "weights" argument. Howeve

Re: RE: [R] Generalized least squares using "gnls" function

2004-01-15 Thread Ravi Varadhan
-Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Ravi Varadhan > Sent: Wednesday, January 14, 2004 6:11 PM > To: [EMAIL PROTECTED] > Subject: [R] Generalized least squares using "gnls" function > > > Hi: > >

Re: RE: [R] Generalized least squares using "gnls" function

2004-01-15 Thread Ravi Varadhan
ays had trouble with this form of varPower (even in S). I > just > wonder if form = ~fitted(".") might work. > > > On Thu, 15 Jan 2004, Ravi Varadhan wrote: > > > Dear Christian: > > > > That is not the problem, but thanks for your attempted help. I > s

[R] Restoring an S object that was data-dumped

2004-01-20 Thread Ravi Varadhan
Hi: In R, how can I "data.restore" an object that was "data.dump"ed in Splus (I am not sure of the exact version, but probably Splus5)? When I use data.restore, I get the following error message (I am using R 1.7.0 on Windows) > data.restore("n2.suicide") Error in ReadSdump(TRUE, " ") : S mod

Re: [R] warning associated with Logistic Regression

2004-01-26 Thread Ravi Varadhan
Hi All: I am really fascinated by the content and the depth of discussion of this thread. This really exemplifies what I have come to love and enjoy about the R user group - that it is not JUST an answering service for getting help on programming issues, but also a forum for some critical and

Re: [R] Robust nonlinear regression - sin(x)/x?

2004-02-02 Thread Ravi Varadhan
You reall have only one parameter in your model, c = a/b. You can't identify both a and b from your model, therefore, you should fit the linear model: lm(z ~ c* sin(x)/x) Ravi. - Original Message - From: cstrato <[EMAIL PROTECTED]> Date: Monday, February 2, 2004 2:28 pm Subject: [R] Ro

Re: [R] Robust nonlinear regression - sin(x)/x?

2004-02-02 Thread Ravi Varadhan
A small correction to my previous email: You actually specify the following call to lm: y <- sin(x)/x lm(z ~ y - 1) to make sure that the intercept is not estimated. Ravi. - Original Message - From: Ravi Varadhan <[EMAIL PROTECTED]> Date: Monday, February 2, 2004 2:46 pm Su

Re: [R] Computing the mode

2004-02-24 Thread Ravi Varadhan
my previous posting. # For example: library(ftnonpar) plot(dclaw(seq(-3,3,len=1000)),type="l") xx <- rclaw(500) pmden(xx,verbose=T) Best, Ravi. - Original Message - From: Ravi Varadhan <[EMAIL PROTECTED]> Date: Tuesday, February 24, 2004 4:23 pm Subject: Re: [R] Computi

Re: [R] Computing the mode

2004-02-24 Thread Ravi Varadhan
I remember Prof. Ripley suggesting the "taut springs" approach to estimating the modes, sometime ago in a posting to this group. I would be interested in knowing whether there is any R implementation of this approach (developed by Davies (1995)), for both non-parametric regression and density e

Re: [R] Help wit matrices

2007-08-10 Thread Ravi Varadhan
An even simpler solution is: mat2 <- 1 * (mat1 > 0.25) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins Univ

Re: [R] Linear models over large datasets

2007-08-17 Thread Ravi Varadhan
> ans1 <- solve(t(X)%*%X,t(X)%*%y) > ans2 <- qr.solve(X,y) > all.equal(ans1,ans2) [1] TRUE Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medici

Re: [R] integrate

2007-08-22 Thread Ravi Varadhan
You can divide your domain of integration into smaller intervals and then add up the individual contributions. This could improve the speed of adaptive Gauss-Kronrod quadrature used in integrate(). Ravi. --- Ravi

RE: [R] (Off topic.) Observed Fisher information.

2005-06-06 Thread Ravi Varadhan
ihood doesn't have to concave. I remember reading something about this in Barndorff-Nielsen and Cox's book on Inference and Asymptotics. There may be better references. Ravi. -- Ravi Varadhan, Ph.D. Assistant Profess

RE: [R] position of a legend-object

2005-06-09 Thread Ravi Varadhan
elps, 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

Re: [R] Representative curves

2005-06-24 Thread Ravi Varadhan
of Computational and Graphical Statistics, Vol. 3, No. 2 (Jun., 1994), pp. 214-233. I don't know of any more recent ones. Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Divisi

Re: [R] Circular Mean Question

2005-06-28 Thread Ravi Varadhan
om the following (where the resultant vector is not zero): > deg(circ.mean(c(rad(211),rad(30 # note 211 = -149 (mod 360) [1] -59.46 which is perfectly alright. Hope this helps, Ravi. ------ Ravi Varadhan, Ph.D. A

Re: [R] x*x*x*... vs x^n

2005-06-29 Thread Ravi Varadhan
Min. 1st Qu. MedianMean 3rd Qu.Max. 0.060 0.100 0.110 0.128 0.170 0.190 > summary(f3time) Min. 1st Qu. MedianMean 3rd Qu.Max. 0. 0.0300 0.0950 0.0779 0.1100 0.1300 Ravi. ------ Ravi V

Re: [R] generalized gamma random number generation

2005-07-05 Thread Ravi Varadhan
Look at the function "rggamma" in J.K. Lindsey's package "rmutil". ------ Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Ho

Re: [R] comparing strength of association instead of strength ofevidence?

2005-07-08 Thread Ravi Varadhan
. Best, 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

Re: [R] Fieller's Conf Limits and EC50's

2005-07-14 Thread Ravi Varadhan
Hi, I didn't verify your formulas for Fieller's method of computing the confidence interval. A slightly simpler approach is to use the Delta method to compute the CI. It is also valid for any link function. It yields a simpler formula for the variance of EC50 (for any link function): varEC50 <-

[R] A statistical modeling problem

2005-07-14 Thread Ravi Varadhan
Hi, This is not an R related question and I apologize for that, but given the brain power of the R community it is hard for me to resist posting this here. I have a problem where each participant is shown a series of visual cues (displayed on a computer screen in a random order) and asked t

Re: [R] Dividing a vector into ntiles

2005-07-15 Thread Ravi Varadhan
Here is an example that shows how to divide a vector into "quartiles" and create a categorical (factor) variable with 4 levels ("A", "B", "C", "D") from it: x <- rnorm(100) xcat <- factor(cut(x, quantile(x), include.lowest = TRUE), labels = LETTERS[1:4]) table(xcat) Ravi. > --

[R] A one-liner to create a 3-dim array

2005-07-25 Thread Ravi Varadhan
Hi, I would like to write a one-line R code to create a 3-dim array, B, of dimension (n,n,m) from a matrix, A, of dimension (m,n) such that the i-th element of the 3-dim array, B[, , i] is the outer product of the i-th row of A. Thanks for any help, Ravi. [[alternative HTML ve

Re: [R] question on graphs and finding area under a curve

2005-08-02 Thread Ravi Varadhan
Hi, To find the area lying between the curve y = y(x) and 45 degree line (which, assuming it goes through the origin, is y = x), you can use the following function based on trapezoidal rule: trap.rule <- function(x,f) {sum(diff(x)*(f[-1]+f[-length(f)]))/2} trap.rule(x,f=y-x) This area will be n

Re: [R] Vector comparison to matrix

2005-08-15 Thread Ravi Varadhan
Hi Todd, Here is a function that was suggested to me by Gabor Grothendieck. This function counts the number of times each row of a matrix B occurs in another matrix A. rowmatch.count <- function(a,b) { f <- function(...) paste(..., sep=":") a2 <- do.call("f", as.data.frame(a)) b2 <-

Re: [R] nonlinear least squares fitting Trust-Region"

2006-09-02 Thread RAVI VARADHAN
As suggested by Prof. Ripley, you should read a good book in the optimization area. One that I would highly recommend is the book by Dennis and Schnabel (1983) - Numerical methods for unconstrained optimization, which does a great job of explaining both "line-search" and "trust-region" approach

Re: [R] nonlinear least squares fitting Trust-Region"

2006-09-02 Thread RAVI VARADHAN
tting Trust-Region" To: RAVI VARADHAN <[EMAIL PROTECTED]> Cc: Prof Brian Ripley <[EMAIL PROTECTED]>, Martin Ivanov <[EMAIL PROTECTED]>, r-help@stat.math.ethz.ch > May I also suggest Bates and Watts (1988) Nonlinear > Regression > Analysis and Its Application

[R] LARS for generalized linear models

2006-09-15 Thread Ravi Varadhan
y in their discussion of Efron et al (2004) describe a LARS-type algorithm for generalized linear models. Has anyone implemented this in R? Thanks for any help. Best, Ravi ------- Ravi Varadhan, Ph.D. Assistant

[R] Propensity score modeling using machine learning methods. WAS: RE: LARS for generalized linear models

2006-09-18 Thread Ravi Varadhan
ity score as weights) should be reasonable. Am I right? I would appreciate comments on these points. Thanks very much. Best, Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and

Re: [R] PDE

2006-09-27 Thread Ravi Varadhan
varying time steps. R has very limited functionality for handling differential equations. So, you should look for FORTRAN libraries, from which you can create DLLs to be used in R. Hope this help, Ravi. --- Ravi

Re: [R] PDE

2006-09-29 Thread Ravi Varadhan
for all t. Hope this is clear. You should also consult a basic numerical analysis text, for example, Burden and Faires (2001, 7th Edition, pages 704 - ...). Best, Ravi. ------- Ravi Varadhan, Ph.D. Assistant Prof

[R] X-axis labels in histograms drawn by the "truehist" function

2006-09-29 Thread Ravi Varadhan
ams to be "X1", "X2", etc. Any help is appreciated. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology

Re: [R] GLM information matrix

2006-09-29 Thread Ravi Varadhan
in accurate Hessian of the log-likelihood. 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-26

[R] X-axis labels in histograms drawn by the "truehist" function

2006-10-02 Thread Ravi Varadhan
X1","X2","X3","X4") par(mfrow=c(2,2)) apply(X, 2, function(x)truehist(x)) In this example, I would like the x-labels of the histograms to be "X1", "X2", etc. Any help is appreciated. Best, Ravi --

Re: [R] X-axis labels in histograms drawn by the "truehist" function

2006-10-02 Thread Ravi Varadhan
Thank you, Marc and Gabor. I apologize for having missed Gabor's reply. Best regards, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicin

Re: [R] Re : Generate a random bistochastic matrix

2006-10-16 Thread Ravi Varadhan
It is interesting to note that the above algorithm converges if we use the infinity norm, instead of the 1-norm, to scale the rows and columns, i.e. we divide rows and columns by their maxima. Best, Ravi. ---- --- Ravi Var

Re: [R] Large matrix into a vector

2007-03-28 Thread Ravi Varadhan
c(HR) will do it. 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] Likelihood returning inf values to optim(L-BFGS-B) other options?

2007-04-05 Thread Ravi Varadhan
gy for picking a starting value) and different optimization methods (e.g. conjugate gradient with "Polak-Ribiere" steplength option, Nelder-Mead, etc.). Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Profes

Re: [R] Computing the rank of a matrix.

2007-04-06 Thread Ravi Varadhan
Hi, qr(A)$rank will work, but just be wary of the tolerance parameter (default is 1.e-07), since the rank computation could be sensitive to the tolerance chosen. Ravi. --- Ravi Varadhan, Ph.D. Assistant

Re: [R] Computing the rank of a matrix.

2007-04-07 Thread RAVI VARADHAN
t;- -(7:16) > tol <- 10^exp > sapply(tol, A=hilbert(20), function(x,A)qr(A, tol=x, LAPACK=FALSE)$rank) [1] 10 12 14 14 15 16 16 17 18 19 > sapply(tol, A=hilbert(20), function(x,A)qr(A, tol=x, LAPACK=TRUE)$rank) [1] 20 20 20 20 20 20 20 20 20 20 Looking forward to comments. Best, Ravi.

Re: [R] convergence

2007-04-19 Thread Ravi Varadhan
No. --- 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

Re: [R] Problems in programming a simple likelihood

2007-04-19 Thread Ravi Varadhan
, method = "CG", y = women$J, X = cbind(1, women$M, women$S)) > out $par [1] -3.0612277 -1.4567141 0.3659251 $value [1] 13.32251 $counts function gradient 357 101 $convergence [1] 1 $message NULL Hope this helps, Ravi. --

Re: [R] Suggestions for statistical computing course

2007-04-20 Thread Ravi Varadhan
tly. 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] Estimates at each iteration of optim()?

2007-04-23 Thread Ravi Varadhan
Why do you want to look at parameter estimates for each step, anyway? Ravi. ---- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopk

Re: [R] Estimates at each iteration of optim()?

2007-04-23 Thread Ravi Varadhan
r constraints. 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.jhsph.edu/a

Re: [R] Simple plot question

2007-04-26 Thread Ravi Varadhan
Check out the function "mvrnorm" in package MASS. library(MASS) ?mvrnorm Ravi. ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontolo

Re: [R] [SPAM] - Re: R package development in windows - BayesianFilter detected spam

2007-05-03 Thread Ravi Varadhan
Harold, I totally echo your sentiments on the difficulty of creating an R package in Windows. I really wish that this process could be made a bit less painful. Ravi. --- Ravi Varadhan, Ph.D. Assistant

Re: [R] A function for raising a matrix to a power?

2007-05-07 Thread Ravi Varadhan
re made to be orthonormal. 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] Bad optimization solution

2007-05-07 Thread Ravi Varadhan
point). However, I do not why optim converges to the boundary maximum, when analytic gradient is supplied (as shown by Sundar). Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health

Re: [R] Bad optimization solution

2007-05-08 Thread RAVI VARADHAN
e solution provided by R is correct or not. In the > case that I reported, it is fairly simple to see that the solution > provided by R (without any warning!) is incorrect, but, in general, > that is not so simple and one may take a wrong solution as a correct > one. > > Pau

Re: [R] A function for raising a matrix to a power?

2007-05-09 Thread Ravi Varadhan
avi. --- 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.jhsph.edu/agingandhealth/Peo

Re: [R] Nonlinear constrains with optim

2007-05-10 Thread Ravi Varadhan
sequential unconstrained minimization techniques. Another good book is that by Roger Fletcher (1987): Practical methods of optimization. Ravi. ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health

Re: [R] Optim

2007-05-10 Thread Ravi Varadhan
"significantly" different but the corresponding parameter estimates differ widely, then you may have identifiability issues. Ravi. ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health D

Re: [R] Time series\optimization question not R question

2007-05-22 Thread Ravi Varadhan
atanh(A + beta) 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 PROTE

Re: [R] Time series\optimization question not R question

2007-05-22 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.jhsph.edu/agingand

Re: [R] Problem with numerical integration and optimization with BFGS

2007-05-25 Thread Ravi Varadhan
You could try that. 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: [

Re: [R] Calculation of ratio distribution properties

2007-05-25 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.jhsph.edu/agingandhealth/People/Fa

Re: [R] ratio distribution - missing attachment

2007-05-29 Thread Ravi Varadhan
Dear Martin and Vitto, Please find attached the R function to compute the density of the ratio of 2 dependent normal variates. Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and

Re: [R] Comparing multiple distributions

2007-05-31 Thread Ravi Varadhan
Your data is "compositional data". The R package "compositions" might be useful. You might also want to consult the book by J. Aitchison: statistical analysis of compositional data. Ravi. ---- ---

Re: [R] Numerical Derivatives in R

2006-03-13 Thread Ravi Varadhan
Hi Paul, Tolga, and others: I had also written some codes to compute derivatives, jacobians, and Hessians. Please see the attached file for the code. I will be happy to help out with the development of a package and/or with the documentation process. Best, Ravi. > -Original Message- >

Re: [R] Jonckheere-Terpstra test

2006-03-25 Thread RAVI VARADHAN
Hi Marie, Here is a function that I wrote based on the "JT.test " function in package "SAGx", to account for missing values and to order based on the groups. JT.fun <- function(y, g) { nas <- is.na(y) | is.na(g) ord <- order(g[!nas]) d <- y[!nas][ord] g <- g[!nas][ord] return (JT.test(dat

Re: [R] Differential Equations

2006-03-27 Thread Ravi Varadhan
Dominik, Adding (1) and (2) yields, A(t) + B(t) = constant = A(0) + B(0) = c So, plug in B = c - A in (1) and solve for A. This should be an easy solution. Hope this is helpful, Ravi. > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Peter

Re: [R] atan2(1,1i)

2006-03-28 Thread Ravi Varadhan
Try this: > atan2(1+0i,1i) [1] NaN-Infi Ravi. > -Original Message- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Robin Hankin > Sent: Tuesday, March 28, 2006 9:13 AM > To: RHelp > Subject: [R] atan2(1,1i) > > Hi > > ?atan2 says that atan2(y,x)=atan(y/x) for

[R] Computing the minimal polynomial or, at least, its degree

2004-12-03 Thread Ravi Varadhan
tions. ------ Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins Univerisity Ph: (410) 502-2619 Fax: (410) 614-9625 Email: <mailto:[EMAIL PROTECTED]> [EMAI

[R] Computing the minimal polynomial or, at least, its degree

2004-12-03 Thread Ravi Varadhan
tions. ------ Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins Univerisity Ph: (410) 502-2619 Fax: (410) 614-9625 Email: <mailto:[EMAIL PROTECTED]> [EMAI

RE: [R] Computing the minimal polynomial or, at least, its degree

2004-12-06 Thread Ravi Varadhan
) = D_{n-1}(\lambda) M(\lambda). Is there a way to use this theorem and the "polynomial" library to compute the minimal polynomial? Thanks once again, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on

[R] Processing and analysis of ECG signals

2004-12-09 Thread Ravi Varadhan
. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins Univerisity Ph: (410) 502-2619 Fax: (410) 614-9625 Email: <mailto:[EMAIL PROTECTED]> [EMAIL PRO

RE: [R] Converting a list to a matrix - I still don't think I have itright

2005-02-17 Thread Ravi Varadhan
This should do it: matrix(unlist(mylist),nrow=length(mylist), by=T) -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph

Re: [R] Generating all possible partitions

2005-11-25 Thread Ravi Varadhan
Isn't Bell number different from the number of partitions, P_n, of a number, n? Bell number, B_n, is the number of subsets into which a set with "n" elements can be divided. So, B_3 = 5, and B_4 = 15, whereas P_3 = 3, and P_4 = 5. Bell numbers grow much more rapidly than the number of partitions

Re: [R] convolution of the double exponential distribution

2005-12-23 Thread Ravi Varadhan
(-2q) \Gamma(n+1) / 2^(n+1). 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

Re: [R] Powell's Metod

2006-01-16 Thread Ravi Varadhan
Tolga, Have you considered an EM algorithm for your factor analysis problem? A reference for this is: Rubin, D. and Thayer, D. (1982). EM algorithms for ML factor analysis. Psychometrika, 47(1):69--76. Hope this is helpful, Ravi. > -Original Message- > From: [EMAIL PROTECTED] [mailto:

[R] Legends in xyplot

2006-01-16 Thread Ravi Varadhan
Hi, How can I add legends in the "xyplot" function, in the "lattice" library? Here is a simulation example: x <- runif(90) z <- sample(1:3, 90, rep=T) y <- rnorm(90, mean = x^2 + z, sd=1) library(lattice) trellis.par.set(col.whitebg()) xyplot(y ~x, groups=as.factor(z), type = c('p',

Re: [R] Legends in xyplot

2006-01-17 Thread Ravi Varadhan
o indicate the 3 different smoothed curves. Can someone give me a simple example or show how to do this for my example? Thanks very much, Ravi. > -Original Message- > From: Uwe Ligges [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 17, 2006 3:08 AM > To: Ravi Varadhan &

[R] Multiple xyplots on the same page

2006-01-31 Thread Ravi Varadhan
Hi, I am using the "xyplot" function in the "lattice" package to generate multiple plots, but I would like to have them plotted on the same page. I would like to set something equivalent to the command: par(mfrow=c(2,2)), in order that I can plot 4 xyplots on the same page. How can I do this

Re: [R] Multiple xyplots on the same page

2006-02-01 Thread Ravi Varadhan
Ravi. > -Original Message- > From: Liaw, Andy [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 31, 2006 1:04 PM > To: 'Ravi Varadhan'; r-help@stat.math.ethz.ch > Subject: RE: [R] Multiple xyplots on the same page > > See ?print.trellis. > >

  1   2   3   >