I think the profiling is failing on confint()
for the Age
variable. There's a diagnostic plot for the profile that you can do, showing the parameter tau
for each coefficient. It has to span a wide enough range (given a specific confidence interval requested, like 0.95 or 0.9 etc) or else the interval can't be calculated. It looks like Age
doesn't meet the criterion. Radically lowering the requested CI (e.g. to 0.4) will give you a result, so I don't think it's a bug—it's just that the quantity you wan't can't be estimated for this model. The reprex below is similar to @cderv's, but I had to adjust the cleaning to get things to work so I've included the whole thing again, in addition to the plot.
url <- "https://community.rstudio.com/uploads/default/original/2X/9/9429c5c23fed9dc09ef30508b8d837930062d5c7.pdf"
pdf_temp <- tempfile(fileext = ".pdf")
download.file(url, pdf_temp, mode = "wb")
## extract from pdf file
library(pdftools)
library(tidyverse)
data <- pdftools::pdf_text(pdf_temp) %>%
read_lines() %>%
str_trim() %>%
str_split_fixed("[ ]+", n = 6) %>%
as.data.frame(, stringsAsFactors = FALSE) %>%
as_tibble() %>%
set_names(nm = map(slice(., 1), as.character)) %>%
slice(-1) %>%
mutate_all(as.numeric)
## actual code ----
library(MASS)
#>
#> Attaching package: 'MASS'
#> The following object is masked from 'package:dplyr':
#>
#> select
data$CHL <- as.factor(data$Challenge)
levels(data$CHL) <- c("No affected","Moderate","Affected")
summary(data)
#> Individual Age gender Distance
#> Min. : 1.00 Min. :20.00 Min. :0.0000 Min. : 529
#> 1st Qu.:23.75 1st Qu.:21.00 1st Qu.:0.0000 1st Qu.:1107
#> Median :46.50 Median :22.00 Median :0.0000 Median :1367
#> Mean :46.50 Mean :22.61 Mean :0.4674 Mean :2345
#> 3rd Qu.:69.25 3rd Qu.:24.00 3rd Qu.:1.0000 3rd Qu.:2079
#> Max. :92.00 Max. :29.00 Max. :1.0000 Max. :8890
#> Challenge help CHL
#> Min. :1.00 Min. :0.0000 No affected:47
#> 1st Qu.:1.00 1st Qu.:0.0000 Moderate :32
#> Median :1.00 Median :1.0000 Affected :13
#> Mean :1.63 Mean :0.5652
#> 3rd Qu.:2.00 3rd Qu.:1.0000
#> Max. :3.00 Max. :1.0000
mo2 <- polr(formula = CHL ~ Age + Distance + gender + help, data,
method = c("logistic"), Hess =TRUE)
summary(mo2)
#> Call:
#> polr(formula = CHL ~ Age + Distance + gender + help, data = data,
#> Hess = TRUE, method = c("logistic"))
#>
#> Coefficients:
#> Value Std. Error t value
#> Age 0.1023205 0.0246094 4.158
#> Distance 0.0005437 0.0002367 2.297
#> gender 0.4871502 0.4608772 1.057
#> help -1.2882294 0.4567059 -2.821
#>
#> Intercepts:
#> Value Std. Error t value
#> No affected|Moderate 2.9482 0.0048 610.0403
#> Moderate|Affected 5.7471 0.5225 10.9983
#>
#> Residual Deviance: 137.6569
#> AIC: 149.6569
confint(mo2, level = 0.4)
#> Waiting for profiling to be done...
#> 30 % 70 %
#> Age 0.0415768227 0.1630394619
#> Distance 0.0004831186 0.0006068731
#> gender 0.2457709578 0.7286012025
#> help -1.5294930492 -1.0494528431
confint(mo2, level = 0.9)
#> Waiting for profiling to be done...
#> 5 % 95 %
#> Age NA NA
#> Distance 0.0003605271 0.0007520464
#> gender -0.2723704121 1.2474223473
#> help -2.0553019090 -0.5450240340
plot(profile(mo2))

Created on 2018-12-23 by the reprex package (v0.2.1)