similar to: Fitting difference models in R (nls, nlme)

Displaying 20 results from an estimated 3000 matches similar to: "Fitting difference models in R (nls, nlme)"

2012 Mar 08
1
sas retain statement in R or fitting differene equations in NLS
I wish to fit a dynamical model in R and I am running in a problem that requires some of your wisdom to solve. For SAS users I am searching for the equivalent of the */retain/ *statement. For people that want to read complicated explanations to help me: I have a system of two equations written as difference equations here. To boil it down. I have a dataframe with three variables y, X1, X2
2012 Jul 17
1
Threshold Quantile Regression code CRASHES in R
I am working on a two stage threshold quantile regression model in R, and my aim is to estimate the threshold of the reduced-form equation (call it rhohat), and the threshold of the structural equation (call it qhat), in two stages. On the first stage, i estimate rhohat by quantile regression and obtain the fitted values. I use these fitted values to estimate qhat on the second stage. The code is
2001 Apr 27
3
nls question
I have a question about passing arguments to the function f that nlm minimizes. I have no problems if I do this: x<-seq(0,1,.1) y<-1.1*x + (1-1.1) + rnorm(length(x),0,.1) fn<-function(p) { yhat<-p*x+(1-p) sum((y-yhat)^2) } out<-nlm(fn,p=1.5,hessian=TRUE) But I would like to define fn<-function(x,y,p) { yhat<-p*x+(1-p) sum((y-yhat)^2) } so
2010 May 11
1
nls() and nls2() behavior?
first, apologies for so many posts yesterday and today. I am wrestling with nls() and nls2(). I have tried to whittle it down to a simple example that still has my problem, yet can be cut-and-pasted into R. here it is: library(nls2) options(digits=12); y= c(0.4334,0.3200,0.5848,0.6214,0.3890,0.5233,0.4753,0.2104,0.3240,0.2827,0.3847,0.5571,0.5432,0.1326,0.3481) x=
2008 Apr 28
0
(no subject)
Hi R users Here is an example of my data (only a small part) Year Season A_Time R_Time O_Time All_Time AandR_Time A_number R_number O_number AandR_number all_number 1999 Winter 9.590741 35.312963 42.759524 23.228431 18.164815 18 9 7 27 34 2000 Winter 9.899537 47.945000 59.744444 20.301333 18.170290 36 10 3
2008 Apr 28
0
Two graphs on one using barchart
> Hi R users > Here is an example of my data (only a small part) > > Year Season A_Time R_Time O_Time All_Time AandR_Time > A_number R_number O_number AandR_number all_number > 1999 Winter 9.590741 35.312963 42.759524 23.228431 18.164815 > 18 9 7 27 > 34 > 2000 Winter 9.899537 47.945000 59.744444 20.301333
2004 Jan 22
4
Fitting compartmental model with nls and lsoda?
Dear Colleagues, Our group is also working on implementing the use of R for pharmacokinetic compartmental analysis. Perhaps I have missed something, but > fit <- nls(noisy ~ lsoda(xstart, time, one.compartment.model, c(K1=0.5, k2=0.5)), + data=C1.lsoda, + start=list(K1=0.3, k2=0.7), + trace=T + ) Error in eval(as.name(varName), data) : Object
2002 Mar 08
1
Matrix multiplication problem
Dear List, I am having trouble with some R code I have written to perform Redundancy Analysis (RDA) on a matrix of species abundance data (Y) and a matrix of environmental data (X). RDA is a constrained form of PCA and can be thought of as a PCA of the fitted values of a regression of each variable in Y on all variables in X. For info, the first use of RDA is in: Rao, C.R, 1964. The use and
2010 Feb 09
1
question about nlme...
I am looking for R code to be able to fit a linear-linear piecewise model with person-specific changepoint. I have searched the web, but have not been able to locate any code. Below is my attempt at some code: chgpt = function(a1,a2,a3,gam,wave){ yht=numeric(10) y1=(wave <= gam)*(a1+(a2*wave)) y2=(wave > gam)*((a1+(a2-a3)*gam)+a3*wave) yhat=y1+y2 return(yht) } nl.dat <- nlme(y ~
2010 Sep 05
0
cov.unscaled in NLS - how to define cov.scaled to make comparable to SAS proc NLIN output - and theoretically WHY are they different
I am running a 3-parameter nonlinear fit using the default Gauss-Newton method of nls. initialValues.L = list(b=4,d=0.04,t=180); fit.nls.L = nls( myModel.nlm , fData.L, start = initialValues.L, control = nls.control(warnOnly = TRUE), trace=T ); summary.nls.L = summary(fit.nls.L); I run the same analysis in SAS proc NLIN. proc nlin data=apples outest=a; parms b=4 d=.04 t=180; model Y =
2001 Dec 14
1
nls fit to exponential decay with unknown time origin
I'm trying to use nls() to fit an exponential decay with an unknown offset in the time (independent variable). (Perhaps this is inherently very difficult?). > decay.pl <- nls (amp ~ expn(b0,b1,tau,t0,t), data = decay, + start = c(b0=1, b1=7.5, tau=3.5, t0=0.1), trace=T) Error in nlsModel(formula, mf, start) : singular gradient matrix at initial parameter estimates
2004 Jul 28
1
a question about using nlme
Hi, I am using Splus to run a multiphase mixed-effects model. The quations of the models are as below: gf[ij]=b0[i]+b1[i]*age[ij]+b2[i]*max(0,(age[ij]-tau[i]))^2+e[ij] b0[i]=b00+e[i0] b1[i]=b10+e[i1] b2[i]=b20+e[i2] tau[i]=tau+e[i3] i: 1,2,...,100 subjects j: 1,2,...,6 occasions The main scripts of Splus is: simu1<-groupedData(gf~age|id) simu.nlme<-nlme(gf~(b0 + b1 * age + b2 *
2004 Jul 30
0
a question about nlme
Hi, Sorry to bother those who are not interested in the question. I am using R to run a multiphase mixed-effects model. I simulated a data set by using the following model. And now I want to use R to estimate the parameters and compare the results with the true values. The equations of the models are as below: gf[ij]=b0[i]+b1[i]*age[ij]+b2[i]*max(0,(age[ij]-tau[i]))+e[ij] b0[i]=b00+e[i0]
2011 May 08
1
Hosmer-Lemeshow 'goodness of fit'
I'm trying to do a Hosmer-Lemeshow 'goodness of fit' test on my logistic regression model. I found some code here: http://sas-and-r.blogspot.com/2010/09/example-87-hosmer-and-lemeshow-goodness.html The R code is above is a little complicated for me but I'm having trouble with my answer: Hosmer-Lemeshow: p=0.6163585 le Cessie and Houwelingen test (Design library): p=0.2843620
2008 May 25
1
How to write a package based on nlme
Dear R Helpers, I try to write a small package that based on nlme however my code does not work. R always appears this message: Error in eval(expr, envir, enclos) : object "y" not found where y is the response variable. Please help me out! This is my code: require(nlme) AMPmixed<-function(y, x, S1=c("asymptotic","logistic"), random,data,
2008 Oct 14
0
nlm return wrong function value - garch fitting
I am using nlm to maximize a likelihood function. When I call the likelihood function (garchLLH) via nlm however, nlm returns the wrong value of the function. When I test the likelihood function manually I get the correct answer. I'm probably doing something really stupid, maybe someone can point it out for me. ###############this is the function i am trying to minimize ############
2005 Mar 04
0
Need suggestions for finding dose response using nls
I am relatively new to R and am looking for advice, ideas or both... I have a data set that consists of pathogen population sizes on individual plant units in an experimental field plot. However, in order to estimate the pathogen population sizes I had to destroy the plant unit and could not determine if that plant unit became diseased or to what extent it would have become diseased. I
2012 Dec 02
0
suggestions for nls error: false convergence
Hi, I'm trying to fit some data using a logistic function defined as y ~ a * (1+m*exp(-x/tau)) / (1+n*exp(-x/tau) My data is below: x <- 1:100 y <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,2,2,2,2,2,3,4,4,4,5, 5,5,5,6,6,6,6,6,8,8,9,9,10,13,14,16,19,21, 24,28,33,40,42,44,50,54,69,70,93,96,110,127,127,141,157,169,
2006 Apr 01
1
Nested error structure in nonlinear model
I am trying to fit a nonlinear regression model to data. There are several predictor variables and 8 parameters. I will write the model as Y ~ Yhat(theta1,...,theta8) OK, I can do this using nls() - but "only just" as there are not as many observations as might be desired. Now the problem is that we have a factor "Site" and I want to include a corresponding error
2013 Apr 23
1
Hosmer Lemeshow test
Hi to everybody. I use the following routine (i found it in the internet) to compute the Hosmer-Lemeshow test in the framework of logistic regression. hosmerlemeshow = function(obj, g=10) { # first, check to see if we fed in the right kind of object stopifnot(family(obj)$family=="binomial" && family(obj)$link=="logit") y = obj$model[[1]] # the double bracket