Re: [R] Double for loop

2008-06-26 Thread sigalit mangut-leiba
loops, but you should be > thinking "vectorized" when using R and avoid 'for' loops since they > are not the most efficient way of going things, especially if you are > going to be them hunreds of times. > > On Thu, Jun 26, 2008 at 4:23 AM, sigalit mangut-leiba <[

[R] Double for loop

2008-06-26 Thread sigalit mangut-leiba
Hi, I'm trying to do a double for loop like this: for (k in 1:1000){ for (i in 1:200){ y[i]<-rbinom(1,1,0.8) x1[i]<-ifelse(y[i]==1,rnorm(1,mean=20, sd=2),rnorm(1,mean=16, sd=2.2)) } for (j in 1:300){ } } Does anyone know a good reference about double loops? Thank you, Sigalit [[a

Re: [R] plotEst

2008-02-23 Thread sigalit mangut-leiba
Thank you for your suggestion, now I get 2 lines but confidence limits just for the first one.. do you know what I'm doing wrong?! Thanks again, Sigalit. On 2/23/08, hadley wickham <[EMAIL PROTECTED]> wrote: > > On Tue, Feb 19, 2008 at 3:53 PM, sigalit mangut-leiba <[EMAIL

Re: [R] clarification about glm

2008-02-23 Thread sigalit mangut-leiba
ransformation) ... > > Does that help you? > > Cheers, > Daniel > > > > > - > cuncta stricte discussurus > - > > -Ursprüngliche Nachricht- > Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im > Auftrag v

[R] clarification about glm

2008-02-23 Thread sigalit mangut-leiba
Hello, I have a question about glm: if i have a binary covariate (unit=1,0) the reference group would be 0? (prediction for unit=1) example: dat1<-data.frame(y,unit,x1,x2) log_u <- glm(y~.,family=binomial,data=dat1) summary(log_u) Estimate Std. Error z value Pr(>|z|) (Intercept) -0.

Re: [R] plotEst

2008-02-19 Thread sigalit mangut-leiba
that It doesn't plot the line (geom_line) for the layer, only the estimate points and conf. limits. It does plot a line for the first set of data defined in 'qplot'. The information from the web site: http://had.co.nz/ggplot2 helps a lot. Thank you, Sigalit. On 2/19/08, sigalit mangut-leiba &

Re: [R] plotEst

2008-02-19 Thread sigalit mangut-leiba
Sorry, I want to plot 2 lines (or pointrange like I used before) together, with confidence limits of the estimates. I want to plot another curve as I did for the first one (with qplot like you suggested). I know how to do it with ggplot *without* confidence limits: SE<-c(0.6,0.7,0.8,0.9) OR<-c(2.

[R] qplot

2008-02-19 Thread sigalit mangut-leiba
Hello, I have a question about "qplot": How can I add another line to the same plot ? (like function "lines" in "plot"). Thank You, Sigalit. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/l

Re: [R] plotEst

2008-02-19 Thread sigalit mangut-leiba
On 2/16/08, hadley wickham <[EMAIL PROTECTED]> wrote: > > On Feb 16, 2008 9:11 AM, sigalit mangut-leiba <[EMAIL PROTECTED]> wrote: > > Hello, > > This is the first time i'm trying to plot in R. I want to plot estimates > of > > OR and their confidence l

[R] plotEst

2008-02-19 Thread sigalit mangut-leiba
-- Forwarded message -- From: sigalit mangut-leiba <[EMAIL PROTECTED]> Date: Feb 19, 2008 12:17 PM Subject: Re: [R] plotEst To: r-help <[EMAIL PROTECTED]> On 2/16/08, hadley wickham <[EMAIL PROTECTED]> wrote: > > On Feb 16, 2008 9:11 AM, sigalit mangut

[R] plotEst

2008-02-16 Thread sigalit mangut-leiba
Hello, This is the first time i'm trying to plot in R. I want to plot estimates of OR and their confidence limits, like a scatter plot: the vertical axis should be the estimated OR (with upper and lower conf. limits), and the horizontal exis should be fixed values: (1,0.8,0.7,0.6,0.5,0.4) Here is

[R] OR estimate

2008-01-27 Thread sigalit mangut-leiba
Hello, I have a loop with 1000 repetitions which includes OR computation of an exposure factor and outcome. I compute OR like this: t<-table(exposure,outcome) oddsratio(t)$measure["estimate"] This gives me the estimates for exposure=0 and exposure=1 but exposure=0 is the reference group and i ne

[R] OR computation

2008-01-25 Thread sigalit mangut-leiba
Hello, I want to compute OR from a simulation, I simulate outcome-y and binary covariate, and I repeat it 1000 times. I built a logistic model, and want to compute OR for every sample At the end I'm looking for the mean(OR) of the 1000 repetitions. Can I use cc (from epicalc)? example: if yall is t

Re: [R] bootstrap sampling

2008-01-15 Thread sigalit mangut-leiba
; [9] 2.574342 3.051137 2.574342 2.574342 3.539000 2.535320 3.539000 > 3.545558 > [17] 3.051137 3.636812 2.475192 2.348048 3.051137 2.535320 3.316083 > 2.348048 > [25] 2.929914 3.539000 3.110048 2.773491 1.962290 2.475192 > > then you can do the rest, eg, take mean, sum, etc

[R] bootstrap sampling

2008-01-15 Thread sigalit mangut-leiba
Hello, How do I sample observations with replacement from a normal distribution with a specific mean and s.d? (I want to see the sample, not only the statistic.) Thank you, Sigalit. [[alternative HTML version deleted]] __ R-help@r-project.org ma

[R] Odds Ratio calculation

2007-11-26 Thread sigalit mangut-leiba
Hello, I want to calculate Odds Ratio. I have a binary outcome and two groups of exposure: '1' are exposed, and '2' are not-exposed. I want '2' to be the reference group. By "factor" I get group '1' as a reference because it sorted in increasing order. How do I change it? Thank you, Sigalit.

[R] rbinom with computed probability

2007-11-23 Thread sigalit mangut-leiba
Hello, I have a loop with probability computed from a logistic model like this: for (i in 1:300){ p[i]<-exp(-0.834+0.002*x[i]+0.023*z[i])/(1+exp(-0.834+0.002*x[i]+0.023 +z[i])) x and z generated from normal distribution. I get 300 different probabilities And I want to generate variables from bern

[R] a repetition of simulation

2007-11-15 Thread sigalit mangut-leiba
From: sigalit mangut-leiba <[EMAIL PROTECTED]> Date: Nov 15, 2007 3:24 PM Subject: Re: [R] a repetition of simulation To: r-help <[EMAIL PROTECTED]> Hello, In addition to my question a few days ago, Now I have a matrix of the coefficients, how can I see all the P.Values ( Pr(&

Re: [R] a repetition of simulation

2007-11-15 Thread sigalit mangut-leiba
Thank you for all your comments, Sigalit. On 11/15/07, Johannes Hüsing <[EMAIL PROTECTED]> wrote: > > Excuse me, but I think your code deserves some comments. Unfortunately, > the history of postings is in reverse order, so I'll address your > first question first: > > > > >>> The simulation look

Re: [R] a repetition of simulation

2007-11-15 Thread sigalit mangut-leiba
> > } > > That will give you a matrix with the coefficients of each model run in > each row. > > Julian > > > sigalit mangut-leiba wrote: > > I want to repeat the simulation 600 times and to get a vector of 600 > > coefficients for every covariate: aps and tiss

Re: [R] a repetition of simulation

2007-11-13 Thread sigalit mangut-leiba
Thank you, I changed that and it's much more efficient. Sigalit. On 11/13/07, Phil Spector <[EMAIL PROTECTED]> wrote: > > You can use the replicate function to do your simulation. First, > put the code to do one repetition in a function: > > dosim0 = function(n=500){ > x <- 0 > y <- 0 > z

Re: [R] a repetition of simulation

2007-11-13 Thread sigalit mangut-leiba
I want to repeat the simulation 600 times and to get a vector of 600 coefficients for every covariate: aps and tiss. Sigalit. On 11/13/07, Julian Burgos <[EMAIL PROTECTED]> wrote: > > And what is your question? > > Julian > > sigalit mangut-leiba wrote: > &

Re: [R] a repetition of simulation

2007-11-12 Thread sigalit mangut-leiba
did > results[[ij]] <- log_v > } > > So now you have a list of 600 results and can do > anything you need (look at lapply/sapply). > > Regards, > > Moshe. > > --- sigalit mangut-leiba <[EMAIL PROTECTED]> wrote: > > > Hello, > > I have a simple (?

[R] a repetition of simulation

2007-11-12 Thread sigalit mangut-leiba
Hello, I have a simple (?) simulation problem. I'm doing a simulation with logistic model and I want to reapet it 600 times. The simulation looks like this: z <- 0 x <- 0 y <- 0 aps <- 0 tiss <- 0 for (i in 1:500){ z[i] <- rbinom(1, 1, .6) x[i] <- rbinom(1, 1, .95) y[i] <- z[i]*x[i] if (y[i]==1) a

[R] how to generate data in a simulation study

2007-11-08 Thread sigalit mangut-leiba
hello, I have a problem in how to generate data in a simulation study. I have a logistic model to evaluate p by 3 covariates. I need to generate 4 variables: the binary outcome Y and 3 covariates: gender (binary) and aps and tiss (continuous variables). I have the logistic model which is the expect

Re: [R] writing a categorical var. with condition

2007-11-02 Thread sigalit mangut-leiba
Thank you! Sigalit. On 11/2/07, Marc Schwartz <[EMAIL PROTECTED]> wrote: > > On Fri, 2007-11-02 at 22:02 +0200, sigalit mangut-leiba wrote: > > Hello, > > I want to create a new variable which includes 4 age categories in this > way: > > > > if (age>

[R] writing a categorical var. with condition

2007-11-02 Thread sigalit mangut-leiba
Hello, I want to create a new variable which includes 4 age categories in this way: if (age>=12 && age<32) age1==1 if (age>=32 && age<52) age1==2 if (age>=52 && age<72) age1==3 if (age>=72 && age<100) age1==4 but I get the results only for the first observation. how can I apply this condition

Re: [R] computing the mean of a few variables

2007-11-01 Thread sigalit mangut-leiba
Thank you! Sigalit. On 11/1/07, Tobias Verbeke <[EMAIL PROTECTED]> wrote: > > sigalit mangut-leiba wrote: > > > I want to compute the average of 6 variables, > > my data looks like this: > > > > t0t1 t2t3 t4 t5 > > 1 32 34 36

[R] computing the mean of a few variables

2007-11-01 Thread sigalit mangut-leiba
hello, I have a simple question: I want to compute the average of 6 variables, my data looks like this: t0t1 t2t3 t4 t5 1 32 34 36 40 38 40 2 35 37 38 36 33 39 . . . I want the mean of t0-t5 for each row (observation). thank you, sigalit. [[alternative

Re: [R] Imputation method on binary data

2007-10-24 Thread sigalit mangut-leiba
Thank yot for your excellent detailed explanation! Sigalit. On 10/24/07, Ted Harding <[EMAIL PROTECTED]> wrote: > > On 24-Oct-07 08:51:30, sigalit mangut-leiba wrote: > > hello, > > I want to do a single Imputation method on binary data set. > > Is it possible t

[R] Imputation method on binary data

2007-10-24 Thread sigalit mangut-leiba
hello, I want to do a single Imputation method on binary data set. Is it possible to use imp.cat from CAT package? I have a problem defining "theta" when data is binary. Do you know any references on the subject? Thank you, Sigalit. [[alternative HTML version deleted]] ___

Re: [R] how to repeat the results of a generated probabilities

2007-10-17 Thread sigalit mangut-leiba
gument is the number of times to replicate, the second is the > expression you want to run multiple times. > > Hope this helps. > > On Oct 17, 2007, at 3:03 AM, sigalit mangut-leiba wrote: > > > hello, > > I want to simulate 200 times the mean of a joint probability

[R] how to repeat the results of a generated probabilities

2007-10-17 Thread sigalit mangut-leiba
hello, I want to simulate 200 times the mean of a joint probability (y1) and 200 times the mean of another joint distribution (y2), that is I'm expecting to get 200 means of y1 and 200 means of y2. y1 and y2 are probabilities that I calculate from the marginal prob. (z1 and z2 respectively) multip