search for: mu1

Displaying 20 results from an estimated 80 matches for "mu1".

Did you mean: m1
2012 Oct 05
2
problem with convergence in mle2/optim function
Hello R Help, I am trying solve an MLE convergence problem: I would like to estimate four parameters, p1, p2, mu1, mu2, which relate to the probabilities, P1, P2, P3, of a multinomial (trinomial) distribution. I am using the mle2() function and feeding it a time series dataset composed of four columns: time point, number of successes in category 1, number of successes in category 2, and number of success...
2012 Sep 27
0
problems with mle2 convergence and with writing gradient function
Dear R help, I am trying solve an MLE convergence problem: I would like to estimate four parameters, p1, p2, mu1, mu2, which relate to the probabilities, P1, P2, P3, of a multinomial (trinomial) distribution. I am using the mle2() function and feeding it a time series dataset composed of four columns: time point, number of successes in category 1, number of successes in category 2, and number of success...
2012 Oct 11
2
model selection with spg and AIC (or, convert list to fitted model object)
...0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("tv", "n1", "n2", "n3"), row.names = c(NA, -20L), class = "data.frame") # Negative log likelihood functions NLL1 <- function(par, y){ p1 <- par[1] p2 <- par[2] mu1 <- par[3] mu2 <- par[4] n1 <- y$n1 n2 <- y$n2 n3 <- y$n3 t <- y$tv P1 <- (p1*((-1 + exp(sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)))*t))*((-mu2)*(mu2 - p1 + p2) + mu1*(mu2 + 2*p2)) - mu2*sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 +...
2007 Oct 23
1
How to avoid the NaN errors in dnbinom?
...aNs 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 to find a workaround for this in my code to avoid it. I appreciate the help. Thanks. Below is the reproducible code: mixnbinom=function(y,k1,mu1,k2,mu2,prob,eps= 1/100000){ new.parms=c(k1,mu1,k2,mu2,prob) err=1 iter=1 maxiter=100 hist(y,probability=T,nclass=30,col="lightgrey",main="The EM algorithm") xvals=seq(min(y),max(y),1) lines(xvals,prob*dnbinom(xvals,size=k1,mu=mu1)+ (1-prob)*dnbinom(xvals,size=k2,mu=mu2),col=&quo...
2006 May 21
2
nls & fitting
...63316 5 894.4272 130.390552 6 1264.9111 36.727069 7 1788.8544 52.848587 8 2449.4897 25.128742 9 3464.1016 7.531766 10 4472.1360 8.827367 11 6123.7244 6.600603 12 8660.2540 4.083339 I would like to fit N as a function of x according to a function depending on 9 parameters (A1,A2,A3,mu1,mu2,mu3,myvar1,myvar2,myvar3), namely N ~ (log(10)*A1/sqrt(2*pi)/log(myvar1)*exp(-((log(x/mu1))^2)/2/log(myvar1)/log(myvar1)) +log(10)*A2/sqrt(2*pi)/log(myvar2)*exp(-((log(x/mu2))^2)/2/log(myvar2)/log(myvar2)) +log(10)*A3/sqrt(2*pi)/log(myvar3)*exp(-((log(x/mu3))^2)/2/log(myvar3)/log(myvar3))) (...
2008 Feb 15
1
Questions about EM algorithm
Dear all: Assume I have 3 distributions, x1, x2, and x3. x1 ~ normal(mu1, sd1) x2 ~ normal(mu2, sd2) x3 ~ normal(mu3, sd3) y1 = x1 + x2 y2 = x1 + x3 Now that the data I can observed is only y1 and y2. It is easy to estimate (mu1+m2), (mu1+mu3), (sd1^2+sd2^2) and (sd1^2+sd3^2) by EM algorithm since y1 ~ normal(mu1+mu2, sqrt(sd1^2+sd2^2)) and y2 ~ normal(mu1+mu3, sqrt(sd...
2011 Feb 24
3
problem in for loop
Hi all. I was having some trouble with a for loop and I found the problem is the following. Does anyone have some idea why I got the following R result? Since mone is equal to 3, why mu1 only have 2 components? library(MASS) > p0 <- seq(0.1, 0.9,by=0.1) > m <- 10 > > > p0 <- p0[7] > > ## data generation > > mzero <- p0*m > mone <- m-mzero > mu1 <- rnorm(mone, 0,1) > mu <- c(rep(0,mzero), mu1) > > var <- diag(m) &gt...
2008 Apr 13
0
R project
Hi,I am currently doing a project in which we are to investigate the size and power of three different one sample tests over three different distributions using a number of different sample sizes and values for mu1. I have written a function and was trying to get my answer for each test into the right position in an array so the output is the power of each combination of test, distribution, sample size and mu1, however my code is not working and i keep getting an error message returned. My code is: proj1.sim...
2012 Feb 15
2
integrate (error: evaluation of function gave a result of wrong length)
Dear all, I am trying to use the integrate function in R but it seems that it does not work in my example and I cannot figure out why. I create a function Mu1 (which works fine) and try to integrate by the code: n <- 100 Ctrl <- as.matrix(cbind(runif(n, -30, 30))) W <- Ctrl + as.matrix(rnorm(n)) Rsp <- (W>as.matrix(sample(10, n, T)))*1 Mu1 <- function(x, Y=Rsp, Xc=Ctrl){ x <- as.matrix(x) k <- dnorm((Xc-matrix(x, n, ncol(Xc...
2005 Nov 09
2
About: Error in FUN(X[[1]], ...) : symbol print-name too long
...directory = NULL, clearWD = FALSE) The objective of the program is to compare means of two independent samples that results in Beherens-Fisher posterior and in the model.file of WinBUGS "d2.bug" there is the following codes: model { for( i in 1 : 30 ) { x[i] ~ dnorm(mu1,sig1) } for( i in 1 : 30 ) { y[i] ~ dnorm(mu2,sig2) } mu1 ~ dnorm(50,1.0E-6) sig1 ~ dgamma(0.001,0.001) mu2 ~ dnorm(50,1.0E-6) sig2 ~ dgamma(0.001,0.001) lbda <- mu1 - mu2 } I??m a new user of WinBUGS and if someone detect error in the model codes too...
2013 Feb 01
2
How does this function print, why is n1 which equals 1 printed as 2?
...2!. I have two questions, (i) how is the function printing when there is no code to print and (ii) how is n1 which equals 1 being reported as 2? I suspect there is something fundamental about R that I don't know. Thank you for the help. John library(epicalc) n.for.2means.js <- function (mu1, mu2, sd1, sd2, ratio = 1, alpha = 0.05, power = 0.8) { n1 <- (sd1^2 + sd2^2/ratio) * (qnorm(1 - alpha/2) - qnorm(1 - power))^2/(mu1 - mu2)^2 n1 <- round(n1) n2 <- ratio * n1 if (length(alpha) == 1) { alpha1 <- NULL } else { alpha1 <- alpha } if (length(powe...
2007 Mar 06
2
Estimating parameters of 2 phase Coxian using optim
Hi, My name is Laura. I'm a PhD student at Queen's University Belfast and have just started learning R. I was wondering if somebody could help me to see where I am going wrong in my code for estimating the parameters [mu1, mu2, lambda1] of a 2-phase Coxian Distribution. cox2.lik<-function(theta, y){ mu1<-theta[1] mu2<-theta[2] lambda1<-theta[3] p<-Matrix(c(1, 0), nrow=1, ncol=2) Q<-Matrix(c(-(lambda1 + mu1), 0, lambda1, -mu2), nrow=2, ncol=2) q<...
2008 Jul 28
1
Mixed model question.
...ed (tested; for reading comprehension) on 6 separate occasions. Initially (square zero) I want to treat the test time as a factor (with 6 levels). The students are of course ``random effects''. Later I want to look at reduced models, with the means at the 6 times following patterns: (mu1, mu2, mu2, mu3, mu3, mu4) or (mu1, mu1+theta, mu1+theta, mu1+2*theta, mu1+2*theta, mu1+3*theta) the idea begin that the tests are given ``in pairs'' at the beginning and end of the school year. Progress is expected over the school year, no progress over the two intervening summers....
2006 Jun 07
2
help with combination problem
hello: I have 3 data.frame objects. First df object: Of dim (149,31). Columns 2:31 are marked as T1..T14 and N1..N16. Name T1 T2 N1 T3 N2 N3 N4 T4 mu1 10 10 9 10 9 9 8 10 mu2 11 11 9 11 9 9 9 11 ... muN 12 12 9 11 9 9 8 12 Second df object: of Dim (50000,31). Columns 2:31 are maked as T1...T14 and N1..N16. Name T1 T2 N1 T3 N2 N3 N4 T4 J1 2 3 20...
2007 Mar 13
0
multiplying matrix by vector of times
...PhD student at Queen's University Belfast >>>>> and have >>>>> just started learning R. I was wondering if somebody could help me >>>>> to see >>>>> where I am going wrong in my code for estimating the parameters >>>>> [mu1, mu2, >>>>> lambda1] of a 2-phase Coxian Distribution. >>>>> >>>>> cox2.lik<-function(theta, y){ >>>>> mu1<-theta[1] >>>>> >>>>> mu2<-theta[2] >>>>> >>>>>...
2013 Apr 09
0
[R-SIG-Finance] EM algorithm with R manually implemented?
...y for sigma, that the > likelihood of some 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<...
2010 Jun 13
1
using latticeExtra plotting confidence intervals
...bel them properly and have it categorized as two. I am not sure what to have to the left side of the formula. This is the example code: library(lattice) library(latticeExtra) sample1<-rnorm(100,10,2) sample2<-rnorm(100,50,3) sample3<-rnorm(100,20,2) sample4<-rnorm(100,40,1) mu1<-mean(sample1) ci.upper1<-mu1+2*2 ci.lower1<-mu1-2*2 mu2<-mean(sample2) ci.upper2<-mu2+2*3 ci.lower2<-mu2-2*3 mu3<-mean(sample3) ci.upper3<-mu3+2*2 ci.lower3<-mu3-2*2 mu4<-mean(sample4) ci.upper4<-mu4+2*1 ci.lower4<-mu4-2*1 categories<-c("A&qu...
2009 Mar 30
0
Problem in S4 object displaying from within a Java application using JRI
I am using JRI (Java R Interface) library in order to call R from within my Java application. But since the "rmu1" and "rmu2" ,see the following code, are objects of type S4 once i run the application the value of Null will be returned for both of them. On this regard, i would appreciate it if anyone can tell me how i am going to display and/ or convert these objects to Java objects or any other...
2008 Mar 15
2
Please find the error in my code
...error as specified below.Any help that would disolve the error will be highly appreciated. Thanks in advance my code looks like this #### R programme for simulating the power of the two sample t test vs various #### non-parametric alternatives sim.size <- 200 sample.size <- 10 set.seed(231) mu1 <- 0 delta <- seq(-2,2, length=50) for (j in 1:length(delta)) { mu2 <- mu1 + delta[j] for (i in 1:sim.size) { # Generate ith sample samp1 <- rnorm(mean=mu1,sample.size) samp2 <- rnorm(mean=mu2,sample.size) # Perform ith set of tests test1 <- t.test(samp1, samp2,altern...
2010 Mar 20
2
EM algorithm in R
Please help me in writing the R code for this problem. I've been solving this for 4 days. It was hard for me to solve it. It's a simulation problem in R. The problem is My true model is a normal mixture which is given as 0.5 N(-0.8,1) + 0.5 N(0.8,1). This model has two components. I will get a random sample of size 100 from this model. I will do this 300 times. That means, I will have