Topic: Growth

Topic Description:

Functions for analyzing tree growth, designed for the standard CTFS R Analytical Tables.



File: growth/growthfit.bin.r

View File Source Download File No help file available

Function: run.growthbin.manyspp

Function Description: run.growthbin.manyspp

Run the model to fit growth rate in bins for many species, 1-4 bins. It takes a list of species, extracts growth rates for each, one at a time, from the table of growth rates, then calls run.growthfit.bin to fit the model for the 4 bin options. Sample species vector from BCI:

Function Arguments:

ArgumentDefault Value
growthdata
size'dbh'
sppspp20
minabund30015
minTotal40
dbhunit'mm'
sdmodellinear.model.ctr
c(.03,.005)
startsdparc(.04,0)
badsdfuncNULL
binoption1:4
noreps5000
noburn2500
noshow500
'linear.fit'
path''
...

Sample Usage:

spp20=c('tri2tu','alsebl','tet2pa','tachve','beilpe','pri2co','quaras','ocotwh','hirttr','gar2in','protpa','protte', 'eugeoe','virose','guargu','maquco','jac1co','cecrin','cordbi','micoar')
Creating the complete table of biomass growth for all individuals in a plot:
agb.growth=extract.growthdata(bci.full5,bci.full6,growthfunc=growth.biomass.indiv,logit='x',
rounddown = FALSE,mindbh = 100,dbhunit = 'mm',err.limit = 4,maxgrow = 75)
Creating a vector of all species names in the agb.growth table.
allspecies=sort(unique(agb.growth$sp))
Fitting the model for all species, 1-4 bins:
fit=run.growthbin.manyspp(growthdata=agb.growth,size='agb',spp=allspecies,minabund300=15,minTotal=40,startpar=c(.03,.005),startsdpar=c(.04,0))


Function Source:


run.growthbin.manyspp=function(growthdata,size='dbh',spp=spp20,minabund300=15, minTotal=40, dbhunit=
        'mm', sdmodel=linear.model.ctr,
startpar=c(.03,.005), startsdpar=c(.04,0), badsdfunc=NULL, binoption=
        1:4, noreps=5000,noburn=2500,noshow=500, outputname='linear.fit',path='',...)
{
result=list()
on.exit(cat(onesp,'\n'))
outputfile=pst(path,outputname,'.rdata')

for(onesp in spp)
{
spdata=subset(growthdata,sp==onesp)
total=dim(spdata)[1]

if(dbhunit=='mm') nobig=dim(subset(spdata,dbh>=log(300)))[1]
else if(dbhunit=='cm') nobig=dim(subset(spdata,dbh>=log(30)))[1]

if(total>=minTotal & nobig>=minabund300)
{
result[[onesp]]=
run.growthfit.bin(growthdata=spdata,size=size,binoption=binoption,startpar=startpar,
sdmodel=sdmodel,startsdpar=startsdpar,badsdfunc=badsdfunc,
norep=noreps,noburn=noburn,noshow=noshow,...)

for(j in 1:length(result[[onesp]]))
result[[onesp]][[j]]$summary=list(dbhunit=dbhunit, totalsample=total, totalbig=nobig)
cat('Finished species ', onesp, ' with ', nobig, ' big trees\n')
}

assign(outputname,result)
save(list=outputname,file=outputfile)
}

return(result)
}