[R] nls and "plinear" algorithm

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Jul 8 22:17:53 CEST 2008


Allan Clark wrote:
> hello all
>
>
> i havnt had a chance to read through the references provided for the
> "nls" function (since the libraries are closed now).
>
> can anyone shed some light on how the "plinear" algorithm works? also,
> how are the fitted values obtained? also, WHAT DOES THE ".lin" below
> REPRESENT?
>
>   
Essentially it gets multiplied onto the 242 (if I got the parenthesis 
count right).

The whole thing is probably better explained using a simpler example:

y ~ A*exp(-a*x) + B*exp(-b*x)

is partially linear. If you fix a and b, finding A and B is a linear 
regression problem. So you can
say

y ~ cbind(exp(-a*x), exp(-b*x)), algorithm="plinear", start=c(.5, .05)

(notice that the left hand side is  a matrix if there is more than one 
linear parameter)

> thanking you in advance
>
> ######################################
> i have a quick example: (data below)
>
>
> f1=nls(r~242*(p+exp(-a1*p)/a1-1/a1)*(1-exp(-a2*o))/(
> (100+exp(-a1*100)/a1-1/a1)*(1-exp(-a2*50)) ) , data = X.m,
> algorithm="plinear",start = list(a1=0.01,a2=.01),trace = TRUE)
>
>   
>> summary(f1)
>>     
>
> Formula: r ~ 242 * (p + exp(-a1 * p)/a1 - 1/a1) * (1 - exp(-a2 *
> o))/((100 + 
>     exp(-a1 * 100)/a1 - 1/a1) * (1 - exp(-a2 * 50)))
>
> Parameters:
>      Estimate Std. Error t value Pr(>|t|)    
> a1   0.027017   0.003493   7.735 6.34e-10 ***
> a2   0.154967   0.012214  12.688  < 2e-16 ***
> .lin 1.042452   0.008010 130.140  < 2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
>
> Residual standard error: 3.979 on 47 degrees of freedom
>
> Number of iterations to convergence: 13 
> Achieved convergence tolerance: 8.91e-06 
>
>
>
>
>
>
>
>
> p	r	o
> 98.96338287	241.2828283	50
> 97.55260431	237.6262626	49
> 95.63989983	233.0606061	48
> 93.91802748	229.3232323	47
> 92.31404009	224.7575758	46
> 90.03746768	220.7878788	45
> 89.30649329	216.6868687	44
> 87.64125166	212.2020202	43
> 86.68123643	207.4646465	42
> 85.25030371	203.3939394	41
> 83.64465743	198.5252525	40
> 82.60251377	193.8787879	39
> 81.62361512	189.1717172	38
> 80.71350574	185.1111111	37
> 79.15697699	180.7171717	36
> 78.11234178	176.5858586	35
> 76.60248492	172.7272727	34
> 76.03845076	168.5353535	33
> 74.32556341	164.6060606	32
> 73.3639895	160.3939394	31
> 72.35840786	156.7272727	30
> 70.90629218	152.5454545	29
> 69.88235864	148.6161616	28
> 68.69538137	144.1818182	27
> 67.6875564	140.5151515	26
> 67.16355934	135.7373737	25
> 66.90502437	131.3636364	24
> 65.63480302	126.8484848	23
> 64.63355769	122.1111111	22
> 63.5529748	117.4040404	21
> 62.65320004	113.4444444	20
> 61.31100803	109.0505051	19
> 60.59542007	105.1836735	18
> 58.43200533	100.244898	17
> 57.13903832	96.68041237	16
> 56.46953877	92.45833333	15
> 54.79475954	87.52083333	14
> 53.85049475	82.21875	13
> 52.50164551	77.84210526	12
> 51.04072849	72.87234043	11
> 49.64840803	68.22580645	10
> 48.24666285	62.76344086	9
> 46.36813455	58.0989011	8
> 44.40690015	51.85714286	7
> 42.8855932	45.13333333	6
> 40.93434063	39.34090909	5
> 37.84871552	32.39772727	4
> 36.10687426	25.8372093	3
> 32.74320593	18.26829268	2
> 28.03072554	9.922077922	1
>
> ______________________________________________
> R-help at 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.
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list