[R] Converting a list from R to Stata
Dear all, I have a list containing 150 simulated datasets in R. Is there a way to convert it to the Stata format such that I will be able to apply some Stata functions on each dataset in the list? Thank you in advance, Vicky Landsman. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] ks.test for conditional distribution Y|x
Dear experts, Is it possible to use ks.test function to check the goodness of fit of the conditional distribution Y|X=x? For example, I would like to check that my data (Y,X) come from Norm(0.5+x,1) using KS. Thank you in advance, Victoria Landsman. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Bivariate lognormal distribution
Thanks to Prof. Ripley, Kjetil and Spencer Graves for help. I will be more specific. I have to simulate a bivariate lognormal pair (Y1,Y0) where E(Y1)=X'b, E(Y0)=X'd, Var(Y1)=c1, Var(Y0)=c0, X is a data matrix, and b and d are vectors of parameters. Vicky. - Original Message - From: Spencer Graves [EMAIL PROTECTED] To: Prof Brian Ripley [EMAIL PROTECTED] Cc: Vicky Landsman [EMAIL PROTECTED]; R-help list R-help@stat.math.ethz.ch Sent: Friday, March 25, 2005 4:40 PM Subject: Re: [R] Bivariate lognormal distribution I hope Professor Ripley will correct me if I'm mistaken, but the documentation for mvrnorm in library(MASS) says it will, Simulate from a Multivariate Normal Distribution. If you want the density function or probabilities or quantiles, you can get those from library(mvtnorm). Just for completeness, to use normal for a lognormal, you need to take the logarithms of your number (which must be all positive; zeros and negative numbers become NA), then compute mean vector and variance matrix of the logs, compute probabilities on the log scale, then back transform by exponentiating to get the results back into the original scale. hope this helps. spencer graves Prof Brian Ripley wrote: On Thu, 24 Mar 2005, Vicky Landsman wrote: Is there a package that enables to create the bivariate log-normal variables? Just exponentiate each of a bivariate normal pair. You can get the latter from mvrnorm in package MASS. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to stop the minimization when the condition does not hold
Dear experts! I have a minimization problem with non-linear constraint and Objective function(theta)=lambda*(Constr)^2-f(x,theta). Theta is a vector of parameters. I'd like to stop the optimization after the value of the constraint is less or equal some constant value, say d, and save the last computed value of the function. For this purpose, I thought to define the Objective function like this: if (Constraintd) fun- else stop but this does not work with error message: Error in f(x, ...) : Object fun not found I am using nlm for minimization. Thanks a lot for help and suggestions, Vicky Landsman. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Bivariate lognormal distribution
Dear experts! Is there a package that enables to create the bivariate log-normal variables? Thanks a lot, Vicky Landsman. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Summing up matrices in a list
Dear all, I think that my question is very simple but I failed to solve it. I have a list which elements are matrices like this: mylist [[1]] [,1] [,2] [,3] [1,]135 [2,]246 [[2]] [,1] [,2] [,3] [1,]79 11 [2,]8 10 12 I'd like to create a matrix M-mylist[[1]]+mylist[[2]] [,1] [,2] [,3] [1,]8 12 16 [2,] 10 14 18 Is there a way to create M without looping? Thanks a lot, Vicky Landsman. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] OPG variance estimate
Dear all, Is there exist a function which provides an OPG (outer product of the gradient) estimate for variance - covariance matrix of the MLE? I tried to write my own function but it produces significantly different results comparing with empirical sd estimates computed from simulations and I cannot understand where is mistake. Thanks a lot, Vicky Landsman. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help with constrained optimization
Dear all, I need an advice in the following problem. I have to maximize two functions of the form f1(x)=f(y1,x,alpha1,beta1) and f2(x)=(y2,x,alpha2,beta2), the maximization is with respect to alpha1, alpha2, beta1, beta2. I can maximize each function separately using nlm. The problem is that I have to add the constraint of the form g(alpha1)=g(alpha2). The total number of parameters is approximately 30. What is the best way to do it? I am using R-1.9.1 on Windows XP. Much thanks in advance for any suggestions, Best regards, Vicky Landsman. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Adding GSL library path to SHLIB
Dear R-list people, I asked a similar question a few hours before. I will try to be more specific. We like to add the GSL library to the file SHLIB in order to make it possible to run the C code using GSL functions from R. We read that the path to the libgsl.a should be added to the line shlib_libadd=' ' in the file SHLIB but it does not work on our system. Dyn.load fails with error referenced symbol symbolname not found. What is wrong? We will much appreciate any help on this. We are using R-1.9.1 on Unix. [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Adding GSL library path to SHLIB
Dear Prof. Ripley, We read the archive thread http://maths.newcastle.edu.au/~rking/R/help/02b/0547.html Thank you for your help, we will try to create the Makevars file. Vicky. - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] To: Vicky Landsman [EMAIL PROTECTED] Cc: r-help [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, September 09, 2004 3:17 PM Subject: Re: [R] Adding GSL library path to SHLIB On Thu, 9 Sep 2004, Vicky Landsman wrote: Dear R-list people, I asked a similar question a few hours before. I will try to be more specific. We like to add the GSL library to the file SHLIB in order to make it possible to run the C code using GSL functions from R. We read Read where? It's incorrect information and only used for Fortran linking. that the path to the libgsl.a should be added to the line shlib_libadd=' ' in the file SHLIB but it does not work on our system. Dyn.load fails with error referenced symbol symbolname not found. What is wrong? We will much appreciate any help on this. We are using R-1.9.1 on Unix. You should have a file called Makevars in the directory from which you are doing the building, defining PKG_LIBS, maybe PKG_LIBS=-L/path/to/libgsl -lgsl in the same way as you would for a package: see `Writing R Extensions'. I don't think that is documented anywere, though. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Dyn.load of sharing object with GSL library
Following the recommendation of Prof. Ripley, I have created the Makevars file with the line: PKG_LIBS=-L/usr/lib/libm -lm -L/usr/local/lib/libgsl -lgsl -L/usr/local/lib /libgslcblas -lgslcblas in the working directory. Now I have the code file Example3.c which computes the Bessel function value (the example is taken from the GSL reference book). I am running: R CMD SHLIB Example3.c and all looks good. The dyn.load(Example3.so) fails with the following error message: Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library /fs/users1/guest/msvika/PhD/R_04/Example3.so: ld.so.1: /usr/local/sbin/R-1.9/R-1.9.1/bin/R.bin: fatal: relocation error: file /fs/users1/guest/msvika/PhD/R_04/Example3.so: symbol gsl_sf_bessel_J0: referenced symbol not found What is wrong? Much thanks, Vicky. - Original Message - From: Vicky Landsman [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Sent: Thursday, September 09, 2004 6:18 PM Subject: Re: [R] Adding GSL library path to SHLIB Dear Prof. Ripley, We read the archive thread http://maths.newcastle.edu.au/~rking/R/help/02b/0547.html Thank you for your help, we will try to create the Makevars file. Vicky. - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] To: Vicky Landsman [EMAIL PROTECTED] Cc: r-help [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, September 09, 2004 3:17 PM Subject: Re: [R] Adding GSL library path to SHLIB On Thu, 9 Sep 2004, Vicky Landsman wrote: Dear R-list people, I asked a similar question a few hours before. I will try to be more specific. We like to add the GSL library to the file SHLIB in order to make it possible to run the C code using GSL functions from R. We read Read where? It's incorrect information and only used for Fortran linking. that the path to the libgsl.a should be added to the line shlib_libadd=' ' in the file SHLIB but it does not work on our system. Dyn.load fails with error referenced symbol symbolname not found. What is wrong? We will much appreciate any help on this. We are using R-1.9.1 on Unix. You should have a file called Makevars in the directory from which you are doing the building, defining PKG_LIBS, maybe PKG_LIBS=-L/path/to/libgsl -lgsl in the same way as you would for a package: see `Writing R Extensions'. I don't think that is documented anywere, though. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Dyn.load of sharing object with GSL library
Dear Prof. Ripley, The GSL reference book explains that lm should be added as well (as far as I understand, and this is what I saw when I run the file in C in a standard way). No matter, with lm and without, I get the same picture. Here is what I get after R CMD SHLIB Example3.c make: Warning: File `Makevars' has modification time 3.4e+03 s in the future gcc -I/usr/local/sbin/R-1.9/R-1.9.1/include -I/usr/local/include -fPIC - g -O2 -c Example3.c -o Example3.o gcc -G -L/usr/local/lib -o Example3.so Example3.o -L/usr/local/lib/ -lgsl -L/usr/local/lib/ -lgslcblas make: warning: Clock skew detected. Your build may be incomplete. Running ldd line as you stated, I get the following: libc.so.1 = /usr/lib/libc.so.1 libdl.so.1 =/usr/lib/libdl.so.1 /usr/platform/SUNW,Sun-Fire-280R/lib/libc_psr.so.1 Sorry for my ignorance in UNIX, where should I run the line export LD_LIBRARY_PATH=:${LD_LIBRARY_PATH}:/usr/local/lib ? Vicky. On Thu, 9 Sep 2004, Vicky Landsman wrote: Following the recommendation of Prof. Ripley, I have created the Makevars file with the line: PKG_LIBS=-L/usr/lib/libm -lm -L/usr/local/lib/libgsl -lgsl -L/usr/local/lib /libgslcblas -lgslcblas in the working directory. No, that's not what I recommended. -L/path/to/libgsl would probably be -L/usr/local/lib if libgsl is in /usr/local/lib. And why do you want -lm? Please consult your unstated OS's documentation for ld. Now I have the code file Example3.c which computes the Bessel function value (the example is taken from the GSL reference book). I am running: R CMD SHLIB Example3.c and all looks good. The dyn.load(Example3.so) fails with the following error message: Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library /fs/users1/guest/msvika/PhD/R_04/Example3.so: ld.so.1: /usr/local/sbin/R-1.9/R-1.9.1/bin/R.bin: fatal: relocation error: file /fs/users1/guest/msvika/PhD/R_04/Example3.so: symbol gsl_sf_bessel_J0: referenced symbol not found Try ldd /fs/users1/guest/msvika/PhD/R_04/Example3.so and get a local expert to interpret it for you. You will need anything you had in -L in PKG_LIBS in your library run path as well. You may need e.g. export LD_LIBRARY_PATH=:${LD_LIBRARY_PATH}:/usr/local/lib and please check with a local expert about this. What is wrong? Much thanks, Vicky. - Original Message - From: Vicky Landsman [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Sent: Thursday, September 09, 2004 6:18 PM Subject: Re: [R] Adding GSL library path to SHLIB Dear Prof. Ripley, We read the archive thread http://maths.newcastle.edu.au/~rking/R/help/02b/0547.html Thank you for your help, we will try to create the Makevars file. Vicky. - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] To: Vicky Landsman [EMAIL PROTECTED] Cc: r-help [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, September 09, 2004 3:17 PM Subject: Re: [R] Adding GSL library path to SHLIB On Thu, 9 Sep 2004, Vicky Landsman wrote: Dear R-list people, I asked a similar question a few hours before. I will try to be more specific. We like to add the GSL library to the file SHLIB in order to make it possible to run the C code using GSL functions from R. We read Read where? It's incorrect information and only used for Fortran linking. that the path to the libgsl.a should be added to the line shlib_libadd=' ' in the file SHLIB but it does not work on our system. Dyn.load fails with error referenced symbol symbolname not found. What is wrong? We will much appreciate any help on this. We are using R-1.9.1 on Unix. You should have a file called Makevars in the directory from which you are doing the building, defining PKG_LIBS, maybe PKG_LIBS=-L/path/to/libgsl -lgsl in the same way as you would for a package: see `Writing R Extensions'. I don't think that is documented anywere, though. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http
[R] R, maximization problem and MINUIT package
Dear all, I have to maximize a ml function which is highly non-linear in all parameters and has a number of local maxima. My main problem is to find an effective and sensitive algorithm for setting the initial values. I did not find an appropriate package for R/Splus. I heard that MINUIT package may be helpful. I'd like to know if someone has an experience with combination MINUIT-R. Much thanks for any suggestions, Vicky. [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html