similar to: Optim

Displaying 20 results from an estimated 2000 matches similar to: "Optim"

2007 Apr 20
1
Estimating a Normal Mixture Distribution
Hi everyone, I am using R 2.4.1 on a MacOS X ("Tiger") operating system. In the last few day I was trying to estimate the parameters of a mixture of two normal distributions using Maximum Likelihood. The code is from Modern Applied Statistics with S (4th edition), chapter 16 ("Optimization"), the dataset is available under MASS in R. Unfortunately, when I tried out the
2011 Dec 01
1
Estimation of AR(1) Model with Markov Switching
Dear R users, I have been trying to obtain the MLE of the following model state 0: y_t = 2 + 0.5 * y_{t-1} + e_t state 1: y_t = 0.5 + 0.9 * y_{t-1} + e_t where e_t ~ iidN(0,1) transition probability between states is 0.2 I've generated some fake data and tried to estimate the parameters using the constrOptim() function but I can't get sensible answers using it. I've tried using
2005 Nov 18
1
Truncated observations in survreg
Dear R-list I have been trying to make survreg fit a normal regression model with left truncated data, but unfortunately I am not able to figure out how to do it. The following survreg-call seems to work just fine when the observations are right censored: library(survival) n<-100000 #censored observations x<-rnorm(n) y<-rnorm(n,mean=x) d<-data.frame(x,y) d$ym<-pmin(y,0.5)
2005 Oct 06
2
data.frame error using sem package
I keep getting this error when I try to use the sem package. I and another person who has successfully used the sem package for similar analysis (fMRI effective connectivity) cannot figure out what is wrong with my code. I would appreciate any suggestions. The error message: Error in data.frame(object$coeff, se, z, 2 * (1 - pnorm(abs(z))), par.code) : arguments imply differing
2004 Aug 06
3
Bug in qnorm or pnorm?
I found the following strange behavior using qnorm() and pnorm(): > x<-8.21;x-qnorm(pnorm(x)) [1] 0.0004638484 > x<-8.22;x-qnorm(pnorm(x)) [1] 0.01046385 > x<-8.23;x-qnorm(pnorm(x)) [1] 0.02046385 > x<-8.24;x-qnorm(pnorm(x)) [1] 0.03046385 > x<-8.25;x-qnorm(pnorm(x)) [1] 0.04046385 > x<-8.26;x-qnorm(pnorm(x)) [1] 0.05046385 > x<-8.27;x-qnorm(pnorm(x))
2011 Feb 21
1
question about solving equation using bisection method
Hi all, I have the following two function f1 and f2. f1 <- function(lambda,z,p1){ lambda*(p1*exp(-3*z-9/2)+(0.2-p1)*exp(4*z-8))-(1-lambda)*0.8} f2 <- function(p1,cl, cu){ 0.8*(pnorm(cl)+(1-pnorm(cu)))/(0.8*(pnorm(cl)+(1-pnorm(cu)))+p1*(pnorm(cl+3)+(1-pnorm(cu+3)))+(0.2-p1)*(pnorm(cl-4)+(1-pnorm(cu-4))))}-0.05 First fix p1 to be 0.15. (i) choose a lambda value, say lamda=0.6, (ii)
2010 Sep 04
0
How to generate integers from uniform distribution with
On 04-Sep-10 19:27:54, Yi wrote: > Enh, I see. > It totally makes sense. > Thank you for your perfect explanation. > Enjoy the long weekend~ > Yi You're welcome! Earlier I tried an experiment with rejection sampling, which seems to work well for the case where you want mean of the sampled values to exactly be the mean of the range being sampled from. The number of tries, even
2012 Mar 24
0
Help ordinal mixed model!
Good afternoon, gentlemen! After several days studying and researching on categorical data (various forums with answers from the owner of the library - all incipient) how to interpret the output the function MCMCglmm, come to enlist the help of you, if someone has already worked with MCMCglmm function in the case of variables ordinal dependent. I've read and reread all the pdf's of the
2008 Sep 18
2
Difficulty understanding sem errors / failed confirmatory factor analysis
Hello, I'm trying to fit a pretty simple confirmatory factor analysis using the sem package. There's a CFA example in the examples, which is helpful, but the output for my (failing) model is hard to understand. I'd be interested in any other ways to do a CFA in R, if this proves troublesome. The CFA is replicating a 5 uncorrelated-factor structure (for those interested, it is a
2013 Apr 22
0
Copula fitMdvc:
Hello, I am trying to do a fit a loglikelihood function with Multivariate distribution via copulas with fitMdvc. The problem is that it doesn't recognize that my beta is a vector of km parameter and when I try to run it it say that the length of my initial values is not the same as the parameter. Can somebody guide me where my mistake is. Thanks, Elisa. #################################
2009 Jul 17
2
how to evaluate character vector within pnorm()
Hi, I'm trying to evaluate a character vector within pnorm. I have a vector with values and names x = c(2,3) names(x) = c("mean", "sd") so that i tried the following temp = paste(names(x), x, sep = "=") #gives #> temp #[1] "mean=2" "sd=3" #Problem is that both values 2 and 3 are taken as values for the mean argument in pnorm pnorm(0,
2012 Feb 02
1
Calculate the natural log of cdf between 2 intervals
Hello all, I was wondering if there is an R function to do the following: [*] log(pnorm(x)-pnorm(y)), where x>y. I don't want all the area under the natural log of the normal pdf less than x, I only want the area between y and x. I am aware of the ability to specify log.p=TRUE, which gives me the log of the probability that X<=x. This does not help me, because the following code:
2006 Dec 15
2
ks.test "greater" and "less"
Hello r-group I have a question to the ks.test. I would expect different values for less and greater between data1 and data2. Does anybody could explain my point of misunderstanding the function? data1<-c(8,12,43,70) data2<- c(70,43,12,8) ks.test(data1,"pnorm") ks.test(data1,"pnorm",alternative ="less") #expected < 0.001
2004 Jun 16
2
erf function documentation
Hi all. I may be wrong, (and often am), but in trying to determine how to calculate the erf function, the documentation for 'pnorm' states: ## if you want the so-called 'error function' erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 ## and the so-called 'complementary error function' erfc <- function(x) 2 * pnorm(x * sqrt(2), lower=FALSE) Should, instead, it read:
2010 May 13
1
results of pnorm as either NaN or Inf
I stumbled across this and I am wondering if this is unexpected behavior or if I am missing something. > pnorm(-1.0e+307, log.p=TRUE) [1] -Inf > pnorm(-1.0e+308, log.p=TRUE) [1] NaN Warning message: In pnorm(q, mean, sd, lower.tail, log.p) : NaNs produced > pnorm(-1.0e+309, log.p=TRUE) [1] -Inf I don't know C and am not that skilled with R, so it would be hard for me to look into
2011 Sep 11
3
(no subject)
Dear all, Can anyone take a look at my program below? There are two functions: f1 (lambda,z,p1) and f2(p1,cl, cu). I fixed p1=0.15 for both functions. For any fixed value of lambda (between 0.01 and 0.99), I solve f1(p1=0.15, lambda=lambda, z)=0 for the corresponding cl and cu values. Then I plug the calculated cl and cu back into the function f2. Eventually, I want to find the lambda value
2010 Jun 10
1
Rmath.dll importing in VB6 problem
Hi, I am facing a problem which i think i need to explain it to you with some background. I need to use the Project R pnorm function in Visual Basic 6.0. I have already installed R and this is how i perform and get back the result: > pnorm(2, 15) [1] 6.117164e-39 which is what i need. I have already installed R, i generated the Rmath.DLL file out so i can import it into my VB6 and use it.
2004 Aug 13
0
pnorm, qnorm
Trenkler, Dietrich said: > > I found the following strange behavior using qnorm() and pnorm(): > > > x<-8.21;x-qnorm(pnorm(x)) > [1] 0.0004638484 > > x<-8.28;x-qnorm(pnorm(x)) > [1] 0.07046385 > > x<-8.29;x-qnorm(pnorm(x)) > [1] 0.08046385 > > x<-8.30;x-qnorm(pnorm(x)) > [1] -Inf > qnorm(1-.Machine$double.eps) [1] 8.12589
2006 Jul 02
1
workaround for numeric problems
Dear R-people, I have to compute C - -(pnorm(B)*dnorm(B)*B + dnorm(B)^2)/pnorm(B)^2 This expression seems to be converging to -1 if B approaches to -Inf (although I am unable to prove it). R has no problems until B equals around -28 or less, where both numerator and denominator go to 0 and you get NaN. A simple workaround I did was C <- ifelse(B > -25, -(pnorm(B)*dnorm(B)*B
2009 Dec 08
4
lower.tail option in pnorm
Hi, I would have thought that these two constructions would produce the same result but they do not. Resp <- rbinom(10, 1, 0.5) Stim <- rep(0:1, 5) mm <- model.matrix(~ Stim) Xb <- mm %*% c(0, 1) ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb))) pnorm(as.vector(Xb), lower.tail = Resp, log.p = TRUE) > ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb))) [1] -0.6931472 -1.8410216