search for: bernoulli

Displaying 20 results from an estimated 99 matches for "bernoulli".

2011 Feb 01
1
Lmer binomial distribution x HLM Bernoulli distribution
Dear R-users, I'm running a lmer model using the lme4 package. My dependent variable is dichotomous and I'm using the "binomial" family. The results are slightly different from the HLM results based on a Bernoulli distribution. I read that a Bernoulli distribution is an extension of a binomial distribution. Is that right? If so, how can I adapt my R model to a Bernoulli distribution so that my R results are the same as my HLM results? Thank you so much, Luana Marotta [[alternative HTML version deleted]]
2008 Jan 02
1
Random Bernoulli sequences with given point-biserial correlation?
Dear R-listers, Can someone suggest a method for generating a finite Bernoulli sequence that is likely to have a given point-biserial correlation with an existing Bernoulli sequence? _____________________________ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 G...
2007 Jul 03
3
generating correlated Bernoulli random variables
Hi all, I was wondering how to generate samples for two RVs X1 and X2. X1 ~ Bernoulli (p1) X2 ~ Bernoulli (p2) Also, X1 and X2 are correlated with correlation \rho. Regards, Vineet [[alternative HTML version deleted]]
2008 Aug 27
0
How to calculate cumulative values for a simple Bernoulli's distribution?
...olnames(data)<-c("D","X") *# 1. question: is it possible to put the following creation of x in a nicer form?* x<-c(sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0)) p1<-seq(0, 1, 0.1) # Posterior Bernoulli distribution Bn1<-(p1^x*(1-p1)^(n-x))*choose(n,x) bn1<-as.data.frame(Bn1) # Normalized posterior Bernoulli distribution f1<-1/sum(bn1) nbn1<-bn1*f1 nbn1 # Control check that sum is equal to 1 sum(nbn1) *# 2. question: how can I calculate cumulative values for nbn1 distribution? Was l...
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 0.2, but won't change for each subject ?? ## or should I use Ber.var <- sample(c(0,1), n, prob=p, replace=TRUE) Or any suggestions on how I can check...
2006 Oct 06
1
Sum of Bernoullis with varying probabilities
Hi Folks, Given a series of n independent Bernoulli trials with outcomes Yi (i=1...n) and Prob[Yi = 1] = Pi, I want P = Prob[sum(Yi) = r] (r = 0,1,...,n) I can certainly find a way to do it: Let p be the vector c(P1,P2,...,Pn). The cases r=0 and r=n are trivial (and also are exceptions for the following routine). For a given value of r in (1:...
2010 Apr 26
3
R.GBM package
HI, Dear Greg, I AM A NEW to GBM package. Can boosting decision tree be implemented in 'gbm' package? Or 'gbm' can only be used for regression? IF can, DO I need to combine the rpart and gbm command? Thanks so much! -- Sincerely, Changbin -- [[alternative HTML version deleted]]
2006 Feb 03
5
pbinom with size argument 0 (PR#8560)
Full_Name: Uffe H?gsbro Thygesen Version: 2.2.0 OS: linux Submission from: (NULL) (130.226.135.250) Hello all. pbinom(q=0,size=0,prob=0.5) returns the value NaN. I had expected the result 1. In fact any value for q seems to give an NaN. Note that dbinom(x=0,size=0,prob=0.5) returns the value 1. Cheers, Uffe
2007 Feb 07
3
generate Binomial (not Binary) data
Dear All, I am looking for an R function or any other reference to generate a series of correlated Binomial (not a Bernoulli) data. The "bindata" library can do this for the binary not the binomial case. Thank you, Bernard --------------------------------- [[alternative HTML version deleted]]
2008 Sep 22
1
gbm error
Good afternoon Has anyone tried using Dr. Elith's BRT script? I cannot seem to run gbm.step from the installed gbm package. Is it something external to gbm? When I run the script itself <- gbm.step(data=model.data, gbm.x = colx:coly, gbm.y = colz, family = "bernoulli", tree.complexity = 5, learning.rate = 0.01, bag.fraction = 0.5) ... I keep encountering the same error: ERROR: unexpected ')' in "bag.fraction = 0.5)" I've tried all sorts of variations (such as) sep22BRT.lr01 <- gbm{data=sep22BRT, gbm.x =...
2005 Jul 13
3
nlme, MASS and geoRglm for spatial autocorrelation?
Hi. I'm trying to perform what should be a reasonably basic analysis of some spatial presence/absence data but am somewhat overwhelmed by the options available and could do with a helpful pointer. My researches so far indicate that if my data were normal, I would simply use gls() (in nlme) and one of the various corSpatial functions (eg. corSpher() to be analagous to similar analysis in SAS)
2001 Oct 02
4
plot of Bernoulli data
I have some Bernoulli data something like this: x<-sort(runif(100,1,20)) p<-pnorm(x,10,3) y<-as.numeric(runif(x)<p) plot(x,y) lines(x,p) This plot is not very satisfactory because the ogive does not visually fit the (0,1) points very well, and also because the points tend to fall on top of one another....
2011 Mar 21
1
Randomly generating data
...that looks like this: [1,] "t" "f" "t" [2,] "f" "t" [3,] "t" "f" [4,] "t" "t" [5,] "f" "f" Second, I determine the second character of the third column with an additional Bernoulli trial with a probability, for example, rbinom(1, 1, 0.3). If the random generation in R is 0, we keep "f", the second character in the first column because the first column has been chosen in the first step, while if the random generation in R is 1, we choose "t" instead, the se...
2009 Jun 17
1
gbm for cost-sensitive binary classification?
...I used is to calculate Area under ROC, cut at 1% FP rate. The higher the better. I think I miss sth here. Anyone has similar experience and can advise me how to implement cost-sensitive classification with gbm. model.gbm <- gbm.fit(tr[,1:DIM],tr.y,offset = NULL,misc = NULL,distribution = "bernoulli",w = tr.w,var.monotone = NULL,n.trees = NTREE,interaction.depth = TREEDEPTH,n.minobsinnode = 10,shrinkage = 0.05,bag.fraction = BAGRATIO,train.fraction = 1.0,keep.data = TRUE,verbose = TRUE,var.names = NULL,response.name = NULL); or model.gbm <- gbm(tr.y ~ .,distribution = "bernoul...
2010 Jul 09
1
Appropriate tests for logistic regression with a continuous predictor variable and Bernoulli response variable
I have a data with binary response variable, repcnd (pregnant or not) and one predictor continuous variable, svl (body size) as shown below. I did Hosmer-Lemeshow test as a goodness of fit (as suggested by a kind “R-helper” previously). To test whether the predictor (svl, or body size) has significant effect on predicting whether or not a female snake is pregnant, I used the differences between
2006 May 27
2
boosting - second posting
...<- gbm(as.factor(train$simNuance) ~ ., # formula + data=train, # dataset + # +1: monotone increase, + # 0: no monotone restrictions + distribution="gaussian", # bernoulli, adaboost, gaussian, + # poisson, and coxph available + n.trees=3000, # number of trees + shrinkage=0.005, # shrinkage or learning rate, + # 0.001 to 0.1 usually work +...
2005 Apr 25
1
Failed to install gbm_1.4-2 (PR#7814)
...====================================== downloaded 246Kb * Installing *source* package 'gbm' ... ** libs g++ -I/package/R/2.0.1-32bit/lib/R/include -I/usr/local/include -fPIC -O2 -c adaboost.cpp -oadaboost.o g++ -I/package/R/2.0.1-32bit/lib/R/include -I/usr/local/include -fPIC -O2 -c bernoulli.cpp -o bernoulli.o g++ -I/package/R/2.0.1-32bit/lib/R/include -I/usr/local/include -fPIC -O2 -c coxph.cpp -o coxph.o g++ -I/package/R/2.0.1-32bit/lib/R/include -I/usr/local/include -fPIC -O2 -c dataset.cpp -o dataset.o g++ -I/package/R/2.0.1-32bit/lib/R/include -I/usr/local/include -fPIC...
2011 Jan 11
1
glm specification where response is a 2col matrix
Hi, when I apply a glm() model in two ways, first with the response in a two column matrix specification with successes and failures y <- matrix(c( 5, 1, 3, 3, 2, 2, 0, 4), ncol=2, byrow=TRUE) X <- data.frame(x1 = factor(c(1,1,0,0)), x2 = factor(c(0,1,0,1))) glm(y ~ x1 + x2, data = X, family="binomial") second with a model matrix that
2012 Jun 18
6
Trying to speed up an if/else statement in simulations
...er changing to vectorisation and using something like: ifelse(data$flag1==1,rbinom(1,1,0.95),rbinom(1,1,0.5)) but the rbinom statements here generate one value and repeat this draw for every element of flag2 that matches the 'if' statement on flag1. Is there a way to assign flag2 to a new bernoulli draw for each subject in the data frame with flag1=1? I hope my question is clear, and thank you in advance for your help. Thanks, Natalie PhD student, Reading University P.S. I am using R 2.12.1 on Windows 7. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-speed-up-a...
2004 Jul 10
1
Exact Maximum Likelihood Package
...d be very interested in having some help/advice on this direction. 2. This is just an example of my ignoRance. I have tried to use R to solve the following MLE problem. But I cannot figure out how to do it. Your help would also be appreciated. Consider the mixture of a pair of four-times repeated Bernoulli trials. Let s and t be the Bernoulli parameters and p the mixing parameter. There are 5 possible outcomes f0 = p*(1-s)^4 + (1-p)*(1-t)^4; f1 = 4*p*s*(1-s)^3 + 4*(1-p)*t*(1-t)^3; f2 = 6*p*s^2*(1-s)^2 + 6*(1-p)*t^2*(1-t)^2; f3 = 4*p*s^3*(1-s) + 4*(1-p)*t^3*(1-t); f4 = p*s^4 + (1-p)*t^4; The polyno...