similar to: dmultinomial

Displaying 20 results from an estimated 300 matches similar to: "dmultinomial"

2008 Mar 18
2
rmultinomial() function
After scouring the online R resources and help pages, I still need clarification on the function rmultinomial(). I would like to create a vector, say of 100 elements, where every element in the vector can take on the value of 0, 1 or 2, and where each of those values have a specific probability. ie. the probability a given element in the vector = 0 is 0.06, 1 = 0.38, 2 = 0.56 (probabilities sum
2005 Mar 29
2
strange error with rw2010dev
With rw2010dev I get a strange protect(): protection stack overflow error with a small data frame which otherwise is usable: If anybody wants to have a look I can provide an RData file with the problematic data frame. Doesn't seem to be necessary, the following simulated example generates the error: > testmat <- matrix(1:80, 20,4) > dim(testmat) [1] 20 4 > str(testmat) int
2009 Nov 04
1
compute maximum likelihood estimator for a multinomial function
Hi there I am trying to learn how to compute mle in R for a multinomial negative log likelihood function. I am using for this the book by B. Bolker "Ecological models and data in R", chapter 6: "Likelihood an all that". But he has no example for multinomial functions. What I did is the following: I first defined a function for the negative log likelihood:
2011 May 19
1
dbetagen function in mc2d package
Hi all, I found this useful package for generalized beta, yet the function that calculates its density leaves me puzzled, especially when I plotted it: plot(function(y) dbetagen(y,4,1.2,min=0,max=40),xlim=c(0,40)) The area between the density curve and the x axis does not seem to measure 1!!! -- View this message in context:
2012 Mar 17
3
rtriang using ifelse statement
Hi All, I want to draw samples (n=4) from one of 2 triangular distributions for each value in a matrix. I am using an ifelse statement to try to define which distribution to draw from. >From the output, I can see that the ifelse statement is choosing the correct distribution, however, my n=4 simulations aren't occurring. Is there a way to adjust the ifelse statement to fix this, or must
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
2011 May 25
1
matrix Manipulation...
Hello everyone, I have a 2 x 5 matrix: say 0.2 0.3 1 -1 3 0.2. 0.4 5 0.5 -1 I want to replace all the values greater than or equal to 1 with 1 and those less than or equal to 0 with 0. So I should end up with a mtrix looking like: 0.2 0.3 1 0 1 0.2. 0.4 1 0.5 0 Any ideas how to do this? -- Thanks, Jim. [[alternative HTML version deleted]]
2007 Mar 30
1
faster computation of cumulative multinomial distribution
Dear list members, I have a series of /unequal/ probabilities [p1,p2,...,pk], describing mutually exclusive events, and a "remainder" class with a probability p0=1-p1-p2-....-pk, and need to calculate, for a given number of trials t>=k, the combined probability that each of the classes 1...k contains at least 1 "event" (the remainder class may be empty). To me this reaks
2010 Feb 12
1
using mle2 for multinomial model optimization
Hi there I'm trying to find the mle fo a multinomial model ->*L(N,h,S?x)*. There is only *N* I want to estimate, which is used in the number of successes for the last cell probability. These successes are given by: p^(N-x1-x2-...xi) All the other parameters (i.e. h and S) I know from somewhere else. Here is what I've tried to do so far for a imaginary data set:
2011 Dec 16
1
kmeans and plot labels
Hi, Thanks Sarah. Unfortunately I did not get a step further. My question, perhaps a bit clearer, is how to display the case control status (or any other arbitrary point label) after clustering in a plot: With a bit of pseudo code, where dataset is a data.frame, parameters are those column names where we find numerical values (no NAs) and nclasses is the desired number of classes. fit <-
2010 Oct 22
3
Conditional looping over a set of variables in R
Here's the problem I'm trying to solve in R: I have a data frame that consists of about 1500 cases (rows) of data from kids who took a test of listening comprehension. The columns are their scores (1 = correct, 0 = incorrect, . = missing) on 140 test items. The items are numbered sequentially and are ordered by increasing difficulty as you go from left to right across the columns. I want
2007 Feb 16
0
re : array searches
Hi, I am not sure to get the issue, but assuming your data are arranged as in your example with dates in column x$V1 and signals as x$V2 , I think that you could use "rle" in the following way : test<-rle(x$V2) testmat<-matrix(NA,length(test$values),2) testmat[,1]<-x[c(1,cumsum(test$length)[1:(length(test$values)-1)]+1),1] testmat[,2]<-test$values And you'll get your
2017 Jan 27
0
Matrix package breaks as.matrix method
Hi, The Matrix package and the as.matrix method do not seem to be compatible inside of a package. Here's an example. I've created a simple package "mat" that defines an eponymous class and as.matrix method on that class. All is well, unless that package has the Matrix package in its Depends or Imports (and imports, e.g. the "Diagonal" function). Then my as.matrix
2017 Jan 30
0
Matrix package breaks as.matrix method
Georgi, Brilliant, thank you very much for the helpful reply and explanation! I added 'importFrom("Matrix","as.matrix")' to my NAMESPACE and all worked fine! As my 'as.matrix' method is used entirely internally to the 'testmat' function (and not "used outside the package"), I don't think I actually need to export it. In my case, testmat is
2010 Dec 13
7
descriptive statistics
Hi. In a data set I have a variable that takes values from 1 to 14. For each subgroup of values of this variable, I would like to obtain some descriptive statistics of other variables present in the data set. I've been trying with a "for" loop but I couldn't get nothing. Could you please suggest me some lines? -- View this message in context:
2011 Jul 24
0
2 x 3 table
I am trying to find the likelihood ratio for a 2 x3 table (actually SNP data). I do not want the log likelihood. Is this the correct R code for the following table? Row totals are fixed at 100 each (case control situation). aa Aa AA Total 10 20 70 100 20 40 50 100 30 60 120 So the row totals are fixed. Is this the correct code3? Likelihood.ratio =
2017 Jan 29
0
R-devel Digest, Vol 167, Issue 25
Hi, Short answer: import 'as.matrix' and export your method(s) for it. From WRE: "All S4 classes to be used outside the package need to be listed in an exportClasses directive. Alternatively, they can be specified using exportClassPattern.(46) in the same style as for exportPattern. To export methods for generics from other packages an exportMethods directive can be used."
2008 Apr 22
2
nth step transition matrices
Hello, I have a question in regards to markov chains and transition probabilities. I am trying to figure out a way to calculate the "kth-step transition matrix" of a given matrix. Say for example I have a single step 2x2 matrix: 1 2 P= 1 .95 .05 2 .01. 99 If I were to convert this matrix to a 2-step transition probability matrix I would get:
2011 Sep 30
1
Covariance-Variance Matrix and For Loops
Hello, I am very new to R (as my Subject probably indicates). I want to do something that should, I think, be very simple. I have five vectors in a list and I want to construct a covariance matrix out of them. Given a 5X5 matrix cvm1, and the list of vectors, cvm1_list, I thought the following would work (sorry cannot find code tags): for(i in 1:5){ for(j in 1:5){ cvm1[i,j] <-
2012 Oct 05
2
problem with convergence in mle2/optim function
Hello R Help, I am trying solve an MLE convergence problem: I would like to estimate four parameters, p1, p2, mu1, mu2, which relate to the probabilities, P1, P2, P3, of a multinomial (trinomial) distribution. I am using the mle2() function and feeding it a time series dataset composed of four columns: time point, number of successes in category 1, number of successes in category 2, and