seeArgumentsc(‘xname’,‘yname’,‘yhat’,‘Rname’,‘Pname’)trendline(x,y,model=”exp3P”,xname=”T”,yname=paste(delta^15,”N”),yhat=FALSE,Rname=1,Pname=0,ePos.x=“bottom”)
Plot,drawregressionlineandconfidenceinterval,andshowregressionequation,R-squareandP-value,assimpleaspossible,
byusingdifferentmodelsbuiltinthe‘trendline()’function.Thefunctionincludesthefollowingmodelsinthelatestversion:
“line2P”(formulaas:y=a*x+b),
“line3P”(y=a*x2+b*x+c),
“log2P”(y=a*ln(x)+b),
“exp2P”(y=a*eb*x),
“exp3P”(y=a*eb*x+c),
“power2P”(y=a*xb),
“power3P”(y=a*xb+c).
Besides,thesummarizedresultsofeachfittedmodelarealsooutputbydefault.
trendline(x,y,model="line2P",Pvalue.corrected=TRUE,linecolor="blue",lty=1,lwd=1,show.equation=TRUE,show.Rpvalue=TRUE,Rname=1,Pname=0,xname="x",yname="y",yhat=FALSE,summary=TRUE,ePos.x=NULL,ePos.y=NULL,text.col="black",eDigit=5,eSize=1,CI.fill=TRUE,CI.level=0.95,CI.color="grey",CI.alpha=1,CI.lty=1,CI.lwd=1,las=1,xlab=NULL,ylab=NULL,...)“参数”介绍x,ythexandyargumentsprovidethexandycoordinatesfortheplot.Anyreasonablewayofdefiningthecoordinatesisacceptable.
modelselectwhichmodeltofit.Defaultis“line2P”.The“model”shouldbeoneofc(“line2P”,“line3P”,“log2P”,“exp3P”,“power3P”),theirformulasareasfollows:“line2P”:y=a*x+b“line3P”:y=a*x2+b*x+c“log2P”:y=a*ln(x)+b“exp2P”:y=a*eb*x“exp3P”:y=a*eb*x+c“power2P”:y=a*xb“power3P”:y=a*xb+c
Pvalue.correctedifP-valuecorrectedornot,thevlaueisoneofc(“TRUE”,“FALSE”).
linecolorcolorofregressionline.
ltylinetype.ltycanbespecifiedusingeithertextc(“blank”,”solid”,”dashed”,”dotted”,”dotdash”,”longdash”,”twodash”)ornumberc(0,1,2,3,4,5,6).Notethatlty=“solid”isidenticaltolty=1.
lwdlinewidth.Defaultis1.
show.equationwhethertoshowtheregressionequation,thevalueisoneofc(“TRUE”,“FALSE”).
show.RpvaluewhethertoshowtheR-squareandP-value,thevalueisoneofc(“TRUE”,“FALSE”).
RnametospecifythecharacterofR-square,thevalueisoneofc(0,1),correspondingtoc(r^2,R^2).
PnametospecifythecharacterofP-value,thevalueisoneofc(0,1),correspondingtoc(p,P).
xnametospecifythecharacterof“x”inequation,seeExamples[case5].
ynametospecifythecharacterof“y”inequation,seeExamples[case5].
yhatwhethertoaddahatsymbol(^)onthetopof“y”inequation.DefaultisFALSE.
summarysummarizingthemodelfits.DefaultisTRUE.
ePos.x,ePos.yequationposition.DefaultasePos.x=“topleft”.Ifnoneedtoshowequation,setePos.x=NA.It’ssameasthoseinlegend.
text.colthecolorusedforthelegendtext.
eDigitthenumbersofdigitsforequationparameters.Defaultis5.
eSizefontsizeinpercentageofequation.Defaultis1.
CI.fillfilltheconfidanceinterval(TRUEbydefault,see‘CI.level’tocontrol)
CI.levellevelofconfidenceintervaltouse(0.95bydefault)
CI.colorlineorfillcolorofconfidenceinterval.
CI.alphaalphavalueoffillcolorofconfidenceinterval.
CI.ltylinetypeofconfidenceinterval.
CI.lwdlinewidthofconfidenceinterval.
lasstyleofaxislabels.(0=parallel,1=allhorizontal,2=allperpendiculartoaxis,3=allvertical)
xlab,ylablabelsofx-andy-axis.
…additionalparameterstoplot,suchastype,main,sub,xlab,ylab,col.
Thelinearmodels(line2P,line3P,log2P)inthispackageareestimatedbylmfunction,whilethenonlinearmodels(exp2P,exp3P,power2P,power3P)areestimatedbynlsfunction(i.e.,least-squaresmethod).Theargument‘Pvalue.corrected’isworkfulfornon-linearregressiononly.If“Pvalue.corrected=TRUE”,theP-vlaueiscalculatedbyusing“ResidualSumofSquares”and“CorrectedTotalSumofSquares(i.e.sum((y-mean(y))^2))”.If“Pvalue.corrected=TRUE”,theP-vlaueiscalculatedbyusing“ResidualSumofSquares”and“UncorrectedTotalSumofSquares(i.e.sum(y^2))”.
Confidenceintervalsfornonlinearregression(i.e.,objectsofclassnls)arebasedonthelinearapproximationdescribedinBates&Watts(2007).
Bates,D.M.,andWatts,D.G.(2007)NonlinearRegressionAnalysisanditsApplications.Wiley.
GreenwellB.M.,andSchubert-Kabban,C.M.(2014)investr:AnRPackageforInverseEstimation.TheRJournal,6(1),90-100.
R2,indicatestheR-Squaredvalueofeachregressionmodel.
p,indicatesthep-valueofeachregressionmodel.
AICorBIC,indicatetheAkaike’sInformationCriterionorBayesianInformationCriterionforfittedmodel.ClickAICfordetails.ThesmallertheAICorBIC,thebetterthemodel.
RSS,indicatesthe“ResidualSumofSquares”ofregressionmodel.
Toseeexamplesonhowtouse“basicTrendline”inRsoftware,youcanrunthefollowingRcodeifyouhavethe“basicTrendline”packageinstalled:
library(basicTrendline)trendline()致谢WewouldliketoexpressmyspecialthankstoUweLigges,SwetlanaHerbrandt,andCRANteamfortheirveryvaluablecommentstothe‘basicTrendline’package.OurthanksalsogotothosewhocontributedRcodesby: