search for: carrieandstat

Displaying 16 results from an estimated 16 matches for "carrieandstat".

2010 May 13
3
select subset based on another variable
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 all your help !! Carrie [[alternative HTML version deleted]]
2010 Jun 23
3
integrate dmvtnorm
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, sd=0.15)} integrate(f, lower=-Inf, upper=Inf) ## error message Error in dmvnorm(c(0.6, 0.8), mean = c(0.75,
2010 Jun 26
4
integration of two normal density
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 < 4.9e-06 Also, is there any R function or package could do multivariate integration ?
2011 Feb 07
2
questions about counting numbers
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 for helps! Carrie-- [[alternative HTML version deleted]]
2010 Jun 25
1
what "density" is plotting ?
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]]
2011 May 08
1
questions about the output of "gee" and its summary
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 at time 1 and time 2 is 5, which is very close from the model output for time 1, z =
2010 Feb 05
1
How do I use "tapply" in this case ?
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, and save as a separate matrix under a list # index is a vector with length smaller than Q, but the
2010 Feb 05
1
Hodges-Lehmann EXACT confidence interval for small dataset with ties
Dear r-helpers, I have a small dataset (n<50), 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 calling wilcox.exact in package exactRankTests ; But when I check
2010 Jun 03
1
Question about avoid the for loop
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 t=rep(c(0,0,1,1,1),3) ## and within strata i and t=0 and t=1, I generate the random binomial variable respectively,
2010 Jul 07
0
start value in nlminb
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 optimization but not being sensitive to the initial guess ? Thanks for any helps. Carrie
2010 Aug 02
1
package for measurement error models
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 simex, and the method is simulation-extrapolation estimation. So I was wondering that if there is any
2009 Sep 13
1
making package interface with FORTRAN under windows
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 .dll file, can I build the package with the dll file directly ? Does any one
2010 May 23
2
Bernoulli random variable with different probability
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, 0.75) n<-5 Ber.var <- rbimon(n,1,p) ## I doubt if this will take the first probability, which is
2010 Jan 21
3
how to give the index with some given index ?
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 # corresponding index, so here, subject 2 and subject 4 share the common index "1" index=c(3,1,2,1,4) #
2013 Jan 24
1
predicted HR in coxph with psline
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 specified for the covariate, what's the reference value for the predictions? I did some test code
2011 Mar 04
2
questions about using loop, while and next
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 smaller than 25 temp=rep(NA, 10) for(i in 1:10) { dt=sum(rbinom(10, 5, 0.5)) while (dt<25) next