Questions tagged [simulation]

A vast area which includes generating results from computer models.

Filter by
Sorted by
Tagged with
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 ...
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 ...
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 ...
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' ...
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 ...
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 ...
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 ...
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)$ ...
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 ...
8
votes
2answers
1k views

Simulate from a dynamic mixture of distributions

I need to sample from the following mixture of two distributions: $h_{\vec{\beta}}(r)=c(\vec{\beta})[(1-w_{m,\tau}(r))f_{\vec{\beta_{0}}}(r)+w_{m,\tau}(r)g_{\epsilon,\sigma}(r)]$ where $c(\vec{\beta}...
8
votes
2answers
2k views

What are Monte Carlo simulations?

Is Monte Carlo Simulation the same as just conducting experiment several times and then averaging results? Why is it then called like that?
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=...
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 ...
9
votes
2answers
8k views

Simulate linear regression with heteroscedasticity

I am trying to simulate a dataset that matches empirical data that I have, but am unsure how to estimate the errors in the original data. The empirical data includes heteroscedasticity, but I am not ...
4
votes
1answer
3k views

Simulation of KS-test with estimated parameters

We know that the original KS-test has a limitation, requiring the Null hypothesis testing underlying distribution to be fully specified, rather than estimated. But in practice, we usually need to test ...
9
votes
2answers
4k views

Simulate from Kernel Density Estimate (empirical PDF)

I have a vector X of N=900 observations that are best modeled by a global bandwidth Kernel density estimator (parametric models, ...
8
votes
1answer
4k views

Monte Carlo estimation of probabilities

I would appreciate some advice on how to use Monte Carlo for estimating probabilities. Generally speaking the problem I have involves running an experiment and counting the frequency of output (which ...
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 ...
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?
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.
9
votes
3answers
737 views

How can I simulate census microdata for small areas using a 1% microdata sample at a large scale and aggregate statistics at the small area scale?

I would like to perform an individual-level multivariate analysis at small levels of geographic aggregation (Australian census collection districts). Clearly, the census isn't available at these ...
10
votes
2answers
12k views

Simulate constrained normal on lower or upper bound in R

I'd like to generate random data from a constrained normal distribution using R. For example I might want to simulate a variable from a normal distribution with ...
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 ...
8
votes
1answer
239 views

What is the equivalent for cdfs of MCMC for pdfs?

In conjunction with a Cross Validated question on simulating from a specific copula, that is, a multivariate cdf $C(u_1,\ldots,u_k)$ defined on $[0,1]^k$, I started wondering about the larger picture, ...
6
votes
2answers
7k views

Number of samples needed in Monte Carlo simulation: how good is this approximation?

In Risk Theory Beard, Pentikanen and Pesonen (1969) mention a method of assessing number of samples needed for Monte Carlo simulation as $$ \sigma = \sqrt{\frac{p(1-p)}{s}} \leq \frac{1}{2} \sqrt{ \...
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 ...
18
votes
4answers
85k 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 ...
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 ...
11
votes
2answers
460 views

In what settings would confidence intervals not get better as sample size increases?

In a blog post, I have found the claim that "I believe WG Cochrane the first point out (roughly 1970′s) that with confidence intervals in an observational setting, small sample sizes result in ...
8
votes
4answers
2k views

Simulation involving conditioning on sum of random variables

I was reading this question, and thought about simulating the required quantity. The problem is as follows: If $A$ and $B$ are iid standard normal, what is $E(A^2|A+B)$? So I want to simulate $E(A^2|A+...
6
votes
2answers
1k views

Generating a sample from Epanechnikov's kernel

So I am really struggling with this problem and could use some help. Consider the Epanechnikov kernel given by $$f_e(x)=\frac{3}{4}\left( 1-x^2 \right)$$ According to Devroye and Gyorfi's "...
10
votes
1answer
1k views

Simulate from a truncated mixture normal distribution

I want to simulate a sample from a mixture normal distribution such that $$p\times\mathcal{N}(\mu_1,\sigma_1^2) + (1-p)\times\mathcal{N}(\mu_2,\sigma_2^2) $$ is restricted to the interval $[0,1]$ ...
5
votes
2answers
75 views

Generating uniform points inside an $m$-dimensional ball [duplicate]

The present question follows on from some other questions on this site asking how to generate uniform points inside a disc (see e.g., here, here and here). The natural extension of that problem is to ...
4
votes
1answer
950 views

Obtain marginal CDF from joint CDF by simulation

How can I evaluate the marginal cumulative distribution function of a set of random variables for which I do not have the CDF in closed form. I can, however, simulate from a joint distribution ...
4
votes
2answers
218 views

Random process not so random after all (deterministic)

I would like to show (demonstrate by simulation) a random process that turns out after $i$ interactions to be deterministic, i.e. ends at predefined value (roughly) known at time $t=1$. Conditions ...
1
vote
1answer
694 views

Forecast bayesian GARCH model

I am using this package in R to do Bayesian estimation of GARCH models. I want to forecast $y_t$ (i.e. the mean equation), but it seems that the package has no built-in function for this. The model ...
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 ...
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 ...
8
votes
2answers
8k views

Generating samples from Gibbs sampling

I am quite new to sampling. I am doing Gibbs sampling for a Bayesian network. I am aware about the algorithm for the Gibbs sampling but there's one thing I am not able to understand. For example let'...
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 ...
5
votes
2answers
15k views

How to sample using MCMC from a posterior distribution in general?

Assume one has the posterior distribution of a parameter, $p(\theta|y)$ and what I mean by having it is that for each point of $\theta$, one can use Monte Carlo method+MCMC to calculate the $p(\theta|...
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 ...
8
votes
1answer
3k views

Simulating the posterior of a Gaussian process

For the first time (excuse imprecission / mistakes) I took a look at Gaussian processes, and more specifically, watched this video by Nando de Freitas. The notes are available online here. At some ...
6
votes
2answers
2k views

Sample random variables conditional on their sum

Let $(X_1, \dots, X_n)$ be an iid sample of random variables with a known continuous distribution. I would like to simulate such a sample, conditional on the value of its sum, that is: $$ X_1, \dots, ...
11
votes
3answers
1k views

Using computer simulations to better understand statistical concepts at the graduate level

Hi I'm taking a graduate course in Statistics and we've been covering Test statistics, and other concepts. However, I am often able to apply the formulas and develop a sort-of intuition on how stuff ...
10
votes
4answers
1k views

Is this correct ? (generating a Truncated-norm-multivariate-Gaussian)

If $X\in\mathbb{R}^n,~X\sim \mathcal{N}(\underline{0},\sigma^2\mathbf{I})$ i.e., $$ f_X(x) = \frac{1}{{(2\pi\sigma^2)}^{n/2}} \exp\left(-\frac{||x||^2}{2\sigma^2}\right) $$ I want an analogous ...
7
votes
1answer
484 views

expectation of log of expectation by Monte Carlo

When considering the approximation by Monte Carlo of an expectation of the form$$\mathfrak{I}=\mathbb{E}^X[\log\{\mathbb{E}^{Y|X}[h(X,Y)|X]\}]$$using a resolution of the form$$\hat{\mathfrak{I}}=\frac{...
7
votes
1answer
8k views

How to simulate the different types of missing data

How do you create a missingness mechanism (MAR, MCAR, NMAR)? Can you generate it directly or do you do it by a model?
6
votes
3answers
6k views

Identify probability distributions

Given a sample data set of floating point numbers, how do we determine its probability distribution and prove it? Also generate random numbers of the same distributions thereafter.
4
votes
1answer
2k views

Explanation regarding Gibbs Sampling

I am new to MCMC and reading a intro paper regarding Gibbs sampling. However, there are two parts in the paper I cannot understand and get stuck. The first part is equation 2.3 in page 168. It says ...

1
2 3 4 5