PKMLp
codemeta.json{"@context": ["https://doi.org/doi:10.5063/schema/codemeta-2.0", "http://schema.org"], "@type": "SoftwareSourceCode", "provider": {"url": "https://www.comses.net", "@type": "Organization", "name": "CoMSES Network (CoMSES)", "@id": "https://www.comses.net"}}PKMLQD>һ
docs/polr.txtpolr {MASS} R Documentation
Ordered Logistic or Probit Regression
Description
Fits a logistic or probit regression model to an ordered factor
response. The default logistic case is /proportional odds logistic
regression/, after which the function is named.
Usage
polr(formula, data, weights, start, ..., subset, na.action,
contrasts = NULL, Hess = FALSE, model = TRUE,
method = c("logistic", "probit", "cloglog", "cauchit"))
Arguments
|formula|
a formula expression as for regression models, of the form |response ~
predictors|. The response should be a factor (preferably an ordered
factor), which will be interpreted as an ordinal response, with levels
ordered as in the factor. The model must have an intercept: attempts to
remove one will lead to a warning and be ignored. An offset may be used.
See the documentation of |formula
| for other details.
|data|
an optional data frame in which to interpret the variables occurring in
|formula|.
|weights|
optional case weights in fitting. Default to 1.
|start|
initial values for the parameters. This is in the format
|c(coefficients, zeta)|: see the Values section.
|...|
additional arguments to be passed to |optim
|, most often a
|control| argument.
|subset|
expression saying which subset of the rows of the data should be used in
the fit. All observations are included by default.
|na.action|
a function to filter missing data.
|contrasts|
a list of contrasts to be used for some or all of the factors appearing
as variables in the model formula.
|Hess|
logical for whether the Hessian (the observed information matrix) should
be returned. Use this if you intend to call |summary| or |vcov| on the fit.
|model|
logical for whether the model matrix should be returned.
|method|
logistic or probit or complementary log-log or cauchit (corresponding to
a Cauchy latent variable).
Details
This model is what Agresti (2002) calls a /cumulative link/ model. The
basic interpretation is as a /coarsened/ version of a latent variable
/Y_i/ which has a logistic or normal or extreme-value or Cauchy
distribution with scale parameter one and a linear model for the mean.
The ordered factor which is observed is which bin /Y_i/ falls into with
breakpoints
/zeta_0 = -Inf < zeta_1 < … < zeta_K = Inf/
This leads to the model
/logit P(Y <= k | x) = zeta_k - eta/
with /logit/ replaced by /probit/ for a normal latent variable, and
/eta/ being the linear predictor, a linear function of the explanatory
variables (with no intercept). Note that it is quite common for other
software to use the opposite sign for /eta/ (and hence the coefficients
|beta|).
In the logistic case, the left-hand side of the last display is the log
odds of category /k/ or less, and since these are log odds which differ
only by a constant for different /k/, the odds are proportional. Hence
the term /proportional odds logistic regression/.
In the complementary log-log case, we have a /proportional hazards/
model for grouped survival times.
There are methods for the standard model-fitting functions, including
|predict |, |summary
|, |vcov
|, |anova
|, |model.frame
| and an
|extractAIC| method for use with |stepAIC
|. There are also
|profile | and
|confint | methods.
Value
A object of class |"polr"|. This has components
|coefficients|
the coefficients of the linear predictor, which has no intercept.
|zeta|
the intercepts for the class boundaries.
|deviance|
the residual deviance.
|fitted.values|
a matrix, with a column for each level of the response.
|lev|
the names of the response levels.
|terms|
the |terms| structure describing the model.
|df.residual|
the number of residual degrees of freedoms, calculated using the weights.
|edf|
the (effective) number of degrees of freedom used by the model
|n, nobs|
the (effective) number of observations, calculated using the weights.
(|nobs| is for use by |stepAIC
|.
|call|
the matched call.
|method|
the matched method used.
|convergence|
the convergence code returned by |optim|.
|niter|
the number of function and gradient evaluations used by |optim|.
|lp|
the linear predictor (including any offset).
|Hessian|
(if |Hess| is true).
|model|
(if |model| is true).
References
Agresti, A. (2002) /Categorical Data./ Second edition. Wiley.
Venables, W. N. and Ripley, B. D. (2002) /Modern Applied Statistics with
S./ Fourth edition. Springer.
See Also
|optim |, |glm
|, |multinom
|.
Examples
options(contrasts = c("contr.treatment", "contr.poly"))
house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
house.plr
summary(house.plr, digits = 3)
## slightly worse fit from
summary(update(house.plr, method = "probit", Hess = TRUE), digits = 3)
## although it is not really appropriate, can fit
summary(update(house.plr, method = "cloglog", Hess = TRUE), digits = 3)
predict(house.plr, housing, type = "p")
addterm(house.plr, ~.^2, test = "Chisq")
house.plr2 <- stepAIC(house.plr, ~.^2)
house.plr2$anova
anova(house.plr, house.plr2)
house.plr <- update(house.plr, Hess=TRUE)
pr <- profile(house.plr)
confint(pr)
plot(pr)
pairs(pr)
------------------------------------------------------------------------
[Package /MASS/ version 7.3-14 Index
]
PKMLVcode/FINAL_MODEL_HIST.txtData<-read.table(file.choose(),header=T,sep=",")
Data[,"compl"]<-as.ordered(as.factor(Data[,"compl"]))
Data[,"IUCN"]<-as.factor(Data[,"IUCN"])
Data[,"part"]<-as.factor(Data[,"part"])
Data1<-Data[is.na(Data[,"IUCN"]==FALSE,]
Data1<-Data[is.na(Data[,"IUCN"])==FALSE,]
Data2<-Data1[is.na(Data1[,"area"])==FALSE,]
nrow(Data2)
library(MASS)
mod1<-polr(compl~1,data=Data2)
mod2<-polr(compl~part,data=Data2)
anova(mod1,mod2)
mod3<-polr(compl~part+age,data=Data2)
anova(mod2,mod3)
mod4<-polr(compl~part+area,data=Data2)
anova(mod2,mod4)
mod5<-polr(compl~part+buffer,data=Data2)
anova(mod2,mod5)
mod6<-polr(compl~part+IUCN,data=Data2)
anova(mod2,mod6)
mod7<-polr(compl~part+GDP,data=Data2)
anova(mod2,mod7)
mod8<-polr(compl~part+pop,data=Data2)
anova(mod2,mod8)
modfinal<-polr(compl~part,data=Data)
summary(modfinal)
modf<-polr(compl~part+age+area+buffer+IUCN+GDP+pop,data=Data2)
summary(modf)
save.image("C:\\Users\\uqgmorgi\\Desktop\\FINAL MODEL")
PKMLS|data/dmr.csvcompl,country,age,area,buffer,IUCN,GDP,pop,part
1,Brazil,30,1550,0,1,10453.25,10.53,1
3,Brazil,22,32972,0,NA,10453.25,0.91,3
2,Bhutan,16,1730,1,1,5131.23,69.29,2
1,Cameroon,50,1294,0,1,2139.57,33.98,1
3,Cameroon,37,1838,1,1,2139.57,4.06,3
2,Cameroon,43,1665,1,1,2139.57,7.95,2
1,Cameroon,43,1407,0,1,2139.57,58.2,2
3,Cameroon,24,200,0,NA,2139.57,150.84,3
1,China,32,2000,0,2,6785.87,69.03,1
1,China,13,822,1,2,6785.87,120.9,1
2,China,53,1428,0,2,6785.87,53.2,2
1,Ecuador,32,750,0,1,7573.13,38.97,1
3,Egypt,23,4712,0,2,6105.91,4.51,3
1,India,23,2236,1,NA,3039.48,31.38,2
1,India,28,820,0,1,3039.48,615.66,1
2,India,35,900,1,1,3039.48,565.29,2
1,India,31,1265,0,1,3039.48,231.35,2
2,India,56,492,0,1,3039.48,400.59,1
1,India,18,625,1,1,3039.48,153.33,1
1,Indonesia,91,740,0,2,4155.45,465.43,1
1,Kenya,65,117,0,1,1614.07,2495.16,1
1,Kenya,63,20812,0,1,1614.07,11.66,1
2,Madagascar,14,2204,1,1,944.95,37.03,2
1,Madagascar,22,154,1,1,944.95,28.04,1
1,Malawi,41,2316,0,1,790.15,31.94,1
3,Malaysia ,20,251,0,1,13733.3,6.74,3
2,Mexico,9,53,0,2,13681.32,12.51,2
1,Mexico,13,1551,1,2,13681.32,89.63,1
1,Mexico,22,7231,1,2,13681.32,10.33,1
1,Mozambique,42,900,0,1,954.04,12.73,1
2,Myanmar,27,1606,1,1,1199.74,54.83,1
1,Myanmar,70,269,1,1,1199.74,65.51,1
2,Myanmar,37,2150,0,1,1199.74,10.58,1
2,Nepal,38,932,1,1,1215.26,322.5,2
2,Nepal,35,968,1,1,1215.26,229.74,2
3,Nepal,19,7629,0,2,1215.26,75.26,3
2,Nepal,35,305,1,1,1215.26,308.17,2
2,Nepal,19,830,1,2,1215.26,49.26,2
1,Nigeria,20,8000,1,1,2274.12,60.38,1
1,Philippines,11,110,1,2,3515.74,243.38,1
2,South Africa,85,9150,0,NA,10237.99,21.76,2
2,South Africa,116,2133,0,1,10237.99,41.7,2
1,South Africa,11,298,0,1,10237.99,17.21,1
3,Taiwan,18,1,0,NA,31769.78,180.1,3
2,Tanzania,60,14763,0,1,1340.91,50.75,2
2,Tanzania,106,44800,1,1,1340.91,15.9,2
2,Tanzania,37,4471,0,1,1340.91,12.49,2
2,Thailand,49,2185,0,1,8488.69,87.12,1
1,Uganda,20,766,0,1,1210.42,197.89,1
3,Uganda,17,NA,0,NA,1210.42,281,3
1,Uganda,29,370,0,1,1210.42,81.34,2
3,Uganda,20,327,0,1,1210.42,212.86,3
3,Uganda,81,38,0,1,1210.42,484.67,2
1,Vietnam,10,414,0,NA,2941.67,45.65,1
1,Zimbabwe,36,5053,0,1,394.3,16.91,1
PKMLp
codemeta.jsonPKMLQD>һ
,docs/polr.txtPKMLVcode/FINAL_MODEL_HIST.txtPKMLS|data/dmr.csvPK&