May be this:

mydf<-read.table(stdin(), head=T, sep=",")
Xvar,Yvar
0,1
2,0.9
5,0.5
7,0.1
10,0.01
mymodel<-loess(Yvar~Xvar, data=mydf)

plot(mymodel)
mydf.new<-data.frame(cbind(Xvar=seq(from=0, to=10, by=0.1)))
mydf.new$Yvar<-predict(mymodel, newdata=mydf.new)
lines(Yvar~Xvar, data=mydf.new, lty=2)

cheers

milton

On Wed, Sep 9, 2009 at 3:01 PM, milton ruser <milton.ru...@gmail.com> wrote:

> Hi Bill,
>
> I am not sure what you want, but...
>
> mydf<-read.table(stdin(), head=T, sep=",")
> Np,year
> 96,2
> 91,5
> 89,7
> 85,10
>
> plot(Np~year, data=mydf)
> mymodel<-lm(Np~year, data=mydf)
> abline(mymodel, col="red")
>
> bests
> milton
>
>   On Wed, Sep 9, 2009 at 2:27 PM, Bill Hyman <billhym...@yahoo.com> wrote:
>
>> My data look like:
>>
>> Np year
>> 96    2
>> 91    5
>> 89    7
>> 85   10
>>
>>
>>
>> ----- Original Message ----
>> From: Bill Hyman <billhym...@yahoo.com>
>> To: r-help@r-project.org
>> Sent: Wednesday, September 9, 2009 11:23:26 AM
>> Subject: [R] fitting nonlinear model
>>
>> I only have 4 data points and want to fit a curve. It does not work in
>> "modreg" due to too few data. Do you have any idea? Many thanks!
>>
>> ______________________________________________
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

        [[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