我的代码应该很容易编织成PDF,但它不会编译,我在R Markdown中得到了这个消息:
!LaTeX错误:Unicode字符(U+2081)未设置用于LaTeX。
错误:LaTeX无法编译L-work-5.tex。有关https://yihui.org/tinytex/r/#debugging调试提示,请参见www.example.com。更多信息请参见L-work-5.log。停止执行
下面是代码:
---
title: "work 5"
author: "PLars"
date: "4/2/2022"
output: pdf_document
fonttheme: professionalfonts
fontsize: 12pt
editor_options:
markdown:
wrap: 72
---
```{r, echo = FALSE, results = "hide", message = FALSE, purl = FALSE}
library(knitr)
opts_chunk$set(tidy = FALSE,
fig.align = "left",
background = '#a6a6a6',
fig.width = 10,
fig.height = 10,
out.width ="\\linewidth",
out.height = "\\linewidth",
message = FALSE,
warning = FALSE,
fig.align = "left"
)
options(width = 55, digits = 3)
library(scales)
percent <- function(x, digits = 2, format = "f", ...) {
paste0(formatC(100 * x, format = format, digits = digits, ...), "%")
}
library(haven)
library(tinytex)
library(stargazer)
library(tidyverse)
library(texreg)
library(dplyr)
library(texreg)
library(AER)
library(tidyverse)
Part I - Categorical Models (5 points)
Say that you estimate an ordered logit model with a three category
dependent variable and two independent variables, X~₁i~ and X~₂i~, and
obtain the following results:
\begin{center}
\begin{tabular}{c|rc}
\hline \hline
& $\hat{\beta}$ & SE \\
\hline
$X_{1}$ & $-0.68$ & $(0.23)$ \\
$X_{2}$ & $-0.47$ & $(0.13)$ \\
\hline
$\tau_1$ & $-1.02$ & $(0.46)$ \\
$\tau_2$ & $.85$ & $(0.21)$ \\
\hline
\end{tabular}
\end{center}
\begin{enumerate}
\item Calculate $\Pr(Y_i=1 | X_{1i}=1, X_{2i}=0)$.
\item Calculate $\Pr(Y_i=2 | X_{1i}=1, X_{2i}=0)$.
\item Calculate $\Pr(Y_i=3 | X_{1i}=1, X_{2i}=0)$.
\item Calculate the first difference (difference in probability in category) that result from changing X_{2i} from -2 to 2, holding X_{1i} fixed at 0. Do calculations for each possible value of Y_i.
\item Explain how we might assess whether the parallel regression assumption holds for this model? If it does not, what alternative might you pursue if this were your model?
\end{enumerate}
First, we calculate $X_i \beta$
(xiB <- (-.068*1) + (-0.47*0))
Then, plug into the following equations:
(prob1 <- 1/(1 + exp(-(-1.02-xiB))))
(prob2 <- 1/(1 + exp(-(.85-xiB))) - prob1)
(prob3 <- 1 - (1/(1 + exp(-(.85-xiB)))))
prob1 + prob2 + prob3
2条答案
按热度按时间rkue9o1l1#
首先,尝试删除行中的特殊字符
₁
和₂
两个自变量X~ i~和X~ i~
这将让你编译。
你可能可以通过包含以下内容来实现这一点:
下标2字符也是如此,位于文件的顶部(来自this TeX Stack Exchange question),但我还没有测试过它,现在也不想进入那个兔子洞。
或者将相关文本更改为
这可能会像最初打算的那样打印出来!
neekobn82#
我在使用图书馆(tidyverse)时遇到了类似的问题。
我可以通过删除
library(tidyverse)
并定义来自tidyverse的软件包来解决它,例如library(tidyr)
,library(dplyr)
等。