On Mon, 6 Nov 2023 14:55:39 -0500
J C Nash wrote:
> However, I'm wondering if this approach is worth writing up, at least
> as a vignette or blog post. It does need a shorter example and some
> explanation of the "why" and some testing perhaps.
Do you mean using this problem as a basis to illust
G'day Troels,
On Tue, 7 Nov 2023 07:14:02 +0100
Troels Ring wrote:
> Be as it may, I wonder if not your method might work if only we KNOW
> that pK1 is either positive OR negative, in which case we have pK1 =
> -exp(theta1)?
If pK1 can be either negative or positive (or 0 :-) ), and it is just
Thanks a lot, Berwin. Unfortunately, pK1 may well be negative and as I
understand the literature it may be poorly defined as such, and also
seems to be at a boundary, since when lower is set to say rep(-4,3) pK1
is returned as -4 while pK2 and pK3 are undisturbed. Perhaps the point
is that pK1
G'day Troels,
On Mon, 6 Nov 2023 20:43:10 +0100
Troels Ring wrote:
> Thanks a lot! This was amazing. I'm not sure I see how the conditiion
> pK1 < pK2 < pK3 is enforced?
One way of enforcing such constraints (well, in finite computer
arithemtic only "<=" can be enforced) is to rewrite the para
I won't send to list, but just to the two of you, as I don't have
anything to add at this time. However, I'm wondering if this approach
is worth writing up, at least as a vignette or blog post. It does need
a shorter example and some explanation of the "why" and some testing
perhaps.
If there's i
Thanks a lot! This was amazing. I'm not sure I see how the conditiion
pK1 < pK2 < pK3 is enforced? - it comes from the derivation via
generalized Henderson-Hasselbalch but perhaps it is not really
necessary. Anyway, the use of Vectorize did the trick!
Best wishes
Troels
Den 06-11-2023 kl. 19:
Your script is missing something (in particular kw).
I presume you are trying to estimate the pK values. You may have more success
with package nlsr than nls(). nlsr::nlxb() tries to get the Jacobian of the
model specified by a formula and do so by applying symbolic or automatic
differentiation.
В Mon, 6 Nov 2023 17:53:49 +0100
Troels Ring пишет:
> Hence I wonder if I could somehow have non linear regression to find
> the 3 pK values. Below is HEPESFUNC which delivers charge in the
> fluid for known pKs, HEPTOT and SID. Is it possible to have
> root-finding in the formula with nls?
Sure
Dear friends - I have a function for the charge in a fluid (water)
buffered with HEPES and otherwise only containing Na and Cl so that [Na]
- [Cl] = SID (strong ion difference) goes from -1 mM to 1 mM. With known
SID and total HEPES concentration I can calculate accurately the pH if I
know 3 pK
I have a fair bit of experience with both nls and rating curves. This is
not a nls() problem, this is a model problem. The power law rating curve
favored by hydrologists would not apply to your data as it's based on
the idea that a log-log plot of discharge vs. stage, or state+a in your
case is
If you insist on using nls() for anything that you don't understand
extremely well, you will end up with frustration. nls() uses the same
method K F Gauss used (with good understanding of the details) over
200 years ago. The Gauss-Newton approach inside works very well and
efficiently for problems
nal Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Zachary
> Shadomy
> Sent: Friday, May 5, 2017 12:58 AM
> To: r-help@r-project.org
> Subject: [R] Non-Linear Regression Help
>
> I am having some errors come up in my first section of code. I have no
I am having some errors come up in my first section of code. I have no
issue in plotting the points. Is there an easier method for creating a
non-linear regression using C*(x+a)^n. The .txt file is named
stage_discharge with the two variables being stage and discharge.
The data is a relatively smal
Thank you for the tip. Indeed, nlxb in nlmrt works and results are not
crazy.
I would like however to assess goodness-of-fit (gof) and ultimately to
compare it with gof from linear regression (fitted with same variables).
Before I used AICc to compare the nls() and lm() fit, however I get now
Packages nlmrt or minpack.lm use a Marquardt method. minpack.lm won't
proceed if the Jacobian singularity is at the starting point as far as
I'm aware, but nlxb in nlmrt can sometimes get going. It has a policy
that is aggressive in trying to improve the sum of squares, so will use
more effort
These appear to be primarily statistics/nonlinear optimization issues
that are off topic here, which is about R programming. Post on a
statistics list like stats.stackexchange.com instead.
Cheers,
Bert
Bert Gunter
"Data is not information. Information is not knowledge. And knowledge
is certa
Dear all,
I am trying to estimate VBGF parameters K and Linf using non linear
regression and nls(). First I used a classic approach where I estimate
both parameters together as below with "alkdyr" being a subset per year
of my age-length-key database and running in a loop.
vbgf.par <- nls(Lg
Jeremy:
Don't be silly. The model is overdetermined -- a and b "tradeoff" with each
other. e.g. for any solution (a,b), (a/k^m,b+m) for any m is also a
solution, where k = const (assuming I have correctly interpreted the model,
of course).
-- Bert
On Wed, Dec 19, 2012 at 11:59 AM, Jeremy Miles w
Could you provide the code that you're running, so we can see what
you're trying to do? Even better would be a repeatable example.
Jeremy
On 19 December 2012 09:42, Yann Labou wrote:
> Hey all,
>
> I'm trying to fit a non-linear model y ~ a * constant ^ b * x ^ c and
> estimates the paramaters
Hey all,
I'm trying to fit a non-linear model y ~ a * constant ^ b * x ^ c and
estimates the paramaters a, b and c.
Using the nls function, I'm getting following error message:
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
If I logarit
Apologies for the phrasing of the question.
I've sorted the problem (thanks Bert Gunter) by using the curly brackets {}
as below (using a simplified version of my real model). I hope this helps
someone else!
Jeff
---
> data
Alpha ip X
1 0.7106967
Your question is (completely) ill-posed. What is your actual
model? What you have said makes no sense at all as it stands.
(Minimal self-contained example .)
cheers,
Rolf Turner
On 28/02/12 09:25, jeff_hawkes wrote:
Hi all,
Is it possible to model a function where the unknow
Hi all,
Is it possible to model a function where the unknown parameter appears both
in the fitted equation AND in the determination of other parameters? E.g.
y = a^2 + b/2 + k
where a = 2/k and b = k^2
and the model needs to determine k? I know this is a very simple equation
(its just an exa
On Jun 17, 2011, at 23:14 , Sean Bignami wrote:
> I am trying to fit a curve to a cumulative mortality curve (logistic) where y
> is the cumulative proportion of mortalities, and t is the time in hours (see
> below). Asym. at 0 and 1
>> y
> [1] 0. 0.04853859 0.08303777 0.15201970 0.4099
Hi:
Perhaps the self-starting functions may be helpful. See ?selfStart.
There are self-starting functions for both the logistic and Gompertz
models (SSlogis and SSgompertz, respectively). Go through the examples
to see how they work.
HTH,
Dennis
On Fri, Jun 17, 2011 at 2:14 PM, Sean Bignami wro
I am trying to fit a curve to a cumulative mortality curve (logistic) where y
is the cumulative proportion of mortalities, and t is the time in hours (see
below). Asym. at 0 and 1
> y
[1] 0. 0.04853859 0.08303777 0.15201970 0.40995074 0.46444992
0.62862069 0.95885057 1.
[10] 1.0
Hi Mario,
yes works great. Thanks!
2011/4/12 Mario Valle
> Use a more realistic starting point instead of the default one:
>
> fit <- nls(yeps ~ p1 / (1 + exp(p2 - x)) * exp(p4 * x),
> start=list(p1=410,p2=18,p4=-.03))
>
> This works for me:
> > fit
> Nonlinear regression model
> model: yeps ~
Use a more realistic starting point instead of the default one:
fit <- nls(yeps ~ p1 / (1 + exp(p2 - x)) * exp(p4 * x),
start=list(p1=410,p2=18,p4=-.03))
This works for me:
> fit
Nonlinear regression model
model: yeps ~ p1/(1 + exp(p2 - x)) * exp(p4 * x)
data: parent.frame()
p1
Hi Peter,
thank you for your reply. Now I see, that P3 is indeed redundand.
But with the simplified model...
fit = nls(yeps ~ p1 / (1 + exp(p2 - x)) * exp(p4 * x))
...nls still produces the same error.
Any ideas?
Felix
2011/4/12 Peter Ehlers
> On 2011-04-11 13:29, Felix Nensa wrote:
>
>> Hi,
On 2011-04-11 13:29, Felix Nensa wrote:
Hi,
I am using nls to fit a non linear function to some data but R keeps giving
me "singular gradient matrix at initial parameter estimates" errors.
For testing purposes I am doing this:
### R code ###
x<- 0:140
y<- 200 / (1 + exp(17 - x)/2) * exp(-0.02*
Hi,
I am using nls to fit a non linear function to some data but R keeps giving
me "singular gradient matrix at initial parameter estimates" errors.
For testing purposes I am doing this:
### R code ###
x <- 0:140
y <- 200 / (1 + exp(17 - x)/2) * exp(-0.02*x) # creating 'perfect' samples
with fit
Thanks a lot, this I(xx^2) ... worked.
I guess, I should learn more abot the function poly itself. (so will I... :)
)
Thanks again!
--
View this message in context:
http://r.789695.n4.nabble.com/non-linear-regression-for-3D-data-tp2320982p2325911.html
Sent from the R help mailing list archive a
On 12/08/2010 10:35 AM, szisziszilvi wrote:
I've tried lm, but something is wrong.
I've made a test dataset of 599 data points, my original equation is
zz = 1 +0.5*xx -3.2*xx*xx -1*yy +4.2*yy*yy
but the R gives this result:
---
> mp <- read.cs
right. How does it come that if I devide the result vector with
10*interception, I get a much better result?
> zz2 <- 25.86 -2239.86*mp$xx -595.01*mp$xx*mp$xx + 2875.54*mp$yy +
> 776.84*mp$yy*mp$yy
> mp$zz2 <- zz2
> library(lattice)
> cloud(zz2/258.6 + zz ~ xx * yy, data=mp)
looks quite pretty.
I've tried lm, but something is wrong.
I've made a test dataset of 599 data points, my original equation is
zz = 1 +0.5*xx -3.2*xx*xx -1*yy +4.2*yy*yy
but the R gives this result:
---
> mp <- read.csv(file="sample.csv",sep=";",header=TRUE)
> lm
oh, god, please don't tell anybody...
--
View this message in context:
http://r.789695.n4.nabble.com/non-linear-regression-for-3D-data-tp2320982p2321082.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
On 11/08/2010 6:15 AM, szisziszilvi wrote:
Hello!
Is there a simplier way in R to get a nonlinear regression (like nls) for a
surface? I have 3D data, and it is definitely not a linear surface with
which it would fit the best. Rather sg like z = a + f(x) + g(y) where
probably both f and g are po
Hello!
Is there a simplier way in R to get a nonlinear regression (like nls) for a
surface? I have 3D data, and it is definitely not a linear surface with
which it would fit the best. Rather sg like z = a + f(x) + g(y) where
probably both f and g are polinomes (hopefully quadratic).
Szilvia
--
It appears my suspicions about this being homework were unfounded.
Given the additional problems with excess zeroes, you may want to
examine the extremely informative material on analysis of such
problems written by Zeileis, Kleiber and Jackman:
(easily found in case you have misplaced it, as
Agreed, it would be simple to propose the relationship, however the
regression is necessary to model the data properly. Unfortunately a simple
decay based on those two points does not have the proper shape necessary.
This is due to an extreme amount of zero inflation with this fisheries data.
On
On Feb 6, 2010, at 10:33 PM, kupz wrote:
So I have a data set I would like to model using a non-linear
method. I know
it should be an exponential decay. However I know what the first
derivative
of the equation should be at two points, x=0 and x=100. Is there
anyway to
establish this when
So I have a data set I would like to model using a non-linear method. I know
it should be an exponential decay. However I know what the first derivative
of the equation should be at two points, x=0 and x=100. Is there anyway to
establish this when inputing the model or how would one go about this
F=0,G=0,H=0,K=0))
>
> HP
>
> matplot(cbind(log(fitted(HP)), log(tx.br)),type="l")
>
>
>
> - Original Message -
> From: "Katharine Mullen"
> To: "AneSR"
> Cc:
> Sent: Thursday, December 10, 2009 9:55 PM
> Subject: R
len"
To: "AneSR"
Cc:
Sent: Thursday, December 10, 2009 9:55 PM
Subject: Re: [R] non-linear regression
You did not provide the data or a way of generating it.
I would guess that Excel finds the same solution (the same residual sum-of
squares) as nls but that it uses a weak
You did not provide the data or a way of generating it.
I would guess that Excel finds the same solution (the same residual sum-of
squares) as nls but that it uses a weak convergence criterion and/or does
not give you information regarding why it terminates.
Regarding the step size: you can set
I have a non-linear regression with 8 parameters to solve however it
does not converge ... easily solves the excel ... including the initial
estimates used in the R were found in the excel ... Another question is how
to establish the increments of R by the parameters in the search ..
qx.sua
ith respect to delta is always 0 and so
> the gradient is singular.
> Why do you need delta at all?
>
> --- On Mon, 27/7/09, Berlinerfee wrote:
>
>
>> From: Berlinerfee
>> Subject: [R] Non-Linear Regression with two Predictors
>> To: r-h...@stat.math.ethz
Hello there,
I am using nls the first time for a non-linear regression with a
logistic growth function:
startparam <- c(alpha=3e+07,beta=4000,gamma=2)
fit <- nls(dataset$V2~(( alpha / ( 1 + exp( beta - gamma * dataset$V1 )
) ) ),data=dataset,start=startparam)
Everything works fine and i get
; Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
>> project.org] On Behalf Of despaired
>> Sent: Tuesday, June 09, 2009 9:
n...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of despaired
> Sent: Tuesday, June 09, 2009 9:59 AM
> To: r-help@r-project.org
> Subject: Re: [R] Non-linear regression/Quantile regression
>
>
> Hi,
>
> thanks, it works :-)
> But where is the differe
half Of despaired
Sent: Tuesday, June 09, 2009 11:59 AM
To: r-help@r-project.org
Subject: Re: [R] Non-linear regression/Quantile regression
Hi,
thanks, it works :-)
But where is the difference between demand ~ Time + I(Time^2) and demand ~
poly(Time, 2) ?
Or: How do I have to interpret the results?
Hi,
thanks, it works :-)
But where is the difference between demand ~ Time + I(Time^2) and demand ~
poly(Time, 2) ?
Or: How do I have to interpret the results? (I get different results for the
two methods)
Thank you again!
Gabor Grothendieck wrote:
>
> Those are linear in the coefficients so
Those are linear in the coefficients so try these:
library(quantreg)
rq1 <- rq(demand ~ Time + I(Time^2), data = BOD, tau= 1:3/4); rq1
# or
rq2 <- rq(demand ~ poly(Time, 2), data = BOD, tau = 1:3/4); rq2
On Tue, Jun 9, 2009 at 10:55 AM, despaired wrote:
>
> Hi,
>
> I'm relatively new to R and
Hi,
I'm relatively new to R and need to do a quantile regression. Linear
quantile regression works, but for my data I need some quadratic function.
So I guess, I have to use a nonlinear quantile regression. I tried the
example on the help page for nlrq with my data and it worked. But the
example
If you have the "RSiteSearch" package installed, you can do the
following:
library(RSiteSearch)
nrow(nll <- RSiteSearch.function("nonlinear regression with latent"))
HTML(nll)
This just produced 8 hits for me. If this doesn't solve your
problem, you might try other search terms.
Hi
Can anyone please suggest me a package where I can estimate a non-linear
regression model? One of the independent variables is latent or unobserved.
I have an indicator variable for this unobserved variable; however the
relationship is known to be non-linear also. In terms of equations my
prob
Thank you! It worked perfectly, also for the other variables!
Messaggio originale
Da: r...@life.ku.dk
Data: 06.02.2009 13.29
A:
Oggetto: Re: [R] non linear regression with nls
Hi Laura,
I think you have to make a list formulas:
formList <- list(NT.N ~ fz1(Portata, a, b), NT.N ~
e how
can someone specify the groups/subset?
Thanks a lot!
Laura
Messaggio originale
Da: kfr...@wisc.edu
Data: 03.02.2009 15.36
A:
Oggetto: Re: [R] non linear regression with nls
Hi, Laura-
You might have a look at ?nlsList().
Ken
- Original Message -
From: "
ent
## notice that the i'th list components in fctList and startList
## are used for the i'th fit
resultList[[i]] <- nls(NT.N ~ fctList[[i]](parList[[i]]), data=subset(dati,
Fiume=="Laveggio"), start=startList
[[i]], nls.control(maxiter=200), algorithm='port
Hello,
I'm a beginner with R and it's the first time I'm using the R-help list... I
hope I'm in the right place, if not:
Sorry!!
I need to do non linear regressions on a data set which columns are:
"river.name""Portata" "PTG.P" "PO4.P" "NT.N""NH4.N" "NO3.N"
"BOD5""SiO2"
I need to do a non-linear regression in the form of
Y = a0 + a1 * arctan(a2 * x) + error.
A data sample (X,Y) is available, but I can't remember how to run this sort
of regression through R so that I get a value for a0, a1 and a2.
Can someone please give me a hint?
Thank you in advance.
__
Dear Rolf,
One thing that sometimes makes nls easier to apply is using the 'formula'
argument like you would use the 'fn' argument of optim. That is, if you
have a residual function that has arguments x, y, a, b and you need to
optimize a and b, you would make a call like
nls(~resid(x,y,a=astart
I have never had much success in using nls(). If you scan the archives
you will find one or two postings from me on this topic. I have
received
no useful responses to these postings.
I have found that anything that I tried (and failed) to do using nls()
could be done quite easily using optim(
Gavin Simpson wrote:
> hits=-2.6 tests=BAYES_00
> X-USF-Spam-Flag: NO
>
> On Wed, 2008-01-16 at 11:02 +0100, Janice Kielbassa wrote:
>> Hello!
>>
>> I want to do a non-linear regression with 2 explanatory variables
>> (something like : length ~ a * time * exp( b* temperature)), having a
>> data
hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO
On Wed, 2008-01-16 at 11:02 +0100, Janice Kielbassa wrote:
> Hello!
>
> I want to do a non-linear regression with 2 explanatory variables
> (something like : length ~ a * time * exp( b* temperature)), having a
> data set (length, time, temperature).
Hello!
I want to do a non-linear regression with 2 explanatory variables
(something like : length ~ a * time * exp( b* temperature)), having a
data set (length, time, temperature). Which function could I use (I
tried nls but I think it doesn't work)
Thanks a lot!
Janice
__
66 matches
Mail list logo