FlexParamCurve-package: Tools to Fit Flexible Parametric Curves

Description Details Note Author(s) References See Also Examples

Description

selfStart functions and model selection tools to fit parametric curves in

nls, nlsList and nlme frameworks.

Details

General approach for using package (also see examples below)

1) Run modpar to produce initial parameter estimates and estimates of parameter bounds for your dataset.

These are used to accomodate fixed parameters and are saved in user-specified list object

All parameters and options in this list can be edited manually or using change.pnparameters. The

list could be created manually given that the elements were labelled sufficiently. Note that this step is

unnecessary when using the model selection routines pn.mod.compare and pn.modselect.step as they

will automatically call modpar if parameter estimates are missing.

2) Determine most appropriate model (number of necessary parameters) for your data

using pn.mod.compare or pn.modselect.step (these rank competing model and then compare nested models using

extraF). This may take some time as many nlsList objects are fitted.

Note that if you perform this step, then you do not need to perform step 1.

If you are sure of your model (e.g. it is a simple logistic) Step 2 may be unnecessary.

3) Fit nls or nlsList or nlme models using SSposnegRichards specifying

the appropriate model number and the list of parameters and options (specified pn.options object).

Note if required model is monotonic (i.e. contains no recession parameters, modno= 12 or 32) recessional parameters

will be ignored unless "force.nonmonotonic" option is TRUE in the specified pn.options list

object (see modpar) in which case they will be included as fixed values from the list object.

Parameter bounds can be refinedto improve fits by altering this list, either manually or using

change.pnparameters.

4) Plot your curves using eqnposnegRichards.eqn specifying the appropriate model number and list of parameters/options.

User level functions include:

pn.mod.compare

1
2
3
4
      all-model selection for positive-negative Richards nlsList models


        

pn.modselect.step

1
2
3
4
      backward stepwise model selection for positive-negative Richards nlsList models


        

SSposnegRichards

1
2
3
4
5
6
7
      selfStart function for estimating parameters of 36 possible reductions of the 8-parameter


      positive-negative Richards model (double-Richards)


        

posnegRichards.eqn

1
2
3
4
5
6
7
      function for evaluating 36 possible reductions of the 8-parameter 


      positive-negative Richards model (double-Richards)


        

modpar

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
      estimates mean parameters (and parameter bounds) for 8-parameter positive-negative Richards


      models or 4-parameter Richards models and saves in objects pnmodelparams


      and pnmodelparamsbounds. (required prior to use of the above functions)


        

change.pnparameters

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
      


      simple function to update pnmodelparams and pnmodelparamsbounds


      with user specified values


        

extraF

1
2
3
4
      performs extra sum-of-squares F test for two nested nlsList models


        

extaF.nls

1
2
3
4
      performs extra sum-of-squares F test for two nested nls models


        
Package: FlexParamCurve
Title: Tools to Fit Flexible Parametric Curves
Version: 1.5-2
Date: 2015-03-31
Author: Stephen Oswald [aut, cre]
Maintainer: Stephen Oswald <steve.oswald@psu.edu>
License: GPL-2
Depends: nlme
LazyLoad: yes

Note

Version 1.5 saves many variables, and internal variables in the package environment:

FlexParamCurve:::FPCEnv. By default, the pn.options file is copied to the environment

specified by the functions (global environment by default). Model selection routines

also copy from FPCenv to the global environment all nlsList models fitted during

model selection to provide backcompatibility with code for earlier versions. The user

can redirect the directory to copy to by altering the Envir argument when calling the

function.

Author(s)

Stephen Oswald <steve.oswald@psu.edu>

References

## Oswald, S.A. et al. 2012. FlexParamCurve: R package for flexible

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
     fitting of nonlinear parametric curves. Methods in Ecology and Evolution. 3(6): 1073-77.


     doi: 10.1111/j.2041-210X.2012.00231.x (see also tutorial and introductory videos at:


     http://www.methodsinecologyandevolution.org/view/0/podcasts.html 


     posted September 2012 - if no longer at this link, check the archived videos at:


     http://www.methodsinecologyandevolution.org/view/0/VideoPodcastArchive.html#allcontent)


                      

See Also

nlme

SSlogis

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#Code is provided here for an illustrative overview of using FlexParamCurve to select,  


# fit, analyze and plot the most appropriate non-linear curves for a dataset.


# NOTE: autorun is disabled for these examples since more detailed examples are provided for the 


# individual functions in their associated help files and runtime for this overview approximates 


# 5 mins. To run, simply copy and paste code from this help file into the R GUI.





# run all-model selection for posneg.data object (Step 2) without need to run any previous functions


## Not run:   


    modseltable <- pn.mod.compare(posneg.data$age, posneg.data$mass,


    posneg.data$id, existing = FALSE, pn.options = "myoptions")
## End(Not run)





# run backwards stepwise model selection (Step 2) for logist.data object


#without need to run any previous functions


## Not run:   


    modseltable <- pn.modselect.step(logist.data$age, logist.data$mass,


    logist.data$id, existing = FALSE, pn.options = "myoptions")
## End(Not run)





# estimate fixed parameters use data object posneg.data (Step 1)


## Not run:   


     modpar(posneg.data$age,posneg.data$mass, pn.options = "myoptions")
## End(Not run)





# change fixed values of M and constrain hatching mass to 45.5 in a growth curve (Step 1)


## Not run:   


      change.pnparameters(M=1,RM=0.5,first.y=45.5, pn.options = "myoptions")
## End(Not run)


    


# fit nlsList object using 6 parameter model with values M and RM (Step 3)


# fixed to value in pnmodelparams and then fit nlme model


## Not run:   


richardsR22.lis <- nlsList(mass ~ SSposnegRichards(age, Asym = Asym, K = K,


      Infl = Infl, RAsym = RAsym, Rk = Rk, Ri = Ri,


      modno = 22, pn.options = "myoptions"), data = posneg.data)


richardsR22.nlme <- nlme(richardsR22.lis, random = pdDiag(Asym + Infl ~ 1))
## End(Not run)


 


# fit reduced nlsList model and then compare performance with extraF (manual version of Step 2)


## Not run:   


 richardsR20.lis <- nlsList(mass ~ SSposnegRichards(age, Asym = Asym, K = K,


      Infl = Infl, modno = 20, pn.options = "myoptions"), data = posneg.data)


 extraF(richardsR20.lis,richardsR22.lis)
## End(Not run)


 


# fit and plot a logistic curve (M=1) to data, note - all parameters set to 1 are ignored


# note code here forces \eqn{modpar} to only estimate 4 curve parameters (simple Richards curve)


#create list for fixed parameters


## Not run:   


modpar(logist.data$age,logist.data$mass,force4par=TRUE, pn.options = "myoptions")


change.pnparameters(M=1, pn.options = "myoptions") # set M to 1 for subsequent fit


richardsR20.nls <- nls(mass ~ SSposnegRichards(age, Asym = Asym, K = K,


      Infl = Infl, modno = 20, pn.options = "myoptions"), data = logist.data)


plot(logist.data$age , logist.data$mass, xlab = "age", ylab = "mass", pch = ".", cex = 0.7) 


par <- coef( richardsR20.nls )
## End(Not run)





#(Step 4)


## Not run:   


curve(posnegRichards.eqn(x, Asym = par[1], K = par[2], Infl = par[3], modno = 20


, pn.options = "myoptions"), add= TRUE)
## End(Not run)

FlexParamCurve documentation built on May 1, 2019, 11:36 p.m.