similar to: How to use "ifelse" to generate random value from a distribution

Displaying 20 results from an estimated 120 matches similar to: "How to use "ifelse" to generate random value from a distribution"

2006 Sep 28
1
Nonlinear fitting - reparametrization help
Hi, I am trying to fit a function of the form: y = A0 + A1 * exp( -0.5* ( (X - Mu1) / Sigma1 )^2 ) - A2 * exp ( -0.5* ( (X-Mu2)/Sigma2 )^2 ) i.e. a mean term (A0) + a difference between two gaussians. The constraints are A1,A2 >0, Sigma1,Sigma2>0, and usually Sigma2>Sigma1. The plot looks like a "Mexican Hat". I had trouble (poor fits) fitting this function to toy data
2008 Nov 11
1
simulate data with binary outcome and correlated predictors
Hi, I would like to simulate data with a binary outcome and a set of predictors that are correlated. I want to be able to fix the number of event (Y=1) vs. non-event (Y=0). Thus, I fix this and then simulate the predictors. I have 2 questions: 1. When the predictors are continuous, I can use mvrnorm(). However, if I have continuous, ordinal and binary predictors, I'm not sure how to simulate
2010 Jul 18
2
loop troubles
Hi all, I appreciate the help this list has given me before. I have a question which has been perplexing me. I have been working on doing a Bayesian calculating inserting studies sequentially after using a non-informative prior to get a meta-analysis type result. I created a function using three iterations of this, my code is below. I insert prior mean and precision (I add precision manually
2005 Mar 23
4
sampling from a mixture distribution
Dear R users, I would like to sample from a mixture distribution p1*f(x1)+p2*f(x2). I usually sample variates from both distributions and weight them with their respective probabilities, but someone told me that was wrong. What is the correct way? Vumani
2000 Nov 14
3
2 plots 1 figure
How do you obtain two plots on the same figure? for example plot(rnorm(100) plot(rnorm(100),type="l") -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To:
2007 Aug 29
3
OT: distribution of a pathological random variate
Folks, I wonder if anything could be said about the distribution of a random variate x, where x = N(0,1)/N(0,1) Obviously x is pathological because it could be 0/0. If we exclude this point, so the set is {x/(0/0)}, does x have a well defined distribution? or does it exist a distribution that approximates x. (The case could be generalized of course to N(mu1, sigma1)/N(mu2, sigma2) and one
2003 Nov 24
2
Questions on Random Forest
Hi, everyone, I am a newbie on R. Now I want to do image pixel classification by random forest. But I has not a clear understanding on random forest. Here is some question: As for an image, for example its size is 512x512 and has only one variable -- gray level. The histogram of the image looks like mixture Gaussian Model, say Gauss distribution (u1,sigma1), (u2,sigma2),(u3,sigma3). And a
2004 Sep 16
3
Estimating parameters for a bimodal distribution
For several years, I have been using Splus to analyze an ongoing series of datasets that have a bimodal distribution. I have used the following functions, in particular the ms() function, to estimate the parameters: two means, two standard deviations, and one proportion. Here is the code I've been using in S: btmp.bi <- function(vec, p, m1, m2, sd1, sd2) {
2006 Sep 23
1
variance-covariance structure of random effects in lme
Dear R users, I have a question about the patterned variance-covariance structure for the random effects in linear mixed effect model. I am reading section 4.2.2 of "Mixed-Effects Models in S and S-Plus" by Jose Pinheiro and Douglas Bates. There is an example of defining a compound symmetry variance-covariance structure for the random effects in a split-plot experiment on varieties of
2006 Jun 01
1
setting the random-effects covariance matrix in lme
Dear R-users, I have longitudinal data and would like to fit a model where both the variance-covariance matrix of the random effects and the residual variance are conditional on a (binary) grouping variable. I guess the model would have the following form (in hierarchical notation) Yi|bi,k ~ N(XiB+Zibi, sigmak*Ident) bi|k ~ N(0, Dk) K~Bernoulli(p) I can obtain different sigmas (sigma0 and
2013 Mar 30
1
normal mixture EM not working?
Hi, I am currently working on fitting a mixture density to financial data. I have the following data: http://s000.tinyupload.com/?file_id=00083355432555420222 I want to fit a mixture density of two normal distributions. I have the formula: f(l)=πϕ(l;μ1,σ21)+(1−π)ϕ(l;μ2,σ22) my R code is: normalmix<-normalmixEM(dat,k=2,fast=TRUE) pi<-normalmix$lambda[1] mu1<-normalmix$mu[1]
2007 Oct 15
1
how to use normalmixEM to get correct result?
Dear R-Users, I have a large number of data(54000) and the field of data is 50 to 2.0e9. I want to use normalmixEM (package:mixtools) to fit them in finite mixture narmal distributions,but get some mistakes.I don't know which steps make the error. I have used the following functions before >x<-read.table("data") >log.x<-log10(x$V1) >log.x<-sort(log.x)
2017 Aug 24
1
Problem in optimization of Gaussian Mixture model
Hello, I am facing a problem with optimization in R from 2-3 weeks. I have some Gaussian mixtures parameters and I want to find the maximum in that *Parameters are in the form * mean1 mean2 mean3 sigma1 sigma2 sigma3 c1 c2 c3 506.8644 672.8448 829.902 61.02859 9.149168 74.84682 0.1241933 0.6329082 0.2428986 I have used optima and optimx to find the
2013 Apr 17
3
t-statistic for independent samples
Hi, Typical things you read when new to stats are cautions about using a t-statistic when comparing independent samples. You are steered toward a pooled test or welch's approximation of the degrees of freedom in order to make the distribution a t-distribution. However, most texts give no information why you have to do this. So I thought I try a little experiment which is outlined here.
2006 Apr 23
2
distribution of the product of two correlated normal
Hi, Does anyone know what the distribution for the product of two correlated normal? Say I have X~N(a, \sigma1^2) and Y~N(b, \sigma2^2), and the \rou(X,Y) is not equal to 0, I want to know the pdf or cdf of XY. Thanks a lot in advance. yu [[alternative HTML version deleted]]
2013 Apr 09
0
[R-SIG-Finance] EM algorithm with R manually implemented?
Moved to R-help because there's no obvious financial content. Michael On Sat, Apr 6, 2013 at 10:56 AM, Stat Tistician <statisticiangermany at gmail.com> wrote: > Hi, > I want to implement the EM algorithm manually, with my own loops and so. > Afterwards, I want to compare it to the normalmixEM output of mixtools > package. > > Since the notation is very advanced, I
2013 Mar 31
0
Skewness of fitted mixture not correct?
I fitted a gaussian mixture to my financial data. The data can be found here: http://uploadeasy.net/upload/32xzq.rar I look at the density with plot(density(dat),col="red",lwd=2) this has a skew of library(e1071) skewness(dat) -0.1284311 Now, I fit a gaussian mixture according to: f(l)=πϕ(l;μ1,σ21)+(1−π)ϕ(l;μ2,σ22) with:
2004 Nov 16
5
Difference between two correlation matrices
Hi Now a more theoretical question. I have two correlation matrices - one of a set of variables under a particular condition, the other of the same set of variables under a different condition. Is there a statistical test I can use to see if these correlation matrices are "different"? Thanks Mick
2007 May 08
0
Question on bivariate GEE fit
Hi, I have a bivariate longitudinal dataset. As an example say, i have the data frame with column names var1 var2 Unit time trt (trt represents the treatment) Now suppose I want to fit a joint model of the form for the *i* th unit var1jk = alpha1 + beta1*timejk + gamma1* trtjk + delta1* timejk:trtjk + error1jk var2 = alpha2 + beta2*timejk + gamma2* trtjk + delta2* timejk:trtjk +
2008 Jul 03
0
Random effects and lme4
I'm running some multi-level binomial models with lme4 and have a question regarding the estimated random effects. Suppose I have nested data e.g. clinic and then patient within clinic. The standard deviations of the random effects at each level are roughly equal in a model for real life data. Attention then turns to examining the individual random effects at each level. I'm extracting