Displaying 20 results from an estimated 2109 matches for "probs".
Did you mean:
probe
2012 Aug 24
6
updating elements of a vector sequentially - is there a faster way?
...s to update the elements of a vector (vec1), where a
particular element i is dependent on the previous one. I need to do this on
vectors that are 1 million or longer and need to repeat that process
several hundred times. The for loop works but is slow. If there is a faster
way, please let me know.
probs <- c(.1, .3, .2, .4, .7, .9, .3, .4, .5, .6)
p10 <- 0.6
p00 <- 0.4
vec1 <- rep(0, 10)
for (i in 2:10) {
vec1[i] <- ifelse(vec1[i-1] == 0,
ifelse(probs[i]<p10, 0, 1),
ifelse(probs[i]<p00, 0, 1))
}
Thanks
GG
[[alternative HTML version...
2007 Sep 23
2
return(x=x,y=y,prob=prob) hasn't been used in R now?
Dear friends,
Now, when i use the argument return(x=x,y=y,prob=prob) , R displays the
waring message:
Warning message:
The return value for multiple variables wasn't used in: return(x = x, y =
gy, prob = prob)
I used the methods of "help.search("return")" and "?return" to get some
help, but didn't find info on it.
Anybody knows how it should be used
2009 Jul 16
2
Count the number of occurences in ranges
I got a vector of probabilities like,
probs<-c(0.001,0.5,0.02,1,.....)
Is there any nice and easy builtin function to get the number of
occurences within some specified probabality range.
Like with 2% it would be
occur[1] = sum(probs[probs>0&probs<0.02])
occur[2] = sum(probs[probs>0.02&probs<0.04])
...
occur[50] =sum...
2007 Oct 23
1
How to avoid the NaN errors in dnbinom?
Hi, The code below is giving me this error message:
Error in while (err > eps) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In dnbinom(x, size, prob, log) : NaNs produced
2: In dnbinom(x, size, prob, log) : NaNs produced
I know from the help files that for dnbinom "Invalid size or prob will
result in return value NaN, with a warning", but I am not able
2016 Mar 10
3
rmultinom.c error probability not sum to 1
Hi all,
I should have given a better explanation of my problem. Here it is.
I extracted from my code the bit that gives the error. Place this in a file called test.c
#include <math.h>
#include <R.h>
#include <Rmath.h>
#include <float.h>
#include <R_ext/Print.h>
int main(){
double prob[3] = {0.0, 0.0, 0.0};
double prob_tot = 0.;
prob[0] = 0.3*dnorm(2, 0,
2006 Aug 04
2
Sampling from a Matrix
Hello all,
Consider the following problem:
There is a matrix of probabilities:
> set.seed(1)
> probs <- array(abs(rnorm(25, sd = 0.33)), dim = c(5,5), dimnames = list(1:5, letters[1:5]))
> probs
a b c d e
1 0.21 0.27 0.50 0.0148 0.303
2 0.06 0.16 0.13 0.0053 0.258
3 0.28 0.24 0.21 0.3115 0.025
4 0.53 0.19 0.73 0.2710 0.656
5 0.11 0.10 0.37 0.1960 0.205
I wa...
2003 May 01
2
What' wrong?
I try to do single proportion test on my category data. Here is my R
script:
library("ctest")
catSignifTest <- function( catFile ) {
###############################################################
## Get the data sets from text file
catData <- read.table( catFile )
ncols <- length(catData)
nrows <- length(catData[,1])
ncol1 <- ncols - 1
probeNbr
2005 Jun 19
1
practical help ... solving a system...
Hello,
I want to estimate the parameters of a binomial distributed rv using MLE.
Other distributions will follow.
The equation system to solve is not very complex, but I've never done such
work in R and don't have any idea how to start...
The system is:
(1) n*P = X
(2) [sum {from j=0 to J-1} Y{j} /(n-j)] = -n * ln (1-X / n)
where * only X is given (empirical mean)
2007 Jan 05
1
Efficient multinom probs
Dear R-helpers,
I need to compute probabilties of multinomial observations, eg by doing the
following:
y=sample(1:3,15,1)
prob=matrix(runif(45),15)
prob=prob/rowSums(prob)
diag(prob[,y])
However, my question is whether this is the most efficient way to do this.
In the call prob[,y] a whole matrix is computed which seems a bit of a
waste.
Is there maybe a vectorized version of dmultinom which
2006 Jul 04
1
problem getting R 2.3.1 svn r38481 to pass make check-all
Hi,
I noticed this problem on my home desktop running FC4 and again on my
laptop running FC5. Both have previously compiled and passed make
check-all on 2.3.1 svn revisions from 10 days ago or so. On both these
machines, make check-all is consistently failing (4 out of 4 attempts on
the FC 4 desktop and 3 out of 3 on the FC 5 laptop) in the
p-r-random-tests tests. This is with both default
2009 Jul 30
1
ask help about boxplot , different list variation into the tick of x-axis?
Hi ,everyone.
I want to draw a boxplot figure, main script shown as below. when I
run the command "boxplot(bjavee~yearname)",it is wrong with the error
information " model.frame.default(formula = bjavee ~ yearname) :
variation 'bjavee' list is wrong".
I want to add the yearname as the x-axis tick. And yearname is a array
with the length 12,while bjavee is a 5*12
2010 Jun 23
1
Generation of binomial numbers using a loop
Dea'R' helpers
I have following data -
prob = c(0.1, 0.2, 0.3, 0.4, 0.5)
frequency = c(100, 75, 45, 30, 25)
no_trials = c(10, 8, 6, 4, 2)
freq1 = rbinom(frequency[1], no_trials[1], prob[1])
freq2 = rbinom(frequency[2], no_trials[2], prob[2])
freq3 = rbinom(frequency[3], no_trials[3], prob[3])
freq4 = rbinom(frequency[4], no_trials[4], prob[4])
freq5 = rbinom(frequency[5],
2006 Jul 11
2
0* log(0) should be zero but NaN
Dear R-users
>prob <- c(0.5,0.4,0.3,0.1,0.0)
>cal <- prob * log(prob,base=2)
>cal
[1] -0.5000000 -0.5287712 -0.5210897 -0.3321928 NaN
Is there any way to change NaN to zero ?
I did come up with this by applying Ripley's relpy to my previous question
cal <-prob*log(pmax(prob,0.00000001),base=2)
Any suggestion ?
Thank you
Taka
2017 Jan 31
1
rnbinom Returns Error that says optional argument is missing
I am trying to reset the default arguments in the rnbinom function with the
following example code:
params <- c("size" = 1, "mu" = 1)
formals(rnbinom)[names(params)] <- params
rnbinom(n = 10)
It returns the following:
Error in rnbinom(n = 10) : argument "prob" is missing, with no default
If I set the defaults with this code:
params <- c("size"
2010 Nov 09
1
Question related to combination and the corresponding probability
Dear r users,
I have 4 variables x1,x2,x3,x4 and each one has two levels, for example Y
and N.
For x1: prob(Y)=0.6, prob(N)=0.4;
For x2: prob(Y)=0.5, prob(N)=0.5;
For x3: prob(Y)=0.8, prob(N)=0.2;
For x4: prob(Y)=0.9, prob(N)=0.1;
Therefore, the sample space for (x1, x2, x3, x4)={YYYY, YYYN, YYNY,......}
(16 possible combination) and the corresponding probabilities are
{(0.6)(0.5)(0.8)(0.9),
2000 May 12
1
Geometric Distribution at prob=c(0,1)
Dear all,
I''m working with the geometric distribution for the time being, and I''m
confused. This may have more to do with statistics than R itself, but
since I''m getting results from R I find counterintuitive (well, yeah, my
statistical intuition has not been properly sharpened), I feel like
asking.
The point first:
If I do
> rgeom(1,prob=1)
I get:
[1] NaN
Warning
2006 Dec 30
2
Error: cannot take a sample larger than the population
Hi,
In Splus7 this statement
xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
worked fine, but in R the interpreter reports that the length of the
vector to chose c(0,1,2) is shorter than the size of many times I want
to be selected from the vector c(0,1,2).
Any good reason?
See below the error.
> xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
Error in
2013 Jul 08
1
Segmentar archivos en R (Antonio José Sáez Castillo)
Habría que buscar la vuelta, yo no lo se, pero posiblemente lo siguiente da una pista.
Nota: al mismo código le sume una línea al final
datos<-c(2,3,4,5,6,7,8)
quantile(datos)
quantile(datos,probs = c(0.25, 0.75, 0.85, 0.90, 0.95))
as.matrix(quantile(datos,probs = c(0.25, 0.75, 0.85, 0.90, 0.95)))
as.data.frame(quantile(datos,probs = c(0.25, 0.75, 0.85, 0.90, 0.95)))
# ¿ y si solo solicita uno por vez ?
as.matrix(quantile(datos,probs = c(0.25)))
as.matrix(quantile(datos,probs = c(0.75)))
cbi...
1998 Feb 26
3
R-beta: quantile
I do:
x<-rnorm(1000)
quantile(x,c(.025,.975))
2% 98%
-1.844753 1.931762
Since I want to find a 95% confidence interval, I take the .025 and .975
quantiles. HOWEVER R says I have the 2% (not 2.5%) and 98% (not 97.5%)
points. Is it just rounding the printed 2% and 98%, or is it REALLY
finding .02 and .98 points instead of .025 and .975?
Thanks for any help.
Bill Simpson
1998 Feb 26
3
R-beta: quantile
I do:
x<-rnorm(1000)
quantile(x,c(.025,.975))
2% 98%
-1.844753 1.931762
Since I want to find a 95% confidence interval, I take the .025 and .975
quantiles. HOWEVER R says I have the 2% (not 2.5%) and 98% (not 97.5%)
points. Is it just rounding the printed 2% and 98%, or is it REALLY
finding .02 and .98 points instead of .025 and .975?
Thanks for any help.
Bill Simpson