similar to: How to print and save simulated data?

Displaying 20 results from an estimated 5000 matches similar to: "How to print and save simulated data?"

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"
2014 Feb 23
1
Random Count Generation with rnbinom
The documentation states : An alternative parametrization (often used in ecology) is by the mean ?mu?, and ?size?, the dispersion parameter. However, this fails : > rnbinom(10, mu = 100, size = 0) [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Warning message: In rnbinom(10, mu = 100, size = 0) : NAs produced For dispersion set to 0, it should work like drawing from a Poisson distribution.
2002 Jun 14
2
minor quirk in rnbinom
I don't want to spoil a nice joke, and recognise it's not a bug as it does have the intended effect, but the error message that is returned if rnbinom is given four parameters is slightly obscure: > rnbinom(0.5,0.5,0.5,0.5) Error in rnbinom(0.5, 0.5, 0.5, 0.5) : couldn't find function "error" > Cheers, Mike.
2006 Jul 14
2
Negative Binomial: Simulation
Hi R-Users! I fitted a negative binomial distribution to my count data using the function glm.nb() and obtained the calculated parameters theta (dispersion) and mu. I would like to simulate values from this negative binomial distribution. Looking at the function rnbinom() I was looking at the relationship between the two possible parametrizations of the negative binomial and found that for this
2005 Aug 16
1
predict nbinomial glm
Dear R-helpers, let us assume, that I have the following dataset: a <- rnbinom(200, 1, 0.5) b <- (1:200) c <- (30:229) d <- rep(c("q", "r", "s", "t"), rep(50,4)) data_frame <- data.frame(a,b,c,d) In a first step I run a glm.nb (full code is given at the end of this mail) and want to predict my response variable a. In a second step, I would
2009 Jul 14
1
Simulation functions for underdispered Poisson and binomial distributions
Dear R users I would like to simulate underdispersed Poisson and binomial distributions somehow. I know you can do this for overdispersed counterparts - using rnbinom() for Poisson and rbetabinom() for binomial. Could anyone share functions to do this? Or please share some tips for modifying existing functions to achieve this. Thank you very much for your help and time Shinichi
2001 Dec 17
1
behavior of r* and d* functions at boundaries (PR#1218)
(Sent this to r-help back in October, got no comments, forgot to re-submit it as a bug report.) There are a few inconsistencies, at least, in some of the functions that generate random deviates from particular distributions (I think they're bugs because they're inconvenient, but maybe someone can make an argument for the current behavior). If people think these are really bugs I can
2002 Aug 02
1
Means of Monte Carlo simulated lists
Hello, I am doing simulations, and I generate a list at each iteration (with three component matrices in the example below), saving the results in a list. For example, after two iterations, I have something like > str(sim.theta) List of 2 $ :List of 3 ..$ : num [1:6, 1:4] -3.67 -1.07 -2.99 -18.38 -3.26 ... ..$ : num [1:6, 1:6] -7.56 -3.14 -4.99 1.03 2.79 ... ..$ : num [1:6, 1:4]
2005 Jan 05
3
strange behaviour of negative binomial
Dear list, I ran into a strange behaviour of the pnbinom function - or maybe I just made a stupid mistake. First thing is that pnbinom seems to be very slow. The other - more interesting one - is that I get two different curves when I plot the estimated density and the density given by pnbinom. Shouldn't it be the same? This is only the case, I think, if I use the parameter size = 1. I
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
2009 Nov 20
6
How to add a top level title to multiple plots
How can I add an overall plot title to these four plots? I would like to have something that says, "Distribution Comparisons": par(mfrow = c(2, 2)) # Plot 1 plot(rnorm(10),type="l",col="red") title(main = list(paste("Normal"), ????????????????????????? col="black", cex = 1.0)) # Plot 2 plot(rpois(10,
2012 Jul 04
2
About nlminb function
Hello I want to use the nlminb function but I have the objective function like characters. I can summarize the problem using the first example in the nlminb documentation. x <- rnbinom(100, mu = 10, size = 10) hdev <- function(par) -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE)) nlminb(c(9, 12), objective=hdev) With the last instructions we obtain appropriate results. If I have
2011 Oct 26
2
gam predictions with negbin model
Hi, I wonder if predict.gam is supposed to work with family=negbin() definition? It seems to me that the values returned by type="response" are far off the observed values. Here is an example output from the negbin examples: > set.seed(3) > n<-400 > dat<-gamSim(1,n=n) > g<-exp(dat$f/5) > dat$y<-rnbinom(g,size=3,mu=g) >
2008 Jul 03
2
what can we do when R gives no response
Hi, dear R experts , I am new. I met this problem when I am trying to learn how to use the nlminb() function. I tried the example which the document provides ( as the following code ) and R gives no response . I don't know whether it is running or not and it takes a very long time but still output nothing so I just close the session window. my question is is there any method
2009 Nov 04
1
simulated data
R users. Thanks in advance.   I would  be glad if someone could tell me how to get a simulated data from AR(1), MA(1)   My email is : assaedi76@yahoo.com    Thanks [[alternative HTML version deleted]]
2011 Aug 28
1
How to add a legend to a goodness-of-fit plot (vcd:goodfit)?
Hello, Sample code: library("vcd") dummy <- rnbinom(200, size=1.5, prob=0.8) gf <- goodfit(dummy, type="nbinomial", method="MinChisq") plot(gf) I would like to: 1. add a lgened stating the bars show the actual counts and the red dots - the fit. 2. show the goodness-of-fit values calculated somewhere on an empty white space ob the plot. But... the legend
2004 Jun 15
1
AIC in glm.nb and glm(...family=negative.binomial(.))
Can anyone explain to me why the AIC values are so different when using glm.nb and glm with a negative.binomial family, from the MASS library? I'm using R 1.8.1 with Mac 0S 10.3.4. >library(MASS) > dfr <- data.frame(c=rnbinom(100,size=2,mu=rep(c(10,20,100,1000),rep(25,4))), + f=factor(rep(seq(1,4),rep(25,4)))) > AIC(nb1 <- glm.nb(c~f, data=dfr)) [1] 1047 >
2008 May 16
1
gam negative.binomial
Dear list members, while I appreciate the possibility to deal with overdispersion for count data either by specifying the family argument to be quasipoisson() or negative.binomial(), it estimates just one overdispersion parameter for the entire data set. In my applications I often would like the estimate for overdispersion to depend on the covariates in the same manner as the mean. For example,
2008 Oct 19
1
number of required trials
Dear Experts, Probably trivial, but I am struggling to get what I want: I need to know how the number of required trials to get a certain number of successes. By example: How many trials do I need to have 98% probability of 50 successes, when the a priory probability is 0.1 per trial. The Negative binomial function may do the job (not sure): NegBinomial {stats} The Negative Binomial
2005 Mar 31
2
how to simulate a time series
Dear useRs, I want to simulate a time series (stationary; the distribution of values is skewed to the right; quite a few ARMA absolute standardized residuals above 2 - about 8% of them). Is this the right way to do it? #-------------------------------- load("rdtb") #the time series > summary(rdtb) Min. 1st Qu. Median Mean 3rd Qu. Max. -1.11800 -0.65010 -0.09091