Title: | Forest Growth Model Utilities |
---|---|
Description: | Growth models and forest production require existing data manipulation and the creation of new data, structured from basic forest inventory data. The purpose of this package is provide functions to support these activities. |
Authors: | Clayton Vieira Fraga Filho, Ana Paula Simiqueli, Gilson Fernandes da Silva, Miqueias Fernandes, Wagner Amorim da Silva Altoe |
Maintainer: | Clayton Vieira Fraga Filho <[email protected]> |
License: | GPL-2 |
Version: | 0.9.5 |
Built: | 2024-12-09 06:51:36 UTC |
Source: | CRAN |
take a data-frame and a vector and combine by columns, respectively.
add.col(dataf, vec, namevec)
add.col(dataf, vec, namevec)
dataf |
dataframe |
vec |
vector |
namevec |
the names of the columns of vector |
dataf dataframe combined with the vector
this function update certain fields in a dataframe, based on the provided key
atualizaCampoBase(camposAtualizar, baseAgrupada, baseAtualizar, keys, verbose = FALSE)
atualizaCampoBase(camposAtualizar, baseAgrupada, baseAtualizar, keys, verbose = FALSE)
camposAtualizar |
is the vector you want to update |
baseAgrupada |
It is the database that contains the data you want to update on dataframe |
baseAtualizar |
It is dataframe that you want to change fields |
keys |
are the keys of the table that will be used in the compare |
verbose |
default false |
baseAtualizar with the updated fields according to baseAgrupada
this function evaluates the quality of the adjustment of the statistical model, rom observed data and those estimated by the model, observed
avaliaAjuste(dataFrame, variavelObservados, variavelEstimados, linear = TRUE, nParametros = NA, intercepto = TRUE, plot = NA, modelo = NA, resumo = FALSE, emf = TRUE)
avaliaAjuste(dataFrame, variavelObservados, variavelEstimados, linear = TRUE, nParametros = NA, intercepto = TRUE, plot = NA, modelo = NA, resumo = FALSE, emf = TRUE)
dataFrame |
dataFrane with information observed, estimated |
variavelObservados |
vector of values observed. |
variavelEstimados |
vector of values estimated. |
linear |
boolean is linear model |
nParametros |
number of parameters used in the adjusted model |
intercepto |
if you model is no-intercepto use FALSE |
plot |
Vector graphic information |
modelo |
the name of the adjusted model |
resumo |
if you want summary information, use TRUE |
emf |
to save the graphic in the format emf use TRUE |
given a list of observations and an estimated list of these observations this function evaluates how close it is the estimated value of observed and saves the differences
avaliaEstimativas(observado, estimado, estatisticas, ajuste = NULL, graficos = NULL, salvarEm = NULL, nome = "observadoXestimado")
avaliaEstimativas(observado, estimado, estatisticas, ajuste = NULL, graficos = NULL, salvarEm = NULL, nome = "observadoXestimado")
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
estatisticas |
list of arg to calc estatistics |
ajuste |
is ajust obtained a function like lm or nlsLM |
graficos |
list of arg to plot graphics |
salvarEm |
directory to save files |
nome |
name of files will be save |
will be returned
this function evaluate volume based on ages
avaliaVolumeAgeBased(base, firstAge, lastAge, models, mapper = list(age1 = "idade1", age2 = "idade2", dap1 = "dap1", dap2 = "dap2", dap2est = "dap2est", ht1 = "ht1", ht2 = "ht2", ht2est = "ht2est", volume1 = "volume1", volume2 = "volume2", volume2est = "volume2est"), groupBy = "parcela", save = NULL, percTraining = 0.7, paramEstatisticsDAP, paramEstatisticsHT, paramEstatisticsVolume, plot = "parcela", ageER = "^.*_", ageRound = NaN, ageInYears = F, forcePredict = F)
avaliaVolumeAgeBased(base, firstAge, lastAge, models, mapper = list(age1 = "idade1", age2 = "idade2", dap1 = "dap1", dap2 = "dap2", dap2est = "dap2est", ht1 = "ht1", ht2 = "ht2", ht2est = "ht2est", volume1 = "volume1", volume2 = "volume2", volume2est = "volume2est"), groupBy = "parcela", save = NULL, percTraining = 0.7, paramEstatisticsDAP, paramEstatisticsHT, paramEstatisticsVolume, plot = "parcela", ageER = "^.*_", ageRound = NaN, ageInYears = F, forcePredict = F)
base |
the data base |
firstAge |
the first age to eval |
lastAge |
the last age to eval |
models |
list of exclusive for base models |
mapper |
mapper from labels of fields volume, dap, ht |
groupBy |
name field of base is group of individuals |
save |
list of param to save the files |
percTraining |
percentage that will be reserved for training (default 0.70) |
paramEstatisticsDAP |
parameters to pass to function 'fnAvaliaEstimativas' |
paramEstatisticsHT |
analogous to paramEstatisticsDAP |
paramEstatisticsVolume |
analogous to paramEstatisticsDAP |
plot |
is list of plots to function roundAges |
ageER |
regex used to discover age in names from dataframe in listOfdata |
ageRound |
synchronize begin of ages with an age? what age? |
ageInYears |
ages are in year? |
forcePredict |
force the calculation without using predict? |
will be returned a list of round ages
this function performs an assessment of estimates of a variable as the forcefulness with expected
avaliaVolumeAvancado(base, mapeamento = list(dap1 = "dap1", dap2 = "dap2", ht1 = "ht1", ht2 = "ht2"), modelos = NULL, salvar = NULL, graficos = NULL, estatisticas = NULL, forcePredict = F, dividirEm = "parcela", percentualDeTreino = 0.7, agruparPor = "parcela", fnCalculaVolume = calculaVolumeDefault)
avaliaVolumeAvancado(base, mapeamento = list(dap1 = "dap1", dap2 = "dap2", ht1 = "ht1", ht2 = "ht2"), modelos = NULL, salvar = NULL, graficos = NULL, estatisticas = NULL, forcePredict = F, dividirEm = "parcela", percentualDeTreino = 0.7, agruparPor = "parcela", fnCalculaVolume = calculaVolumeDefault)
base |
data.frame with data |
mapeamento |
name of field eight and diameter |
modelos |
list of exclusive for base models |
salvar |
list of param to save the files |
graficos |
list of param to plot graphics |
estatisticas |
list of param to caclc estatistics |
forcePredict |
force the calculation without using predict? |
dividirEm |
how divide the base in training and validation |
percentualDeTreino |
how many percent will stay in the training group? |
agruparPor |
name field of base is group of individuals |
fnCalculaVolume |
list of estatistics results |
will be returned a result of statistics and ranking of volume
In statistics, the bias (or bias function) of an estimator is the difference between this estimator's expected value and the true value of the parameter being estimated. An estimator or decision rule with zero bias is called unbiased. Otherwise the estimator is said to be biased.
bias(observados, estimados)
bias(observados, estimados)
observados |
vector of values observed. |
estimados |
vector of values estimated. |
bias = (sum(estimados-observados))/length(observados)
see https://en.wikipedia.org/wiki/Bias_of_an_estimator for more details.
The linear intercept model,
calculaA(n, k)
calculaA(n, k)
n |
the size of the vector of regression model data |
k |
is the number of model parameters |
a = (n-1)/(n-k-1)
With this function, you can calculate the ratio of one quantity or magnitude relative to another evaluated in percentage.
calculaPerc(valor, observados)
calculaPerc(valor, observados)
valor |
number amount you to know the percentage |
observados |
number relationship to which you want to calculate the percentage, if it is a vector of integers is calculated its average. |
calculaPerc = ((valor)/mean(observados))*100
this function calculates the volume based on the height and volume of literature of the equation
calculaVolumeDefault(ht, dap, ...)
calculaVolumeDefault(ht, dap, ...)
ht |
is list of height of individuals |
dap |
is list of diameter of individuals |
... |
only for compatibility with other functions |
will be returned a list of volume calc
Nash Sutcliffe 1970 model efficiency coefficient is used to assess the predictive power of hydrological models.
ce(observados, estimados)
ce(observados, estimados)
observados |
vector of values observed. |
estimados |
vector of regression model data. |
( Nash and Sutcliffe, 1970) https://en.wikipedia.org/wiki/Nash-Sutcliffe_model_efficiency_coefficient for more details.
checks if a variable is integer
check.integer(x)
check.integer(x)
x |
any variable |
TRUE if "x" is integer, FALSE if "x" not is interger
x = 5 check.integer(x)
x = 5 check.integer(x)
the center of the class that the DAP belongs.
classificaClasseDAP(dfClassesDAP, dap, getNhaClasse = FALSE, getNCLASSES = FALSE)
classificaClasseDAP(dfClassesDAP, dap, getNhaClasse = FALSE, getNCLASSES = FALSE)
dfClassesDAP |
a frequency distribution with the attributes $classe and $centro |
dap |
integer Diameter at breast height |
getNhaClasse |
get NhaClasse field of dfClassesDAP, default false |
getNCLASSES |
get NCLASSES field of dfClassesDAP, default false |
dados = defineClasses(1, 10, 2, getDataFrame = TRUE) classificaClasseDAP(dados,7)
dados = defineClasses(1, 10, 2, getDataFrame = TRUE) classificaClasseDAP(dados,7)
classify field dap as specified amplitude and includes a few fields
classificarDAP(inventario, amplitude = 1, verbose = FALSE)
classificarDAP(inventario, amplitude = 1, verbose = FALSE)
inventario |
the database to update |
amplitude |
it is amplitude of dap class |
verbose |
use TRUE to show status of process |
data.frame with classeDAP field and other
this function checks whether the labels of the parameters list to move to the functions is sufficient
contemParametros(funcoes, parametro, addParametro = c(), addArgs = c(), exclui3pontos = T)
contemParametros(funcoes, parametro, addParametro = c(), addArgs = c(), exclui3pontos = T)
funcoes |
is a or set of functions whose param will be verify |
parametro |
is list whose labels is name of param in funcoes, list of args to funcoes ex list(a="1", b="2") |
addParametro |
list of param included |
addArgs |
more param required |
exclui3pontos |
verify por ... ? in f<-function(a, ...) |
will be returned the parameters that have not been reported in parametro and addParametro
converts a column of a dataframe to String
converteCampoParaCharacter(nomeCampo, base)
converteCampoParaCharacter(nomeCampo, base)
nomeCampo |
the column name you want to convert |
base |
the column having dataFrame, that you want to convert to String |
base dataFrame with a column converted to String
measurement_date <- c(02/2009,02/2010,02/2011,02/2011) plot <- c(1,2,3,4) test <- data.frame(measurement_date,plot) converteCampoParaCharacter("measurement_date",test)
measurement_date <- c(02/2009,02/2010,02/2011,02/2011) plot <- c(1,2,3,4) test <- data.frame(measurement_date,plot) converteCampoParaCharacter("measurement_date",test)
paired a dataframe
criaDadosPareados(dataFrame, campoChave, campoComparacao, camposPareados, camposNaoPareados, progress = TRUE)
criaDadosPareados(dataFrame, campoChave, campoComparacao, camposPareados, camposNaoPareados, progress = TRUE)
dataFrame |
dataframe that you want to pair dataFrame must contain columns cod_id, ANO_MEDICAO1, ANO_MEDICAO2, DAP1, DAP2, HT1, HT2, ID_PROJETO |
campoChave |
character the column that will be paired |
campoComparacao |
character the field used to compare the period of change |
camposPareados |
vector the fields that will be paired exemple CampoesPareados=c(dap,ht) |
camposNaoPareados |
the fields he wants to be present without the paired |
progress |
if TRUE show a progress bar |
will be returned a dataframe containing columns cod_id, ANO_MEDICAO1, ANO_MEDICAO2, DAP1, DAP2, HT1, HT2, ID_PROJETO
this function returns a unique model is variable receive each mapeda variable ex .: criaModeloExclusivo (modeloCamposLeite, c ("age1", "age2", "bai1", "s"))
criaModeloExclusivo(modeloGenerico, variaveis, palpite = NULL)
criaModeloExclusivo(modeloGenerico, variaveis, palpite = NULL)
modeloGenerico |
model of pattern criaModeloGenerico |
variaveis |
list of name fields (strings) in database and model, the order of variables matter |
palpite |
string containing start values of function of regression |
will be returned a function with exclusive model
This function creates a generic model that will be a funcao that has parameters for the variables that can be mapped to each different base. her return will be a generic model that should be mapped to be used by the function avaliaEstimativas
criaModeloGenerico(nome, formula, funcaoRegressao, variaveis, palpite = NULL, maisParametros = NULL, requires = NULL)
criaModeloGenerico(nome, formula, funcaoRegressao, variaveis, palpite = NULL, maisParametros = NULL, requires = NULL)
nome |
is the name of model |
formula |
is the string formula begin with y2~y1 |
funcaoRegressao |
is the function that will make the regression, ex.: 'nlsLM' |
variaveis |
list variables that are present in the model that are field database |
palpite |
param start of funcaoRegressao |
maisParametros |
string add in funcaoRegressao, ex lm(y2~y1, data=base, maisParametros) |
requires |
list of string of packges used to work with funcaoRegressao |
will be returned function with generic model to map to a base
creates a list with the class interval of a frequency distribution
defineClasses(limiteMin, limiteMax, amplitude, decrescente = TRUE, getDataFrame = FALSE, verbose = FALSE)
defineClasses(limiteMin, limiteMax, amplitude, decrescente = TRUE, getDataFrame = FALSE, verbose = FALSE)
limiteMin |
the lowest list number |
limiteMax |
the largest number in the list |
amplitude |
List amplitude |
decrescente |
order by true decreasing , false increasing |
getDataFrame |
return a data.frame default false because old uses |
verbose |
show status default false |
creates a list with the class interval of a frequency distribution
defineClasses2(dados, amplitude)
defineClasses2(dados, amplitude)
dados |
a vector of numbers |
amplitude |
integer Class amplitude range |
dados <- c(1,2,3,4) defineClasses2(dados,2)
dados <- c(1,2,3,4) defineClasses2(dados,2)
this function returns a data.frame containing fields observado and estimado
estatisticas(observado, estimado, dfEstatisticas = NULL, ...)
estatisticas(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned a list with data.frame with observado and estimado fields and other with statictcs of model add
this function returns a data.frame containing fields bias
estatisticasBIAS(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasBIAS(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with bias
this function returns a data.frame containing fields biasPERCENTUAL
estatisticasBiasPERCENTUAL(observado, estimado, dfEstatisticas, ...)
estatisticasBiasPERCENTUAL(observado, estimado, dfEstatisticas, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame with field bias |
... |
only for compatibility with other functions |
will be returned data.frame with biasPERCENTUAL
this function returns a data.frame containing fields
estatisticasCE(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasCE(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with CE
this function returns a data.frame containing fields corr
estatisticasCORR(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasCORR(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with corr field
this function returns a data.frame containing fields corr_PERCENTUAL
estatisticasCorrPERCENTUAL(observado, estimado, dfEstatisticas, ...)
estatisticasCorrPERCENTUAL(observado, estimado, dfEstatisticas, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame with corr field |
... |
only for compatibility with other functions |
will be returned data.frame with corr_PERCENTUAL field
this function returns a data.frame containing fields cv
estatisticasCV(observado, estimado, ajuste = NULL, dfEstatisticas = NULL, baseDoAjuste = NULL, formulaDoAjuste = NULL, ...)
estatisticasCV(observado, estimado, ajuste = NULL, dfEstatisticas = NULL, baseDoAjuste = NULL, formulaDoAjuste = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
ajuste |
is ajust obtained a function like lm or nlsLM |
dfEstatisticas |
a data.frame |
baseDoAjuste |
data.frame optional |
formulaDoAjuste |
formula used in ajust |
... |
only for compatibility with other functions |
will be returned data.frame with cv
this function returns a data.frame containing fields cvPERCENTUAL
estatisticasCvPERCENTUAL(observado, estimado, dfEstatisticas, ...)
estatisticasCvPERCENTUAL(observado, estimado, dfEstatisticas, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame with cv field |
... |
only for compatibility with other functions |
will be returned data.frame with cvPERCENTUAL
this function returns a data.frame containing fields mae
estatisticasMAE(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasMAE(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with mae
this function returns a data.frame containing fields r2
estatisticasR2(observado, estimado, dfEstatisticas = NULL, ajuste = NULL, intercepto = TRUE, formulaDoAjuste = NULL, baseDoAjuste = NULL, ...)
estatisticasR2(observado, estimado, dfEstatisticas = NULL, ajuste = NULL, intercepto = TRUE, formulaDoAjuste = NULL, baseDoAjuste = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
ajuste |
is ajust obtained a function like lm or nlsLM |
intercepto |
intercepts? |
formulaDoAjuste |
formula used in ajust |
baseDoAjuste |
data.frame optional |
... |
only for compatibility with other functions |
will be returned data.frame with r2
this function returns a data.frame containing field residuoPERCENTUAL
estatisticasResiduoPERCENTUAL(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasResiduoPERCENTUAL(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame containing field residuo |
... |
only for compatibility with other functions |
will be returned data.frame with percent Residuals field
this function returns a data.frame containing field residuo
estatisticasResiduos(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasResiduos(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with Residuals field
this function returns a data.frame containing fields rmse
estatisticasRMSE(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasRMSE(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with RMSE calc
this function returns a data.frame containing fields rmsePERCENTUAL
estatisticasRmsePERCENTUAL(observado, estimado, dfEstatisticas, ...)
estatisticasRmsePERCENTUAL(observado, estimado, dfEstatisticas, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame containing field rmse |
... |
only for compatibility with other functions |
will be returned data.frame with rmse PERCENTUAL calc
this function returns a data.frame containing fields RRMSE
estatisticasRRMSE(observado, estimado, dfEstatisticas = NULL, ...)
estatisticasRRMSE(observado, estimado, dfEstatisticas = NULL, ...)
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
dfEstatisticas |
a data.frame |
... |
only for compatibility with other functions |
will be returned data.frame with rrmse
This function evaluates the volume of past data frames based on the parameter 'listOfdata'
evalAgeBased(listOfdata, mapper = list(volume2 = "volume2", volume2est = "volume2est", dap2 = "dap2", dap2est = "dap2est", ht2 = "ht2", ht2est = "ht2est"), fnAvaliaEstimativas = avaliaEstimativas, paramEstatisticsDAP, paramEstatisticsHT, paramEstatisticsVolume, titulos = "paste(\"Idade\", idade)", ageER = "^.*_", nameModel = NULL)
evalAgeBased(listOfdata, mapper = list(volume2 = "volume2", volume2est = "volume2est", dap2 = "dap2", dap2est = "dap2est", ht2 = "ht2", ht2est = "ht2est"), fnAvaliaEstimativas = avaliaEstimativas, paramEstatisticsDAP, paramEstatisticsHT, paramEstatisticsVolume, titulos = "paste(\"Idade\", idade)", ageER = "^.*_", nameModel = NULL)
listOfdata |
the list that contains the data frames predicts |
mapper |
mapper from labels of fields volume, dap, ht |
fnAvaliaEstimativas |
funcion to evaluate dataframes of listOfdata |
paramEstatisticsDAP |
parameters to pass to function 'fnAvaliaEstimativas' |
paramEstatisticsHT |
analogous to paramEstatisticsDAP |
paramEstatisticsVolume |
analogous to paramEstatisticsDAP |
titulos |
customize titles of grafics |
ageER |
regex used to discover age in names from dataframe in listOfdata |
nameModel |
name of model used to predict to generate listOfdata optional |
will be returned a list of round ages
The bias factor indicates the average of the observed values is above or below the equity line.
fator_bias(observados, estimados, n)
fator_bias(observados, estimados, n)
observados |
vector of values observed. |
estimados |
vector of values estimated. |
n |
the size of the vector of regression model data |
fator_bias = 10^(sum(log(estimados/observados)/n)) #' @references see https://www.sciencedirect.com/science/article/pii/S0165176599001949 for more details.
this function generates unique model given: A formula and a guess (optional: name, funcaoRegressao, maisParametros, requires - proidido: custom)] or[A string saying how the return will be obtained eg custom = "lm (dap2 dap1 ~ * b 0)" (if the formula can not be passed just go empty, ex .: formula = "")]
geraModelo(nome = "modelo sem nome", formula, funcaoRegressao = "nlsLM", palpite = NULL, maisParametros = NULL, requires = NULL, customizado = NULL)
geraModelo(nome = "modelo sem nome", formula, funcaoRegressao = "nlsLM", palpite = NULL, maisParametros = NULL, requires = NULL, customizado = NULL)
nome |
is the name of model |
formula |
is the string formula begin with y2~y1 |
funcaoRegressao |
is the function that will make the regression, ex.: 'nlsLM' |
palpite |
param start of funcaoRegressao |
maisParametros |
string add in funcaoRegressao, ex lm(y2~y1, data=base, maisParametros) |
requires |
list of string of packges used to work with funcaoRegressao |
customizado |
if you want to write as the return will be obtained report as a string |
will be returned a function with exclusive model
using column_name_measurement_date column in the form MM/YYYY creates a new column with the name "ANO_MEDICAO" in YYYY format
getAnoMedicao(dataFrame, column_name_measurement_date, column_name_plot)
getAnoMedicao(dataFrame, column_name_measurement_date, column_name_plot)
dataFrame |
that has the column DATE(MM/YYYY) and a ID column_name_plot |
column_name_measurement_date |
column with a date format |
column_name_plot |
a column of dataFrame, identification of plot (ID_plot) |
dataFrame dataframe that has columns column_name_measurement_date, column_name_plot, ANO_MEDICAO
column_name_measurement_date <- c("02/2009","02/2010","02/2011","02/2012") column_name_plot <- c(1,2,3,4) test <- data.frame(column_name_measurement_date,column_name_plot) getAnoMedicao(test,"column_name_measurement_date","column_name_plot")
column_name_measurement_date <- c("02/2009","02/2010","02/2011","02/2012") column_name_plot <- c(1,2,3,4) test <- data.frame(column_name_measurement_date,column_name_plot) getAnoMedicao(test,"column_name_measurement_date","column_name_plot")
this function returns the database used in the setting
getBaseOfAjust(ajuste)
getBaseOfAjust(ajuste)
ajuste |
is ajust obtained a function like lm or nlsLM |
will be returned a string which is the database of ajust
this function return a list of data.frame where each contains a number of dap classes according to reported basis
getClasses(base, amplitude, verbose = FALSE)
getClasses(base, amplitude, verbose = FALSE)
base |
the data.frame containing fields limiteMin, limiteMax of parcela and idadearred |
amplitude |
it is amplitude of dap class |
verbose |
use TRUE to show status of process |
list of data.frame
this function returns an array with the column names that are on the model and reported basis or basis used in ajust
getColumnsOfAjust(ajuste, dfDados = NULL, excludeY1andY2 = T)
getColumnsOfAjust(ajuste, dfDados = NULL, excludeY1andY2 = T)
ajuste |
is ajust obtained a function like lm or nlsLM |
dfDados |
data.frame optional |
excludeY1andY2 |
delete Y1 and Y2 fields? del formula(y1~y2...) |
will be returned list of columns used in ajust
this function returns the columns of a base whose names are present in the string strColumns
getColumnsOfBase(base, strColumns)
getColumnsOfBase(base, strColumns)
base |
data.frame |
strColumns |
string containing name fields of the base |
will be returned list with fields whose name are present in the string
this function returns the formula of the model used in ajust
getFormulaExclusivaOfAjust(ajuste)
getFormulaExclusivaOfAjust(ajuste)
ajuste |
is ajust obtained a function like lm or nlsLM |
will be returned a string which is the formula of ajust
this function displays/saves/returns a Graphical ggplot2 illustrating the difference between the observed and estimated
getggplot2GraphicObservadoXEstimado(titulo = "observadoXestimado", nome = "observadoXestimado", observado, estimado, identificadorIndividual = NULL, identificadorGrupal = NULL, showTestF = TRUE, TestFposition = 4, titleIdentificadorGrupal = NULL, save = NULL, labsX = "observado", labsy = "estimado", nomeParaExibir = NULL, environ = 1, extensao = ".png", ...)
getggplot2GraphicObservadoXEstimado(titulo = "observadoXestimado", nome = "observadoXestimado", observado, estimado, identificadorIndividual = NULL, identificadorGrupal = NULL, showTestF = TRUE, TestFposition = 4, titleIdentificadorGrupal = NULL, save = NULL, labsX = "observado", labsy = "estimado", nomeParaExibir = NULL, environ = 1, extensao = ".png", ...)
titulo |
is the title graphic |
nome |
name of file case save |
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
identificadorIndividual |
list containing 'id' of individuals |
identificadorGrupal |
list containing group of individuals |
showTestF |
draw results of test F in graphic? |
TestFposition |
show one of the four corners of the graph clockwise |
titleIdentificadorGrupal |
title of Legend of the groups |
save |
If you want to save enter the directory as a string |
labsX |
label x |
labsy |
label y |
nomeParaExibir |
This is the name to display the graph as a function after the completion of this |
environ |
environment in which the function to display the ggplot2 must be saved |
extensao |
type of image that will be saved |
... |
only for compatibility with other functions |
will be returned the graphical generated by ggplot2
this function displays/saves a histogram graph illustrating the frequency of waste in classes
getGraphicHistogram(titulo = "residuos", nome = "observadoXestimado", estatisticas, save = NULL, vetorial = T, ...)
getGraphicHistogram(titulo = "residuos", nome = "observadoXestimado", estatisticas, save = NULL, vetorial = T, ...)
titulo |
is the title graphic |
nome |
name of file case save |
estatisticas |
data.frame containing field 'residuo' |
save |
If you want to save enter the directory as a string |
vetorial |
save picture in vector type? (Default TRUE) |
... |
only for compatibility with other functions |
this function display/save a graphic scatter.smooth illustrating the difference between the observed and estimated
getGraphicObservadoXEstimado(titulo = "observadoXestimado", nome = "observadoXestimado", observado, estimado, showTestF = TRUE, save = NULL, labsX = "observado", labsy = "estimado", vetorial = T, ...)
getGraphicObservadoXEstimado(titulo = "observadoXestimado", nome = "observadoXestimado", observado, estimado, showTestF = TRUE, save = NULL, labsX = "observado", labsy = "estimado", vetorial = T, ...)
titulo |
is the title graphic |
nome |
name of file case save |
observado |
list containing the observations of variable |
estimado |
list containing estimates of variable |
showTestF |
draw results of test F in graphic? |
save |
If you want to save enter the directory as a string |
labsX |
label x |
labsy |
label y |
vetorial |
save picture in vector type? (Default TRUE) |
... |
only for compatibility with other functions |
this function displays/saves a graph illustrating the distribution scatter.smooth of residues
getGraphicResiduoAbs(titulo = "residuo absoluto", nome = "observadoXestimado", strVariavelXResiduo = NULL, estatisticas, save = NULL, labsX = "observacao", labsy = "residuos", vetorial = T, ...)
getGraphicResiduoAbs(titulo = "residuo absoluto", nome = "observadoXestimado", strVariavelXResiduo = NULL, estatisticas, save = NULL, labsX = "observacao", labsy = "residuos", vetorial = T, ...)
titulo |
is the title graphic |
nome |
name of file case save |
strVariavelXResiduo |
list containing variable for compare with residuals |
estatisticas |
data.frame containing field 'residuo' |
save |
If you want to save enter the directory as a string |
labsX |
label x |
labsy |
label y |
vetorial |
save picture in vector type? (Default TRUE) |
... |
only for compatibility with other functions |
this function displays/saves a graph illustrating the distribution scatter.smooth of residues
getGraphicResiduoPerc(titulo = "Residuo Percentual (%)", nome = "observadoXestimado", strVariavelXResiduo = NULL, estatisticas, save = NULL, labsX = "observacao", labsy = "residuos", vetorial = T, ...)
getGraphicResiduoPerc(titulo = "Residuo Percentual (%)", nome = "observadoXestimado", strVariavelXResiduo = NULL, estatisticas, save = NULL, labsX = "observacao", labsy = "residuos", vetorial = T, ...)
titulo |
is the title graphic |
nome |
name of file case save |
strVariavelXResiduo |
list containing variable for compare with residuals |
estatisticas |
data.frame containing field 'residuoPERCENTUAL' |
save |
If you want to save enter the directory as a string |
labsX |
label x |
labsy |
label y |
vetorial |
save picture in vector type? (Default TRUE) |
... |
only for compatibility with other functions |
this function retona columns the base of the parameter or setting present in the model
getParametrosOfModel(ajuste, base = NULL, formula = NULL)
getParametrosOfModel(ajuste, base = NULL, formula = NULL)
ajuste |
is ajust obtained a function like lm or nlsLM |
base |
optional data.frame whose fields name is present in formula |
formula |
string containing name fields of the base |
will be returned list of columns used in ajust or in formula
if the object does not exist an error will not happen.
ifrm(obj, env = globalenv())
ifrm(obj, env = globalenv())
obj |
the object that you want to remove |
env |
The global environment |
a = 5 ifrm(a) ifrm(b)
a = 5 ifrm(a) ifrm(b)
check if a data.frame has any non-finite elements
isfinitedataframe(obj)
isfinitedataframe(obj)
obj |
any object |
TRUE if "x" is finite, FALSE if "x" is not finite
date <- c("02/2009","02/2010","02/2011","02/2012") x <- c(1,2,3,4) test <- data.frame(x,date) isfinitedataframe(test) isfinitedataframe(x)
date <- c("02/2009","02/2010","02/2011","02/2012") x <- c(1,2,3,4) test <- data.frame(x,date) isfinitedataframe(test) isfinitedataframe(x)
converts a list in a dataframe
listToDataFrame(dlist)
listToDataFrame(dlist)
dlist |
a list |
a <- 1:5 listToDataFrame(a) b = listToDataFrame(a)
a <- 1:5 listToDataFrame(a) b = listToDataFrame(a)
is a quantity used to measure how close forecasts or predictions are to the eventual outcomes. The mean absolute error is given by.
mae(observados, estimados)
mae(observados, estimados)
observados |
vector of values observed. |
estimados |
vector of regression model data. |
mae = mean(abs(observados-estimados))
Function that returns Mean Absolute Error
see https://en.wikipedia.org/wiki/Mean_absolute_error for more details.
the MSE is the mean of the square of the errors, corresponding to the expected value of the squared error loss or quadratic loss. The difference occurs because of randomness or because the estimator doesn't account for information that could produce a more accurate estimate.
mse(observados, estimados, k)
mse(observados, estimados, k)
observados |
vector of values observed. |
estimados |
vector of regression model data. |
k |
the number of model parameters |
mse = (sum(estimados-observados)^2)/(length(observados)-k)
See https://en.wikipedia.org/wiki/Mean_squared_error for more details.
average square of the prediction errors .
mspr(observados, estimados, nValidacao)
mspr(observados, estimados, nValidacao)
observados |
vector of values observed. |
estimados |
vector of regression model data. |
nValidacao |
number of cases in the validation data set. |
JESUS, S. C.; MIURA, A. K. Analise de regressao linear multipla para estimativa do indice de vegetacao melhorado (EVI) a partir das bandas 3 4 e 5 do sensor TM/Landsat 5. In: SIMPOSIO BRASILEIRO DE SENSORIAMENTO REMOTO, 14. (SBSR), 2009, Natal. Anais... Sao Jose dos Campos: INPE, 2009. p. 1103-1110. DVD, On-line. ISBN 978-85-17-00044-7. (INPE-15901-PRE/10511)
this function is the replacement predict, she tries to predict if the return zero predict it calculates the prediction with the coefficients reported in the parameter setting
predizer(ajuste, newdata, force = FALSE, ...)
predizer(ajuste, newdata, force = FALSE, ...)
ajuste |
is ajust obtained a function like lm or nlsLM |
newdata |
dataframe where fields will be update |
force |
force the calculation without using predict? |
... |
only for compatibility with other functions |
will be returned list of values predicts
this function build a list of dataframe with projects of ages between 'firstAge' and 'lastAge' params
projectBaseOriented(firstAge = NaN, lastAge = NaN, fitDAP, fitHT, base, mapper = list(age1 = "idadearred1", dap1 = "dap1", dap2 = "dap2", ht1 = "ht1", ht2 = "ht2"), calcVolume = calculaVolumeDefault, forcePredict = F)
projectBaseOriented(firstAge = NaN, lastAge = NaN, fitDAP, fitHT, base, mapper = list(age1 = "idadearred1", dap1 = "dap1", dap2 = "dap2", ht1 = "ht1", ht2 = "ht2"), calcVolume = calculaVolumeDefault, forcePredict = F)
firstAge |
the first age to predict |
lastAge |
the last age to predict |
fitDAP |
a fit get function inherit lm to DAP |
fitHT |
a fit get function inherit lm to HT |
base |
data base |
mapper |
the label used in fields to age, dap and ht |
calcVolume |
function to calc volume |
forcePredict |
force calc base coefficients or se predict()? |
will be returned a list of volume predict to ages in dataframe and/or param
To avoid any problems and confudion on the part of the data analyst, it seems a safe recommendation to use R21a consistently for any type of model with the appropeiate a value, rather than ajusting any of the other
R21a(observados, estimados, k)
R21a(observados, estimados, k)
observados |
vector of values observed. |
estimados |
vector of values estimated. |
k |
is the number of model parameters |
R21a <- 1-a*(1 - R21)
To avoid any problems and confusion on the part of the data analyst, it seems a safe recommendation to use R21a consistently for any type of model with the appropeiate a value, rather than adjusting any of the other.
R29a(observados, estimados, k)
R29a(observados, estimados, k)
observados |
vector of values observed. |
estimados |
vector of values estimated. |
k |
is the number of model parameters |
R29a <- 1-a*(1 - R29)
this function calculates the vector residue percentage.
residuoPerc(observados, estimados)
residuoPerc(observados, estimados)
observados |
vector of values observed. |
estimados |
vector of values estimated. |
calculaPerc = ((valor)/mean(observados))*100
this feature is designed to fix variables that its content was a command
retornaValor(valor)
retornaValor(valor)
valor |
any variable |
the variable converted to its value
a = 5 retornaValor(a)
a = 5 retornaValor(a)
The root-mean-square error (RMSE) is a frequently used measure of the differences between values (sample and population values) predicted by a model or an estimator and the values actually observed.
rmse(observados, estimados)
rmse(observados, estimados)
observados |
vector of values observed. |
estimados |
vector of regression model data. |
rmse = sqrt(mean((observados - estimados)^2))
See https://en.wikipedia.org/wiki/Root-mean-square_deviation for more details.
this function approaching the age to the nearest age as an integer
roundAge(plots, ages, inYears = F, firstAge = NaN)
roundAge(plots, ages, inYears = F, firstAge = NaN)
plots |
is list of plots |
ages |
is list of age |
inYears |
ages are in year? |
firstAge |
synchronize begin of ages with an age? what age? |
will be returned a list of round ages
relative root mean square error (RRMSE) is calculated by dividing the RMSE by the mean observed data
rrmse(observados, estimados)
rrmse(observados, estimados)
observados |
vector of values observed. |
estimados |
vector of regression model data. |
save function with Model of type criaModeloGenerico or criaModeloExclusivo
salvaModelo(modelo, diretorio = "")
salvaModelo(modelo, diretorio = "")
modelo |
function with Model the save |
diretorio |
directory to save the file, if not informed saved in the work directory |
divides the dataFrame as the percentage defined in percTraining enabling apply and measure the performance of the regression equation.
separaDados(dataFrame, fieldName, percTraining = 0.7, seed = NULL)
separaDados(dataFrame, fieldName, percTraining = 0.7, seed = NULL)
dataFrame |
source of data |
fieldName |
column of dataFrame that will be applied regression |
percTraining |
percentage that will be reserved for training (default 0.70) |
seed |
integer that determines how the sample is randomly chosen (default NULL) |
Measures the variability, or scatter of the observed values around the regression line
syx(observados, estimados, n, p)
syx(observados, estimados, n, p)
observados |
vector of values observed. |
estimados |
vector of values estimated. |
n |
the amount of values observed |
p |
the size of the vector of regression model data |
Measures the variability, or scatter of the observed values around the regression line
syxPerc(syx, observados)
syxPerc(syx, observados)
syx |
result of the function syx(Standard Error of Estimate). |
observados |
vector of values observed. |
this function returns the type of a column of a dataFrame, if it is numeric or character.
verificaTipoColuna(coluna)
verificaTipoColuna(coluna)
coluna |
column of dataframe |
ID_REGIAO <- c(1,2,3,4) CD_PLANTIO <- c("ACD","CDB","CDC","CDD") test <- data.frame(ID_REGIAO,CD_PLANTIO) verificaTipoColuna(test$ID_REGIAO)
ID_REGIAO <- c(1,2,3,4) CD_PLANTIO <- c("ACD","CDB","CDC","CDD") test <- data.frame(ID_REGIAO,CD_PLANTIO) verificaTipoColuna(test$ID_REGIAO)
vector position that has its closest median value
whichmedian(x)
whichmedian(x)
x |
a vector of numbers |
vector position that has its closest median value
dados <- c(1,2,3,4,9,5,6) whichmedian(dados)
dados <- c(1,2,3,4,9,5,6) whichmedian(dados)