Re: [R] problem with nls starting values

2012-09-27 Thread Benedikt Gehr
these data? thanks for the help Am 27.09.2012 21:27, schrieb Berend Hasselman: y_val<-115-118*exp(-0.12*(seq(1,100)+rnorm(100,0,0.8))) >x_val<-seq(1:100) >plot(y_val~x_val) >summary(mod1<-nls(y_val~a-b*exp(-c*x_val),start=list(a=115,b=118,c=0.12))) > -- Benedikt G

Re: [R] problem with nls starting values

2012-09-27 Thread Benedikt Gehr
line does about as well as anything except for the 3 high leverage points, which the minimization is probably having trouble with. -- Bert On Thu, Sep 27, 2012 at 10:43 AM, Benedikt Gehr wrote: quantiles<-c(seq(.05,.95,0.05)) slopes<-c( 0.00e+00, 1.622074e-04 , 3.103918e-03 , 2.

[R] problem with nls starting values

2012-09-27 Thread Benedikt Gehr
l the values it doesn't work any longer. Then I simulated perfect asymptotic decay data and tried to to fit an nls() with the correct parameter values, but it won't work either. What am I doing wrong? Any help would be most appreciated Best benedikt -- Benedikt Gehr Ph.D. Student I

Re: [R] order a data frame by date with orderl

2012-05-16 Thread Benedikt Gehr
> Sent from my iPad > > On May 16, 2012, at 3:27, Benedikt Gehr <[hidden email] > > wrote: > > > Hi > > > > I have a rather large data frame (>7000 rows with 28 columns) which > I want > > to sort by date. Below I have a example of the data frame

[R] order a data frame by date with order

2012-05-16 Thread Benedikt Gehr
Hi I have a rather large data frame (>7000 rows with 28 columns) which I want to sort by date. Below I have a example of the data frame. The Date column is called DT, is a factor and looks like this: class(res.merge$DT) [1] "factor" head(res.merge$DT) [1] 17.3.2012 13:54:02 17.3.2012 14:00:07 17.

[R] true time series lags behind fitted values in arima model

2010-10-29 Thread Benedikt Gehr
Hi I am fitting an arima model to some time series X. When I was comparing the fitted values of the model to the true time series I realized that the true time series lags one time step behind the fitted values of the arima model. And this is the case for any model. When I did a simple linear

[R] problem with arima() function

2010-10-25 Thread benedikt . gehr
Hi I posted this problem yesterday but didn't get a reply so I try again today. I hope someone can help me with this. thank you very much for the help cheers Benedikt I would like to use arima () to find the best arima model for a time series. The default in arima appar

[R] non-stationary ar part in css

2010-10-25 Thread Benedikt Gehr
Hi I would like to use arima () to find the best arima model for y time series. The default in arima apparently is to use conditional sum of squares to find the starting values and then ML (as described on the help page). Now using the default may lead to error messages saying: "non-stationary

[R] the arima()-function and AICc

2010-09-28 Thread Benedikt Gehr
Hi I'm trying to fit arima models with the arima() function and I have two questions. ## ##1. ## ## I have n observations for my time series. Now, no matter what arima(p,d,q)- model I fit, I always get n residuals. How is that possible? For example: If I try this out myself on an AR(

[R] Antwort: Re: an alternative to R for nonlinear stat models

2010-06-16 Thread benedikt . gehr
Hi I think my first answer doesn't seem to have gone through due to the attachement. So I copy pasted my last answer including the code below. Sorry about that: Hi Paul Oh ok sorry, I send you below a copy of the R code I was using. It's very possible that my programmi

[R] Antwort: Re: an alternative to R for nonlinear stat models

2010-06-16 Thread benedikt . gehr
Hi Paul Oh ok sorry, I send you below a copy of the R code I was using. It's very possible that my programming is slow as well. I'm very happy to learn. Sorry the code is a bit long, but its structured like this and cotains three main functions and the optimization: 1. Input

[R] an alternative to R for nonlinear stat models

2010-06-15 Thread benedikt . gehr
Hi I implemented the age-structure model in Gove et al (2002) in R, which is a nonlinear statistical model. However running the model in R was very slow. So Dave Fournier suggested to use the AD Model Builder Software package and helped me implement the model there. ADMB was incr

[R] read in data file into R

2010-05-31 Thread Benedikt Gehr
Hi I'm trying to read a data file with output from another program (admb) into R for further analysis. However I'm not very successfull. The file extension for the data file is file.rep but it also doesn't help when I change it to file.txt I have two problems/questions: 1. The file is a sin

[R] running admb from R using system()

2010-05-31 Thread Benedikt Gehr
Hi I'm trying to run an admb model from R by using the system () command. The admb model runs fine when running it from the admb command line or when using emacs. However when I try it with system() then R crashes every time. And I tried using the R command line and RGui and in both it crashes

[R] likelihood profiles for multiple parameters

2010-03-24 Thread Benedikt Gehr, Institut für Evolutionsbiologie und Umweltwissenschaften
Hi I'm using mle2 for optimization of a multinomial likelihood. The model fit is not very good and I would like to look at the likelihood profiles. However I'm optimizing many parameters (~40) so using the function profile() takes forever and is not practical. How can I calculate approximate

[R] optimize a joint lieklihood with mle2

2010-03-24 Thread Benedikt Gehr, Institut für Evolutionsbiologie und Umweltwissenschaften
Hi I'm trying to maximize a joint likelihood of 2 likelihoods (Likelihood 1 and Likelihood 2) in mle2, where the parameters I estimate in Likelihood 2 go into the likelihood 1. In Likelihood 1 I estimate the vector logN with length 37, and for the Likelihood 2 I measure a vector s of length 8.

Re: [R] using near-zero probabilities in optimization

2010-03-10 Thread Benedikt Gehr, Institut für Evolutionsbiologie und Umweltwissenschaften
numbers vs expected from the model",xlim=c(0,200),ylim=c(0,200)) abline(0,1) ## ##Plots ## ##Plot true population trend <-> compare with estimated trend plot(rowSums(N.true)~seq(1:y),ylim=c(0,5000),col="red",pch=17,main="True vs estimated population trend") lines(rowSums(N.true)~seq(1:y),col="red") points(rowSums(Nya)~seq(1:y),ylim=c(0,5000),col=&quo

[R] using near-zero probabilities in optimization

2010-03-09 Thread Benedikt Gehr
Hi there I am using mle2 for a multinomial likelihood optimization problem. My function works fine when I'm using simulated data, however my cell probabilities of the true data for the multinomial likelihood are sometimes very small (in some cases <0.00...) and the estimated point estimates f

[R] function odiag(): assigning values to off-diagonal

2010-03-01 Thread Benedikt Gehr
hi I'm trying to use the function odiag(x) for matrix calculations. I would like to assign new values to an off-diagonal in a matrix. When I use the diag (x) function I could write something like p<-matrix(seq(1:12),ncol=4) p.new<-matrix(rep(0,12),ncol=4) diag(p.new)<-diag(p) p.new But this w

[R] using mle2 for multinomial model optimization

2010-02-12 Thread Benedikt Gehr
Hi there I'm trying to find the mle fo a multinomial model ->*L(N,h,S¦x)*. There is only *N* I want to estimate, which is used in the number of successes for the last cell probability. These successes are given by: p^(N-x1-x2-...xi) All the other parameters (i.e. h and S) I know from somewhere

[R] compute maximum likelihood estimator for a multinomial function

2009-11-04 Thread Benedikt Gehr
Hi there I am trying to learn how to compute mle in R for a multinomial negative log likelihood function. I am using for this the book by B. Bolker "Ecological models and data in R", chapter 6: "Likelihood an all that". But he has no example for multinomial functions. What I did is the follo