similar to: how to repeat the results of a generated probabilities

Displaying 20 results from an estimated 4000 matches similar to: "how to repeat the results of a generated probabilities"

2007 Nov 08
1
how to generate data in a simulation study
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 expected model: log(p(y=1)/(1-p(y=1))=-1.659-0.05*sex+0.063*aps+0.04*tiss0) I generate the outcome y like
2007 Nov 12
4
a repetition of simulation
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) aps[i] <- rnorm(1,mean=13.4, sd=7.09) else aps[i] <-
2007 Nov 23
2
rbinom with computed probability
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 bernulli distribution with P for every observation: T[i]<-rbinom(1,1,p[i]) But i get missing
2007 Aug 11
1
binomial simulation
hello, I asked about this simulation a few days ago, but still i can't get what i need. I have 2 units: icu and regular. from icu I want to take 200 observations from binomial distribution, when probability for disease is: p=0.6. from regular I want to take 300 observation with the same probability: p=0.6 . the distribution to detect disease when disease occurred- *for someone from icu* - is:
2008 Jun 26
1
Double for loop
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 [[alternative HTML version deleted]]
2006 Jun 14
3
A question about stepwise procedures: step function
Dear all, I tried to use "step" function to do model selection, but I got an error massage. What I don't understand is that data as data.frame worked well for my other programs, how come I cannot make it run this time. Could you please tell me how I can fix it? ***************************************************************************************************
2007 Aug 08
1
simulation-binomial
hello, i want to do a binomial simulation, by taking 200 var. from one group (x) and 300 from another (y). the prob. for disease=.6 in both groups. x <- rbinom(200, 1, .6) y <- rbinom(300, 1, .6) if the person is from group x - the probability to find the disease, assuming the person is sick, is .95, if he is from group Y its .80. i want to know the joint probability: p(the person has the
2015 Sep 22
4
Excel vs. R
Hola, escribo porque tengo una gran duda como gráficas tan fáciles en Excel son tan difíciles en R? No consigo hacer una gráfica en R de estas características. Osea como puedo dividir por sitios por tamaños. En una planilla enorme tengo la primera columna son las estaciones (pero solo quiero las tres ultimas) y después muchos parámetros, en las columnas 46, 53 y 60 los promedios ponderados. Y no
2012 Aug 29
2
Estimation parameters of lognormal censored data
Hi, I am trying to get the maximum likelihood estimator for lognormal distribution with censored data;when we have left, interval and right censord. I built my code in R, by writing the deriving of log likelihood function and using newton raphson method but my estimators were too high " overestimation", where the values exceed the 1000 in some runing of my code. is there any one can
2012 Aug 31
3
fitting lognormal censored data
Hi , I am trying to get some estimator based on lognormal distribution when we have left,interval, and right censored data. Since, there is now avalible pakage in R can help me in this, I had to write my own code using Newton Raphson method which requires first and second derivative of log likelihood but my problem after runing the code is the estimators were too high. with this email ,I provide
2008 Jan 15
3
bootstrap sampling
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]]
2004 Mar 02
5
cat() in long-running functions only shows up on window resize (PR#6634)
Full_Name: Peter McMahan Version: R 1.8.0 GUI OS: Windows 2000 Submission from: (NULL) (67.107.205.66) when running long functions with cat() commands inside, the requested data doesn't show up until either the function has finished or the window is resized. this is very frustrating for development purposes. thanks, peter
2007 Jul 19
3
tapply
hello, i want to compute the mean of a variable ("aps") for every class (1,2, and 3). every id have a few obs., "aps" and class are constant over id. like this: id aps class 1 11 2 1 11 2 1 11 2 1 11 2 1 11 2 2 8 3 2 8 3 2 8 3 3 12 2 3 12 2 . . i tried:
2007 Nov 01
2
computing the mean of a few variables
hello, I have a simple question: I want to compute the average of 6 variables, my data looks like this: t0 t1 t2 t3 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 HTML version deleted]]
2005 Jul 12
2
how to generate argument from a vector automatically
hi netters i have a vector NAMES containing a series of variable names: NAMES=c(x,r,z,m,st,qr,.....nn). i wanna fit a regression tree by using the code: my.tree<-tree(y~x+r+z+m+....nn,my.dataframe) but i don't want to type out "x+r+z+m+....+nn" one by one, as there are so many variables. besides, sometimes i wanna put the code in a function. so i need to have the
2007 Nov 02
3
writing a categorical var. with condition
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 to all observations? Thanks in advance,
2006 Jul 08
2
String mathematical function to R-function
hello I make a subroutine that give-me a (mathematical) function in string format. I would like transform this string into function ( R function ). thanks for any tips. cleber #e.g. fun_String = "-100*x1 + 0*x2 + 100*x3" fun <- function(x1,x2,x3){ return( ############ evaluation( fun_String ) ############ ) True String mathematical function :-( :-( > nomes [1]
2008 Jan 08
1
loading igraph package on Solaris
Hello, I'm having trouble getting the igraph package to load on Solaris. I can get igraph to compile and install from a local directory without issues using simply "R CMD INSTALL igraph", however "library(igraph)" from within R gives the following errors: Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library
2009 Nov 09
3
How to transform the Matrix into the way I want it ???
Hi, R users, I'm trying to transform a matrix A into B (see below). Anyone knows how to do it in R? Thanks. Matrix A (zone to zone travel time) zone z1 z2 z3 z1 0 2.9 4.3 z2 2.9 0 2.5 z3 4.3 2.5 0 B: from to time z1 z1 0 z1 z2 2.9 z1 z3 4.3 z2 z1 2.9 z2 z2 0 z2 z3 2.5 z3 z1 4.3 z3 z2 2.5 z3 z3 0 The real matrix I have is much larger, with more than 2000 zones. But I think it should
2009 Jul 24
2
How to test frequency independence (in a 2 by 2 table) with many missing values
Hello dear R help group. My question is statistical and not R specific, yet I hope some of you might be willing to help. *Experiment settings*: We have a list of subjects. each of them went through two tests with the answer to each can be either 0 or 1. *Goal*: We want to know if the two experiments yielded different results in the subjects answers. *Statistical test (and why it won't