Last data update: 2014.03.03

R: Function to coerce growth or survival objects, i.e., impose...
coerceGrowthObjR Documentation

Function to coerce growth or survival objects, i.e., impose user-defined parameters

Description

Supplied with a growth and survival object, over-writes coefficients, and for growth, the sd of growth

Usage


coerceGrowthObj(growthObj, coeff, sd)
coerceSurvObj(survObj,coeff)

Arguments

growthObj

an object of class growthObj

survObj

an object of class survObj

coeff

a numeric vector

sd

a numeric vector of length 1

Details

These functions can be used to impose coefficients and sd on growth and survival objects where direct fitting is not desired

Value

an object of class growthObj / survObj

Author(s)

C. Jessica E. Metcalf, Sean M. McMahon, Roberto Salguero-Gomez, Eelke Jongejans & Cory Merow.

See Also

makeSurvObj, makeGrowthObj

Examples

dff<-generateData()

#for growth
gr1 <- makeGrowthObj(dataf=dff,
Formula=sizeNext~size,regType="constantVar")

#halve the slope
gr2 <- coerceGrowthObj(gr1,coeff=c(gr1@fit$coefficients[1],
    gr1@fit$coefficients[2]*0.5),
    sd=gr1@sd)

par(mfrow=c(1,2),pty="s")
picGrow(dff,gr1)
picGrow(dff,gr2)

#for survival
sv1 <- makeSurvObj(dataf=dff,
Formula=surv~size)

#halve the slope
sv2 <- coerceSurvObj(sv1,coeff=c(sv1@fit$coefficients[1],
    sv1@fit$coefficients[2]*0.5))

par(mfrow=c(1,2),pty="s")
picSurv(dff,sv1)
picSurv(dff,sv2)


Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(IPMpack)
Loading required package: Matrix
Loading required package: MASS
Loading required package: nlme
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IPMpack/coerceGrowthObj.Rd_%03d_medium.png", width=480, height=480)
> ### Name: coerceGrowthObj
> ### Title: Function to coerce growth or survival objects, i.e., impose
> ###   user-defined parameters
> ### Aliases: coerceGrowthObj coerceSurvObj
> 
> ### ** Examples
> 
> dff<-generateData()
> 
> #for growth
> gr1 <- makeGrowthObj(dataf=dff,
+ Formula=sizeNext~size,regType="constantVar")
> 
> #halve the slope
> gr2 <- coerceGrowthObj(gr1,coeff=c(gr1@fit$coefficients[1],
+     gr1@fit$coefficients[2]*0.5),
+     sd=gr1@sd)
> 
> par(mfrow=c(1,2),pty="s")
> picGrow(dff,gr1)
> picGrow(dff,gr2)
> 
> #for survival
> sv1 <- makeSurvObj(dataf=dff,
+ Formula=surv~size)
> 
> #halve the slope
> sv2 <- coerceSurvObj(sv1,coeff=c(sv1@fit$coefficients[1],
+     sv1@fit$coefficients[2]*0.5))
> 
> par(mfrow=c(1,2),pty="s")
> picSurv(dff,sv1)
> picSurv(dff,sv2)
> 
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>