# Load a database
data(NouraguesHD)
data(KarnatakaForest)
# Modelling height-diameter relationship
HDmodel <- modelHD(D = NouraguesHD$D, H = NouraguesHD$H, method = "log2")
# Retrieving wood density values
# \donttest{
KarnatakaWD <- getWoodDensity(KarnatakaForest$genus, KarnatakaForest$species,
stand = KarnatakaForest$plotId
)
# }
# Propagating errors with a standard error in wood density in one plot
filt <- KarnatakaForest$plotId == "BSP20"
set.seed(10)
# \donttest{
resultMC <- AGBmonteCarlo(
D = KarnatakaForest$D[filt], WD = KarnatakaWD$meanWD[filt],
errWD = KarnatakaWD$sdWD[filt], HDmodel = HDmodel
)
str(resultMC)
# }
# If only the coordinates are available
lat <- KarnatakaForest$lat[filt]
long <- KarnatakaForest$long[filt]
coord <- cbind(long, lat)
# \donttest{
resultMC <- AGBmonteCarlo(
D = KarnatakaForest$D[filt], WD = KarnatakaWD$meanWD[filt],
errWD = KarnatakaWD$sdWD[filt], coord = coord
)
str(resultMC)
# }
# Propagating errors with a standard error in wood density in all plots at once
# \donttest{
KarnatakaForest$meanWD <- KarnatakaWD$meanWD
KarnatakaForest$sdWD <- KarnatakaWD$sdWD
resultMC <- by(
KarnatakaForest, KarnatakaForest$plotId,
function(x) AGBmonteCarlo(
D = x$D, WD = x$meanWD, errWD = x$sdWD,
HDmodel = HDmodel, Dpropag = "chave2004"
)
)
meanAGBperplot <- unlist(sapply(resultMC, "[", 1))
credperplot <- sapply(resultMC, "[", 4)
# }
Run the code above in your browser using DataLab