<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Vejam o seguinte script:</p>
<p><br>
</p>
<p></p>
<div><br>
</div>
<div>rm(list=ls(all=TRUE))</div>
<div><br>
</div>
<div>library(minpack.lm)</div>
<div><br>
</div>
<div>dados<-read.table(header = TRUE, dec=",",text=</div>
<div>"psi<span style="white-space:pre"> </span>theta</div>
<div>0,01<span style="white-space:pre"> </span>0,5</div>
<div>0,5<span style="white-space:pre"> </span>0,48</div>
<div>1<span style="white-space:pre"> </span>0,42</div>
<div>3<span style="white-space:pre"> </span>0,4</div>
<div>10<span style="white-space:pre"> </span>0,39</div>
<div>30<span style="white-space:pre"> </span>0,35</div>
<div>100<span style="white-space:pre"> </span>0,3</div>
<div>300<span style="white-space:pre"> </span>0,28</div>
<div>1000<span style="white-space:pre"> </span>0,27</div>
<div>")</div>
<div>dados</div>
<div><br>
</div>
<div>theta=dados$theta</div>
<div>psi=dados$psi</div>
<div><br>
</div>
<div>durner<-as.formula(theta~0.6*(thetar+((thetas-thetar)/(1+(alpha0*psi)^n0)^(1-1/n0)))+</div>
<div>                         0.4*(thetar+((thetas-thetar)/(1+(alpha1*psi)^n1)^(1-1/n1))))</div>
<div><br>
</div>
<div>dur<-nlsLM(durner,</div>
<div>          start=list(thetas=0.5,thetar=0.25,alpha0=0.1,n0=2,alpha1=0.1,n1=1),data = dados,</div>
<div>          algorithm = "LM",</div>
<div>          trace = "F",</div>
<div>          control = list(maxiter = 500))</div>
<div>summary(dur)</div>
<div><br>
</div>
<div>rsquared<-1-(sum(residuals(dur)^2)/sum((theta - mean(theta))^2))</div>
<div>rsquared</div>
<div><br>
</div>
<div>thetas=coef(dur)[1]</div>
<div>thetar=coef(dur)[2]</div>
<div>alpha0=coef(dur)[3]</div>
<div>n0=coef(dur)[4]</div>
<div>alpha1=coef(dur)[5]</div>
<div>n1=coef(dur)[6]</div>
<div><br>
</div>
<div>par(mar=c(4,4,1,1))</div>
<div>par(mfrow = c(1, 1))</div>
<div>plot(psi,theta,xlim = c(min(psi),max(psi)),log = "x",las=1,xaxt="n",ylab=expression(theta~(m^{3}~m^{-3})),xlab=expression(abs(psi)~(kPa)),mgp=c(2.5, 1, 0))</div>
<div>labels <- 10^(-3:3)</div>
<div>axis(1, at=labels, labels=labels,lwd.ticks = 2) #,tck=-0.05</div>
<div>axis(1, at=sort(sapply(1:9, function(x) x*10^(-3:3))), label=NA, lwd=0.5)</div>
<div><br>
</div>
<div>curve(0.6*(thetar+((thetas-thetar)/(1+(alpha0*psi)^n0)^(1-1/n0)))+</div>
<div>      0.4*(thetar+((thetas-thetar)/(1+(alpha1*psi)^n1)^(1-1/n1))),add = T,xname = "psi")</div>
<div><br>
</div>
<p></p>
<p><br>
</p>
<p><b>Gostaria de, ao invés de dar valores (0.6 e 0.4):</b></p>
<p></p>
<div style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
durner<-as.formula(theta~0.6*(thetar+((thetas-thetar)/(1+(alpha0*psi)^n0)^(1-1/n0)))+</div>
<div style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
                         0.4*(thetar+((thetas-thetar)/(1+(alpha1*psi)^n1)^(1-1/n1))))</div>
<div><br>
</div>
<p></p>
<p><b>adicionar dois parâmetros (w0 e w1):</b></p>
<p></p>
<div style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
durner<-as.formula(theta~w0*(thetar+((thetas-thetar)/(1+(alpha0*psi)^n0)^(1-1/n0)))+</div>
<div style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
                         w1*(thetar+((thetas-thetar)/(1+(alpha1*psi)^n1)^(1-1/n1))))</div>
<div><br>
</div>
<div><b>mas de tal forma que: w0+w1==1.</b></div>
<div><br>
</div>
Alguém tem sabe como poderia fazer isso?
<p></p>
<p><br>
</p>
<p>Att., Delcio Bortolanza</p>
<p><span style="font-size: 12pt;">Doutorando em Agronomia-UPF</span><br>
</p>
<p></p>
</div>
</body>
</html>