Re: [R] predicted HR in coxph with psline

2013-01-25 Thread Carrie Li
Thank you, Terry. So in the spline model, how to do the interpretation for HR? For linear term, the HR can be interpreted as comparing a person with age 65, for example, against mean age. But if there is no defined centering point in spline, what's the compared value when we do the interpretation?

[R] predicted HR in coxph with psline

2013-01-24 Thread Carrie Li
Hi all, I have some questions about the predicted HR in coxph function including psline covariate. If just fitting covariate as linear form, by default, the reference value for each of predictions type (linear predictor, risk and terms) is the mean covariate within strata. If the psline is

[R] questions about the output of gee and its summary

2011-05-08 Thread Carrie Li
Dear R-helpers, I am using the package gee to run a marginal model. Here is the output. In my simulated data, both x and z are time-varying, so I include their interaction terms with time indicator (i.e. tind=0, if time 1, and 1 if time 2) The data is simulated, so the true parameter of z both

[R] questions about using loop, while and next

2011-03-03 Thread Carrie Li
Hello R helpers, I have a quick question about loop and next In my loop, I have some random generation of data, but if the data doesn't meet some condition, then I want it to go next, and generate data again for next round. # just an example.. # i want to generate the data again, if the sum is

[R] questions about counting numbers

2011-02-06 Thread Carrie Li
Hello R-helpers, I have a question about counting numbers. Here is a simple example. a=c(2, 3, 3,4) table(a) a 2 3 4 1 2 1 so, I can to create another variables that has the corresponding counting numbers. In this case, I want to have: b=c(1,2,2,1) Is there any way coding for this ? Thanks

Re: [R] questions about counting numbers

2011-02-06 Thread Carrie Li
(a)] a 4 3 2 3 1 2 1 2 HTH Ray Brownrigg On Mon, 07 Feb 2011, Jorge Ivan Velez wrote: Hi Carrie, Try x - rle(a) rep(x$lengths, x$lengths) [1] 1 2 2 1 HTH, Jorge On Sun, Feb 6, 2011 at 8:21 PM, Carrie Li wrote: Hello R-helpers, I have a question about counting

Re: [R] Matching patients

2011-02-01 Thread Carrie Li
Here is a paper that gives an review of matching Elizabeth A. Stuart. (2010) Matching Methods for Causal Inference: A Review and a Look Forward. Statistical Science; 25(1):1-21. In the paper, there is a list of R packages that does matching. hope this helps. On Tue, Feb 1, 2011 at 2:01 PM,

Re: [R] maximum matrix size if it runs with 64-bit R

2010-10-06 Thread Carrie Li
) 4000112 bytes b=rnorm(P*P)*1000 D2=matrix(b, nrow=P) object.size(D2) 8000112 bytes On Wed, Oct 6, 2010 at 5:44 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 5, 2010, at 11:17 PM, Carrie Li wrote: Thank you, Henrik! That makes more sense now. You mentioned that every double value

Re: [R] maximum matrix size if it runs with 64-bit R

2010-10-05 Thread Carrie Li
at 12:22 PM, Marc Schwartz marc_schwa...@me.com wrote: On Oct 2, 2010, at 11:14 AM, Carrie Li wrote: Hi everyone, If I run on a 64-bit R, what is the maximum matrix size that it can handle ? Is a matrix 20,000 x 20,000 possible on 32 bit ? Thanks for answering! A matrix is a vector

Re: [R] maximum matrix size if it runs with 64-bit R

2010-10-05 Thread Carrie Li
appreciate your explanation and helps! On Tue, Oct 5, 2010 at 8:32 PM, Henrik Bengtsson h...@stat.berkeley.eduwrote: On Tue, Oct 5, 2010 at 5:21 PM, Carrie Li carrieands...@gmail.com wrote: I am sorry that it has been couple days. I've read the website you provided below, but still don't quite know

[R] maximum matrix size if it runs with 64-bit R

2010-10-02 Thread Carrie Li
Hi everyone, If I run on a 64-bit R, what is the maximum matrix size that it can handle ? Is a matrix 20,000 x 20,000 possible on 32 bit ? Thanks for answering! Carrie-- [[alternative HTML version deleted]] __ R-help@r-project.org mailing

Re: [R] package for measurement error models

2010-08-11 Thread Carrie Li
: On Tue, 10 Aug 2010, peter dalgaard wrote: On Aug 10, 2010, at 3:52 AM, Carrie Li wrote: Thanks. I found the code in the link you gave me very helpful. But, I just have few questions regarding the code. It seems to me that in (from wikipdeia)Deming regression, it assumes that the ratios

Re: [R] package for measurement error models

2010-08-09 Thread Carrie Li
Thanks. I found the code in the link you gave me very helpful. But, I just have few questions regarding the code. It seems to me that in (from wikipdeia)Deming regression, it assumes that the ratios of the variances of two measurement errors are constant for all pairs of (x_i, y_i). However, if

[R] package for measurement error models

2010-08-07 Thread Carrie Li
Hi,all, I posted this question couple of days again, but haven't gotten any answers back. I would like to post it again, and if you have any ideas, please let me know. Any helps and suggestions are very much appreciated. The problem is about linear regression with both y and x have measurement,

[R] package for measurement error models

2010-08-01 Thread Carrie Li
Hi, R-helpers, I am working on a problem of measurement error modeling. (I am new to this filed) The model I am dealing with is simple. Consider a linear regression y= beta0 + beta1 * x + error, in which x is measured with errors. (the variance of errors are known. ) I looked up the package

[R] start value in nlminb

2010-07-07 Thread Carrie Li
Hi, all I am doing a optimization problem using nlminb. It seems to me that the result is kind of sensitive to the starting value. (It happened that the resulting parameter doesn't change from the starting value.) Any suggestions on giving the starting value ? or any other function that can do

[R] integration of two normal density

2010-06-25 Thread Carrie Li
Hello everyone, I have a question about integration of two density function Intuitively, I think the value after integration should be 1, but they are not. Am I missing something here ? t=function(y){dnorm(y, mean=3)*dnorm(y/2, mean=1.5)} integrate(t, -Inf, Inf) 0.3568248 with absolute error

[R] what density is plotting ?

2010-06-24 Thread Carrie Li
Hi everyone, I am confused regarding the function density. suppose that there is a sample x of 100 data points, and plot(density(x)) gives it's pdf ? or it's more like histogram only ? thanks for any answering Carrie [[alternative HTML version deleted]]

Re: [R] what density is plotting ?

2010-06-24 Thread Carrie Li
, Jun 24, 2010 at 10:35 PM, Carrie Li carrieands...@gmail.com wrote: Hi everyone, I am confused regarding the function density. suppose that there is a sample x of 100 data points, and plot(density(x)) gives it's pdf ? or it's more like histogram only ? thanks for any answering

[R] integrate dmvtnorm

2010-06-23 Thread Carrie Li
Hello, everyone, I have a question about integration of product of two densities. Here is the sample code; however the mean of first density is a function of another random variable, which is to be integrated. ## f=function(x) {dmvnorm(c(0.6, 0.8), mean=c(0.75, 0.75/x))*dnorm(x, mean=0.6,

Re: [R] integrate dmvtnorm

2010-06-23 Thread Carrie Li
Thanks! Both suggestions are very helpful. One more question: Can I use Vectorize to solve double integration question ? Now that f=function(x, y) {dnorm(y, mean= 0.75/x)*dnorm(x, mean=0.6, sd=0.15)} And I want to integrate x first,then y. Ravi used sapply, which is good, but it seems to be

[R] Optimization of multivariate nonlinear function with equality constrain

2010-06-15 Thread Carrie Li
Dear R-helpers, I am working on an optimization problem, and I tried to use nlminb function to solve it. But now I have an equality constrain, the Langrange multiplier can solve it. However I would like to know if there is any existing function or package solving this kind of problem. Any

[R] Question about avoid the for loop

2010-06-03 Thread Carrie Li
Dear R-helpers, I would like to generate a binary random variable within a stratum's stratum. Here is a simple example. ## x is the first level strata index, here I have 3 strata. x=c(rep(1,5), rep(2,5), rep(3,5)) ## within x, there is a second strata indexed by t=0 and t=1

Re: [R] Question about avoid the for loop

2010-06-03 Thread Carrie Li
many 0's and 1's you have within each strata spd - with(d, split(d, x)) do.call(c, lapply(spd, function(comp) with(comp, ifelse(t == 0, rbinom(sum(t==0), 1, 0.2), rbinom(sum(t!=0), 1, 0.8) HTH, Jorge On Thu, Jun 3, 2010 at 11:49 AM, Carrie Li wrote: Dear R-helpers

Re: [R] Question about avoid the for loop

2010-06-03 Thread Carrie Li
as the binary part, it's all 0 0 1 1 1 for each stratum. Is there way to make them complete randomly different over the strata ? Thank you again! Carrie On Thu, Jun 3, 2010 at 7:24 PM, Carrie Li carrieands...@gmail.com wrote: Thanks! Jorge Just one more question I don't get it even after

Re: [R] Question about avoid the for loop

2010-06-03 Thread Carrie Li
because you have the same number of 0's and 1's within each strata. If that would not be the case, option 1 would not work. That's why I provided you a second option. Best, Jorge On Thu, Jun 3, 2010 at 7:24 PM, Carrie Li wrote: Thanks! Jorge Just one more question I don't get it even after

[R] Bernoulli random variable with different probability

2010-05-22 Thread Carrie Li
Dear R-helpers, I would like to generate a variable that takes 0 or 1, and each subject has different probabilities of taking the draw. So, which of the following code I should use ? suppose there are 5 subjects, and their probabilities of this Bernoulli variable is p=c(0.2, 0.9, 0.15, 0.8,

[R] select subset based on another variable

2010-05-13 Thread Carrie Li
Hi, dear R-helpers, I have a simple question regarding selecting subset of a variable based on another variable. Here is the example: xx=rnorm(10) id=sample(1:10, 10) temp=c(6, 1, 8, 2) Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the position. Any suggestions ? Thank you

[R] How do I use tapply in this case ?

2010-02-04 Thread Carrie Li
Dear R-helpers , I have a simple loop as follows, however, to be more efficient, I would like to use any apply functions (tapply, I suppose) But how can I do this ? I am not very clear about this. # Z is a P * Q matrix # so for each row of Z, I would like to pull out only some of the elements,

Re: [R] How do I use tapply in this case ?

2010-02-04 Thread Carrie Li
by the matrix index And, since I have large P, so I would like to avoid loop. Any quick way to do this ? Thanks again!! Carrie On Thu, Feb 4, 2010 at 10:39 PM, David Winsemius dwinsem...@comcast.netwrote: On Feb 4, 2010, at 9:51 PM, Carrie Li wrote: Dear R-helpers , I have a simple loop

Re: [R] How do I use tapply in this case ?

2010-02-04 Thread Carrie Li
! On Fri, Feb 5, 2010 at 12:24 AM, David Winsemius dwinsem...@comcast.netwrote: On Feb 4, 2010, at 11:53 PM, Carrie Li wrote: Thank you, David Here is an example : Z=matrix(rnorm(20), nrow=4) index=replicate(4, sample(1:5, 3)) P=4 tmpr=list() for (i in 1:P) { tmp = Z[i,index[,i]] tmpr[[i

[R] Hodges-Lehmann EXACT confidence interval for small dataset with ties

2010-02-04 Thread Carrie Li
Dear r-helpers, I have a small dataset (n50), and I want to compute the Hodges Lehmann exact confidence interval. So far, I know that pairwiseCI has the function HL.diff. The description is as follows : HL.diff calculates the Hodges-Lehmann confidence interval for the difference of locations by

[R] how to give the index with some given index ?

2010-01-20 Thread Carrie Li
Dear R-helpers, I have a question about giving index. Suppose that I have a vector say, id=1:5, and each of them have some given index but some of them may share the same index Now, I have another vector, and I want to give it a index based what just defined. # 5 subjects test1=1:5 #

[R] how to give the index with some given index ?

2010-01-20 Thread Carrie Li
Dear R-helpers, I have a question about giving index. Suppose that I have a vector say, id=1:5, and each of them have some given index but some of them may share the same index Now, I have another vector, and I want to give it a index based what just defined. # 5 subjects test1=1:5 #

[R] how to give the index with some given index ?

2010-01-20 Thread Carrie Li
Dear R-helpers, I have a question about giving index. Suppose that I have a vector say, id=1:5, and each of them have some given index but some of them may share the same index Now, I have another vector, and I want to give it a index based what just defined. # 5 subjects test1=1:5 #

[R] making package interface with FORTRAN under windows

2009-09-13 Thread Carrie Li
Dear r-help group, I am creating a package that has some FORTRAN code under windows. I have read through Writing R Extension but still not so clear about the steps. Before R CMD build, how can I create a dynamic library and later in my R function using dyn.load (xxx.dll) ? If I already have a