I was able to solve this problem by going back to nls and obtaining the
initial parameter estimates through optim. When I used nlsList with my
dataset, it took 2 minutes to solve and was not limited by the bounds. Now I
have the bounds working and it takes 45 seconds to solve. Here is the new
I adapted a selfStart function and the lower bounds are not working. The
parameter b is negative, whereas I would like the lower bound to be zero.
Any ideas? Thanks.
Here is my code (I am still figuring out how to easily make replicable
examples):
A-1.75
mu-.2
l-2
b-0
x-seq(0,18,.25)
I tested the optim function and that is returning non-negative parameter
values (meaning they are bound by the lower limits), but I think those are
the starting estimates for the nlsList model which is then finding negative
values for the solution.
-
In theory, practice and theory are the
I ran the code again and got an error saying that the x was unknown. I
don't know why I hadn't seen that error before. Anyway, I made the edits to
func1 so instead of x, it is xy$x.
#function to optimize
func1 - function(value) {
A.s - value[1]
mu.s - value[2]
l.s - value[3]
b.s-
I have encountered this problem on several occasions and am not sure how to
handle it. I use for-loops to cycle through datasets. When each dataset is
of equal length, it works fine as I can combine the datasets and have each
loop pick up a different column, but when the datasets are differing
Sometimes I have NA values within specific columns of a dataframe (in this
example, the first two columns can have NAs). If there are NA values, I
would like them to be removed.
I have been using the code:
y-c(NA,5,4,2,5,6,NA)
z-c(NA,3,4,NA,1,3,7)
x-1:7
adata-data.frame(y,z,x)
Thank you for the help and explanations. I used the complete.cases function
and it is working great.
adata[complete.cases(adata[,1:2]),]
-
In theory, practice and theory are the same. In practice, they are not - Albert
Einstein
--
View this message in context:
Here is the code I am running:
library(nls2)
modeltest- function(A,mu,l,b,thour){
out-vector(length=length(thour))
for (i in 1:length(thour)) {
out[i]-b+A/(1+exp(4*mu/A*(l-thour[i])+2))
}
return(out)
}
A=1.3
mu=.22
l = 15
b = .07
thour = 1:25
Yvals-modeltest(A,mu,l,b,thour)-.125+runif(25)/4
st2
I decided to go with circles instead of rectangles. Thank you for your help.
Here is the new code:
dev.new(width=2.5, height=3,mar=c(0,0,0,0))
par(mfrow=c(1,1),mar=c(0,0,0,0))
x=c(-1,1,1,-1,-3,-3,5)
y=c(1.2,0.6,-.7,-1.3,-.7,0.6,5)
plot(0,xlim=c(-4,2),ylim=c(-2,2),type=n,axes=FALSE,xlab=,ylab=)
dev.new(width=6, height=1.5,mar=c(0,0,0,0))
par(mfrow=c(1,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0))
barplot(c(1,1,1,1,1,1),col=c(blue,purple,red,green,orange,yellow),
axes = FALSE)
I have a barplot that returns six colors in a line. I would like to get the
same six color blocks in a hexagram
I'm not sure this is the right location (maybe R-devel would be better).
-
In theory, practice and theory are the same. In practice, they are not - Albert
Einstein
--
View this message in context:
http://r.789695.n4.nabble.com/barplot-in-hexagram-layout-tp3807600p3807608.html
Sent from the
I will try stacking 5 barplots (with 5 bars per plot) and somehow only
showing the middle bar for the top and bottom plots and the two end bars for
the two middle plots.
-
In theory, practice and theory are the same. In practice, they are not - Albert
Einstein
--
View this message in
Here is the new code. It works just like I wanted.
dev.new(width=6, height=6.5,mar=c(0,0,0,0))
par(mfrow=c(5,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0))
barplot(c(1,1,1,1,1),col=c(white,white,red,white,white), axes =
FALSE,border=NA)
barplot(c(1,1,1,1,1),col=c(orange,white,white,white,yellow),
I updated the code as follows:
dev.new(width=2.5, height=3,mar=c(0,0,0,0))
par(mfrow=c(5,1),mar=c(.5, .5, 1.5, .5), oma=c(.4, 0,.5, 0))
barplot(c(1,1,1,1,1),col=c(white,white,red,white,white), axes =
FALSE,border=NA)
barplot(c(1,1,1,1,1),col=c(orange,white,white,white,yellow), axes
=
not seem to work
or they only increase the size to a certain degree, even though I can
manually increase it to fill my screen.
Schatzi wrote:
Thanks all for the replies. I am getting better slowly but surely. I
imagine that I will get better at figuring out things as well so I don't
have to post
I am plotting 28 plots on one screen:
par(mfrow=c(4,7))
for (i in 1:28) {
a-seq(1,3,1)
plot(a,a, ann=FALSE)
}
I want a main title for all the plots (I tried using main but that doesn't
work). I deleted the axes, but am not sure how to delete the space. There
are such large margins between plots
I have a combined date and time. I would like to separate them out into two
columns so I can do things such as take the mean by time across all dates.
meas-runif(435)
nTime-seq(1303975800, 1304757000, 1800)
nDateT-as.POSIXct(nTime, origin=1970-01-01)
mat1-cbind(nDateT,meas)
means1-
That is wonderful. Thank you.
Adele
Ken Takagi wrote:
Schatzi adele_thompson at cargill.com writes:
I have a combined date and time. I would like to separate them out into
two
columns so I can do things such as take the mean by time across all
dates.
meas-runif(435)
nTime-seq
I have a dataset where I have missing times (11:00 and 16:00). I would like
the outputs to include the missing time so that the final time vector looks
like realt and has the previous time's value. Ex. If meas at time 15:30 is
0.45, then the meas for time 16:00 will also be 0.45.
meas are the
I have a matrix where one column has a date and another column has a time. I
need to delete all times before 6am. I had combined the Date and Time column
into DateTime.
Mat1:
Weight Date Time
7.6 04/28/11 09:03
8.4 04/29/11 03:11
8.6 04/29/11 05:32
8.6 04/29/11 09:53
1.4
I have times and would like to round down to the earliest 30 minute
increment. For instance, a time of
2011-04-28 09:02:00
(the as.numeric value = 1303999320)
I would like it to be rounded down to:
2011-04-28 09:00:00
(the as.numeric value = 1303999200)
Any ideas of how to do this?
-
In
In Matlab, an array can be created from 1 - 30 using the command similar to R
which is 1:30. Then, to make the array step by 0.1 the command is 1:0.1:30
which is 1, 1.1, 1.2,...,29.9,30. How can I do this in R?
-
In theory, practice and theory are the same. In practice, they are not - Albert
I can get around it by doing something like:
as.matrix(rep(1,291))*row(as.matrix(rep(1,291)))/10+.9
I was just hoping for a simple command.
Schatzi wrote:
In Matlab, an array can be created from 1 - 30 using the command similar
to R which is 1:30. Then, to make the array step by 0.1
I have a new device that takes measurements anywhere from every second, to
every 15 minutes (depending on changes). The matrix has a date, time and Y
column (Y is the measurement). For three days it is 25,000 rows. How do I
average the measurements by every 30 minutes so my matrix is 48 rows per
I do not want smoothing as the data should have jumps (it is weight left in
feeding bunker). I was thinking of maybe using a histogram-like function and
then averaging that. Not sure if this is possible.
-
In theory, practice and theory are the same. In practice, they are not - Albert
information from list which class is nls
On Tue, Apr 26, 2011 at 2:21 PM, Schatzi [hidden
email]/user/SendEmail.jtp?type=nodenode=3477116i=0by-user=t wrote:
How do I extract the standard error of the parameter estimates?
Also, if I would like to add two parameters together (x+y), can I use
:15 AM
To: Thompson, Adele - adele_thomp...@cargill.com
Subject: Re: How can I extract information from list which class is nls
On Apr 27, 2011, at 9:28 AM, Schatzi wrote:
Here is more information on the equation. It is a growth function:
Growth = a + b*(1-exp(-k*time))
where a, b and k
I wanted to use an F-statistic to get p-values for treatment differences. I
have parameter estimates and standard errors. I posted about combining the
parameters in a previous post, but here I would just like to test the
parameter differences by treatments (it is a nonlinear function). I
How do I extract the standard error of the parameter estimates?
Also, if I would like to add two parameters together (x+y), can I use this
equation to calculate the new standard error?:
x = parameter 1
y = parameter 2
xSE = SE parameter 1
ySE = SE parameter 2
Inter ocular data
Quite amusing :)
Thank you for the help. For some reason I was thinking that I could get the
n values for the combined test, but that doesn't make sense as there could
be an infinite number of combinations of n values.
Thanks again for the replies.
--
View this message in
I am trying to do a power analysis to get the number of replicas per
treatment.
If I try to get the power it works just fine:
setn=c(2,3)
sdx=c(1.19,4.35)
power.t.test(n = setn, delta = 13.5, sd = sdx, sig.level = 0.05,power =
NULL)
If I go the other way to obtain the n I have problems.
Here is a reply by Bart:
Yes you're right (I should have taken off my glasses and looked closer).
However, the argument is essentially the same:
Suppose you have a solution with a,b,k,l. Then for any positive c, [a+b-bc]
+ [bc] + (bc) *exp(kl')exp(-kx) is also a solution, where l'
= l - log(c)/k
I am running the following nls equation. I tried it with data that excel was
fitting and got the error:
singular gradient matrix at initial parameter estimates
I thought it was due to a low number of points (6), but when I create a
dataset, I get the same problem. If I remove the parameter a,
I am running the following nls equation. I tried it with data that excel was
fitting and got the error:
singular gradient matrix at initial parameter estimates
I thought it was due to a low number of points (6), but when I create a
dataset, I get the same problem. If I remove the parameter a,
If no one is able to help with this issue, do you have any idea where I can
post this question to receive help? Thank you.
--
View this message in context:
http://r.789695.n4.nabble.com/nls-help-tp3328521p3328611.html
Sent from the R help mailing list archive at Nabble.com.
I am running the following nls equation. I tried it with data that excel was
fitting and got the error:
singular gradient matrix at initial parameter estimates
I thought it was due to a low number of points (6), but when I create a
dataset, I get the same problem. If I remove the parameter a,
By the way, sorry about the reposts. I subscribed but wasn't sure what was
happening. Hopefully this worked.
--
View this message in context:
http://r.789695.n4.nabble.com/nls-not-solving-tp3328647p3328659.html
Sent from the R help mailing list archive at Nabble.com.
I am not sure how you simplified the model to:
y = a + b(1 - exp(kl)) - b exp(-kx)
I tried simplifying it but only got to:
y = a + b - b * exp(kl) * exp(-kx)
I agree that the model must not be identifiable. That makes sense,
especially given that removing either a or l makes the model work. Can
Great. Thanks. Here is the new code:
xyplot(Y~X,groups = TRT,type=n)
text(x,y,labels=TRT)
--
View this message in context:
http://r.789695.n4.nabble.com/Plot-using-treatment-letter-as-points-tp3276743p3276808.html
Sent from the R help mailing list archive at Nabble.com.
I would like to create a plot of y vs x with different treatments where the
points are actually the letter of the treatment. Here is the code:
A-as.matrix(rnorm(10,10))
B-as.matrix(rnorm(10,9.5))
C-as.matrix(rnorm(10,10.5))
Y-as.matrix(rnorm(30,13))
X-rbind(A,B,C)
nA-matrix(A,10,1)
40 matches
Mail list logo