Questions tagged [simulation]

A vast area which includes generating results from computer models.

Filter by
Sorted by
Tagged with
65
votes
8answers
102k views

How to simulate data that satisfy specific constraints such as having specific mean and standard deviation?

This question is motivated by my question on meta-analysis. But I imagine that it would also be useful in teaching contexts where you want to create a dataset that exactly mirrors an existing ...
63
votes
5answers
4k views

Why does collecting data until finding a significant result increase Type I error rate?

I was wondering exactly why collecting data until a significant result (e.g., $p \lt .05$) is obtained (i.e., p-hacking) increases the Type I error rate? I would also highly appreciate an ...
48
votes
2answers
45k views

How to simulate artificial data for logistic regression?

I know I'm missing something in my understanding of logistic regression, and would really appreciate any help. As far as I understand it, the logistic regression assumes that the probability of a '1' ...
43
votes
6answers
7k views

When to use simulations?

So this is a very simple and basic question. However, when I was in school, I paid very little attention to the whole concept of simulations in class and that's left me a little terrified of that ...
39
votes
2answers
18k views

Simulation of logistic regression power analysis - designed experiments

This question is in response to an answer given by @Greg Snow in regards to a question I asked concerning power analysis with logistic regression and SAS ...
35
votes
6answers
11k views

Approximate $e$ using Monte Carlo Simulation

I've been looking at Monte Carlo simulation recently, and have been using it to approximate constants such as $\pi$ (circle inside a rectangle, proportionate area). However, I'm unable to think of a ...
31
votes
5answers
8k views

Generating random numbers manually

How can I manually generate a random number from a given distribution, as for instance, 10 realisations from the standard normal distribution?
29
votes
2answers
4k views

How well does bootstrapping approximate the sampling distribution of an estimator?

Having recently studied bootstrap, I came up with a conceptual question that still puzzles me: You have a population, and you want to know a population attribute, i.e. $\theta=g(P)$, where I use $P$ ...
24
votes
1answer
2k views

How to create a multivariate Brownian Bridge?

It is known, that a standard multivariate Brownian bridge $ y(\mathbf u) $ is a centered Gaussian process with covariance function $$ \mathbb E(y(\mathbf u) y(\mathbf v)) = \prod_{j=1}^d (u_j \wedge ...
23
votes
2answers
11k views

What is importance sampling?

I'm trying to learn reinforcement learning and this topic is really confusing to me. I have taken an introduction to statistics, but I just couldn't understand this topic intuitively.
23
votes
2answers
8k views

Why is it necessary to sample from the posterior distribution if we already KNOW the posterior distribution?

My understanding is that when using a Bayesian approach to estimate parameter values: The posterior distribution is the combination of the prior distribution and the likelihood distribution. We ...
21
votes
1answer
12k views

When would one use Gibbs sampling instead of Metropolis-Hastings?

There are different kinds of MCMC algorithms: Metropolis-Hastings Gibbs Importance/rejection sampling (related). Why would one use Gibbs sampling instead of Metropolis-Hastings? I suspect there ...
20
votes
1answer
2k views

How to sample from Cantor distribution?

What would be the best way to sample from Cantor distribution? It only has cdf and we can't invert it.
20
votes
1answer
391 views

How can we simulate from a geometric mixture?

If $f_1,\ldots,f_k$ are known densities from which I can simulate, i.e., for which an algorithm is available. and if the product $$\prod_{i=1}^k f_i(x)^{\alpha_i}\qquad \alpha_1,\ldots,\alpha_k>0$$ ...
20
votes
1answer
633 views

Can adaptive MCMC be trusted?

I am reading about adaptive MCMC (see e.g., Chapter 4 of the Handbook of Markov Chain Monte Carlo, ed. Brooks et al., 2011; and also Andrieu & Thoms, 2008). The main result of Roberts and ...
20
votes
2answers
2k views

Simulating time-series given power and cross spectral densities

I am having trouble generating a set of stationary colored time-series, given their covariance matrix (their power spectral densities (PSDs) and cross-power spectral densities (CSDs)). I know that, ...
19
votes
4answers
4k views

Posterior distribution and MCMC [duplicate]

I have read something like 6 articles on Markov Chain Monte carlo methods, there are a couple of basic points I can't seem to wrap my head around. How can you "draw samples from the posterior ...
19
votes
3answers
2k views

Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?

CrossValidated has several questions on when and how to apply the rare event bias correction by King and Zeng (2001). I am looking for something different: a minimal simulation-based demonstration ...
18
votes
4answers
84k views

Generate random numbers following a distribution within an interval

I need to generate random numbers following Normal distribution within the interval $(a,b)$. (I am working in R.) I know the function rnorm(n,mean,sd) will ...
18
votes
3answers
2k views

Negative-binomial GLM vs. log-transforming for count data: increased Type I error rate

Some of you might have read this nice paper: O’Hara RB, Kotze DJ (2010) Do not log-transform count data. Methods in Ecology and Evolution 1:118–122. klick. In my field of research (ecotoxicology) we'...
18
votes
1answer
24k views

How to simulate from a Gaussian copula?

Suppose that I have two univariate marginal distributions, say $F$ and $G$, which I can simulate from. Now, construct their joint distribution using a Gaussian copula, denoted $C(F,G;\Sigma)$. All the ...
18
votes
2answers
2k views

What would be an example of a really simple model with an intractable likelihood?

Approximate Bayesian computation is a really cool technique for fitting basically any stochastic model, intended for models where the likelihood is intractable (say, you can sample from the model if ...
18
votes
3answers
866 views

How to simulate data to be statistically significant?

I am in 10th grade and I am looking to simulate data for a machine learning science fair project. The final model will be used on patient data and will predict the correlation between certain times of ...
18
votes
1answer
1k views

$ARIMA(p,d,q)+X_t$, Simulation over Forecasting period

I have time series data and I used an $ARIMA(p,d,q)+X_t$ as the model to fit the data. The $X_t$ is an indicator random variable that is either 0 (when I don’t see a rare event) or 1 (when I see the ...
17
votes
2answers
13k views

Generate data samples from Poisson regression

I was wondering how you would generate data from a Poisson regression equation in R? I'm kind of confused how to approach the problem. So if I assume we have two predictors $X_1$ and $X_2$ which are ...
17
votes
1answer
533 views

simulating random samples with a given MLE

This Cross Validated question asking about simulating a sample conditional on having a fixed sum reminded me of a problem set to me by George Casella. Given a parametric model $f(x|\theta)$, and ...
17
votes
1answer
1k views

Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis

I heard that under the null hypothesis the p-value distribution should be uniform. However, simulations of binomial test in MATLAB return very different-from-uniform distributions with mean larger ...
17
votes
1answer
22k views

Generate two variables with precise pre-specified correlation [duplicate]

I want to generate two variables with (pseudo-) random numbers with an exact pearson's r. How do I do that? Python and/or R solutions would be nice! I am able to generate random data that ...
17
votes
2answers
513 views

Independence of residuals in a computer-based experiment/simulation?

I conducted a computer-based assessment of different methods of fitting a particular type of model used in the palaeo sciences. I had a large-ish training set and so I randomly (stratified random ...
16
votes
3answers
1k views

Generating random points uniformly on a disk [duplicate]

I have to randomly generate 1000 points over a unit disk such that are uniformly distributed on this disk. Now, for that, I select a radius $r$ and angular orientation $\alpha$ such that the radius $r$...
16
votes
2answers
9k views

Simulating draws from a Uniform Distribution using draws from a Normal Distribution

I recently purchased a data science interview resource in which one of the probability questions was as follows: Given draws from a normal distribution with known parameters, how can you simulate ...
16
votes
2answers
1k views

What is the connection between Markov chain and Markov chain monte carlo

I am trying to understand Markov chains using SAS. I understand that a Markov process is one where the future state depends only on the current state and not on the past state and there is a ...
16
votes
3answers
3k views

Is there a general method for simulating data from a formula or analysis available?

De novo simulation of data from an experimental design data frame. With a focus on R (though other language solution would be great). In designing an experiment or a survey, simulating data and ...
16
votes
1answer
2k views

Metropolis-Hastings integration - why isn't my strategy working?

Assume I have a function $g(x)$ that I want to integrate $$ \int_{-\infty}^\infty g(x) dx.$$ Of course assuming $g(x)$ goes to zero at the endpoints, no blowups, nice function. One way that I've been ...
15
votes
3answers
7k views

What does truncated distribution mean?

In a research article about sensitivity analysis of an ordinary differential equation model of a dynamic system, the author provided the distribution of a model parameter as Normal distribution (mean=...
15
votes
2answers
24k views

Multiple Linear Regression Simulation

I'm new to the R language. I would like to know how to simulate from a multiple linear regression model that fulfills all four assumptions of the regression. ok.. thank you. Let say i want to ...
15
votes
4answers
2k views

How to generate random auto correlated binary time series data?

How can I generate binary time series such that: Average probability of observing 1 is specified (say 5%); Conditional probability of observing 1 at time $t$ given the value at $t-1$ ( say 30% if $t-...
15
votes
1answer
3k views

Advantages of Box-Muller over inverse CDF method for simulating Normal distribution?

In order to simulate a normal distribution from a set of uniform variables, there are several techniques: The Box-Muller algorithm, in which one samples two independent uniform variates on $(0,1)$ ...
14
votes
1answer
2k views

Why use the parametric bootstrap?

I am currently trying to get my head around some things concerning parametric bootstrap. Most things are probably trivial but I still think I may have missed something. Suppose I want to get ...
13
votes
2answers
2k views

Numeric solvers for stochastic differential equations in R: are there any?

I'm looking for a general, clean and fast (i.e. using C++ routines) R package for simulating paths from a non-homogeneous nonlinear diffusion like (1) using the Euler-Maruyama scheme, the Milstein ...
12
votes
4answers
18k views

Explanation of statistical simulation

I'm not a statistician. So, please bear with my blunders if any. Would you please explain in a simple manner how simulation is done? I know that it picks some random sample from a normal distribution ...
12
votes
9answers
934 views

Book for broad and conceptual overview of statistical methods

I am very interested about the potential of statistical analysis for simulation/forecasting/function estimation, etc. However, I don't know much about it and my mathematical knowledge is still quite ...
12
votes
6answers
1k views

Does there exist any univariate distribution that we can't sample from?

We have great variety of methods for random generation from univariate distributions (inverse transform, accept-reject, Metropolis-Hastings etc.) and it seems that we can sample from literally any ...
12
votes
2answers
1k views

Why does thinning work in Bayesian inference?

In Bayesian inference, one needs to determine the posterior distribution of the parameters from the prior distribution and the likelihood of the data. As this computation might not be possible ...
12
votes
3answers
2k views

How to program a Monte Carlo simulation of Bertrand's box paradox?

The following problem has been posted on Mensa International Facebook Page: $\quad\quad\quad\quad\quad\quad\quad\quad$ The post itself received 1000+ comments but I won't go into details about the ...
12
votes
2answers
6k views

How to simulate censored data

I'm wondering how can I simulate a sample of n Weibull distribution lifetimes that include Type I right-censored observations. For instance lets have the n = 3, shape = 3, scale = 1 and the censoring ...
12
votes
2answers
3k views

How to simulate functional data?

I'm trying to test various functional data analysis approaches. Ideally, i'd like to test the panel of approaches i have on simulated functional data. I've tried to generate simulated FD using an ...
12
votes
2answers
1k views

Generate uniform noise from a p-norm ball ($||x||_p \leq r$)

I am trying to write a function which generates uniformly distributed noise which comes from a p-norm ball of $n$ dimensions: \begin{equation} ||x||_p \leq r \end{equation} I found possible ...
12
votes
2answers
4k views

Finding precision of Monte Carlo simulation estimate

Background I am designing a Monte Carlo simulation that combines the outputs of series of models, and I want to be sure that the simulation will allow me to make reasonable claims about the ...
12
votes
3answers
515 views

A potential confound in an experiment design

Overview of the question Warning: This question requires a lot of set-up. Please bear with me. A colleague of mine and I are working on an experiment design. The design must work around a large ...

1
2 3 4 5
29