Description Usage Arguments Value Author(s) References See Also Examples
Runs the multinomial logistic regression via nnet::multinom
to produce spatial predictions of the target factor-type variable. It requires point locations of observed classes and a list of covariate layers provided as "SpatialPixelsDataFrame-class"
object. The resulting predicted classes are then used to estimate class centres and variances per class.
1 2 3 4 | ## S4 method for signature
## 'formula,SpatialPointsDataFrame,SpatialPixelsDataFrame'
spmultinom(formulaString,
observations, covariates, class.stats = TRUE, predict.probs = TRUE, ...)
|
formulaString |
formula string |
observations |
object of type |
covariates |
object of type |
class.stats |
logical; species wether to estimate class centres |
predict.probs |
logical; species wether to predict probabilities per class |
... |
optional arguments |
Returns an object of type "SpatialMemberships"
with following slots: predicted
(classes predicted by the multinomial logistic regression, model
(the multinomial logistic regression model), mu
(probabilities derived using the mutinom model), class.c
(derived class centres), class.sd
(derived class deviations), confusion
(confusion matrix).
Bas Kempen and Tomislav Hengl
Multinomial logistic regression (http://en.wikipedia.org/wiki/Multinomial_logit)
Nnet package (https://CRAN.R-project.org/package=nnet)
spfkm
, SpatialMemberships-class
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 | # load data:
library(plotKML)
library(sp)
data(eberg)
# subset to 20%:
eberg <- eberg[runif(nrow(eberg))<.2,]
data(eberg_grid)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
# derive soil predictive components:
eberg_spc <- spc(eberg_grid, ~PRMGEO6+DEMSRT6+TWISRT6+TIRAST6)
# predict memberships:
formulaString = soiltype ~ PC1+PC2+PC3+PC4+PC5+PC6+PC7+PC8+PC9+PC10
eberg_sm <- spmultinom(formulaString, eberg, eberg_spc@predicted)
## Not run: # plot memberships:
pal = seq(0, 1, 1/50)
spplot(eberg_sm@mu, col.regions=pal)
image(eberg_sm@mu[1], col=pal)
text(eberg@coords, paste(eberg$soiltype), cex=.6, col="black")
# classes predicted:
Ls = length(levels(eberg_sm@predicted$soiltype))
pnts = list("sp.points", eberg, pch="+", cex=.6, col="black")
spplot(eberg_sm@predicted, col.regions=rainbow(Ls)[rank(runif(Ls))], sp.layout=pnts)
## End(Not run)
|
GSIF version 0.5-5.1 (2019-01-04)
URL: http://gsif.r-forge.r-project.org/
plotKML version 0.6-1 (2020-03-08)
URL: http://plotkml.r-forge.r-project.org/
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum Deutsches_Hauptdreiecksnetz in CRS definition
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum Deutsches_Hauptdreiecksnetz in CRS definition
Converting PRMGEO6 to indicators...
Converting covariates to principal components...
Warning message:
In proj4string(obj) : CRS object has comment, which is lost in output
Fitting a multinomial logistic regression model...
# weights: 132 (110 variable)
initial value 1222.926589
iter 10 value 862.881524
iter 20 value 844.249559
iter 30 value 831.862150
iter 40 value 827.678064
iter 50 value 825.941255
iter 60 value 825.149303
iter 70 value 824.914320
iter 80 value 824.825869
final value 824.824380
converged
Estimated Cohen Kappa (weighted): 0.2045
Map purity: 32.1
Warning message:
In nnet::multinom(formulaString, ov, ...) : groups ‘Ha’ ‘Hw’ are empty
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.