Learn R Programming

lmfor (version 1.2)

ddcomp: Evaluate the fit of a tree diameter distribution

Description

A function to compare the fit of the observed tree diameter data (d) to a specified diameter distribution (density).

Usage

ddcomp(d,density="dweibull",power=0,limits=seq(0,100),limitsd=limits,plot=FALSE,...)

Arguments

d

numeric vector of observed diameters

density

either a valid name for a probability density function in R or a vector of diameter class densities for diameter classes whose limits are given in vector limitsd

power

gives the weights (2 gives BA weight, 0 (default) the unweighted

limits

the diameter class limits to compute the error index

limitsd

see the description of argument density

plot

logical. Should a graph be produced to illustrate the ecdf of d and the cdf corresponding to density

...

additional arguments passed to function specified by a character-type density. e.g. Weibull shape and scale of if density="dweibull"

Value

A list of components

mudif

The difference in means

vardif

The difference in variances

sddif

The difference in standard deviations

errorindex

the error index (see details)

Details

The comparison is first done for mean, variance and standard deviation. Thereafter, a location switch and rescaling is done to the predicted density so that it has exactly same mean and variance as the given diameter data, but the shape is not changed. The shape is thereafter compared by computing the sum of absolute differences (error index) in densities for the observed data and rescaled density in diameter classes specified by "limits". The error index has therefore a value between 0 (complete match) and 2 (complete mismatch).

Examples

Run this code
# NOT RUN {
# Example 
# Observed diameters 
d<-c(18.8,24.2,18.7,13.0,18.9,22.4,17.6,22.0,18.8,22.9,
     16.7,13.7,20.6,15.1,31.8,17.2,19.6,16.8,19.3,27.4,
	 23.7,18.2,19.7,18.9,23.0,21.4,23.8,22.1,24.2,20.9)

# Weibull(5,20) distribution in 1 cm classes (class limits from 0,...,60)
f<-pweibull(1:60,5,20)-pweibull(0:59,5,20)

# compare using the classified true distribution (approximate)
ddcomp(d,density=f,limitsd=0:60,limits=0:100,plot=TRUE)

# compare b specifying a Weibull dsitribution (accurate)
ddcomp(d,density="dweibull",shape=5,scale=20,plot=TRUE)
# }

Run the code above in your browser using DataLab