Title: | Fiber Length Determination |
---|---|
Description: | Routines for estimating tree fiber (tracheid) length distributions in the standing tree based on increment core samples. Two types of data can be used with the package, increment core data measured by means of an optical fiber analyzer (OFA), e.g. such as the Kajaani Fiber Lab, or measured by microscopy. Increment core data analyzed by OFAs consist of the cell lengths of both cut and uncut fibres (tracheids) and fines (such as ray parenchyma cells) without being able to identify which cells are cut or if they are fines or fibres. The microscopy measured data consist of the observed lengths of the uncut fibres in the increment core. A censored version of a mixture of the fine and fiber length distributions is proposed to fit the OFA data, under distributional assumptions (Svensson et al., 2006) <doi:10.1111/j.1467-9469.2006.00501.x>. The package offers two choices for the assumptions of the underlying density functions of the true fiber (fine) lenghts of those fibers (fines) that at least partially appear in the increment core, being the generalized gamma and the log normal densities. |
Authors: | Natalya Pya Arnqvist[aut, cre], Sara Sjöstedt de Luna [aut], Konrad Abramowicz [aut] |
Maintainer: | Natalya Pya Arnqvist <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1-8 |
Built: | 2024-12-13 06:32:10 UTC |
Source: | CRAN |
fiberLD
provides functions for estimating tree fiber (tracheid) length distributions in the standing tree based on increment core samples. Two types of data can be used with the package, increment core data measured by means of an optical fiber analyzer (OFA), e.g. such as the Kajaani Fiber Lab, or measured by microscopy. Increment core data analyzed by OFAs consist of the cell lengths of both cut and uncut fibres (tracheids) and fines (such as ray parenchyma cells) without being able to identify which cells are cut or if they are fines or fibres. The microscopy measured data consist of the observed lengths of the uncut fibres in the increment core.
A censored version of a mixture of the fine and fiber length distributions is proposed to fit the OFA data, under distributional assumptions. The package offers two choices for the assumptions of the underlying density functions of the true fiber (fine) lenghts of those fibers (fines) that at least partially appear in the increment core, being the generalized gamma and the log normal densities.
Maximum likelihood estimation is used for estimating the model parameters for both the OFA analyzed data and the microscopy measured data. In addition a stochastic version of the expectation-maximization method is provided to fit the log normal model to the increment core data analyzed by OFAs. Details about methods and data can be found in references.
Package: | fiberLD |
Type: | Package |
License: | GPL (>= 2) |
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
Maintainer: Natalya Pya Arnqvist<[email protected]>
Svensson, I., Sjöstedt de Luna, S., Bondesson, L. (2006). Estimation of wood fibre length distributions from censored data through an EM algorithm. Scandinavian Journal of Statistics, 33(3), 503–522.
Chen, Z. Q., Abramowicz, K., Raczkowski, R., Ganea, S., Wu, H. X., Lundqvist, S. O., Mörling, T., Sjöstedt de Luna, S., Gil, M.R.G., Mellerowicz, E. J. (2016). Method for accurate fiber length determination from increment cores for large-scale population analyses in Norway spruce. Holzforschung. Volume 70(9), 829–838.
Functions to get values of the density functions of the fiber length on three different scales: as observed in the increment core corresponding to cut and uncut fiber lengths in the core (dx.fibers
), as true fiber lengths of the fibres that at least partially appear in the increment core (dy.fibers
) and as the true fiber lengths in the standing tree (dw.fibers
).
dx.fibers(x, par, r, model="ggamma") dy.fibers(x, par, model="ggamma") dw.fibers(x, par, r, model="ggamma")
dx.fibers(x, par, r, model="ggamma") dy.fibers(x, par, model="ggamma") dw.fibers(x, par, r, model="ggamma")
x |
vector of fiber lengths |
par |
vector of parameters for fiber length distribution |
r |
radius of the increment core |
model |
either |
returns a vector of density values
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
dx.mixture
, dy.mixture
, dw.mixture
library(fiberLD) r <- 2.5 par <- c(1.8,2.7,2.6) x <- seq(.01, 2*r-.01,length=100) f1 <- dy.fibers(x, par) plot(x,f1,type="l") f2 <- dx.fibers(x, par, r) f3 <- dw.fibers(x, par, r) ## the same functions can be used for plotting fine densities... par.fines <- c(-2, .5) x <- seq(0, 2,length=100) f1.fines <- dy.fibers(x, par.fines, model="lognorm") plot(x,f1.fines,type="l") ## getting the distribution in the tree that goes beyond the length ## of the diameter, 2r ... w <- seq(0,8,length=200) f5 <- dw.fibers(w,par,r) ## fiber density in the tree par.fines <- c(.06,1.5,3.3) f2.fines <- dw.fibers(w, par.fines,r) par(mfrow=c(1,2)) plot(w,f5,type="l", main="fiber density") plot(w,f2.fines,type="l", main="fine density")
library(fiberLD) r <- 2.5 par <- c(1.8,2.7,2.6) x <- seq(.01, 2*r-.01,length=100) f1 <- dy.fibers(x, par) plot(x,f1,type="l") f2 <- dx.fibers(x, par, r) f3 <- dw.fibers(x, par, r) ## the same functions can be used for plotting fine densities... par.fines <- c(-2, .5) x <- seq(0, 2,length=100) f1.fines <- dy.fibers(x, par.fines, model="lognorm") plot(x,f1.fines,type="l") ## getting the distribution in the tree that goes beyond the length ## of the diameter, 2r ... w <- seq(0,8,length=200) f5 <- dw.fibers(w,par,r) ## fiber density in the tree par.fines <- c(.06,1.5,3.3) f2.fines <- dw.fibers(w, par.fines,r) par(mfrow=c(1,2)) plot(w,f5,type="l", main="fiber density") plot(w,f2.fines,type="l", main="fine density")
Functions to get values of the density functions of the fiber length on three different scales based on microscopy data, being the uncut fibres in the core: the uncut fibres in the increment core (dx.fibers.micro
), as true fiber lengths of those fibres that at least partially appears in the increment core (dy.fibers.micro
) and as the true fiber lengths in the standing tree (dw.fibers.micro
).
dx.fibers.micro(x, par, r, model="ggamma") dy.fibers.micro(x, par, model="ggamma") dw.fibers.micro(x, par, r, model="ggamma")
dx.fibers.micro(x, par, r, model="ggamma") dy.fibers.micro(x, par, model="ggamma") dw.fibers.micro(x, par, r, model="ggamma")
x |
vector of fiber length |
par |
vector of parameters for fiber length distribution |
r |
radius of the increment core |
model |
either |
returns a vector of density values
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
library(fiberLD) r <- 2.5 par <- c(1.8,2.7,2.6) x <- seq(.01, 2*r-.01,length=100) f1 <- dy.fibers.micro(x, par) plot(x,f1,type="l") f2 <- dx.fibers.micro(x, par, r) ## getting the density in the tree that goes beyond the length ## of the diameter, 2r,... w <- seq(0,8,length=200) f3 <- dw.fibers.micro(w, par, r) plot(w,f3,type="l")
library(fiberLD) r <- 2.5 par <- c(1.8,2.7,2.6) x <- seq(.01, 2*r-.01,length=100) f1 <- dy.fibers.micro(x, par) plot(x,f1,type="l") f2 <- dx.fibers.micro(x, par, r) ## getting the density in the tree that goes beyond the length ## of the diameter, 2r,... w <- seq(0,8,length=200) f3 <- dw.fibers.micro(w, par, r) plot(w,f3,type="l")
Functions to get values of the mixture density functions of the cell lengths on three different scales: as observed in the increment core, i.e. cut or uncut fibers or fines (dx.mixture
), as true cell lengths (fibers or fines) that at least partially appears in the increment core (dy.mixture
) and as the true cell lengths (fines or fibres) in the standing tree (dw.mixture
).
dx.mixture(x, par, r, model="ggamma") dy.mixture(x, par, model="ggamma") dw.mixture(x, par, r, model="ggamma")
dx.mixture(x, par, r, model="ggamma") dy.mixture(x, par, model="ggamma") dw.mixture(x, par, r, model="ggamma")
x |
vector of cell length values |
par |
vector of mixture model parameters |
r |
radius of the increment core |
model |
either |
returns a vector of density values
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
dx.fibers
, dy.fibers
, dw.fibers
## Not run: library(fiberLD) data(ofa) r <- 2.5 d <- fled(data=ofa,model="lognorm",r=r) x <- seq(0, 8,length=100) f1 <- dx.mixture(x=x, par=d$par,r=r, model="lognorm") plot(x,f1,type="l") w <- seq(0, 2*r+2,length=150) f2 <- dy.mixture(w, d$par, model="lognorm") f3 <- dw.mixture(w, d$par, 6, model="lognorm") plot(w,f3,type="l") ## End(Not run)
## Not run: library(fiberLD) data(ofa) r <- 2.5 d <- fled(data=ofa,model="lognorm",r=r) x <- seq(0, 8,length=100) f1 <- dx.mixture(x=x, par=d$par,r=r, model="lognorm") plot(x,f1,type="l") w <- seq(0, 2*r+2,length=150) f2 <- dy.mixture(w, d$par, model="lognorm") f3 <- dw.mixture(w, d$par, 6, model="lognorm") plot(w,f3,type="l") ## End(Not run)
This function estimates fiber (tracheid) and fine (e.g. ray parenchyma cells and other small particles) lengths distribution in standing trees based on increment cores (cylindric wood samples). The data from the increment cores contain uncut fiber, fibers cut once or twice (cut by the borer) as well as non-fiber cells so-called 'fines'. A censored version of a mixture of the fine and fiber length distributions is therefore proposed to fit the data. The function offers two choices for the underlying density functions of the true unobserved uncut lengths of the fines and fibers in the increment core such as generalized gamma and log normal densities. The parameters of the mixture models are estimated by log likelihood maximization. The routine calls an optim()
or nlm()
functions for optimization procedure with the possibility to use a supplied gradient function. Some parameters of the generalized gamma mixture model can be fixed (rather than estimated) at the given values.
fled(data=stop("No data supplied"), data.type="ofa", r=2.5, model="ggamma", method="ML", parStart=NULL, fixed=NULL, optimizer=c("optim","L-BFGS-B","grad"),lower=-Inf,upper=Inf,cluster=1,...)
fled(data=stop("No data supplied"), data.type="ofa", r=2.5, model="ggamma", method="ML", parStart=NULL, fixed=NULL, optimizer=c("optim","L-BFGS-B","grad"),lower=-Inf,upper=Inf,cluster=1,...)
data |
A numeric vector of cell lengths from increment cores. |
data.type |
type of data supplied: ”ofa” (default) measured by an optical fiber analyser, or measured by ”microscopy” (only the lengths of uncut fibers in the core). |
r |
radius of the increment core (default 2.5). |
model |
if |
method |
either |
parStart |
numerical vector of starting values of parameters (or fixed values for ggamma model when
The parameter values of the log normal model are in the order
|
fixed |
TRUE/FALSE vector of seven components used to tell which parameters of ggamma model to fix. These are fixed at the values given in the argument |
optimizer |
numerical optimization method used to minimize 'minus' the loglikelihood function of the observed data: 'optim', 'nlm' or 'nlm.fd' (nlm is based on finite-difference approximation of the derivatives). If optimizer==”optim” then the second argument specifies the numerical method to be used in 'optim' (”Nelder-Mead”, ”BFGS”, ”CG”, ”L-BFGS-B”, ”SANN”. The third element of
|
lower , upper
|
Bounds on the parameters for the "L-BFGS-B" method. The order of the bounds values has to be the same as the order of the |
cluster |
either '0' for no parallel computing to be used; or '1' (default) for one less than
the number of cores; or user-supplied cluster on which to do estimation. |
... |
Further arguments to be passed to |
The probability density function of the three-parameter generalized gamma distribution proposed by Stacy (1962) can be written as
where ,
,
,
and
.
The probability density function of the log normal distribution can be written as
where and
.
cov.par |
approximate covariance matrix of the estimated parameters. |
cov.logpar |
approximate covariance matrix of the transformed estimated parameters. |
loglik |
the log likelihood value corresponding to the estimated parameters. |
model |
model used |
mu.fibers |
estimated mean value of the fiber lengths in the standing tree. |
mu.fines |
estimated mean value of the fine lengths in the standing tree. |
mu.cell |
estimated mean value of the cell lengths in the standing tree. |
prop.fines |
estimated proportion of fines in the standing tree. |
par |
the estimated parameters on the original scale. |
logpar |
the estimated values of the transformed parameters. |
termcode |
an integer indicating why the optimization process terminated (see |
conv |
indicates why the optimization algorithm terminated. |
iterations |
number of iterations of the optimization method taken to get convergence. |
fixed |
TRUE/FALSE vector denoting if a parameter of ggamma model is fixed or not. |
n |
number of observations |
Fixing the parameters with the generalized gamma model may lead to unstable results of the optim method.
The idea and some of the code for fixing parameters with optim()
is due to Barry Rowlingson, October 2011.
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
Svensson, I., Sjöstedt de Luna, S., Bondesson, L. (2006). Estimation of wood fibre length distributions from censored data through an EM algorithm. Scandinavian Journal of Statistics, 33(3), 503–522.
Chen, Z. Q., Abramowicz, K., Raczkowski, R., Ganea, S., Wu, H. X., Lundqvist, S. O., Mörling, T., Sjöstedt de Luna, S., Gil, M.R.G., Mellerowicz, E. J. (2016). Method for accurate fiber length determination from increment cores for large-scale population analyses in Norway spruce. Holzforschung. Volume 70(9), 829–838.
Stacy, E. W. (1962). A generalization of the gamma distribution. Annals of Mathematical Statistics, 33(3), 1187–1192.
library(fiberLD) ## using microscopy data (uncut fiber lengths in the increment core) data(microscopy) dat <- microscopy[1:200] m1 <- fled(data=dat,data.type="microscopy",model="ggamma",r=2.5) summary(m1) plot(m1) ## and with log normal model... m2 <- fled(data=dat,data.type="microscopy",model="lognorm",r=2.5) summary(m2) plot(m2) ## Not run: ## using data measured by an optical fiber analyser data(ofa) d1 <- fled(data=ofa,model="lognorm",r=2.5) summary(d1) plot(d1) x11() plot(d1,select=2,density.scale="uncut.core") ## change the model to generalized gamma ## and set lower and upper bounds on the parameters for ## the "L-BFGS-B" method ... d2 <- fled(data=ofa,model="ggamma",r=2.5,lower=c(.12,1e-3,.05,rep(.3,4)), upper=c(.5,2,rep(7,5)),cluster=1) d2 summary(d2) plot(d2,select=1) ## change "ML" default method to a stochastic version of the EM algorithm... d3 <- fled(data=ofa,model="lognorm",r=2.5,method="SEM",cluster=0) d3 ## End(Not run)
library(fiberLD) ## using microscopy data (uncut fiber lengths in the increment core) data(microscopy) dat <- microscopy[1:200] m1 <- fled(data=dat,data.type="microscopy",model="ggamma",r=2.5) summary(m1) plot(m1) ## and with log normal model... m2 <- fled(data=dat,data.type="microscopy",model="lognorm",r=2.5) summary(m2) plot(m2) ## Not run: ## using data measured by an optical fiber analyser data(ofa) d1 <- fled(data=ofa,model="lognorm",r=2.5) summary(d1) plot(d1) x11() plot(d1,select=2,density.scale="uncut.core") ## change the model to generalized gamma ## and set lower and upper bounds on the parameters for ## the "L-BFGS-B" method ... d2 <- fled(data=ofa,model="ggamma",r=2.5,lower=c(.12,1e-3,.05,rep(.3,4)), upper=c(.5,2,rep(7,5)),cluster=1) d2 summary(d2) plot(d2,select=1) ## change "ML" default method to a stochastic version of the EM algorithm... d3 <- fled(data=ofa,model="lognorm",r=2.5,method="SEM",cluster=0) d3 ## End(Not run)
Simulated data of lengths of uncut fibers in the increment core (as measured by microscopy), under the assumption that the true lengths of those fibers that at least partially appear in the increment core follow a generalized gamma distribution with parameters par=c(2.4, 3.3, 1.5)
.
Useful for illustrating the use of fled()
.
data(microscopy)
data(microscopy)
microscopy
is a vector of 300 fiber lengths simulated from the density
dx.fibers.micro(x, par, r=2.5, model="ggamma")
with parameters par=c(2.4, 3.3, 1.5)
Simulated data of cell lengths of both cut and uncut fines and fibres from an increment core (as measured by means of an optical fiber analyzer). The data were simulated from a censored version of a mixture of the fine and fiber length distributions under the assumption that the true lengths of those cells (fines and fibers) that at least partially appear in the increment core follow generalized gamma distributions. Useful for illustrating the use of fled()
. The values of the parameters of the mixture density are par=c(0.32, 0.001, 0.2757,5.022, 2.4, 3.3, 1.5)
, and the radius of the core is r=2.5mm
.
data(ofa)
data(ofa)
ofa
is a vector of 3000 cell lengths simulated from the density
dx.mixture(x, par, r=2.5, model="ggamma")
with parameters
par=c(0.32, 0.001, 0.2757, 5.022, 2.4, 3.3, 1.5)
.
Svensson, I., Sjöstedt de Luna, S., Bondesson, L. (2006). Estimation of wood fibre length distributions from censored data through an EM algorithm. Scandinavian Journal of Statistics, 33(3), 503–522.
The function
takes a fled
object produced by fled()
and creates several density plots. When the data consists of cell lengths from the increment core measured by an optical fiber analyzer ("ofa"), the function creates a histogram of the given data values together with the estimated density of the mixture model and two separate plots of the estimated fiber and fine lengths densities in the standing tree. With a microscopy sample (consisting of the lengths of uncut fibers in the increment core) the function creates two plots, a histogram of the given data with the estimated density of lenghts of the uncut fibers in the increment core and the estimated fiber length density in the standing tree.
## S3 method for class 'fled' plot(x,select=NULL, density.scale="tree", rvec=NULL, xlab=NULL, ylab=NULL, main=NULL, col=4, lwd=2, ...)
## S3 method for class 'fled' plot(x,select=NULL, density.scale="tree", rvec=NULL, xlab=NULL, ylab=NULL, main=NULL, col=4, lwd=2, ...)
x |
a |
select |
allows one plot to be selected for printing. e.g., if you just want the plot for the fiber length density set |
density.scale |
one of three options which define the scale on which the fiber/fine length densities should be plotted: "tree" (default) plots the estimated densities of the fiber/fine lengths in the tree, "uncut.core" plots densities of cell lengths of those cells that at least partially appear in the increment core, "core" plots densities of the observed (cut or uncut) cell lengths in the increment core |
rvec |
values of cell lengths used to get estimates of densities. |
xlab |
If supplied then this will be used as the x label for all plots. |
ylab |
If supplied then this will be used as the y label for all plots. |
main |
Used as title for plots if supplied. |
col |
defines the color used for density plotting. |
lwd |
defines the line width. |
... |
other graphics parameters to pass on to plotting commands. |
The function generates plots.
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
Svensson, I., Sjöstedt de Luna, S., Bondesson, L. (2006). Estimation of wood fibre length distributions from censored data through an EM algorithm. Scandinavian Journal of Statistics, 33(3), 503–522.
Chen, Z. Q., Abramowicz, K., Raczkowski, R., Ganea, S., Wu, H. X., Lundqvist, S. O., Mörling, T., Sjöstedt de Luna, S., Gil, M.R.G., Mellerowicz, E. J. (2016). Method for accurate fiber length determination from increment cores for large-scale population analyses in Norway spruce. Holzforschung. Volume 70(9), 829–838.
## see ?fled help files
## see ?fled help files
The default print method for a fled
object.
## S3 method for class 'fled' print(x,digits = max(3, getOption("digits") - 3),...)
## S3 method for class 'fled' print(x,digits = max(3, getOption("digits") - 3),...)
x , ...
|
fitted model objects of class |
digits |
controls the number of digits printed in the output. |
Prints the model, type of data, estimated model parameters, optimized value of the minus log likelihood and number of observations supplied.
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
Takes a fled
object produced by fled()
and produces various useful
summaries from it.
## S3 method for class 'fled' summary(object,...) ## S3 method for class 'summary.fled' print(x,digits = max(3, getOption("digits") - 3),...)
## S3 method for class 'fled' summary(object,...) ## S3 method for class 'summary.fled' print(x,digits = max(3, getOption("digits") - 3),...)
object |
a fitted |
x |
a |
digits |
controls the number of digits printed in the output. |
... |
other arguments. |
summary.fled
produces the following list of summary information for a fled
object.
fixed |
is a logical vector for any model parameters that are fixed |
n |
number of observations |
loglik |
minimized minus log likelihood for the model |
model |
the model used |
method |
'ML' method used |
data.type |
type of data used |
conv |
indicates why the optimization algorithm terminated |
p.table |
table of model parameters |
ss.table |
table of summary statistics for cell lengths in the increment core |
w.fine |
table of summary statistics for fine lengths in the standing tree |
w.fiber |
table of summary statistics for fiber lengths in the standing tree |
mean.w |
expected value of the cell lengths in the standing tree |
eps.tree |
proportion of fines in the standing tree |
se.eps.tree |
standard error of eps.tree |
Sara Sjöstedt de Luna, Konrad Abramowicz, Natalya Pya Arnqvist
Svensson, I., Sjöstedt de Luna, S., Bondesson, L. (2006). Estimation of wood fibre length distributions from censored data through an EM algorithm. Scandinavian Journal of Statistics, 33(3), 503–522.
Chen, Z. Q., Abramowicz, K., Raczkowski, R., Ganea, S., Wu, H. X., Lundqvist, S. O., Mörling, T., Sjöstedt de Luna, S., Gil, M.R.G., Mellerowicz, E. J. (2016). Method for accurate fiber length determination from increment cores for large-scale population analyses in Norway spruce. Holzforschung. Volume 70(9), 829–838.
## see ?fled help files
## see ?fled help files