search for: sigma1

Displaying 20 results from an estimated 26 matches for "sigma1".

Did you mean: sigma
2013 Apr 09
0
[R-SIG-Finance] EM algorithm with R manually implemented?
...observations is zero and therefore the log is -Inf. > > Where is my mistake? > > My code: > > # EM algorithm manually > # dat is the data > > > # initial values > pi1<-0.5 > pi2<-0.5 > mu1<--0.01 > mu2<-0.01 > sigma1<-0.01 > sigma2<-0.02 > loglik[1]<-0 > loglik[2]<-sum(pi1*(log(pi1)+ > log(dnorm(dat,mu1,sigma1))))+sum(pi2*(log(pi2)+log(dnorm(dat,mu2,sigma2)))) > > > > tau1<-0 > tau2<-0 > k<-1 > > # loop > while(abs(logli...
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...
2008 Nov 11
1
simulate data with binary outcome and correlated predictors
...re is the code I wrote where all predictors are continuous with variance =1 and correlations between predictors vary for each condition of Y. _________ library(MASS) N<-1000 nbX<-3 propSick<-0.2 corrSick<-.8 corrHealthy<-.9 sigma0<-matrix(corrHealthy,nbX,nbX) diag(sigma0)<-1 sigma1<-matrix(corrSick,nbX,nbX) diag(sigma1)<-1 dataHealthy<-mvrnorm(N*(1-propSick),c(0,0,0),sigma0) dataSick<-mvrnorm(N*propSick,c(1,1,1),sigma1) dataS<-as.data.frame(matrix(0,ncol=4,nrow=N)) dimnames(dataS)[[2]]<-c("IV1","IV2","IV3","DV") dataS...
2013 Mar 31
0
Skewness of fitted mixture not correct?
...an mixture according to: f(l)=πϕ(l;μ1,σ21)+(1−π)ϕ(l;μ2,σ22) with: datnormalmixturegaussian<-normalmixEM(dat,lambda=c(0.3828,(1-0.3828)),k=2,fast=TRUE) save the values with: pi<-datnormalmixturegaussian$lambda[1] mu1<-datnormalmixturegaussian$mu[1] mu2<-datnormalmixturegaussian$mu[2] sigma1<-datnormalmixturegaussian$sigma[1] sigma2<-datnormalmixturegaussian$sigma[2] the values are: pi = 0.383 mu1= -0.00089 mu2= 0.00038 sigma1= 0.0123 sigma2= 0.02815 Plot the single densities and the mixture: plot.new() xval<-seq(-0.06,0.06,length=1000) mixturedensity<-pi*dnorm(xval,mu1,...
2010 Mar 17
2
How to use "ifelse" to generate random value from a distribution
I need use different parameters of distribution for different case to generate random value, but I use ifelse, the generated value is fixed without change. Here is example data1 y x 1 1 2 2 2 1 3 3 2 4 4 3 5 5 3 6 6 1 7 7 2 8 8 1 9 9 1 10 10 3 11 11 3 12 12 2 ifelse(data1$x==1,rnorm(1,2,1),ifelse(data1$x==2,rnorm(1,-2,1),rnorm(1,110,1))) [1] -1.8042172 0.8478681
2010 Jul 18
2
loop troubles
...and starting precision of 0. bayes.analysis.treat<-function(mu0,p0){ n1 = 5 n2 = 10 n3 = 15 ybar1 = 12 ybar2 = 13 ybar3 = 14 sd1 = 2 sd2 = 3 sd3 = 4 #posterior 1 var1 = sd1^2 #sample variance p1 = n1/var1 #sample precision p1n = p0+p1 mu1 = ((p0)/(p1n)*mu0)+((p1)/(p1n))*ybar1 sigma1 = 1/sqrt(p1n) #posterior 2 var2 = sd2^2 #sample variance p2 = n2/var2 #sample precision p2n = p1n+p2 mu2 = ((p1n)/(p2n)*mu1)+((p2)/(p2n))*ybar2 sigma2 = 1/sqrt(p2n) #posterior 3 var3 = sd3^2 #sample variance p3 = n3/var3 #sample precision p3n = p2n+p3 mu3 = ((p2n)/(p3n)*mu2)+((p3)/(p3n))...
2007 May 08
0
Question on bivariate GEE fit
...index the treatment received Using indicator variables I have been able to fit and run the code for a bivariate model using unstructured covariance matrix. However, I want to fit a model for a structured variance covariance matrix. The error structure for the grouping unit is as follows sigma = ( sigma1 sigma12 ) ( sigma12 sigma2) sigma1, sigma2 and sigma12 are matrices with where sigma1 = sig1 * AR1(rho1) sigma2 = sig2* AR1(rho2) sigma12 = sig12 * AR1(rho12) My question is whether there is any method to fit such data using packages like gee or geepack (or may be any othe...
2008 Jul 03
0
Random effects and lme4
...ercepts are smaller then expected and in particular are much smaller at the patient within clinic level. Is this normal or am I interpreting the estimated intercepts incorrectly? An example from some simulated data: Model: Logit(p)=a+bx+c+d Where c is the level 1 random effect - clinic - N(0,sd=sigma1) Where d is the level 2 random effect - patient within clinic - N(0,sd=sigma2). Here a=-0.8,b=1,sigma1=0.3,sigma2=0.3 I'm simulating for 50 clinics each with 25 patients and 5 visits per patient (a total of 6250 observations per simulation). There are 200 runs. The results - mean - from 200...
2013 Apr 22
0
Copula fitMdvc:
...Thanks, Elisa. ################################# #### OLS ESTIMATION fit1 <- lm(Y1 ~ Xi) fit2 <- lm(Y2 ~ Xi) fit3 <- lm(Y3~ Xi) resid1 <- Y1-as.matrix(cbind( 1,Xi))%*%fit1$coef resid2 <- Y2-as.matrix(cbind( 1,Xi))%*%fit2$coef resid3 <- Y3-as.matrix(cbind( 1,Xi))%*%fit3$coef sigma1<-sum(resid1*resid1)/nrow(Xi) sigma2<-sum(resid2*resid2)/nrow(Xi) sigma3<-sum(resid3*resid3)/nrow(Xi) rho12<- cor(resid1, resid2) rho13<- cor(resid1, resid3) rho23<- cor(resid2, resid3) library("copula") library(mvtnorm) x<-as.matrix(cbind( 1,Xi)) km<- as.numeric(n...
2007 Aug 29
3
OT: distribution of a pathological random variate
...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 still couldn't get away from the singularity.) Any insight or reference to related discussion is appreciated. Horace Tso
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
2003 Nov 24
2
Questions on Random Forest
...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 image classified by K-means or EM algorithm, so the class label image is also 512x512 and has 0, 1, 2 value. I read the binary image data as follows: datafile <- file("bone.img","rb") img <- readBin(datafile,size=2,what="integer&qu...
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:
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 Jun 01
1
setting the random-effects covariance matrix in lme
...ovariance 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 sigma1 based on the factor 'dx') using the weights option in the call to lme: lme(fixed = height ~ -1 + bage + mat_ht + pat_ht + dx + time:dx + time2:dx , weights=varIdent(form=~1|dx), random = ~ time + time2 |subject, data = pilot, na.action=na.omit) but I...
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
2013 Mar 30
1
normal mixture EM not working?
...ad.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] mu2<-normalmix$mu[2] sigma1<-normalmix$sigma[1] sigma2<-normalmix$sigma[2] Now I have the problem, that the output is not consistent, i.e. every time I run the code, I get different outputs! And they are very different, no small differences, which could be due to the precision of the numerical procedures. E.g. sometim...
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 maxima, but it gives me value near by the highest mean as an output, for example 830 in the above parameters. The code for my...
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]]
2008 Oct 30
0
a nlm() question
Dear R listers, I have a very annoying problem using nlm(). I want to find the minimizer of my target function, if written in \LaTeX is f(\mu1,\mu2,\sigma1,\sigma2) = \sum_i^n( w_ig_t(z_i) ), where g_t(z) is a pdf of bivariate normal distribution and z_i is my samples. I cannot get the estimation result generated by nlm(), and I got the following errors " Error in nlm(foo, theta.start, hessian = TRUE) : non-finite value supplied b...