best_migramod: Select best migramod model.

Description Usage Arguments Value Examples

View source: R/best_migramod.R

Description

One solution to initial values problem based on the generation of a random sample with size equals one from uniform a priori distributions with values between 0 and 1 for the initial parameters.

Usage

1
2
best_migramod(dataIn, profile = "eleven",
      maxite = 100, epsilon = 1e-05, datasimul = TRUE)

Arguments

dataIn

Standardized migration data set for optimization.

profile

Number of parameters of a Roger and Castro model.

maxite

Maximum number of iterations for model optimization.

epsilon

Tolerance in which the difference between the Mean Squared Error that will finish the algorithm.

datasimul

Table with the different simulations and values of the parameters estimated.

Value

a list with named parameters

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
library(migraR)
library(dplyr)
data("es_asmr")
data1 <- es_asmr[-c(1,2),c(1,6)]
colnames(data1) <- c("x","y")
# Fitting and Plotting data
fitted.val.7  <- best_migramod(dataIn = data1, maxite = 200, profile = "seven")
fitted.val.9  <- best_migramod(dataIn = data1, maxite = 200, profile = "nine")
fitted.val.11 <- best_migramod(dataIn = data1, maxite = 200, profile = "eleven")
fitted.val.13 <- best_migramod(dataIn = data1, maxite = 200, profile = "thirteen")
x11()
plot(data1, cex=0.1, xlab = 'Age',
     ylab = 'Standarized Migration Rate')
lines(data1[,1], fitted.val.7$modelClass$value(fitted.val.7$bestParam,data1), col="blue")
lines(data1[,1], fitted.val.9$modelClass$value(fitted.val.9$bestParam,data1), col="orange")
lines(data1[,1], fitted.val.11$modelClass$value(fitted.val.11$bestParam,data1), col="blue", lty=3)
lines(data1[,1], fitted.val.13$modelClass$value(fitted.val.13$bestParam,data1), col="green")
legend('topright',
      legend = c(paste("(7)", "MAPE:", round(as.numeric(fitted.val.7$bestMAPE),2),
                       "R²:", round(as.numeric(fitted.val.7$bestRcuad),3)),
                 paste("(9)", "MAPE:", round(as.numeric(fitted.val.9$bestMAPE),2),
                       "R²:", round(as.numeric(fitted.val.9$bestRcuad),3)),
                 paste("(11)", "MAPE:", round(as.numeric(fitted.val.11$bestMAPE),2),
                       "R²:", round(as.numeric(fitted.val.11$bestRcuad),3)),
                 paste("(13)", "MAPE:", round(as.numeric(fitted.val.13$bestMAPE),2),
                       "R²:", round(as.numeric(fitted.val.13$bestRcuad),3))),
      col = c("red",'orange',"blue","darkgreen"), lty = c(2,6,3,5))

## End(Not run)

elflacosebas/migraR documentation built on Feb. 26, 2021, 3:03 p.m.