Calc_Polygon_Areas_and_Polygons_Fn: Generate design matrix and polygon areas for a given set of... In aaronmberger/Geo_dGLMM_habitat: Package for conducting spatial estimation of CPUE index standardization (fisheries, ecology, etc).

Usage

 `1` ```Calc_Polygon_Areas_and_Polygons_Fn(loc_x, Data_Extrap, Covariates = "none", a_el = NULL) ```

Arguments

 `loc_x` `Data_Extrap` `Covariates` `a_el`

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 31 32``` ```##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function (loc_x, Data_Extrap, Covariates = "none", a_el = NULL) { if (is.null(a_el)) { a_el = rep(1, nrow(Data_Extrap)) } NN_Extrap = nn2(data = loc_x[, c("E_km", "N_km")], query = Data_Extrap[, c("E_km", "N_km")], k = 1) a_xl = matrix(NA, ncol = ncol(a_el), nrow = n_x, dimnames = list(NULL, colnames(a_el))) for (l in 1:ncol(a_xl)) { a_xl[, l] = tapply(a_el[, l], INDEX = factor(NN_Extrap\$nn.idx, levels = 1:nrow(loc_x)), FUN = sum) a_xl[, l] = ifelse(is.na(a_xl[, l]), 0, a_xl[, l]) } if (length(Covariates) == 1 && Covariates == "none") { X_xj = cbind(Dummy = rep(0, n_x)) } else { X_xj = matrix(NA, ncol = length(Covariates), nrow = n_x) for (j in 1:ncol(X_xj)) { X_xj[, j] = tapply(Data_Extrap[, Covariates[j]], INDEX = factor(NN_Extrap\$nn.idx, levels = 1:nrow(loc_x)), FUN = sum, na.rm = TRUE) } } Return = list(X_xj = X_xj, a_xl = a_xl) } ```

aaronmberger/Geo_dGLMM_habitat documentation built on May 10, 2019, 3:20 a.m.