Hi Petr,
Thank you for the response.

I am not familiar with the nls package. I am interested in obtaining a
function to represent the relationship observed in "dat" over x.seq (days)
so that I can calculate a minimum and maximum of the function.

In the example below, it seems like you are using a data frame, but I tried
to create the data frame from x.seq and dat:

dat.df <- data.frame(x.seq, dat)

However, I got the following error:

Error in nls(dat ~ SSlogis(x, Asym, xmid, scal), data = dat.df, start =
list(Asym = 90,  :
  parameters without starting value in 'data': x

Thank you for your assistance,

Katrina

On Thu, Aug 4, 2011 at 11:14 PM, Petr PIKAL <petr.pi...@precheza.cz> wrote:

> Hi
>
> Are you sure about sine fit? Seems to me that logistics would be better
>
> fit<-nls(dat ~ SSlogis(x, Asym, xmid,scal), data = dat.df, start =
> list(Asym=90, xmid = 75, scal = -6))
> plot(dat.df)
> lines(dat.df$x[complete.cases(dat.df)], predict(fit))
>
> Regards
> Petr
>
>
>
> >
> > Hello, I'm trying to generate a sine wave in R to fit my observations
> using
> > the general formula:
> >
> > y=a*sin(b[x+h*pi)]+k
> >
> > where a = amplitude, b=period, h=phase shift, and k=vertical shift
> >
> > I want to use following translation to bring the sine function up onto
> the
> > y-axis to range from 0-1, and this will place the wave on the x-axis
> from
> > 0-pi/2.
> >
> > y=1/2sin(2[x+ 1/4*pi]) + 1/2
> >
> > Additionally, I need to spread this along a x-axis that spans 1-153
> (days).
> >
> > Can anyone help with this? I seem to be able to use the curve function
> fine,
> > but entering the translations doesn't seem to provide an answer.
> >
> > Here is an example of the data set I am trying to 'match' using this
> > function.
> >
> > dat <-
> >
> c(75.44855206,NA,NA,NA,82.70745342,82.5335019,88.56617647,80.00128866,94.
> > 15418227,86.63987539,93.91052952,74.10612245,86.62289562,90.
> > 47961047,NA,NA,82.45320197,72.14371257,NA,71.44104803,72.59742896,68.
> > 36363636,NA,NA,61,NA,NA,71.26502909,NA,85.93333333,84.34248284,79.
> > 00522193,79.64223058,97.2074017,88.43700548,96.40413877,95.13511869,92.
> > 57379057,93.97498475,NA,97.55995131,89.53321146,97.21728545,93.21980198,
> > 77.54054054,95.85392575,86.25684723,97.55325624,80.03950617,NA,91.
> > 34023128,92.42906574,88.59433962,65.77272727,89.63772455,NA,NA,NA,NA,74.
> > 86344239,83.57594937,70.22516556,65.30543319,NA,NA,67.84852294,60.
> > 90909091,54.79303797,NA,52.18735363,33.47003155,NA,41.34693878,24.
> > 5047043,NA,NA,NA,NA,9.944444444,13.6875,NA,11.90267176,84.14285714,3.
> > 781456954,NA,1.432926829,4.26557377,1.823529412,0.444620253,4.
> >
> 711155378,NA,6.320284698,0.581632653,0.144578313,3.666666667,0,0,0,0,0,NA,
> > 0.032947462,0,0,10.54545455,0,NA,0.561007958,0.75,NA,0.048780488,0.
> > 74137931,NA,2.023339318,0,0,0,NA,NA,0.156950673,NA,0.283769634,32.
> >
> 81818182,NA,NA,0,NA,0,0,0,NA,0.212454212,3.120181406,NA,0.011811024,NA,0,
> >
> 0.120430108,5.928571429,1.75,0.679292929,0.97,NA,0,NA,NA,1,0.38547486,NA,
> > 1.460732984,0.007795889,0.05465288,0.004341534)
> > plot(dat/100)
> > par(new=F)
> > x.seq <- seq(100, 0, , 153)
> > y <- ??? #*y = 2 sin 2Ď€ (x - 1/4)* or y ~ a + c*sin(x+b)
> >
> > However, I can't find a reference for the no place for k. Also, I've
> tried a
> > lot of different iterations, but can't seem to figure out how to do this
> in
> > R.
> >
> > Any thoughts or ideas on this?
> >
> > Thank you,
> >
> > Katrina
> >
> >    [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>


-- 
Katrina E. Bennett
PhD Student
University of Alaska Fairbanks
International Arctic Research Center
930 Koyukuk Drive, PO Box 757340
Fairbanks, Alaska 99775-7340
907-474-1939 office
907-385-7657 cell
kebenn...@alaska.edu


Personal Address:
UAF, PO Box 752525
Fairbanks, Alaska 99775-2525
bennett.katr...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to