jobu
1
Hey there!
I have some trouble calculating the probabilities from my polr-model. How could I do that in R?
polr(formula = factor(dectime) ~ mediause_12 + age + sexe, data = voxit_destill_1,
na.action = na.omit)
Coefficients:
Value Std. Error t value
mediause_12 0.163902 0.067468 2.429
age 0.008661 0.001453 5.962
sexe -0.249021 0.047387 -5.255
Intercepts:
Value Std. Error t value
1|2 -3.0008 0.1251 -23.9882
2|3 -1.4883 0.1134 -13.1246
3|4 0.1354 0.1116 1.2134
4|5 1.0144 0.1121 9.0460
============================
Model 1
mediause_12 0.16 *
(0.07)
age 0.01 ***
(0.00)
sexe -0.25 ***
(0.05)
AIC 16924.57
BIC 16971.31
Log Likelihood -8455.29
Deviance 16910.57
Num. obs. 5864
Would be most greatful if you could help me.
Thanks,
Johanna
FJCC
2
Is this the type of thing you want to do? I used some built-in data to create a polr object.
library(MASS)
options(contrasts = c("contr.treatment", "contr.poly"))
house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
house.plr
#> Call:
#> polr(formula = Sat ~ Infl + Type + Cont, data = housing, weights = Freq)
#>
#> Coefficients:
#> InflMedium InflHigh TypeApartment TypeAtrium TypeTerrace
#> 0.5663937 1.2888191 -0.5723501 -0.3661866 -1.0910149
#> ContHigh
#> 0.3602841
#>
#> Intercepts:
#> Low|Medium Medium|High
#> -0.4961353 0.6907083
#>
#> Residual Deviance: 3479.149
#> AIC: 3495.149
DF <- housing[1:6,] #this could be entirely new data
predict(object = house.plr, newdata = DF, type = "class")
#> [1] Low Low Low High High High
#> Levels: Low Medium High
predict(object = house.plr, newdata = DF, type = "probs")
#> Low Medium High
#> 1 0.3784493 0.2876752 0.3338755
#> 2 0.3784493 0.2876752 0.3338755
#> 3 0.3784493 0.2876752 0.3338755
#> 4 0.2568264 0.2742122 0.4689613
#> 5 0.2568264 0.2742122 0.4689613
#> 6 0.2568264 0.2742122 0.4689613
Created on 2020-08-15 by the reprex package (v0.3.0)
1 Like
system
Closed
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.