Displaying 20 results from an estimated 1000 matches similar to: "rbinom with computed probability"
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,
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 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] <-
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]]
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]]
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:
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
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]]
2008 Feb 23
1
clarification about glm
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.54247 0.24658 -2.200 0.0278 *
unit1 -0.13052 0.22861 -0.571 0.5680
aps
2007 Aug 05
1
t-test
Hi all,
i'm trying to run a two-sample t-test.
i have a longitudinal data that looks like this:
idn age class
1 22 1
1 22 1
1 22 1
1 22 1
2 63 3
2 63 3
2 63 3
3 43 2
3 43 2
3 43 2
3 43 2
3 43 2
3 43 2
4 37 1
4 37
2008 Feb 16
1
plotEst
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 a part of my code:
...ests=matrix(ncol=3,nrow=6)
2007 Jul 08
2
longitudinal data
Hello all,
I want to analyze data that looks like this:
Id var1 var2 var3..
1 0 1 0
1 0 1 1
2
2
2
2
Not all id's have the same no. of observations.
At the first stage I want to count how many people in the survey, how many
have 1 in var1, etc.
How do I do that?
Thank you,
Sigalit.
[[alternative HTML version deleted]]
2007 Jul 18
1
filter out observation by condition
hello,
I have a longitudinal data:
idn mort30 newinfec
1 0 1
1 0 1
1 0 1
1 0 1
2 1 1
2 1 1
2 1 1
3 0 0
3 0 0
3 0 0
3 0 0
3
2007 Oct 24
1
Imputation method on binary data
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]]
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
2008 Feb 19
2
qplot
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]]
2008 Jan 27
1
OR estimate
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 need only the estimate for exposure=1.
I specified a matrix OR with 3 columns (for OR
2007 Oct 17
3
how to repeat the results of a generated probabilities
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) multiple by the conditional prob. (x1 and x2 respectively),
which I generaterd from the binomial
2007 Jul 16
1
table function
Hello all,
I want to use the "table" function, but for every id I have a different no.
of rows (obs.).
If I write:
table(x$class, x$infec)
I don't get the right frequencies because I should count every id once, if
id 1 has 20 observations It should count as one.
can I use unique func. here?
Hope it's clear.
thank you,
Sigalit.
[[alternative HTML version
2007 May 30
1
Static and dynamic graphics course, July 2007, Salt Lake City
We're pleased to announce a one day course covering static and dynamic
graphics using R, ggplot and GGobi. The course will be held just
before the JSM, on Saturday, 28 July 2007, in Salt Lake City. The
course will be presented by Dianne Cook and Hadley Wickham.
In the course you will learn:
* How to build presentation quality static graphics using the R
package, ggplot. We will cover plot